changeset 83224:7a0245dd1848

Merged in changes from CVS trunk. Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-653 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-654 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-655 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-656 Update from CVS: lisp/man.el (Man-xref-normal-file): Fix help-echo. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-657 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-658 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-659 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-660 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-661 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-662 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-663 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-664 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-665 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-666 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-667 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-668 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-669 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-670 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-671 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-64 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-65 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-66 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-67 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-68 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-264
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 06 Nov 2004 17:52:02 +0000
parents 4056279af756 (current diff) 47b64fe4daa8 (diff)
children 07964164a825
files ChangeLog admin/FOR-RELEASE etc/TODO lisp/ChangeLog lisp/allout.el lisp/emacs-lisp/bytecomp.el lisp/files.el lisp/international/mule-cmds.el lisp/progmodes/idlw-shell.el lisp/progmodes/idlwave.el lisp/progmodes/vhdl-mode.el lisp/simple.el lisp/url/url-imap.el lisp/url/url-irc.el lisp/url/url-news.el lisp/url/url-nfs.el lisp/vc-cvs.el lisp/vc.el lisp/x-dnd.el man/ChangeLog man/speedbar.texi src/.gdbinit src/Makefile.in src/config.in src/dispnew.c src/emacs.c src/fileio.c src/fontset.c src/keyboard.c src/keyboard.h src/lisp.h src/process.c src/w32term.c src/window.c src/xdisp.c src/xfns.c src/xmenu.c src/xselect.c src/xterm.c src/xterm.h
diffstat 148 files changed, 4168 insertions(+), 1829 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Oct 31 02:05:24 2004 +0000
+++ b/ChangeLog	Sat Nov 06 17:52:02 2004 +0000
@@ -1,3 +1,12 @@
+2004-11-02  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* configure.in (HAVE_GTK_FILE_CHOOSER, $HAVE_GTK_FILE_SELECTION): New
+	tests for new and old GTK file dialogs.
+	(HAVE_GTK): Only set with_toolkit_scroll_bars if not explicitly set
+	to no.
+
+	* configure: Rebuild
+
 2004-10-20  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
 	* configure.in (HAVE_PERSONALITY_LINUX32): New test if PER_LINUX32
--- a/admin/ChangeLog	Sun Oct 31 02:05:24 2004 +0000
+++ b/admin/ChangeLog	Sat Nov 06 17:52:02 2004 +0000
@@ -1,3 +1,7 @@
+2004-11-02  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* FOR-RELEASE (Indications): Remove two stage update for toolbar (Done).
+
 2004-09-20  Luc Teirlinck  <teirllm@auburn.edu>
 
 	* FOR-RELEASE (Indications): Rearrange checklists for Emacs and
--- a/admin/FOR-RELEASE	Sun Oct 31 02:05:24 2004 +0000
+++ b/admin/FOR-RELEASE	Sat Nov 06 17:52:02 2004 +0000
@@ -8,6 +8,8 @@
 
 ** Face remapping.
 
+** Let mouse-1 follow links.
+
 
 * FATAL ERRORS
 
@@ -18,12 +20,228 @@
 which then returns a NULL pointer.  Said to happen with
 isearch faces.
 
+** Investigate reported crashes in compact_small_strings.
+
+** Investigate reported crashes related to using an
+invalid pointer from string_free_list.
+
+
+* LOSSAGE
+
+** Clean up flymake.el to follow Emacs Lisp conventions.
+
 
 * GTK RELATED BUGS
 
 ** Make GTK scrollbars behave like others w.r.t. overscrolling.
 
 
+* REDISPLAY RELATED BUGS
+
+** Avoid unbreakable loops in redisplay.
+
+Redisplay may loop if there is an error in some display property, e.g.
+     (space 'left-margin)
+
+A fix would be to somehow disable handling of display properties if an error
+is encountered.
+
+** Problem with cursor border around images and window-margins:
+
+The border around the image when the cursor is on the image
+flows into the right fringe and margin.
+
+     (progn
+       (auto-image-file-mode 1)
+       (find-file (concat data-directory "splash.xpm"))
+       (set-window-margins (selected-window) 25 25))
+
+
+** Problem with modeline and window margins:
+
+The mode line's right "box" line is misplaced under the right margin,
+rather than at the right window edge.
+
+emacs -Q
+(set-window-margins nil 25 25)
+C-x 2
+
+
+** custom mode-line face makes Emacs freeze up
+
+From: Stephen Berman <Stephen.Berman@gmx.net>
+Date: Sun, 24 Oct 2004 02:08:56 +0200
+
+1. Start Emacs with -q -no-site-file.
+
+2. Type `M-x customize-face' and at the prompt `mode-line'.
+
+3. In the Custom buffer for mode-line face
+   a. check width and give it the value `narrow';
+   b. check height and give it the value 120 in 1/10 pt;
+   c. check underline and give it the value `on' (or `colored');
+   d. check overline and give it the value `on' (or `colored').
+
+4. Set for current session.
+
+5. Invoke Ediff on any two files.
+
+6. Now Emacs is frozen and consumes 95-99% of CPU.
+
+The customizations in step 3 appear to be the minimum necessary to
+induce this bug.  Leave out any one of them and Ediff runs without a
+problem.  Also if the 1/10 point value of height is 130 or greater
+there's no bug (with the default font family; with e.g. Helvetica the
+bug is induced only by a value of 100 or less).
+
+I've noticed this freeze up only when invoking Ediff.  The only thing
+I've been able to do is kill Emacs externally, via top or with kill
+when run in gdb, after interrupting.  When the freeze up happens
+within a gdb session, there is no automatic debugging feedback.  After
+interrupting I can get a backtrace, here's an example:
+
+Update: Maybe only reveals itself when compiled with GTK+
+
+
+** Mouse-face overlay bleeds into header line
+
+From: Stephen Berman <Stephen.Berman@gmx.net>
+Date: Thu, 21 Oct 2004 18:11:01 +0200
+
+Mouse-face overlays bleed into the header line when the beginning of
+the overlay is above (point-min).  To reproduce:
+
+1. Start Emacs with -q -no-site-file.
+
+2. In *scratch* eval (setq ov (make-overlay 66 92)), (overlay-put ov
+'mouse-face 'highlight), and (setq header-line-format "test").
+
+3. Drag the mouse over the string "evaluation.\n;; If you want" and
+notice the highlighting of only this string.
+
+4. Now click on the down arrow in the scroll bar until the line
+beginning ";; If you want" is directly below the header line.
+
+5. Drag the mouse over ";; If you want" and notice that not only it
+but also the header line are highlighted.
+
+
+** scroll-preserve-screen-position doesn't work with a header-line-format
+
+From: jbyler+emacs-lists@anon41.eml.cc
+Date: Tue, 17 Aug 2004 17:10:14 -0400
+
+There seems to be an off-by-one error triggered by using a header line
+together with scroll-preserve-screen-position.  The symptom: instead of
+staying in the same position on the screen when scrolling, the cursor
+moves one screen line down each time the buffer is scrolled.  Put
+another way: repeatedly typing C-v M-v or using a mouse scroll wheel to
+scroll up and down causes the cursor to migrate slowly down the screen
+instead of staying put as it should.
+
+To reproduce:
+
+emacs -q --no-site-file
+(setq scroll-preserve-screen-position t)
+(setq header-line-format "")
+C-v M-v C-v M-v C-v M-v etc.
+
+
+** Clicking on partially visible lines fails
+
+From: David Kastrup <dak@gnu.org>
+Date: 27 Apr 2004 16:42:58 +0200
+
+I had gnus display a mouse-highlighted line (a URL from browse-url)
+partially at the bottom of its window.  If I click with middle mouse
+key on it, the window gets recentered while I hold the mouse key
+pressed.  If I release it, the window returns into its old position
+(cursor in top row) and nothing happens, presumably because the click
+was not registered on the line itself, but on the magically
+recentered version.
+
+That is a nuisance.  Recentering of even partially visible click
+targets should only happen if window-point moves there, but not at
+the time of the click.  From the moment I hold down a key until it
+gets released, the displayed window portion should not change, with
+the sole exception of scrolling when dragging at the edge of the
+screen.
+
+
+** Can't drag modeline when mouse-autoselect-window is set
+
+From: Klaus Zeitler <kzeitler@lucent.com>
+Date: Mon, 11 Oct 2004 11:14:49 +0200
+
+1. start emacs -q --no-site-file
+2. set variable mouse-autoselect-window to t
+3. split-window-vertically
+
+now I can drag the modeline only upwards but not downwards
+
+
+** line-spacing and (recenter -1)
+
+From: SAITO Takuya <tabmore@rivo.mediatti.net>
+Date: Mon, 31 May 2004 02:07:57 +0900 (JST)
+
+(recenter -1) does not show point at the bottom of the window
+if line-spacing is set to positive integer.
+
+Start emacs -Q, and evaluate below:
+
+(progn
+  (setq line-spacing 1)
+  (dotimes (i (window-height))
+    (insert "\n" (int-to-string i)))
+  (recenter -1))
+
+Then, point is displayed at the center of the window.
+But point should be displayed at the bottom of the window like Emacs-21.3.
+
+
+** line-spacing and garbage in fringe
+
+From: SAITO Takuya <tabmore@rivo.mediatti.net>
+Date: Mon, 31 May 2004 02:08:05 +0900 (JST)
+
+Start emacs -Q and evaluate below with C-xC-e:
+
+(let ((lines 2)
+      (spacing 1))
+  (setq line-spacing spacing
+	indicate-buffer-boundaries t)
+  (insert (make-string (window-height) ?\n))
+  (goto-char (point-min))
+  (message (make-string (* (window-width) lines) ?.))
+  (scroll-up 1))
+
+then, garbage is displayed in right fringe.
+
+Above code reproduces this bug with
+(frame-parameter nil 'font)
+=> "-Adobe-Courier-Medium-R-Normal--12-120-75-75-M-70-ISO8859-1"
+
+If you use different font, you may need different value of
+`lines' and/or `spacing'.
+
+
+** line-spacing and Electric-pop-up-window
+
+From: SAITO Takuya <tabmore@rivo.mediatti.net>
+Date: Mon, 31 May 2004 02:08:10 +0900 (JST)
+
+Electric-pop-up-window does not work well
+if truncate long lines disabled and/or
+`line-spacing' is set to positive integer.
+
+For example, start emacs -Q --line-spacing 1, and type M-` .
+Then, the last line of *Completions* buffer is not visible.
+
+fit-window-to-buffer works well for me, so I guess
+Electric-pop-up-window can use it.
+
+
 * DOCUMENTATION
 
 ** Finish updating the Emacs Lisp manual.
--- a/configure	Sun Oct 31 02:05:24 2004 +0000
+++ b/configure	Sat Nov 06 17:52:02 2004 +0000
@@ -9797,7 +9797,9 @@
 
   USE_X_TOOLKIT=none
 
-      with_toolkit_scroll_bars=yes
+      if test "$with_toolkit_scroll_bars" != no; then
+    with_toolkit_scroll_bars=yes
+  fi
 
       HAVE_GTK_MULTIDISPLAY=no
 
@@ -9909,6 +9911,222 @@
 _ACEOF
 
   fi
+      HAVE_GTK_FILE_SELECTION=no
+
+for ac_func in gtk_file_selection_new
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&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); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+ HAVE_GTK_FILE_SELECTION=yes
+fi
+done
+
+
+      HAVE_GTK_FILE_CHOOSER=no
+
+for ac_func in gtk_file_chooser_dialog_new
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&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); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+ HAVE_GTK_FILE_CHOOSER=yes
+fi
+done
+
+
+  if test "$HAVE_GTK_FILE_SELECTION" = yes \
+     && test "$HAVE_GTK_FILE_CHOOSER" = yes;  then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_GTK_FILE_BOTH 1
+_ACEOF
+
+  fi
 fi
 
 if test x"${USE_X_TOOLKIT}" = xmaybe; then
--- a/configure.in	Sun Oct 31 02:05:24 2004 +0000
+++ b/configure.in	Sat Nov 06 17:52:02 2004 +0000
@@ -1967,7 +1967,9 @@
 
   dnl  GTK scrollbars resemble toolkit scrollbars a lot, so to avoid
   dnl  a lot if #ifdef:s, say we have toolkit scrollbars.
-  with_toolkit_scroll_bars=yes
+  if test "$with_toolkit_scroll_bars" != no; then
+    with_toolkit_scroll_bars=yes
+  fi
 
   dnl  Check if we can use multiple displays with this GTK version.
   dnl  If gdk_display_open exists, assume all others are there also.
@@ -1977,6 +1979,21 @@
     AC_DEFINE(HAVE_GTK_MULTIDISPLAY, 1,
               [Define to 1 if GTK can handle more than one display.])
   fi
+  dnl  Check if we have the old file selection dialog.
+  dnl  If gdk_display_open exists, assume all others are there also.
+  HAVE_GTK_FILE_SELECTION=no
+  AC_CHECK_FUNCS(gtk_file_selection_new, HAVE_GTK_FILE_SELECTION=yes)
+
+  dnl  Check if we have the new file chooser dialog
+  dnl  If gdk_display_open exists, assume all others are there also.
+  HAVE_GTK_FILE_CHOOSER=no
+  AC_CHECK_FUNCS(gtk_file_chooser_dialog_new, HAVE_GTK_FILE_CHOOSER=yes)
+
+  if test "$HAVE_GTK_FILE_SELECTION" = yes \
+     && test "$HAVE_GTK_FILE_CHOOSER" = yes;  then
+    AC_DEFINE(HAVE_GTK_FILE_BOTH, 1,
+              [Define to 1 if GTK has both file selection and chooser dialog.])
+  fi
 fi
 
 dnl Do not put whitespace before the #include statements below.
--- a/etc/NEWS	Sun Oct 31 02:05:24 2004 +0000
+++ b/etc/NEWS	Sat Nov 06 17:52:02 2004 +0000
@@ -643,14 +643,17 @@
 
 ** BibTeX mode:
 *** The new command bibtex-url browses a URL for the BibTeX entry at
-point (bound to C-c C-l and mouse-2 on clickable fields).
+point (bound to C-c C-l and mouse-2, RET on clickable fields).
+
 *** The new command bibtex-entry-update (bound to C-c C-u) updates
 an existing BibTeX entry.
+
 *** New `bibtex-entry-format' option `required-fields', enabled by default.
+
 *** bibtex-maintain-sorted-entries can take values `plain',
 `crossref', and `entry-class' which control the sorting scheme used
-for BibTeX entries. `bibtex-sort-entry-class' controls the sorting
-scheme `entry-class'. TAB completion for reference keys and
+for BibTeX entries.  `bibtex-sort-entry-class' controls the sorting
+scheme `entry-class'.  TAB completion for reference keys and
 automatic detection of duplicates does not require anymore that
 bibtex-maintain-sorted-entries is non-nil.
 
@@ -667,11 +670,22 @@
 point according to context (bound to M-tab).
 
 *** The new commands bibtex-find-entry and bibtex-find-crossref
-locate entries and crossref'd entries.
+locate entries and crossref'd entries.  Crossref fields are clickable
+(bound to mouse-2, RET).
 
 *** In BibTeX mode the command fill-paragraph (bound to M-q) fills
 individual fields of a BibTeX entry.
 
+*** The new command bibtex-validate-globally checks for duplicate keys
+in multiple BibTeX files.  See also the new variables bibtex-files
+and bibtex-file-path.
+
+*** The new command bibtex-find-entry-globally searches BibTeX entries
+in multiple BibTeX files.
+
+*** The new command bibtex-copy-summary-as-kill pushes summary
+of BibTeX entry to kill ring (bound to C-c C-t).
+
 ** When display margins are present in a window, the fringes are now
 displayed between the margins and the buffer's text area, rather than
 at the edges of the window.
@@ -917,16 +931,27 @@
 
 ---
 ** The pop up menus for Lucid now stay up if you do a fast click and can
-be navigated with the arrow keys (like Gtk+ and W32).
-
----
-** Dialogs for Lucid/Athena and Lesstif/Motif pops down when pressing ESC.
-
-+++
-** The file selection dialog for Gtk+, W32 and Motif/Lesstif can be
+be navigated with the arrow keys (like Gtk+, Mac and W32).
+
+---
+** Dialogs for Lucid/Athena and Lesstif/Motif now pops down when pressing
+ESC, like they do for Gtk+, Mac and W32.
+
+---
+** The menu item "Open File..." has been split into two items, "New File..."
+and "Open File...".  "Open File..." now opens only existing files.  This is
+to support existing GUI file selection dialogs better.
+
++++
+** The file selection dialog for Gtk+, Mac, W32 and Motif/Lesstif can be
 disabled by customizing the variable `use-file-dialog'.
 
 +++
+** For Gtk+ version 2.4, you can make Emacs use the old file dialog
+by setting the variable `use-old-gtk-file-dialog' to t.  Default is to use
+the new dialog.
+
++++
 ** Emacs can produce an underscore-like (horizontal bar) cursor.
 The underscore cursor is set by putting `(cursor-type . hbar)' in
 default-frame-alist.  It supports variable heights, like the `bar'
@@ -2299,6 +2324,13 @@
 * Lisp Changes in Emacs 21.4
 
 +++
+** The new function `called-interactively-p' does what many people
+have mistakenly believed `interactively-p' did: it returns t if the
+calling function was called through `call-interactively'.
+This should only be used when you cannot add a new "interactively"
+argument to the command.
+
++++
 ** An interactive specification may now use the code letter 'U' to get
 the up-event that was discarded in case the last key sequence read for a
 previous 'k' or 'K' argument was a down-event; otherwise nil is used.
--- a/etc/TODO	Sun Oct 31 02:05:24 2004 +0000
+++ b/etc/TODO	Sat Nov 06 17:52:02 2004 +0000
@@ -85,6 +85,8 @@
 	at the same time and do it in a context-sensitive way.
 *** ability to add mode-specific data to the partial-parse-state.
 
+** Add a way to convert a keyboard macro to equivalent Lisp code.
+
 ** Have a command suggestion help system that recognizes patterns
   of commands which could be replaced with a simpler common command.
   It should not make more than one suggestion per 10 minutes.
--- a/lisp/ChangeLog	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/ChangeLog	Sat Nov 06 17:52:02 2004 +0000
@@ -1,7 +1,346 @@
+2004-11-05  Juri Linkov  <juri@jurta.org>
+
+	* info.el (Info-search): Don't search in node header lines
+	and file headers.
+
+	* emacs-lisp/edebug.el (edebug-next-token-class): Allow all
+	symbol-constituent characters after dot, not only digits.
+
+2004-11-04  Daniel Pfeiffer  <occitan@esperanto.org>
+
+	* files.el (set-auto-mode): Don't get error after setting
+	-*-mode-*-.
+
+2004-11-04  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* dired.el (dired-read-dir-and-switches): Call read-directory-name
+	if a dialog will be used, read-file-name otherwise.
+
+2004-11-04  Richard M. Stallman  <rms@gnu.org>
+
+	* textmodes/table.el (table group): Add :version.
+
+	* textmodes/ispell.el (ispell-word):
+	Don't alter args; set them only thru `interactive' spec.
+
+	* textmodes/flyspell.el (flyspell-word):
+	Don't alter FOLLOWING; set it only thru `interactive' spec.
+
+	* progmodes/f90.el (f90-end-of-block): Don't use interactive-p.
+
+	* net/browse-url.el (browse-url-maybe-new-window):
+	Use called-interactively-p.
+
+	* mail/supercite.el (sc-cite-region):
+	Don't use interactive-p.  Add arg INTERACTIVE.
+	(sc-version): Don't use interactive-p.  Rename arg to MESSAGE.
+
+	* international/mule-cmds.el (set-input-method, toggle-input-method):
+	Don't use interactive-p.  Add arg INTERACTIVE.
+
+	* eshell/esh-mode.el (eshell-show-maximum-output):
+	Don't use interactive-p.
+	(eshell-truncate-buffer): Just message, no error, if buffer is short.
+
+	* mouse.el (mouse-show-mark): Get positions to delete from mark
+	and point, not from mouse-drag-overlay.
+
+	* imenu.el (imenu-eager-completion-buffer): Add :version.
+
+	* filesets.el (filesets group): Add :version.
+
+2004-11-03  Daniel Pfeiffer  <occitan@esperanto.org>
+
+	* files.el (xml-based-modes): Delete var.
+	(magic-mode-alist): New more general var.
+	(set-auto-mode): Use it.
+
+	* buff-menu.el (Buffer-menu-make-sort-button): Preserve point even
+	when clicking from another window.
+
+2004-11-03  Thien-Thi Nguyen  <ttn@gnu.org>
+
+	* vc-cvs.el (vc-cvs-local-month-numbers): Delete var.
+	(vc-cvs-annotate-time): Incorporate value of deleted var.
+	Remove special-case handling of beginning-of-buffer cruft.
+	Cache ending position (point) and return value in text property
+	`vc-cvs-annotate-time', and consult it on subsequent invocations.
+
+	* vc-cvs.el (vc-cvs-annotate-command):
+	Delete extraneous lines from beginning of buffer.
+	* vc-mcvs.el (vc-mcvs-annotate-command): Likewise.
+
+	* progmodes/grep.el (grep-default-command): Take empty string
+	for tag if all other methods yield nil.  Shell-quote the tag.
+
+	* vc.el (vc-annotate-display-autoscale): Add prefix-arg
+	spec in `interactive' form, and mention it in the docstring.
+	Also, make sure point is at bol after calling `annotate-time'.
+
+2004-11-02  Richard M. Stallman  <rms@gnu.org>
+
+	* cus-edit.el (customize-group-other-window):
+	Select the window that displays the custom buffer.
+	(custom-buffer-create-other-window): Likewise.
+
+	* comint.el (comint-insert-input): Fix previous change.
+
+	* emacs-lisp/elp.el (elp-instrument-function):
+	Use called-interactively-p.
+
+	* emacs-lisp/easymenu.el (easy-menu-intern):
+	Don't downcase; rather, case-flip the first letter of each word.
+
+	* emacs-lisp/easy-mmode.el (define-minor-mode):
+	Use called-interactively-p.
+
+	* emacs-lisp/bytecomp.el (byte-compile-warning-types):
+	Add interactive-only.
+	(byte-compile-warnings): Add interactive-only as option.
+	(byte-compile-interactive-only-functions): New variable.
+	(byte-compile-form): Warn about calls to functions
+	in byte-compile-interactive-only-functions.
+
+	* emacs-lisp/autoload.el (update-file-autoloads):
+	Don't use interactive-p; take new arg SAVE-AFTER.
+
+	* emacs-lisp/advice.el (ad-make-advised-definition):
+	Use called-interactively-p.
+
+2004-11-02  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* files.el (find-file-existing): New function.
+
+	* menu-bar.el (menu-bar-files-menu): Make "Open File..." call
+	find-file-existing.  Add "New File..." that calls find-file.
+
+	* diropen.pbm diropen.xpm: New files.
+
+	* toolbar/tool-bar.el (tool-bar-setup): Tool bar item dired uses
+	icon diropen.  New tool bar item find-file-existing uses icon open.
+
+	* dired.el (dired-read-dir-and-switches): Call read-driectory-name
+	instead of read-file-name.
+
+2004-11-02  Ulf Jasper  <ulf.jasper@web.de>
+
+	* calendar/icalendar.el (icalendar-version): Increase to 0.08.
+	(icalendar--split-value): Change name of work buffer.
+	(icalendar--get-weekday-abbrev): Return nil on error.
+	(icalendar--date-to-isodate): New function.
+	(icalendar-convert-diary-to-ical)
+	(icalendar-extract-ical-from-buffer): Use only two args for
+	make-obsolete (XEmacs compatibility).
+	(icalendar-export-file, icalendar-import-file): Blank at end of
+	prompt.
+	(icalendar-export-region): Doc fix.
+	If error, return non-nil and write errors to a buffer.
+	Use correct weekday for weekly recurring events.
+	Check whether date has been parsed for ordinary events.
+	Make weekly events start in the year 2000.
+	DTEND is non-inclusive, shift end date by one day if
+	necessary (not for entries that have date and time).
+	Rename local let variables: oops -> found-error, datestring ->
+	startdatestring.
+
+2004-11-02  Kim F. Storm  <storm@cua.dk>
+
+	* files.el (set-auto-mode-0): Don't rely on dynamic binding of
+	keep-mode-if-same variable.  Add it as optional arg instead.
+	(set-auto-mode): Call set-auto-mode-0 with keep-mode-if-same.
+
+	* ehelp.el (electric-help-map): Reorder Q/q and R/r entries so
+	substitute-command-keys will select lower-case bindings like those
+	used in the static help texts.
+
+	* descr-text.el (describe-text-properties): Don't err if called in
+	the *Help* buffer; output to *Help-2* buffer instead.
+
+	* kmacro.el (group kmacro): Add :version.
+	(kmacro-keyboard-quit): New function to cleanup on C-g.
+	(kmacro-start-macro): Set defining-kbd-macro to append when
+	appending to last macro.
+
+	* simple.el (keyboard-quit): Call kmacro-keyboard-quit.
+
+2004-11-02  Nick Roberts  <nickrob@snap.net.nz>
+
+	* progmodes/gdb-ui.el (gdb-enable-debug-log)
+	(gdb-use-inferior-io-buffer, gdb-use-colon-colon-notation)
+	(gud-gdba-command-name, gdb-show-main, gdb-many-windows):
+	Add :version keyword.
+
+2004-11-02  Pavel Kobiakov <pk_at_work@yahoo.com>
+
+	* progmodes/flymake.el (flymake-err-line-patterns): Use
+	`flymake-reformat-err-line-patterns-from-compile-el' to convert
+	`compilation-error-regexp-alist-alist' to internal Flymake format.
+
+	* progmodes/flymake.el: eliminated byte-compiler warnings.
+
+2004-11-01  Jay Belanger  <belanger@truman.edu>
+
+	* calc/calc-frac.el (calc-over-notation): Replaced
+	`completing-read' with `interactive "s"'.
+
+2004-11-01  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* mouse.el (mouse-yank-at-click, mouse-yank-secondary):
+	Revert change from 2004-10-16.  '*' checks the current buffer, but the
+	mouse click may be in another buffer.
+
+2004-11-01  John Paul Wallington  <jpw@gnu.org>
+
+	* files.el (large-file-warning-threshold): Add :version keyword.
+	(kill-some-buffers): Doc fix.
+
+	* thumbs.el (group thumbs): Add :version keyword.
+
+	* textmodes/bibtex.el (bibtex-make-field): Fix typo.
+
+2004-11-01  Richard M. Stallman  <rms@gnu.org>
+
+	* textmodes/ispell.el (ispell-word): Don't use interactive-p.
+
+	* textmodes/flyspell.el (flyspell-word): Don't use interactive-p.
+
+	* allout.el (allout group): Add :version.
+	(allout-init): Don't use interactive-p.
+	(allout-ascend-to-depth, allout-ascend, allout-end-of-level)
+	(allout-forward-current-level, allout-backward-current-level):
+	Don't use interactive-p.
+
+	* textmodes/bibtex.el (bibtex-make-field): Don't use interactive-p.
+	(bibtex-find-text): Likewise.
+
+	* progmodes/vhdl-mode.el (vhdl-fill-region)
+	(vhdl-beginning-of-statement): Don't use interactive-p.
+
+	* progmodes/idlwave.el (idlwave-update-routine-info):
+	Don't use interactive-p.
+
+	* progmodes/idlw-shell.el (idlwave-shell-send-char):
+	Don't use interactive-p.
+
+	* progmodes/cperl-mode.el (cperl-switch-to-doc-buffer):
+	Don't use interactive-p.
+
+	* progmodes/ada-xref.el (ada-make-body-gnatstub):
+	Don't use interactive-p.
+
+	* play/fortune.el (fortune-to-signature): Don't use interactive-p.
+	(fortune-in-buffer): Doc fix.
+
+	* play/5x5.el (5x5-new-game): Set up the buffer even if not interactive.
+
+	* net/eudc.el (eudc-display-records): Use with-output-to-temp-buffer;
+	don't select the temporary buffer.
+	(eudc-get-email): New optional arg ERROR; don't use interactive-p.
+	(eudc-get-phone): Likewise.
+
+2004-11-01  Kim F. Storm  <storm@cua.dk>
+
+	* man.el (Man-xref-normal-file): Fix help-echo.
+
+2004-10-31  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* reveal.el (reveal-last-tick): New var.
+	(reveal-post-command): Use it to avoid closing overlays when we're
+	appending text to them.
+
+2004-10-31  Roland Winkler  <Roland.Winkler@physik.uni-erlangen.de>
+
+	* textmodes/bibtex.el: Require button.
+	(bibtex-autokey-transcriptions): Translate TeX `\ ' to space.
+	(bibtex-reference-keys): Distinguish between header keys and
+	crossref keys.
+	(bibtex-beginning-of-field): New function.
+	(bibtex-url-map): Remove.
+	(bibtex-font-lock-keywords): Use bibtex-font-lock-crossref.
+	(bibtex-font-lock-url-regexp): Assume that field names begin at
+	the beginning of a line.
+	(bibtex-font-lock-url): Simplify.  Do not use bibtex-enclosing-field.
+	Remove field delimiters.  Use bibtex-beginning-of-field.
+	Bugfix, point can be inside a field with a url.
+	(bibtex-font-lock-crossref, bibtex-button-action, bibtex-button):
+	New functions.
+	(bibtex-mark-active, bibtex-run-with-idle-timer): Remove.
+	(bibtex-key-in-head): Simplify.
+	(bibtex-current-line): Use bolp.
+	(bibtex-parse-keys): Remove unused arg `add'.
+	Use bibtex-type-in-head and bibtex-key-in-head.
+	(bibtex-parse-entry, bibtex-autofill-entry):
+	Use bibtex-type-in-head and bibtex-key-in-head.
+	(bibtex-autokey-get-field): Do not alter case of replacement text.
+	(bibtex-autokey-get-names): Do all processing of name list.
+	(bibtex-autokey-get-year): New function.
+	(bibtex-autokey-get-title): Do all processing of title words.
+	(bibtex-generate-autokey): Simplify.
+	(bibtex-string-files-init): Use default-directory.
+	Allow for absolute file names in bibtex-string-files.
+	(bibtex-files, bibtex-file-path): New variables.
+	(bibtex-files-expand): New function.
+	(bibtex-find-entry-globally): New command.
+	(bibtex-summary-function): New variable.
+	(bibtex-summary): Default value of bibtex-summary-function.
+	(bibtex-find-crossref): New optional args pnt and split.
+	(bibtex-complete-key-cleanup): Call bibtex-summary-function.
+	(bibtex-copy-summary-as-kill): New command bound to C-cC-t.
+	(bibtex-validate): Fix docstring.  Check only abbreviated month fields.
+	Fix handling of required and alternative fields.
+	Identify duplicate keys even if bibtex-maintain-sorted-entries is nil.
+	Use cons and display-buffer.
+	(bibtex-validate-globally): New command.
+	(bibtex-clean-entry): Use bibtex-files-expand.  Do not call
+	bibtex-parse-keys and bibtex-parse-strings for updating
+	bibtex-reference-keys and bibtex-strings.
+	(bibtex-realign): Remove blank lines past the last entry.
+	(bibtex-reformat): Use bibtex-entry-format as default.
+	(bibtex-choose-completion-string): Remove.
+	(bibtex-complete): Do not use bibtex-choose-completion-string.
+	(bibtex-url): Simplify.
+
+2004-10-31  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* x-dnd.el (x-dnd-test-function, x-dnd-protocol-alist)
+	(x-dnd-types-alist, x-dnd-open-file-other-window)
+	(x-dnd-known-types): Add :version.
+
+2004-10-31  John Paul Wallington  <jpw@gnu.org>
+
+	* ibuffer.el (group ibuffer): Add :version keyword.
+
+2004-10-31  Kim F. Storm  <storm@cua.dk>
+
+	* ido.el (group ido): Add :version keyword.
+	(ido-mode): Remove :version keyword.
+
+	* emulation/cua-base.el (group cua): Add :version keyword.
+	(cua-mode): Remove :version keyword.
+
+2004-10-30  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* autorevert.el (auto-revert-tail-mode-text): Add :version keyword.
+
+	* help-at-pt.el (help-at-pt-timer): Move defvar up to avoid
+	compiler warning.
+	(help-at-pt-timer-delay): Add :initialize keyword.  Simplify :set
+	function.
+	(help-at-pt-display-when-idle): Remove autoload.
+
+2004-10-30  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* makefile.w32-in (custom-deps, autoloads): Fix *-hooks -> *-hook.
+
+2004-10-30  Juri Linkov  <juri@jurta.org>
+
+	* help.el (function-called-at-point):
+	* help-fns.el (variable-at-point): Read -> intern.
+
 2004-10-30  Simon Josefsson  <jas@extundo.com>
 
-	* progmodes/autoconf.el (autoconf-font-lock-keywords): Recognize
-	AS_* too.
+	* progmodes/autoconf.el (autoconf-font-lock-keywords):
+	Recognize AS_* too.
 
 2004-10-29  Simon Josefsson  <jas@extundo.com>
 
@@ -18,7 +357,7 @@
 	* mouse.el (mouse-show-mark): Replace the last occurrence of
 	x-lost-selection-hooks with x-lost-selection-functions.
 
-2004-10-28  Stefan  <monnier@iro.umontreal.ca>
+2004-10-28  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* mouse.el (mouse-show-mark): Adjust to new name and don't assume
 	x-lost-selection-functions is bound.
@@ -70,8 +409,8 @@
 
 2004-10-28  Kenichi Handa  <handa@m17n.org>
 
-	* international/utf-8.el (utf-translate-cjk-charsets): Add
-	katakana-jisx0201.
+	* international/utf-8.el (utf-translate-cjk-charsets):
+	Add katakana-jisx0201.
 
 	* international/subst-jis.el: Add data for JISX0201.
 
@@ -1126,7 +1465,7 @@
 
 2004-09-17  Jay Belanger  <belanger@truman.edu>
 
-	* calc/calc.el (calc-mode-var-list): Fixed the value of
+	* calc/calc.el (calc-mode-var-list): Fix the value of
 	`calc-matrix-brackets'.
 
 2004-09-17  Romain Francoise  <romain@orebokech.com>
--- a/lisp/allout.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/allout.el	Sat Nov 06 17:52:02 2004 +0000
@@ -68,7 +68,8 @@
 (defgroup allout nil
   "Extensive outline mode for use alone and with other modes."
   :prefix "allout-"
-  :group 'editing)
+  :group 'editing
+  :version "21.4")
 
 ;;;_ + Layout, Mode, and Topic Header Configuration
 
@@ -954,20 +955,16 @@
 \(require 'allout)
 \(allout-init t)"
 
-  (interactive)
-  (if (interactive-p)
-      (progn
-	(setq mode
-	      (completing-read
-	       (concat "Select outline auto setup mode "
-		       "(empty for report, ? for options) ")
-	       '(("nil")("full")("activate")("deactivate")
-		 ("ask") ("report") (""))
-	       nil
-	       t))
-	(if (string= mode "")
-	    (setq mode 'report)
-	  (setq mode (intern-soft mode)))))
+  (interactive
+   (let ((m (completing-read
+	     (concat "Select outline auto setup mode "
+		     "(empty for report, ? for options) ")
+	     '(("nil")("full")("activate")("deactivate")
+	       ("ask") ("report") (""))
+	     nil
+	     t)))
+     (if (string= m "") 'report
+       (intern-soft m))))
   (let
       ;; convenience aliases, for consistent ref to respective vars:
       ((hook 'allout-find-file-hook)
@@ -1902,16 +1899,12 @@
         (if (= (allout-recent-depth) depth)
             (progn (goto-char allout-recent-prefix-beginning)
                    depth)
-          (goto-char last-good)
-          nil))
-    (if (interactive-p) (allout-end-of-prefix))))
+          (goto-char last-good)))))
 ;;;_   > allout-ascend ()
 (defun allout-ascend ()
   "Ascend one level, returning t if successful, nil if not."
-  (prog1
-      (if (allout-beginning-of-level)
-	  (allout-previous-heading))
-    (if (interactive-p) (allout-end-of-prefix))))
+  (if (allout-beginning-of-level)
+      (allout-previous-heading)))
 ;;;_   > allout-descend-to-depth (depth)
 (defun allout-descend-to-depth (depth)
   "Descend to depth DEPTH within current topic.
@@ -1931,13 +1924,13 @@
       nil))
   )
 ;;;_   > allout-up-current-level (arg &optional dont-complain)
-(defun allout-up-current-level (arg &optional dont-complain)
+(defun allout-up-current-level (arg &optional dont-complain interactive)
   "Move out ARG levels from current visible topic.
 
 Positions on heading line of containing topic.  Error if unable to
 ascend that far, or nil if unable to ascend but optional arg
 DONT-COMPLAIN is non-nil."
-  (interactive "p")
+  (interactive "p\np")
   (allout-back-to-current-heading)
   (let ((present-level (allout-recent-depth))
 	(last-good (point))
@@ -1958,12 +1951,12 @@
     (if (or failed
 	    (> arg 0))
 	(progn (goto-char last-good)
-	       (if (interactive-p) (allout-end-of-prefix))
+	       (if interactive (allout-end-of-prefix))
 	       (if (not dont-complain)
 		   (error "Can't ascend past outermost level")
-		 (if (interactive-p) (allout-end-of-prefix))
+		 (if interactive (allout-end-of-prefix))
 		 nil))
-      (if (interactive-p) (allout-end-of-prefix))
+      (if interactive (allout-end-of-prefix))
       allout-recent-prefix-beginning)))
 
 ;;;_  - Linear
@@ -2029,7 +2022,7 @@
   (let ((depth (allout-depth)))
     (while (allout-previous-sibling depth nil))
     (prog1 (allout-recent-depth)
-      (if (interactive-p) (allout-end-of-prefix)))))
+      (allout-end-of-prefix))))
 ;;;_   > allout-next-visible-heading (arg)
 (defun allout-next-visible-heading (arg)
   "Move to the next ARG'th visible heading line, backward if arg is negative.
@@ -2067,13 +2060,13 @@
   (interactive "p")
   (allout-next-visible-heading (- arg)))
 ;;;_   > allout-forward-current-level (arg)
-(defun allout-forward-current-level (arg)
+(defun allout-forward-current-level (arg &optional interactive)
   "Position point at the next heading of the same level.
 
 Takes optional repeat-count, goes backward if count is negative.
 
 Returns resulting position, else nil if none found."
-  (interactive "p")
+  (interactive "p\np")
   (let ((start-depth (allout-current-depth))
 	(start-point (point))
 	(start-arg arg)
@@ -2101,7 +2094,7 @@
 		  (= (allout-recent-depth) start-depth)))
 	allout-recent-prefix-beginning
       (goto-char last-good)
-      (if (not (interactive-p))
+      (if (not interactive)
 	  nil
 	(allout-end-of-prefix)
 	(error "Hit %s level %d topic, traversed %d of %d requested"
@@ -2110,10 +2103,10 @@
 	       (- (abs start-arg) arg)
 	       (abs start-arg))))))
 ;;;_   > allout-backward-current-level (arg)
-(defun allout-backward-current-level (arg)
+(defun allout-backward-current-level (arg &optional interactive)
   "Inverse of `allout-forward-current-level'."
-  (interactive "p")
-  (if (interactive-p)
+  (interactive "p\np")
+  (if interactive
       (let ((current-prefix-arg (* -1 arg)))
 	(call-interactively 'allout-forward-current-level))
     (allout-forward-current-level (* -1 arg))))
--- a/lisp/autorevert.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/autorevert.el	Sat Nov 06 17:52:02 2004 +0000
@@ -172,7 +172,8 @@
 
 \(When the string is not empty, make sure that it has a leading space.)"
   :group 'auto-revert
-  :type 'string)
+  :type 'string
+  :version "21.4")
 
 (defcustom auto-revert-mode-hook nil
   "Functions to run when Auto-Revert Mode is activated."
--- a/lisp/buff-menu.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/buff-menu.el	Sat Nov 06 17:52:02 2004 +0000
@@ -627,8 +627,9 @@
 			(define-key map [header-line mouse-2]
 			  `(lambda (e)
 			     (interactive "e")
-			     (if e (set-buffer (window-buffer (posn-window (event-end e)))))
-			     (Buffer-menu-sort ,column)))
+			     (save-window-excursion
+			       (if e (mouse-select-window e))
+			       (Buffer-menu-sort ,column))))
 			map)))
 
 (defun list-buffers-noselect (&optional files-only)
--- a/lisp/calc/calc-frac.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/calc/calc-frac.el	Sat Nov 06 17:52:02 2004 +0000
@@ -54,12 +54,7 @@
 
 
 (defun calc-over-notation (fmt)
-  (interactive
-   (list
-    (completing-read "Fraction separator: " (mapcar (lambda (s)
-						      (cons s 0))
-						    '(":" "::" "/" "//" ":/"))
-		     nil t)))
+  (interactive "sFraction separator: ")
   (calc-wrapper
    (if (string-match "\\`\\([^ 0-9][^ 0-9]?\\)[0-9]*\\'" fmt)
        (let ((n nil))
--- a/lisp/calendar/icalendar.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/calendar/icalendar.el	Sat Nov 06 17:52:02 2004 +0000
@@ -31,16 +31,7 @@
 
 ;;; History:
 
-;;  0.07: Renamed commands!
-;;        icalendar-extract-ical-from-buffer -> icalendar-import-buffer
-;;        icalendar-convert-diary-to-ical    -> icalendar-export-file
-;;        Naming scheme: icalendar-.* = user command; icalendar--.* =
-;;        internal.
-;;        Added icalendar-export-region.
-;;        The import and export commands do not clear their target file,
-;;        but append their results to the target file.
-;;        I18n-problems fixed -- use calendar-(month|day)-name-array.
-;;        Fixed problems with export of multi-line diary entries.
+;;  0.07 onwards: see lisp/ChangeLog
 
 ;;  0.06: Bugfixes regarding icalendar-import-format-*.
 ;;        Fix in icalendar-convert-diary-to-ical -- thanks to Philipp
@@ -99,7 +90,7 @@
 
 ;;; Code:
 
-(defconst icalendar-version 0.07
+(defconst icalendar-version 0.08
   "Version number of icalendar.el.")
 
 ;; ======================================================================
@@ -333,7 +324,7 @@
         param-name param-value)
     (when value-string
       (save-current-buffer
-        (set-buffer (get-buffer-create " *ical-temp*"))
+        (set-buffer (get-buffer-create " *icalendar-work*"))
         (set-buffer-modified-p nil)
         (erase-buffer)
         (insert value-string)
@@ -529,7 +520,17 @@
                 (setq num (1+ num))))
             calendar-day-name-array))
     ;; Error:
-    "??"))
+    nil))
+
+(defun icalendar--date-to-isodate (date &optional day-shift)
+  "Convert DATE to iso-style date.
+DATE must be a list of the form (month day year).
+If DAY-SHIFT is non-nil, the result is shifted by DAY-SHIFT days."
+  (let ((mdy (calendar-gregorian-from-absolute
+              (+ (calendar-absolute-from-gregorian date)
+                 (or day-shift 0)))))
+    (format "%04d%02d%02d" (nth 2 mdy) (nth 0 mdy) (nth 1 mdy))))
+
 
 (defun icalendar--datestring-to-isodate (datestring &optional day-shift)
   "Convert diary-style DATESTRING to iso-style date.
@@ -587,7 +588,7 @@
     (if (> day 0)
         (let ((mdy (calendar-gregorian-from-absolute
                     (+ (calendar-absolute-from-gregorian (list month day
-							       year))
+                                                               year))
                        (or day-shift 0)))))
           (format "%04d%02d%02d" (nth 2 mdy) (nth 0 mdy) (nth 1 mdy)))
       nil)))
@@ -625,22 +626,24 @@
   "Export diary file to iCalendar format.
 All diary entries in the file DIARY-FILENAME are converted to iCalendar
 format.  The result is appended to the file ICAL-FILENAME."
-  (interactive "FExport diary data from file:
+  (interactive "FExport diary data from file: 
 Finto iCalendar file: ")
   (save-current-buffer
     (set-buffer (find-file diary-filename))
     (icalendar-export-region (point-min) (point-max) ical-filename)))
 
 (defalias 'icalendar-convert-diary-to-ical 'icalendar-export-file)
-(make-obsolete 'icalendar-convert-diary-to-ical 'icalendar-export-file
-               "icalendar 0.07")
+(make-obsolete 'icalendar-convert-diary-to-ical 'icalendar-export-file)
 
 ;; User function
 (defun icalendar-export-region (min max ical-filename)
   "Export region in diary file to iCalendar format.
 All diary entries in the region from MIN to MAX in the current buffer are
 converted to iCalendar format.  The result is appended to the file
-ICAL-FILENAME."
+ICAL-FILENAME.
+
+Returns non-nil if an error occurred.  In this case an error message is
+written to the buffer ` *icalendar-errors*'."
   (interactive "r
 FExport diary data into iCalendar file: ")
   (let ((result "")
@@ -649,9 +652,14 @@
         (entry-rest "")
         (header "")
         (contents)
-        (oops nil)
+        (found-error nil)
         (nonmarker (concat "^" (regexp-quote diary-nonmarking-symbol)
                            "?")))
+    ;; prepare buffer with error messages
+    (save-current-buffer
+      (set-buffer (get-buffer-create " *icalendar-errors*"))
+      (erase-buffer))
+    ;; here we go
     (save-excursion
       (goto-char min)
       (while (re-search-forward
@@ -664,330 +672,366 @@
                              (car (current-time))
                              (cadr (current-time))
                              (car (cddr (current-time)))))
-        (setq oops nil)
-        (cond
-         ;; anniversaries
-         ((string-match
-           (concat nonmarker
-                   "%%(diary-anniversary \\([^)]+\\))\\s-*\\(.*\\)")
-           entry-main)
-          (icalendar--dmsg "diary-anniversary %s" entry-main)
-          (let* ((datetime (substring entry-main (match-beginning 1)
-                                      (match-end 1)))
-                 (summary (icalendar--convert-string-for-export
-                           (substring entry-main (match-beginning 2)
-                                      (match-end 2))))
-                 (startisostring (icalendar--datestring-to-isodate
-                                  datetime))
-                 (endisostring (icalendar--datestring-to-isodate
-                                datetime 1)))
-            (setq contents
-                  (concat "\nDTSTART;VALUE=DATE:" startisostring
-                          "\nDTEND;VALUE=DATE:" endisostring
-                          "\nSUMMARY:" summary
-                          "\nRRULE:FREQ=YEARLY;INTERVAL=1"
-                          ;; the following is redundant,
-                          ;; but korganizer seems to expect this... ;(
-                          ;; and evolution doesn't understand it... :(
-                          ;; so... who is wrong?!
-                          ";BYMONTH=" (substring startisostring 4 6)
-                          ";BYMONTHDAY=" (substring startisostring 6 8)
-                          )))
-          (unless (string= entry-rest "")
-            (setq contents (concat contents "\nDESCRIPTION:"
-                                   (icalendar--convert-string-for-export
-                                    entry-rest)))))
-         ;; cyclic events
-         ;; %%(diary-cyclic )
-         ((string-match
-           (concat nonmarker
-                   "%%(diary-cyclic \\([^ ]+\\) +"
-                   "\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\))\\s-*\\(.*\\)")
-           entry-main)
-          (icalendar--dmsg "diary-cyclic %s" entry-main)
-          (let* ((frequency (substring entry-main (match-beginning 1)
-                                       (match-end 1)))
-                 (datetime (substring entry-main (match-beginning 2)
-                                      (match-end 2)))
-                 (summary (icalendar--convert-string-for-export
-                           (substring entry-main (match-beginning 3)
-                                      (match-end 3))))
-                 (startisostring (icalendar--datestring-to-isodate
-                                  datetime))
-                 (endisostring (icalendar--datestring-to-isodate
-                                datetime 1)))
-            (setq contents
-                  (concat "\nDTSTART;VALUE=DATE:" startisostring
-                          "\nDTEND;VALUE=DATE:" endisostring
-                          "\nSUMMARY:" summary
-                          "\nRRULE:FREQ=DAILY;INTERVAL=" frequency
-                          ;; strange: korganizer does not expect
-                          ;; BYSOMETHING here...
-                          )))
-          (unless (string= entry-rest "")
-            (setq contents (concat contents "\nDESCRIPTION:"
-                                   (icalendar--convert-string-for-export
-                                    entry-rest)))))
-         ;; diary-date -- FIXME
-         ((string-match
-           (concat nonmarker
-                   "%%(diary-date \\([^)]+\\))\\s-*\\(.*\\)")
-           entry-main)
-          (icalendar--dmsg "diary-date %s" entry-main)
-          (setq oops t))
-         ;; float events -- FIXME
-         ((string-match
-           (concat nonmarker
-                   "%%(diary-float \\([^)]+\\))\\s-*\\(.*\\)")
-           entry-main)
-          (icalendar--dmsg "diary-float %s" entry-main)
-          (setq oops t))
-         ;; block events
-         ((string-match
-           (concat nonmarker
-                   "%%(diary-block \\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\) +"
-                   "\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\))\\s-*\\(.*\\)")
-           entry-main)
-          (icalendar--dmsg "diary-block %s" entry-main)
-          (let* ((startstring (substring entry-main (match-beginning 1)
-                                         (match-end 1)))
-                 (endstring (substring entry-main (match-beginning 2)
-                                       (match-end 2)))
-                 (summary (icalendar--convert-string-for-export
-                           (substring entry-main (match-beginning 3)
-                                      (match-end 3))))
-                 (startisostring (icalendar--datestring-to-isodate
-                                  startstring))
-                 (endisostring (icalendar--datestring-to-isodate
-                                endstring 1)))
-            (setq contents
-                  (concat "\nDTSTART;VALUE=DATE:" startisostring
-                          "\nDTEND;VALUE=DATE:" endisostring
-                          "\nSUMMARY:" summary
-                          ))
-            (unless (string= entry-rest "")
-              (setq contents (concat contents "\nDESCRIPTION:"
-                                     (icalendar--convert-string-for-export
-                                      entry-rest))))))
-         ;; other sexp diary entries -- FIXME
-         ((string-match
-           (concat nonmarker
-                   "%%(\\([^)]+\\))\\s-*\\(.*\\)")
-           entry-main)
-          (icalendar--dmsg "diary-sexp %s" entry-main)
-          (setq oops t))
-         ;; weekly by day
-         ;; Monday 8:30 Team meeting
-         ((and (string-match
-                (concat nonmarker
-                        "\\([a-z]+\\)\\s-+"
-                        "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?"
-                        "\\(-0?"
-                        "\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?"
-                        "\\)?"
-                        "\\s-*\\(.*\\)$")
-                entry-main)
-               (icalendar--get-weekday-abbrev
-                (substring entry-main (match-beginning 1) (match-end 1))))
-          (icalendar--dmsg "weekly %s" entry-main)
-          (let* ((day (icalendar--get-weekday-abbrev
-                       (substring entry-main (match-beginning 1)
-                                  (match-end 1))))
-                 (starttimestring (icalendar--diarytime-to-isotime
-                                   (if (match-beginning 3)
-                                       (substring entry-main
-                                                  (match-beginning 3)
-                                                  (match-end 3))
-                                     nil)
-                                   (if (match-beginning 4)
-                                       (substring entry-main
-                                                  (match-beginning 4)
-                                                  (match-end 4))
-                                     nil)))
-                 (endtimestring (icalendar--diarytime-to-isotime
-                                 (if (match-beginning 6)
-                                     (substring entry-main
-                                                (match-beginning 6)
-                                                (match-end 6))
-                                   nil)
-                                 (if (match-beginning 7)
-                                     (substring entry-main
-                                                (match-beginning 7)
-                                                (match-end 7))
-                                   nil)))
-                 (summary (icalendar--convert-string-for-export
-                           (substring entry-main (match-beginning 8)
-                                      (match-end 8)))))
-            (when starttimestring
-              (unless endtimestring
-                (let ((time (read (icalendar--rris "^T0?" ""
-                                                   starttimestring))))
-                  (setq endtimestring (format "T%06d" (+ 10000 time))))))
-            (setq contents
-                  (concat "\nDTSTART"
-                          (if starttimestring "" ";VALUE=DATE")
-                          ":19000101" ;; FIXME? Probability that this
-                          ;; is the right day is 1/7
-                          (or starttimestring "")
-                          "\nDTEND"
-                          (if endtimestring "" ";VALUE=DATE")
-                          ":19000101" ;; FIXME?
-                          (or endtimestring "")
-                          "\nSUMMARY:" summary
-                          "\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=" day
-                          )))
-          (unless (string= entry-rest "")
-            (setq contents (concat contents "\nDESCRIPTION:"
-                                   (icalendar--convert-string-for-export
-                                    entry-rest)))))
-         ;; yearly by day
-         ;; 1 May Tag der Arbeit
-         ((string-match
-           (concat nonmarker
-                   (if european-calendar-style
-                       "0?\\([1-9]+[0-9]?\\)\\s-+\\([a-z]+\\)\\s-+"
-                     "\\([a-z]+\\)\\s-+0?\\([1-9]+[0-9]?\\)\\s-+")
-                   "\\*?\\s-*"
-                   "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?"
-                   "\\("
-                   "-0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?"
-                   "\\)?"
-                   "\\s-*\\([^0-9]+.*\\)$" ; must not match years
-                   )
-           entry-main)
-          (icalendar--dmsg "yearly %s" entry-main)
-          (let* ((daypos (if european-calendar-style 1 2))
-                 (monpos (if european-calendar-style 2 1))
-                 (day (read (substring entry-main (match-beginning daypos)
-                                       (match-end daypos))))
-                 (month (icalendar--get-month-number
-                         (substring entry-main (match-beginning monpos)
-                                    (match-end monpos))))
-                 (starttimestring (icalendar--diarytime-to-isotime
-                                   (if (match-beginning 4)
-                                       (substring entry-main
-                                                  (match-beginning 4)
-                                                  (match-end 4))
-                                     nil)
-                                   (if (match-beginning 5)
-                                       (substring entry-main
-                                                  (match-beginning 5)
-                                                  (match-end 5))
-                                     nil)))
-                 (endtimestring (icalendar--diarytime-to-isotime
-                                 (if (match-beginning 7)
-                                     (substring entry-main
-                                                (match-beginning 7)
-                                                (match-end 7))
-                                   nil)
-                                 (if (match-beginning 8)
-                                     (substring entry-main
-                                                (match-beginning 8)
-                                                (match-end 8))
-                                   nil)))
-                 (summary (icalendar--convert-string-for-export
-                           (substring entry-main (match-beginning 9)
-                                      (match-end 9)))))
-            (when starttimestring
-              (unless endtimestring
-                (let ((time (read (icalendar--rris "^T0?" ""
-                                                   starttimestring))))
-                  (setq endtimestring (format "T%06d" (+ 10000 time))))))
-            (setq contents
-                  (concat "\nDTSTART"
-                          (if starttimestring "" ";VALUE=DATE")
-                          (format ":1900%02d%02d" month day)
-                          (or starttimestring "")
-                          "\nDTEND"
-                          (if endtimestring "" ";VALUE=DATE")
-                          (format ":1900%02d%02d" month day)
-                          (or endtimestring "")
-                          "\nSUMMARY:" summary
-                          "\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH="
-                          (format "%2d" month)
-                          ";BYMONTHDAY="
-                          (format "%2d" day)
-                          )))
-          (unless (string= entry-rest "")
-            (setq contents (concat contents "\nDESCRIPTION:"
-                                   (icalendar--convert-string-for-export
-                                    entry-rest)))))
-         ;; "ordinary" events, start and end time given
-         ;; 1 Feb 2003 Hs Hochzeitsfeier, Dreieich
-         ((string-match
-           (concat nonmarker
-                   "\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\)\\s-+"
-                   "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?"
-                   "\\("
-                   "-0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?"
-                   "\\)?"
-                   "\\s-*\\(.*\\)")
-           entry-main)
-          (icalendar--dmsg "ordinary %s" entry-main)
-          (let* ((datestring (icalendar--datestring-to-isodate
-                              (substring entry-main (match-beginning 1)
-                                         (match-end 1))))
-                 (starttimestring (icalendar--diarytime-to-isotime
-                                   (if (match-beginning 3)
-                                       (substring entry-main
-                                                  (match-beginning 3)
-                                                  (match-end 3))
-                                     nil)
-                                   (if (match-beginning 4)
-                                       (substring entry-main
-                                                  (match-beginning 4)
-                                                  (match-end 4))
-                                     nil)))
-                 (endtimestring (icalendar--diarytime-to-isotime
-                                 (if (match-beginning 6)
-                                     (substring entry-main
-                                                (match-beginning 6)
-                                                (match-end 6))
-                                   nil)
-                                 (if (match-beginning 7)
-                                     (substring entry-main
-                                                (match-beginning 7)
-                                                (match-end 7))
-                                   nil)))
-                 (summary (icalendar--convert-string-for-export
-                           (substring entry-main (match-beginning 8)
-                                      (match-end 8)))))
-            (when starttimestring
-              (unless endtimestring
-                (let ((time (read (icalendar--rris "^T0?" ""
-                                                   starttimestring))))
-                  (setq endtimestring (format "T%06d" (+ 10000 time))))))
-            (setq contents (format
-                            "\nDTSTART%s:%s%s\nDTEND%s:%s%s\nSUMMARY:%s"
-                            (if starttimestring "" ";VALUE=DATE")
-                            datestring
-                            (or starttimestring "")
-                            (if endtimestring ""
-                              ";VALUE=DATE")
-                            datestring
-                            (or endtimestring "")
-                            summary))
-            (unless (string= entry-rest "")
-              (setq contents (concat contents "\nDESCRIPTION:"
-                                     (icalendar--convert-string-for-export
-                                      entry-rest))))))
-         ;; everything else
-         (t
-          ;; Oops! what's that?
-          (setq oops t)))
-        (if oops
-            (message "Cannot export entry on line %d"
-                     (count-lines (point-min) (point)))
-          (setq result (concat result header contents "\nEND:VEVENT"))))
+        (condition-case error-val
+            (progn
+              (cond
+               ;; anniversaries
+               ((string-match
+                 (concat nonmarker
+                         "%%(diary-anniversary \\([^)]+\\))\\s-*\\(.*\\)")
+                 entry-main)
+                (icalendar--dmsg "diary-anniversary %s" entry-main)
+                (let* ((datetime (substring entry-main (match-beginning 1)
+                                            (match-end 1)))
+                       (summary (icalendar--convert-string-for-export
+                                 (substring entry-main (match-beginning 2)
+                                            (match-end 2))))
+                       (startisostring (icalendar--datestring-to-isodate
+                                        datetime))
+                       (endisostring (icalendar--datestring-to-isodate
+                                      datetime 1)))
+                  (setq contents
+                        (concat "\nDTSTART;VALUE=DATE:" startisostring
+                                "\nDTEND;VALUE=DATE:" endisostring
+                                "\nSUMMARY:" summary
+                                "\nRRULE:FREQ=YEARLY;INTERVAL=1"
+                                ;; the following is redundant,
+                                ;; but korganizer seems to expect this... ;(
+                                ;; and evolution doesn't understand it... :(
+                                ;; so... who is wrong?!
+                                ";BYMONTH=" (substring startisostring 4 6)
+                                ";BYMONTHDAY=" (substring startisostring 6 8)
+                                )))
+                (unless (string= entry-rest "")
+                  (setq contents (concat contents "\nDESCRIPTION:"
+                                         (icalendar--convert-string-for-export
+                                          entry-rest)))))
+               ;; cyclic events
+               ;; %%(diary-cyclic )
+               ((string-match
+                 (concat nonmarker
+                         "%%(diary-cyclic \\([^ ]+\\) +"
+                         "\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\))\\s-*\\(.*\\)")
+                 entry-main)
+                (icalendar--dmsg "diary-cyclic %s" entry-main)
+                (let* ((frequency (substring entry-main (match-beginning 1)
+                                             (match-end 1)))
+                       (datetime (substring entry-main (match-beginning 2)
+                                            (match-end 2)))
+                       (summary (icalendar--convert-string-for-export
+                                 (substring entry-main (match-beginning 3)
+                                            (match-end 3))))
+                       (startisostring (icalendar--datestring-to-isodate
+                                        datetime))
+                       (endisostring (icalendar--datestring-to-isodate
+                                      datetime 1)))
+                  (setq contents
+                        (concat "\nDTSTART;VALUE=DATE:" startisostring
+                                "\nDTEND;VALUE=DATE:" endisostring
+                                "\nSUMMARY:" summary
+                                "\nRRULE:FREQ=DAILY;INTERVAL=" frequency
+                                ;; strange: korganizer does not expect
+                                ;; BYSOMETHING here...
+                                )))
+                (unless (string= entry-rest "")
+                  (setq contents (concat contents "\nDESCRIPTION:"
+                                         (icalendar--convert-string-for-export
+                                          entry-rest)))))
+               ;; diary-date -- FIXME
+               ((string-match
+                 (concat nonmarker
+                         "%%(diary-date \\([^)]+\\))\\s-*\\(.*\\)")
+                 entry-main)
+                (icalendar--dmsg "diary-date %s" entry-main)
+                (error "`diary-date' is not supported yet"))
+               ;; float events -- FIXME
+               ((string-match
+                 (concat nonmarker
+                         "%%(diary-float \\([^)]+\\))\\s-*\\(.*\\)")
+                 entry-main)
+                (icalendar--dmsg "diary-float %s" entry-main)
+                (error "`diary-float' is not supported yet"))
+               ;; block events
+               ((string-match
+                 (concat nonmarker
+                         "%%(diary-block \\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\) +"
+                         "\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\))\\s-*\\(.*\\)")
+                 entry-main)
+                (icalendar--dmsg "diary-block %s" entry-main)
+                (let* ((startstring (substring entry-main (match-beginning 1)
+                                               (match-end 1)))
+                       (endstring (substring entry-main (match-beginning 2)
+                                             (match-end 2)))
+                       (summary (icalendar--convert-string-for-export
+                                 (substring entry-main (match-beginning 3)
+                                            (match-end 3))))
+                       (startisostring (icalendar--datestring-to-isodate
+                                        startstring))
+                       (endisostring (icalendar--datestring-to-isodate
+                                      endstring 1)))
+                  (setq contents
+                        (concat "\nDTSTART;VALUE=DATE:" startisostring
+                                "\nDTEND;VALUE=DATE:" endisostring
+                                "\nSUMMARY:" summary
+                                ))
+                  (unless (string= entry-rest "")
+                    (setq contents (concat contents "\nDESCRIPTION:"
+                                           (icalendar--convert-string-for-export
+                                            entry-rest))))))
+               ;; other sexp diary entries -- FIXME
+               ((string-match
+                 (concat nonmarker
+                         "%%(\\([^)]+\\))\\s-*\\(.*\\)")
+                 entry-main)
+                (icalendar--dmsg "diary-sexp %s" entry-main)
+                (error "sexp-entries are not supported yet"))
+               ;; weekly by day
+               ;; Monday 8:30 Team meeting
+               ((and (string-match
+                      (concat nonmarker
+                              "\\([a-z]+\\)\\s-+"
+                              "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?"
+                              "\\(-0?"
+                              "\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?"
+                              "\\)?"
+                              "\\s-*\\(.*\\)$")
+                      entry-main)
+                     (icalendar--get-weekday-abbrev
+                      (substring entry-main (match-beginning 1) (match-end 1))))
+                (icalendar--dmsg "weekly %s" entry-main)
+                (let* ((day (icalendar--get-weekday-abbrev
+                             (substring entry-main (match-beginning 1)
+                                        (match-end 1))))
+                       (starttimestring (icalendar--diarytime-to-isotime
+                                         (if (match-beginning 3)
+                                             (substring entry-main
+                                                        (match-beginning 3)
+                                                        (match-end 3))
+                                           nil)
+                                         (if (match-beginning 4)
+                                             (substring entry-main
+                                                        (match-beginning 4)
+                                                        (match-end 4))
+                                           nil)))
+                       (endtimestring (icalendar--diarytime-to-isotime
+                                       (if (match-beginning 6)
+                                           (substring entry-main
+                                                      (match-beginning 6)
+                                                      (match-end 6))
+                                         nil)
+                                       (if (match-beginning 7)
+                                           (substring entry-main
+                                                      (match-beginning 7)
+                                                      (match-end 7))
+                                         nil)))
+                       (summary (icalendar--convert-string-for-export
+                                 (substring entry-main (match-beginning 8)
+                                            (match-end 8)))))
+                  (when starttimestring
+                    (unless endtimestring
+                      (let ((time (read (icalendar--rris "^T0?" ""
+                                                         starttimestring))))
+                        (setq endtimestring (format "T%06d" (+ 10000 time))))))
+                  (setq contents
+                        (concat "\nDTSTART;"
+                                (if starttimestring
+                                    "VALUE=DATE-TIME:"
+                                  "VALUE=DATE:")
+                                ;; find the correct week day,
+                                ;; 1st january 2000 was a saturday
+                                (format
+                                 "200001%02d"
+                                 (+ (icalendar--get-weekday-number day) 2))
+                                (or starttimestring "")
+                                "\nDTEND;"
+                                (if endtimestring
+                                    "VALUE=DATE-TIME:"
+                                  "VALUE=DATE:")
+                                (format
+                                 "200001%02d"
+                                 ;; end is non-inclusive!
+                                 (+ (icalendar--get-weekday-number day)
+                                    (if endtimestring 2 3)))
+                                (or endtimestring "")
+                                "\nSUMMARY:" summary
+                                "\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=" day
+                                )))
+                (unless (string= entry-rest "")
+                  (setq contents (concat contents "\nDESCRIPTION:"
+                                         (icalendar--convert-string-for-export
+                                          entry-rest)))))
+               ;; yearly by day
+               ;; 1 May Tag der Arbeit
+               ((string-match
+                 (concat nonmarker
+                         (if european-calendar-style
+                             "0?\\([1-9]+[0-9]?\\)\\s-+\\([a-z]+\\)\\s-+"
+                           "\\([a-z]+\\)\\s-+0?\\([1-9]+[0-9]?\\)\\s-+")
+                         "\\*?\\s-*"
+                         "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?"
+                         "\\("
+                         "-0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?"
+                         "\\)?"
+                         "\\s-*\\([^0-9]+.*\\)$" ; must not match years
+                         )
+                 entry-main)
+                (icalendar--dmsg "yearly %s" entry-main)
+                (let* ((daypos (if european-calendar-style 1 2))
+                       (monpos (if european-calendar-style 2 1))
+                       (day (read (substring entry-main (match-beginning daypos)
+                                             (match-end daypos))))
+                       (month (icalendar--get-month-number
+                               (substring entry-main (match-beginning monpos)
+                                          (match-end monpos))))
+                       (starttimestring (icalendar--diarytime-to-isotime
+                                         (if (match-beginning 4)
+                                             (substring entry-main
+                                                        (match-beginning 4)
+                                                        (match-end 4))
+                                           nil)
+                                         (if (match-beginning 5)
+                                             (substring entry-main
+                                                        (match-beginning 5)
+                                                        (match-end 5))
+                                           nil)))
+                       (endtimestring (icalendar--diarytime-to-isotime
+                                       (if (match-beginning 7)
+                                           (substring entry-main
+                                                      (match-beginning 7)
+                                                      (match-end 7))
+                                         nil)
+                                       (if (match-beginning 8)
+                                           (substring entry-main
+                                                      (match-beginning 8)
+                                                      (match-end 8))
+                                         nil)))
+                       (summary (icalendar--convert-string-for-export
+                                 (substring entry-main (match-beginning 9)
+                                            (match-end 9)))))
+                  (when starttimestring
+                    (unless endtimestring
+                      (let ((time (read (icalendar--rris "^T0?" ""
+                                                         starttimestring))))
+                        (setq endtimestring (format "T%06d" (+ 10000 time))))))
+                  (setq contents
+                        (concat "\nDTSTART;"
+                                (if starttimestring "VALUE=DATE-TIME:"
+                                  "VALUE=DATE:")
+                                (format "1900%02d%02d" month day)
+                                (or starttimestring "")
+                                "\nDTEND;"
+                                (if endtimestring "VALUE=DATE-TIME:"
+                                  "VALUE=DATE:")
+                                ;; end is not included! shift by one day
+                                (icalendar--date-to-isodate
+                                 (list month day 1900) (if endtimestring 0 1))
+                                (or endtimestring "")
+                                "\nSUMMARY:"
+                                summary
+                                "\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH="
+                                (format "%2d" month)
+                                ";BYMONTHDAY="
+                                (format "%2d" day)
+                                )))
+                (unless (string= entry-rest "")
+                  (setq contents (concat contents "\nDESCRIPTION:"
+                                         (icalendar--convert-string-for-export
+                                          entry-rest)))))
+               ;; "ordinary" events, start and end time given
+               ;; 1 Feb 2003 Hs Hochzeitsfeier, Dreieich
+               ((string-match
+                 (concat nonmarker
+                         "\\([^ /]+[ /]+[^ /]+[ /]+[^ ]+\\)\\s-+"
+                         "\\(0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?"
+                         "\\("
+                         "-0?\\([1-9][0-9]?:[0-9][0-9]\\)\\([ap]m\\)?\\)?"
+                         "\\)?"
+                         "\\s-*\\(.*\\)")
+                 entry-main)
+                (icalendar--dmsg "ordinary %s" entry-main)
+                (let* ((startdatestring (icalendar--datestring-to-isodate
+                                         (substring entry-main
+                                                    (match-beginning 1)
+                                                    (match-end 1))))
+                       (starttimestring (icalendar--diarytime-to-isotime
+                                         (if (match-beginning 3)
+                                             (substring entry-main
+                                                        (match-beginning 3)
+                                                        (match-end 3))
+                                           nil)
+                                         (if (match-beginning 4)
+                                             (substring entry-main
+                                                        (match-beginning 4)
+                                                        (match-end 4))
+                                           nil)))
+                       (endtimestring (icalendar--diarytime-to-isotime
+                                       (if (match-beginning 6)
+                                           (substring entry-main
+                                                      (match-beginning 6)
+                                                      (match-end 6))
+                                         nil)
+                                       (if (match-beginning 7)
+                                           (substring entry-main
+                                                      (match-beginning 7)
+                                                      (match-end 7))
+                                         nil)))
+                       (summary (icalendar--convert-string-for-export
+                                 (substring entry-main (match-beginning 8)
+                                            (match-end 8)))))
+                  (unless startdatestring
+                    (error "Could not parse date"))
+                  (when starttimestring
+                    (unless endtimestring
+                      (let ((time (read (icalendar--rris "^T0?" ""
+                                                         starttimestring))))
+                        (setq endtimestring (format "T%06d" (+ 10000 time))))))
+                  (setq contents (concat
+                                  "\nDTSTART;"
+                                  (if starttimestring "VALUE=DATE-TIME:"
+                                    "VALUE=DATE:")
+                                  startdatestring
+                                  (or starttimestring "")
+                                  "\nDTEND;"
+                                  (if endtimestring "VALUE=DATE-TIME:"
+                                    "VALUE=DATE:")
+                                  (icalendar--datestring-to-isodate
+                                   (substring entry-main
+                                              (match-beginning 1)
+                                              (match-end 1))
+                                   (if endtimestring 0 1))
+                                  (or endtimestring "")
+                                  "\nSUMMARY:"
+                                  summary))
+                  ;; could not parse the date
+                  (unless (string= entry-rest "")
+                    (setq contents (concat contents "\nDESCRIPTION:"
+                                           (icalendar--convert-string-for-export
+                                            entry-rest))))))
+               ;; everything else
+               (t
+                ;; Oops! what's that?
+                (error "Could not parse entry")))
+              (setq result (concat result header contents "\nEND:VEVENT")))
+          ;; handle errors
+          (error
+           (setq found-error t)
+           (save-current-buffer
+             (set-buffer (get-buffer-create " *icalendar-errors*"))
+             (insert (format "Error in line %d -- %s: `%s'\n"
+                             (count-lines (point-min) (point))
+                             (cadr error-val)
+                             entry-main))))))
+
       ;; we're done, insert everything into the file
       (let ((coding-system-for-write 'utf8))
         (set-buffer (find-file ical-filename))
         (goto-char (point-max))
         (insert "BEGIN:VCALENDAR")
-	(insert "\nPRODID:-//Emacs//NONSGML icalendar.el//EN")
+        (insert "\nPRODID:-//Emacs//NONSGML icalendar.el//EN")
         (insert "\nVERSION:2.0")
         (insert result)
-        (insert "\nEND:VCALENDAR\n")))))
+        (insert "\nEND:VCALENDAR\n")))
+    found-error))
 
 ;; ======================================================================
 ;; Import -- convert icalendar to emacs-diary
@@ -1001,7 +1045,7 @@
 Argument DIARY-FILENAME input `diary-file'.
 Optional argument NON-MARKING determines whether events are created as
 non-marking or not."
-  (interactive "fImport iCalendar data from file:
+  (interactive "fImport iCalendar data from file: 
 Finto diary file:
 p")
   ;; clean up the diary file
@@ -1062,9 +1106,7 @@
        "Current buffer does not contain icalendar contents!"))))
 
 (defalias 'icalendar-extract-ical-from-buffer 'icalendar-import-buffer)
-
-(make-obsolete 'icalendar-extract-ical-from-buffer 'icalendar-import-buffer
-               "icalendar 0.07")
+(make-obsolete 'icalendar-extract-ical-from-buffer 'icalendar-import-buffer)
 
 ;; ======================================================================
 ;; private area
@@ -1184,7 +1226,7 @@
                                (setq diary-string
                                      (format "%s %s%s%s"
                                              (aref calendar-day-name-array
- 						   weekday)
+                                                   weekday)
                                              start-t (if end-t "-" "")
                                              (or end-t "")))
                              ;; FIXME!!!!
--- a/lisp/comint.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/comint.el	Sat Nov 06 17:52:02 2004 +0000
@@ -788,7 +788,7 @@
 
 (defun comint-insert-input (&optional event)
   "In a Comint buffer, set the current input to the previous input at point."
-  (interactive "@")
+  (interactive "e")
   (if event (mouse-set-point event))
   (let ((pos (point)))
     (if (not (eq (get-char-property pos 'field) 'input))
--- a/lisp/cus-edit.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/cus-edit.el	Sat Nov 06 17:52:02 2004 +0000
@@ -896,15 +896,14 @@
   (let ((name (format "*Customize Group: %s*"
 		      (custom-unlispify-tag-name group))))
     (if (get-buffer name)
-	(let ((window (selected-window))
+	(let (
 	      ;; Copied from `custom-buffer-create-other-window'.
 	      (pop-up-windows t)
 	      (special-display-buffer-names nil)
 	      (special-display-regexps nil)
 	      (same-window-buffer-names nil)
 	      (same-window-regexps nil))
-	  (pop-to-buffer name)
-	  (select-window window))
+	  (pop-to-buffer name))
       (custom-buffer-create-other-window
        (list (list group 'custom-group))
        name
@@ -1240,21 +1239,20 @@
 
 ;;;###autoload
 (defun custom-buffer-create-other-window (options &optional name description)
-  "Create a buffer containing OPTIONS.
+  "Create a buffer containing OPTIONS, and display it in another window.
+The result includes selecting that window.
 Optional NAME is the name of the buffer.
 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
 SYMBOL is a customization option, and WIDGET is a widget for editing
 that option."
   (unless name (setq name "*Customization*"))
-  (let ((window (selected-window))
-	(pop-up-windows t)
+  (let ((pop-up-windows t)
 	(special-display-buffer-names nil)
 	(special-display-regexps nil)
 	(same-window-buffer-names nil)
 	(same-window-regexps nil))
     (pop-to-buffer (custom-get-fresh-buffer name))
-    (custom-buffer-create-internal options description)
-    (select-window window)))
+    (custom-buffer-create-internal options description)))
 
 (defcustom custom-reset-button-menu nil
   "If non-nil, only show a single reset button in customize buffers.
--- a/lisp/descr-text.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/descr-text.el	Sat Nov 06 17:52:02 2004 +0000
@@ -176,11 +176,12 @@
       (describe-text-properties-1 pos output-buffer)
     (if (not (or (text-properties-at pos) (overlays-at pos)))
 	(message "This is plain text.")
-      (let ((buffer (current-buffer)))
-	(when (eq buffer (get-buffer "*Help*"))
-	  (error "Can't do self inspection"))
+      (let ((buffer (current-buffer))
+	    (target-buffer "*Help*"))
+	(when (eq buffer (get-buffer target-buffer))
+	  (setq target-buffer "*Help-2*"))
 	(save-excursion
-	  (with-output-to-temp-buffer "*Help*"
+	  (with-output-to-temp-buffer target-buffer
 	    (set-buffer standard-output)
 	    (setq output-buffer (current-buffer))
 	    (widget-insert "Text content at position " (format "%d" pos) ":\n\n")
--- a/lisp/dired.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/dired.el	Sat Nov 06 17:52:02 2004 +0000
@@ -546,8 +546,14 @@
 	    (if current-prefix-arg
 		(read-string "Dired listing switches: "
 			     dired-listing-switches))
-	    (read-file-name (format "Dired %s(directory): " str)
-			    nil default-directory nil))))
+	    ;; If a dialog is about to be used, call read-directory-name so
+	    ;; the dialog code knows we want directories.  Some dialogs can
+	    ;; only select directories or files when popped up, not both.
+	    (if (next-read-file-uses-dialog-p)
+		(read-directory-name (format "Dired %s(directory): " str)
+				     nil default-directory nil)
+	      (read-file-name (format "Dired %s(directory): " str)
+			      nil default-directory nil)))))
 
 ;;;###autoload (define-key ctl-x-map "d" 'dired)
 ;;;###autoload
--- a/lisp/ehelp.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/ehelp.el	Sat Nov 06 17:52:02 2004 +0000
@@ -85,11 +85,11 @@
     (define-key map "<" 'beginning-of-buffer)
     (define-key map ">" 'end-of-buffer)
     ;(define-key map "\C-g" 'electric-help-exit)
+    (define-key map "Q" 'electric-help-exit)
     (define-key map "q" 'electric-help-exit)
-    (define-key map "Q" 'electric-help-exit)
     ;;a better key than this?
+    (define-key map "R" 'electric-help-retain)
     (define-key map "r" 'electric-help-retain)
-    (define-key map "R" 'electric-help-retain)
     (define-key map "\ex" 'electric-help-execute-extended)
     (define-key map "\C-x" 'electric-help-ctrl-x-prefix)
 
--- a/lisp/emacs-lisp/advice.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/emacs-lisp/advice.el	Sat Nov 06 17:52:02 2004 +0000
@@ -3106,7 +3106,7 @@
 			  (not advised-interactive-form))
 		     ;; Check whether we were called interactively
 		     ;; in order to do proper prompting:
-		     `(if (interactive-p)
+		     `(if (called-interactively-p)
 			  (call-interactively ',origname)
 			,(ad-make-mapped-call orig-arglist
 					      advised-arglist
--- a/lisp/emacs-lisp/autoload.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/emacs-lisp/autoload.el	Sat Nov 06 17:52:02 2004 +0000
@@ -360,11 +360,14 @@
     (message "Generating autoloads for %s...done" file)))
 
 ;;;###autoload
-(defun update-file-autoloads (file)
+(defun update-file-autoloads (file &optional save-after)
   "Update the autoloads for FILE in `generated-autoload-file'
 \(which FILE might bind in its local variables).
-Return FILE if there was no autoload cookie in it."
-  (interactive "fUpdate autoloads for file: ")
+If SAVE-AFTER is non-nil (which is always, when called interactively),
+save the buffer too.
+
+Return FILE if there was no autoload cookie in it, else nil."
+  (interactive "fUpdate autoloads for file: \np")
   (let ((load-name (let ((name (file-name-nondirectory file)))
 		     (if (string-match "\\.elc?\\(\\.\\|$\\)" name)
 			 (substring name 0 (match-beginning 0))
@@ -464,7 +467,7 @@
 			   (or existing-buffer
 			       (kill-buffer (current-buffer))))))))
 	      (generate-file-autoloads file))))
-      (and (interactive-p)
+      (and save-after
 	   (buffer-modified-p)
 	   (save-buffer))
 
--- a/lisp/emacs-lisp/bytecomp.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/emacs-lisp/bytecomp.el	Sat Nov 06 17:52:02 2004 +0000
@@ -98,6 +98,9 @@
 ;;				`obsolete'  (obsolete variables and functions)
 ;;				`noruntime' (calls to functions only defined
 ;;					     within `eval-when-compile')
+;;				`cl-warnings' (calls to CL functions)
+;;				`interactive-only' (calls to commands that are
+;;						   not good to call from Lisp)
 ;; byte-compile-compatibility	Whether the compiler should
 ;;				generate .elc files which can be loaded into
 ;;				generic emacs 18.
@@ -325,7 +328,8 @@
   :type 'boolean)
 
 (defconst byte-compile-warning-types
-  '(redefine callargs free-vars unresolved obsolete noruntime cl-functions)
+  '(redefine callargs free-vars unresolved
+	     obsolete noruntime cl-functions interactive-only)
   "The list of warning types used when `byte-compile-warnings' is t.")
 (defcustom byte-compile-warnings t
   "*List of warnings that the byte-compiler should issue (t for all).
@@ -341,13 +345,21 @@
   noruntime   functions that may not be defined at runtime (typically
               defined only under `eval-when-compile').
   cl-functions    calls to runtime functions from the CL package (as
-		  distinguished from macros and aliases)."
+		  distinguished from macros and aliases).
+  interactive-only
+	      commands that normally shouldn't be called from Lisp code."
   :group 'bytecomp
   :type `(choice (const :tag "All" t)
 		 (set :menu-tag "Some"
 		      (const free-vars) (const unresolved)
 		      (const callargs) (const redefine)
-		      (const obsolete) (const noruntime) (const cl-functions))))
+		      (const obsolete) (const noruntime)
+		      (const cl-functions) (const interactive-only))))
+
+(defvar byte-compile-interactive-only-functions
+  '(beginning-of-buffer end-of-buffer replace-string replace-regexp
+			insert-file)
+  "List of commands that are not meant to be called from Lisp.")
 
 (defvar byte-compile-not-obsolete-var nil
   "If non-nil, this is a variable that shouldn't be reported as obsolete.")
@@ -2710,6 +2722,10 @@
 	   (byte-compile-set-symbol-position fn)
 	   (when (byte-compile-const-symbol-p fn)
 	     (byte-compile-warn "`%s' called as a function" fn))
+	   (and (memq 'interactive-only byte-compile-warnings)
+		(memq (car form) byte-compile-interactive-only-functions)
+		(byte-compile-warn "`%s' used from Lisp code\n\
+That command is designed for interactive use only" fn))
 	   (if (and handler
 		    (or (not (byte-compile-version-cond
 			      byte-compile-compatibility))
--- a/lisp/emacs-lisp/easy-mmode.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/emacs-lisp/easy-mmode.el	Sat Nov 06 17:52:02 2004 +0000
@@ -209,7 +209,7 @@
 	 ,@body
 	 ;; The on/off hooks are here for backward compatibility only.
 	 (run-hooks ',hook (if ,mode ',hook-on ',hook-off))
-	 (if (interactive-p)
+	 (if (called-interactively-p)
 	     (progn
 	       ,(if globalp `(customize-mark-as-set ',mode))
 	       (unless (current-message)
--- a/lisp/emacs-lisp/easymenu.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/emacs-lisp/easymenu.el	Sat Nov 06 17:52:02 2004 +0000
@@ -42,7 +42,25 @@
   :version "20.3")
 
 (defsubst easy-menu-intern (s)
-  (if (stringp s) (intern (downcase s)) s))
+  (if (stringp s)
+      (let ((copy (copy-sequence s))
+	    (pos 0)
+	    found)
+	;; For each letter that starts a word, flip its case.
+	;; This way, the usual convention for menu strings (capitalized)
+	;; corresponds to the usual convention for menu item event types
+	;; (all lower case).  It's a 1-1 mapping so causes no conflicts.
+	(while (setq found (string-match "\\<\\sw" copy pos))
+	  (setq pos (match-end 0))
+	  (unless (= (upcase (aref copy found))
+		     (downcase (aref copy found)))
+	    (aset copy found
+		  (if (= (upcase (aref copy found))
+			 (aref copy found))
+		      (downcase (aref copy found))
+		    (upcase (aref copy found))))))
+	 (intern copy))
+    s))
 
 ;;;###autoload
 (put 'easy-menu-define 'lisp-indent-function 'defun)
--- a/lisp/emacs-lisp/edebug.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/emacs-lisp/edebug.el	Sat Nov 06 17:52:02 2004 +0000
@@ -714,8 +714,10 @@
   (if (and (eq (following-char) ?.)
 	   (save-excursion
 	     (forward-char 1)
-	     (and (>= (following-char) ?0)
-		  (<= (following-char) ?9))))
+	     (or (and (eq (aref edebug-read-syntax-table (following-char))
+			  'symbol)
+		      (not (= (following-char) ?\;)))
+		 (memq (following-char) '(?\, ?\.)))))
       'symbol
     (aref edebug-read-syntax-table (following-char))))
 
--- a/lisp/emacs-lisp/elp.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/emacs-lisp/elp.el	Sat Nov 06 17:52:02 2004 +0000
@@ -257,7 +257,7 @@
     (setq newguts (append newguts `((elp-wrapper
 				     (quote ,funsym)
 				     ,(when (commandp funsym)
-					'(interactive-p))
+					'(called-interactively-p))
 				     args))))
     ;; to record profiling times, we set the symbol's function
     ;; definition so that it runs the elp-wrapper function with the
--- a/lisp/emulation/cua-base.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/emulation/cua-base.el	Sat Nov 06 17:52:02 2004 +0000
@@ -267,6 +267,7 @@
   :group 'editing-basics
   :group 'convenience
   :group 'emulations
+  :version "21.4"
   :link '(emacs-commentary-link :tag "Commentary" "cua-base.el")
   :link '(emacs-library-link :tag "Lisp File" "cua-base.el"))
 
@@ -1338,7 +1339,6 @@
   :set-after '(cua-enable-modeline-indications cua-use-hyper-key)
   :require 'cua-base
   :link '(emacs-commentary-link "cua-base.el")
-  :version "21.4"
   (setq mark-even-if-inactive t)
   (setq highlight-nonselected-windows nil)
   (make-variable-buffer-local 'cua--explicit-region-start)
--- a/lisp/eshell/esh-mode.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/eshell/esh-mode.el	Sat Nov 06 17:52:02 2004 +0000
@@ -943,10 +943,11 @@
       (eshell-bol)
       (kill-region (point) here))))
 
-(defun eshell-show-maximum-output ()
-  "Put the end of the buffer at the bottom of the window."
-  (interactive)
-  (if (interactive-p)
+(defun eshell-show-maximum-output (&optional interactive)
+  "Put the end of the buffer at the bottom of the window.
+When run interactively, widen the buffer first."
+  (interactive "p")
+  (if interactive
       (widen))
   (goto-char (point-max))
   (recenter -1))
@@ -1002,7 +1003,7 @@
       (let ((pos (point)))
 	(if (bobp)
 	    (if (interactive-p)
-		(error "Buffer too short to truncate"))
+		(message "Buffer too short to truncate"))
 	  (delete-region (point-min) (point))
 	  (if (interactive-p)
 	      (message "Truncated buffer from %d to %d lines (%.1fk freed)"
--- a/lisp/fast-lock.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/fast-lock.el	Sat Nov 06 17:52:02 2004 +0000
@@ -26,7 +26,7 @@
 
 ;;; Commentary:
 
-;; Lazy Lock mode is a Font Lock support mode.
+;; Fast Lock mode is a Font Lock support mode.
 ;; It makes visiting a file in Font Lock mode faster by restoring its face text
 ;; properties from automatically saved associated Font Lock cache files.
 ;;
--- a/lisp/files.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/files.el	Sat Nov 06 17:52:02 2004 +0000
@@ -676,7 +676,7 @@
 both at the level of the file and at the level of the directories
 containing it, until no links are left at any level.
 
-\(fn FILENAME)"
+\(fn FILENAME)"  ;; Don't document the optional arguments.
   ;; COUNTER and PREV-DIRS are only used in recursive calls.
   ;; COUNTER can be a cons cell whose car is the count of how many
   ;; more links to chase before getting an error.
@@ -977,6 +977,14 @@
 	  (mapcar 'switch-to-buffer (cdr value)))
       (switch-to-buffer-other-frame value))))
 
+(defun find-file-existing (filename &optional wildcards)
+  "Edit the existing file FILENAME.
+Like \\[find-file] but only allow files that exists."
+  (interactive (find-file-read-args "Find existing file: " t))
+  (unless (file-exists-p filename) (error "%s does not exist" filename))
+  (find-file filename wildcards)
+  (current-buffer))
+
 (defun find-file-read-only (filename &optional wildcards)
   "Edit file FILENAME but don't allow changes.
 Like \\[find-file] but marks buffer as read-only.
@@ -1225,6 +1233,7 @@
 When nil, never request confirmation."
   :group 'files
   :group 'find-file
+  :version "21.4"
   :type '(choice integer (const :tag "Never request confirmation" nil)))
 
 (defun find-file-noselect (filename &optional nowarn rawfile wildcards)
@@ -1836,20 +1845,27 @@
 regular expression.  The mode is then determined as the mode associated
 with that interpreter in `interpreter-mode-alist'.")
 
-(defvar xml-based-modes '(html-mode)
-  "Modes that override an XML declaration.
-When `set-auto-mode' sees an <?xml or <!DOCTYPE declaration, that
-buffer will be in some XML mode.  If `auto-mode-alist' associates
-the file with one of the modes in this list, that mode will be
-used.  Else `xml-mode' or `sgml-mode' is used.")
+(defvar magic-mode-alist
+  '(;; The < comes before the groups (but the first) to reduce backtracking.
+    ;; Is there a nicer way of getting . including \n?
+    ;; TODO: UTF-16 <?xml may be preceded by a BOM 0xff 0xfe or 0xfe 0xff.
+    ("\\(?:<\\?xml\\s +[^>]*>\\)?\\s *<\\(?:!--\\(?:.\\|\n\\)*?-->\\s *<\\)*\\(?:!DOCTYPE\\s +[^>]*>\\s *<\\)?\\s *\\(?:!--\\(?:.\\|\n\\)*?-->\\s *<\\)*[Hh][Tt][Mm][Ll]" . html-mode)
+    ;; These two must come after html, because they are more general:
+    ("<\\?xml " . xml-mode)
+    ("\\s *<\\(?:!--\\(?:.\\|\n\\)*?-->\\s *<\\)*!DOCTYPE " . sgml-mode)
+    ("%![^V]" . ps-mode))
+  "Alist of buffer beginnings vs corresponding major mode functions.
+Each element looks like (REGEXP . FUNCTION).  FUNCTION will be
+called, unless it is nil.")
 
 (defun set-auto-mode (&optional keep-mode-if-same)
   "Select major mode appropriate for current buffer.
+
 This checks for a -*- mode tag in the buffer's text, checks the
 interpreter that runs this file against `interpreter-mode-alist',
-looks for an <?xml or <!DOCTYPE declaration (see
-`xml-based-modes'), or compares the filename against the entries
-in `auto-mode-alist'.
+compares the buffer beginning against `magic-mode-alist',
+or compares the filename against the entries in
+`auto-mode-alist'.
 
 It does not check for the `mode:' local variable in the
 Local Variables section of the file; for that, use `hack-local-variables'.
@@ -1895,7 +1911,8 @@
 	    (if (not (functionp mode))
 		(message "Ignoring unknown mode `%s'" mode)
 	      (setq done t)
-	      (or (set-auto-mode-0 mode)
+	      (or (set-auto-mode-0 mode keep-mode-if-same)
+		  ;; continuing would call minor modes again, toggling them off
 		  (throw 'nop nil)))))
       ;; If we didn't, look for an interpreter specified in the first line.
       ;; As a special case, allow for things like "#!/bin/env perl", which
@@ -1909,47 +1926,49 @@
 	    ;; same time.
 	    done (assoc (file-name-nondirectory mode)
 			interpreter-mode-alist))
-      ;; If we found an interpreter mode to use, invoke it now.
-      (if done (set-auto-mode-0 (cdr done))))
-    (if (and (not done) buffer-file-name)
-	(let ((name buffer-file-name))
-	  ;; Remove backup-suffixes from file name.
-	  (setq name (file-name-sans-versions name))
-	  (while name
-	    ;; Find first matching alist entry.
-	    (let ((case-fold-search
-		   (memq system-type '(vax-vms windows-nt cygwin))))
-	      (if (and (setq mode (assoc-default name auto-mode-alist
+      (if done
+	  (set-auto-mode-0 (cdr done) keep-mode-if-same)))
+    ;; If we found an interpreter mode to use, invoke it now.
+    (unless done
+      (if (setq done (save-excursion
+		       (goto-char (point-min))
+		       (assoc-default nil magic-mode-alist
+				      (lambda (re dummy)
+					(looking-at re)))))
+	  (set-auto-mode-0 done keep-mode-if-same)
+	(if buffer-file-name
+	    (let ((name buffer-file-name))
+	      ;; Remove backup-suffixes from file name.
+	      (setq name (file-name-sans-versions name))
+	      (while name
+		;; Find first matching alist entry.
+		(let ((case-fold-search
+		       (memq system-type '(vax-vms windows-nt cygwin))))
+		  (if (and (setq mode (assoc-default name auto-mode-alist
 						 'string-match))
-		       (consp mode)
-		       (cadr mode))
-		  (setq mode (car mode)
-			name (substring name 0 (match-beginning 0)))
-		(setq name)))
-	    (when mode
-	      (if xml (or (memq mode xml-based-modes)
-			  (setq mode 'xml-mode)))
-	      (set-auto-mode-0 mode)
-	      (setq done t)))))
-    (and xml
-	 (not done)
-	 (set-auto-mode-0 'xml-mode))))
+			   (consp mode)
+			   (cadr mode))
+		      (setq mode (car mode)
+			    name (substring name 0 (match-beginning 0)))
+		    (setq name)))
+		(when mode
+		  (set-auto-mode-0 mode keep-mode-if-same)))))))))
 
 
 ;; When `keep-mode-if-same' is set, we are working on behalf of
 ;; set-visited-file-name.  In that case, if the major mode specified is the
 ;; same one we already have, don't actually reset it.  We don't want to lose
 ;; minor modes such as Font Lock.
-(defun set-auto-mode-0 (mode)
+(defun set-auto-mode-0 (mode &optional keep-mode-if-same)
   "Apply MODE and return it.
-If `keep-mode-if-same' is non-nil MODE is chased of any aliases and
-compared to current major mode.  If they are the same, do nothing
-and return nil."
+If optional arg KEEP-MODE-IF-SAME is non-nil, MODE is chased of
+any aliases and compared to current major mode.  If they are the
+same, do nothing and return nil."
   (when keep-mode-if-same
     (while (symbolp (symbol-function mode))
       (setq mode (symbol-function mode)))
     (if (eq mode major-mode)
-	(setq mode)))
+	(setq mode nil)))
   (when mode
     (funcall mode)
     mode))
@@ -3813,7 +3832,7 @@
 
 (defun kill-some-buffers (&optional list)
   "Kill some buffers.  Asks the user whether to kill each one of them.
-Non-interactively, if optional argument LIST is non-`nil', it
+Non-interactively, if optional argument LIST is non-nil, it
 specifies the list of buffers to kill, asking for approval for each one."
   (interactive)
   (if (null list)
--- a/lisp/filesets.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/filesets.el	Sat Nov 06 17:52:02 2004 +0000
@@ -295,7 +295,8 @@
 (defgroup filesets nil
   "The fileset swapper."
   :prefix "filesets-"
-  :group 'convenience)
+  :group 'convenience
+  :version "21.4")
 
 (defcustom filesets-menu-name "Filesets"
   "*Filesets' menu name."
--- a/lisp/gnus/ChangeLog	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/ChangeLog	Sat Nov 06 17:52:02 2004 +0000
@@ -1,5 +1,140 @@
+2004-11-04  Richard M. Stallman  <rms@gnu.org>
+
+	* spam.el (spam group): Add :version.
+
+	* pgg-def.el (pgg group): Add :version.
+
+2004-11-04  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-art. (gnus-article-edit-article): Don't associate the
+	article buffer with a draft file.  This is a temporary measure
+	against the 2004-08-22 change to gnus-article-edit-mode.
+
+2004-11-02  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* html2text.el (html2text-get-attr): Remove unused argument `tag'.
+	(html2text-format-tags): Remove unused variable `attr'.
+
+	* mm-util.el (mm-enrich-utf-8-by-mule-ucs): Fix cleaning of
+	after-load-alist.
+
+	* mm-util.el (mm-mime-mule-charset-alist): Add the windows-1251
+	entry.  From Ilya N. Golubev <gin@mo.msk.ru>.
+	(mm-enrich-utf-8-by-mule-ucs): New function run when Mule-UCS is
+	loaded under XEmacs.
+	(): Don't make duplicated entries in mm-mime-mule-charset-alist.
+
+	* mm-util.el (mm-coding-system-p): Return a coding-system.
+	(mm-mime-mule-charset-alist): Use shift_jis instead of
+	iso-2022-jp-2 for the katakana-jisx0201 mule charset; add new
+	entries for the mime charsets iso-2022-jp-3 and shift_jis.
+	(mm-coding-system-priorities): Use shift_jis and iso-8859-1
+	instead of japanese-shift-jis and iso-latin-1 respectively in
+	order to share the default value with both Emacs and XEmacs-mule.
+	(mm-mule-charset-to-mime-charset): Make
+	mm-coding-system-priorities effective.
+	(mm-sort-coding-systems-predicate): Canonicalize coding-systems
+	while predicating of candidates upon the priorities.
+
+2004-11-01  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* gnus-msg.el (gnus-summary-resend-default-address): Add :version.
+
+	* tls.el (tls-process-connection-type, tls-success)
+	(tls-certtool-program): Add :version.
+
+	* starttls.el (starttls-gnutls-program, starttls-use-gnutls)
+	(starttls-extra-arguments, starttls-process-connection-type)
+	(starttls-connect, starttls-failure, starttls-success): 
+
+	* spam-stat.el (spam-stat): Add :version.
+
+	* sieve.el (sieve): Add :version.
+
+	* sha1.el (sha1): Added :version.
+	(sha1-use-external): Removed redundant version.
+
+	* nnmail.el (nnmail-split-fancy-with-parent-ignore-groups)
+	(nnmail-cache-ignore-groups, nnmail-spool-hook)
+	(nnmail-split-fancy-match-partial-words)
+	(nnmail-split-lowercase-expanded): 
+
+	* nndiary.el (nndiary): Add :version.
+
+	* mml2015.el (mml2015-unabbrev-trust-alist): Add :version.
+
+	* mml-sec.el (mml-default-sign-method)
+	(mml-default-encrypt-method, mml-signencrypt-style-alist): Add
+	:version.
+
+	* mm-uu.el (mm-uu-diff-groups-regexp): Add :version.
+
+	* mm-url.el (mm-url-use-external, mm-url-program)
+	(mm-url-arguments): Add :version.
+
+	* mm-decode.el (mm-inline-text-html-with-w3m-keymap)
+	(mm-attachment-file-modes, mm-decrypt-option)
+	(mm-w3m-safe-url-regexp): Add :version.
+
+	* message.el (message-cite-prefix-regexp)
+	(message-sendmail-envelope-from, message-minibuffer-local-map)
+	(message-user-fqdn, message-completion-alist): Add :version.
+
+	* gnus-win.el (gnus-configure-windows-hook)
+	(gnus-use-frames-on-any-display): Add :version.
+
+	* gnus-art.el (gnus-article-address-banner-alist)
+	(gnus-treat-unsplit-urls, gnus-treat-unfold-headers)
+	(gnus-treat-from-picon, gnus-treat-mail-picon)
+	(gnus-treat-x-pgp-sig): Add :version.
+
+	* gnus-sum.el (gnus-spam-mark, gnus-recent-mark)
+	(gnus-undownloaded-mark, gnus-summary-article-move-hook)
+	(gnus-summary-article-delete-hook)
+	(gnus-summary-display-while-building): Add :version.
+
+	* gnus-start.el (gnus-subscribe-newsgroup-hooks)
+	(gnus-get-top-new-news-hook):Add :version.
+
+	* gnus-srvr.el (gnus-server-agent-face, gnus-server-opened-face)
+	(gnus-server-closed-face, gnus-server-denied-face): Add :version.
+
+	* gnus-registry.el (gnus-registry): Add :version.
+
+	* gnus-spec.el (gnus-use-correct-string-widths)
+	(gnus-make-format-preserve-properties): Add :version.
+
+	* gnus.el (gnus-group-charter-alist)
+	(gnus-group-fetch-control-use-browse-url)
+	(gnus-install-group-spam-parameters): Add :version.
+
+	* gnus-diary.el (gnus-diary): Add :version.
+
+	* gnus-delay.el (gnus-delay): Add :version.
+
+	* gnus-cite.el (gnus-cite-unsightly-citation-regexp)
+	(gnus-cite-ignore-quoted-from, gnus-cite-attribution-face)
+	(gnus-cite-blank-line-after-header, gnus-article-boring-faces):
+	Add :version.
+
+	* gnus-agent.el (gnus-agent-max-fetch-size)
+	(gnus-agent-enable-expiration, gnus-agent-queue-mail)
+	(gnus-agent-prompt-send-queue): Add :version.
+
+	* deuglify.el (gnus-outlook-deuglify): Add :version.
+
+	* html2text.el: Beautify code.  Improve doc strings.  Some checkdoc
+	cleanup.
+	(html2text-get-attr, html2text-fix-paragraph): Simplify code.
+	(html2text-format-tag-list): Added "strong" and "em".  From
+	"Alfred M. Szmidt" <ams@kemisten.nu> (tiny change).
+
 2004-10-29  Katsumi Yamaoka  <yamaoka@jpl.org>
 
+	* gnus-msg.el (gnus-configure-posting-styles): Work with empty
+	signature file.  Suggested by Manoj Srivastava
+	<srivasta@golden-gryphon.com>.
+
 	* mm-util.el (mm-coding-system-priorities): Prefer iso-8859-1 than
 	iso-2022-jp even in the Japanese language environment.  Suggested
 	by Jason Rumney <jasonr@gnu.org>.
--- a/lisp/gnus/deuglify.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/deuglify.el	Sat Nov 06 17:52:02 2004 +0000
@@ -230,7 +230,8 @@
 ;;; User Customizable Variables:
 
 (defgroup gnus-outlook-deuglify nil
-  "Deuglify articles generated by broken user agents like MS Outlook (Express).")
+  "Deuglify articles generated by broken user agents like MS Outlook (Express)."
+  :version "21.4")
 
 ;;;###autoload
 (defcustom gnus-outlook-deuglify-unwrap-min 45
--- a/lisp/gnus/gnus-agent.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/gnus-agent.el	Sat Nov 06 17:52:02 2004 +0000
@@ -160,6 +160,7 @@
   "Chunk size for `gnus-agent-fetch-session'.
 The function will split its article fetches into chunks smaller than
 this limit."
+  :version "21.4"
   :group 'gnus-agent
   :type 'integer)
 
@@ -170,6 +171,7 @@
 to disable expiration in specific categories, topics, and groups.  Of
 course, you could change gnus-agent-enable-expiration to DISABLE then
 enable expiration per categories, topics, and groups."
+  :version "21.4"
   :group 'gnus-agent
   :type '(radio (const :format "Enable " ENABLE)
                 (const :format "Disable " DISABLE)))
@@ -195,6 +197,7 @@
   "Whether and when outgoing mail should be queued by the agent.
 When `always', always queue outgoing mail.  When nil, never
 queue.  Otherwise, queue if and only if unplugged."
+  :version "21.4"
   :group 'gnus-agent
   :type '(radio (const :format "Always" always)
 		(const :format "Never" nil)
@@ -203,6 +206,7 @@
 (defcustom gnus-agent-prompt-send-queue nil
   "If non-nil, `gnus-group-send-queue' will prompt if called when
 unplugged."
+  :version "21.4"
   :group 'gnus-agent
   :type 'boolean)
 
--- a/lisp/gnus/gnus-art.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/gnus-art.el	Sat Nov 06 17:52:02 2004 +0000
@@ -318,6 +318,7 @@
 		   (symbol :tag "Item in `gnus-article-banner-alist'" none)
 		   regexp
 		   (const :tag "None" nil))))
+  :version "21.4"
   :group 'gnus-article-washing)
 
 (defcustom gnus-emphasis-alist
@@ -920,6 +921,7 @@
   "Remove newlines from within URLs.
 Valid values are nil, t, `head', `last', an integer or a predicate.
 See Info node `(gnus)Customizing Articles' for details."
+  :version "21.4"
   :group 'gnus-article-treat
   :link '(custom-manual "(gnus)Customizing Articles")
   :type gnus-article-treat-custom)
@@ -1124,6 +1126,7 @@
   "Unfold folded header lines.
 Valid values are nil, t, `head', `last', an integer or a predicate.
 See Info node `(gnus)Customizing Articles' for details."
+  :version "21.4"
   :group 'gnus-article-treat
   :link '(custom-manual "(gnus)Customizing Articles")
   :type gnus-article-treat-custom)
@@ -1238,6 +1241,7 @@
 Valid values are nil, t, `head', `last', an integer or a predicate.
 See Info node `(gnus)Customizing Articles' and Info node
 `(gnus)Picons' for details."
+  :version "21.4"
   :group 'gnus-article-treat
   :group 'gnus-picon
   :link '(custom-manual "(gnus)Customizing Articles")
@@ -1253,6 +1257,7 @@
 Valid values are nil, t, `head', `last', an integer or a predicate.
 See Info node `(gnus)Customizing Articles' and Info node
 `(gnus)Picons' for details."
+  :version "21.4"
   :group 'gnus-article-treat
   :group 'gnus-picon
   :link '(custom-manual "(gnus)Customizing Articles")
@@ -1338,6 +1343,7 @@
 To automatically treat X-PGP-Sig, set it to head.
 Valid values are nil, t, `head', `last', an integer or a predicate.
 See Info node `(gnus)Customizing Articles' for details."
+  :version "21.4"
   :group 'gnus-article-treat
   :group 'mime-security
   :link '(custom-manual "(gnus)Customizing Articles")
@@ -5645,7 +5651,10 @@
   "Start editing the contents of the current article buffer."
   (let ((winconf (current-window-configuration)))
     (set-buffer gnus-article-buffer)
-    (gnus-article-edit-mode)
+    (let ((message-auto-save-directory
+	   ;; Don't associate the article buffer with a draft file.
+	   nil))
+      (gnus-article-edit-mode))
     (funcall start-func)
     (set-buffer-modified-p nil)
     (gnus-configure-windows 'edit-article)
--- a/lisp/gnus/gnus-cite.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/gnus-cite.el	Sat Nov 06 17:52:02 2004 +0000
@@ -124,6 +124,7 @@
 (defcustom gnus-cite-unsightly-citation-regexp
   "^-----Original Message-----\nFrom: \\(.+\n\\)+\n"
   "Regexp matching Microsoft-type rest-of-message citations."
+  :version "21.4"
   :group 'gnus-cite
   :type 'regexp)
 
@@ -131,6 +132,7 @@
   "Non-nil means don't regard lines beginning with \">From \" as cited text.
 Those lines may have been quoted by MTAs in order not to mix up with
 the envelope From line."
+  :version "21.4"
   :group 'gnus-cite
   :type 'boolean)
 
@@ -141,6 +143,7 @@
 (defcustom gnus-cite-attribution-face 'gnus-cite-attribution-face
   "Face used for attribution lines.
 It is merged with the face for the cited text belonging to the attribution."
+  :version "21.4"
   :group 'gnus-cite
   :type 'face)
 
@@ -278,7 +281,6 @@
 
 (defcustom gnus-cite-blank-line-after-header t
   "If non-nil, put a blank line between the citation header and the button."
-  :version "21.4"
   :group 'gnus-cite
   :type 'boolean)
 
@@ -290,7 +292,6 @@
 If an article has more pages below the one you are looking at, but
 nothing on those pages is a word of at least three letters that is not
 in a boring face, then the pages will be skipped."
-  :version "21.4"
   :type '(repeat face)
   :group 'gnus-article-hiding)
 
--- a/lisp/gnus/gnus-delay.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/gnus-delay.el	Sat Nov 06 17:52:02 2004 +0000
@@ -41,6 +41,7 @@
 ;;;###autoload
 (defgroup gnus-delay nil
   "Arrange for sending postings later."
+  :version "21.4"
   :group 'gnus)
 
 (defcustom gnus-delay-group "delayed"
--- a/lisp/gnus/gnus-diary.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/gnus-diary.el	Sat Nov 06 17:52:02 2004 +0000
@@ -102,7 +102,8 @@
 (require 'gnus-art)
 
 (defgroup gnus-diary nil
-  "Utilities on top of the nndiary backend for Gnus.")
+  "Utilities on top of the nndiary backend for Gnus."
+  :version "21.4")
 
 (defcustom gnus-diary-summary-line-format "%U%R%z %uD: %(%s%) (%ud)\n"
   "*Summary line format for nndiary groups."
--- a/lisp/gnus/gnus-msg.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/gnus-msg.el	Sat Nov 06 17:52:02 2004 +0000
@@ -281,6 +281,7 @@
   "If non-nil, Gnus tries to suggest a default address to resend to.
 If nil, the address field will always be empty after invoking
 `gnus-summary-resend-message'."
+  :version "21.4"
   :group 'gnus-message
   :type 'boolean)
 
@@ -1871,8 +1872,9 @@
 	      (setq v (with-temp-buffer
 			(insert-file-contents v)
 			(goto-char (point-max))
-			(while (bolp)
-			  (delete-char -1))
+			(skip-chars-backward "\n")
+			(delete-region (+ (point) (if (bolp) 0 1))
+				       (point-max))
 			(buffer-string))))
 	    (setq results (delq (assoc element results) results))
 	    (push (cons element v) results))))
--- a/lisp/gnus/gnus-registry.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/gnus-registry.el	Sat Nov 06 17:52:02 2004 +0000
@@ -66,6 +66,7 @@
 
 (defgroup gnus-registry nil
   "The Gnus registry."
+  :version "21.4"
   :group 'gnus)
 
 (defvar gnus-registry-hashtb nil
--- a/lisp/gnus/gnus-spec.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/gnus-spec.el	Sat Nov 06 17:52:02 2004 +0000
@@ -32,12 +32,14 @@
 
 (defcustom gnus-use-correct-string-widths (featurep 'xemacs)
   "*If non-nil, use correct functions for dealing with wide characters."
+  :version "21.4"
   :group 'gnus-format
   :type 'boolean)
 
 (defcustom gnus-make-format-preserve-properties (featurep 'xemacs)
   "*If non-nil, use a replacement `format' function which preserves
 text properties. This is only needed on XEmacs, as FSF Emacs does this anyway."
+  :version "21.4"
   :group 'gnus-format
   :type 'boolean)
 
--- a/lisp/gnus/gnus-srvr.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/gnus-srvr.el	Sat Nov 06 17:52:02 2004 +0000
@@ -205,21 +205,25 @@
 
 (defcustom gnus-server-agent-face 'gnus-server-agent-face
   "Face name to use on AGENTIZED servers."
+  :version "21.4"
   :group 'gnus-server-visual
   :type 'face)
 
 (defcustom gnus-server-opened-face 'gnus-server-opened-face
   "Face name to use on OPENED servers."
+  :version "21.4"
   :group 'gnus-server-visual
   :type 'face)
 
 (defcustom gnus-server-closed-face 'gnus-server-closed-face
   "Face name to use on CLOSED servers."
+  :version "21.4"
   :group 'gnus-server-visual
   :type 'face)
 
 (defcustom gnus-server-denied-face 'gnus-server-denied-face
   "Face name to use on DENIED servers."
+  :version "21.4"
   :group 'gnus-server-visual
   :type 'face)
 
--- a/lisp/gnus/gnus-start.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/gnus-start.el	Sat Nov 06 17:52:02 2004 +0000
@@ -299,6 +299,7 @@
 (defcustom gnus-subscribe-newsgroup-hooks nil
   "*Hooks run after you subscribe to a new group.
 The hooks will be called with new group's name as argument."
+  :version "21.4"
   :group 'gnus-group-new
   :type 'hook)
 
@@ -405,6 +406,7 @@
 
 (defcustom gnus-get-top-new-news-hook nil
   "A hook run just before Gnus checks for new news globally."
+  :version "21.4"
   :group 'gnus-group-new
   :type 'hook)
 
--- a/lisp/gnus/gnus-sum.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/gnus-sum.el	Sat Nov 06 17:52:02 2004 +0000
@@ -469,6 +469,7 @@
 
 (defcustom gnus-spam-mark ?$
   "*Mark used for spam articles."
+  :version "21.4"
   :group 'gnus-summary-marks
   :type 'character)
 
@@ -505,6 +506,7 @@
 
 (defcustom gnus-recent-mark ?N
   "*Mark used for articles that are recent."
+  :version "21.4"
   :group 'gnus-summary-marks
   :type 'character)
 
@@ -552,6 +554,7 @@
 
 (defcustom gnus-undownloaded-mark ?-
   "*Mark used for articles that weren't downloaded."
+  :version "21.4"
   :group 'gnus-summary-marks
   :type 'character)
 
@@ -890,16 +893,19 @@
 
 (defcustom gnus-summary-article-move-hook nil
   "*A hook called after an article is moved, copied, respooled, or crossposted."
+  :version "21.4"
   :group 'gnus-summary
   :type 'hook)
 
 (defcustom gnus-summary-article-delete-hook nil
   "*A hook called after an article is deleted."
+  :version "21.4"
   :group 'gnus-summary
   :type 'hook)
 
 (defcustom gnus-summary-article-expire-hook nil
   "*A hook called after an article is expired."
+  :version "21.4"
   :group 'gnus-summary
   :type 'hook)
 
@@ -9178,6 +9184,7 @@
   "If non-nil, show and update the summary buffer as it's being built.
 If the value is t, update the buffer after every line is inserted.  If
 the value is an integer (N), update the display every N lines."
+  :version "21.4"
   :group 'gnus-thread
   :type '(choice (const :tag "off" nil)
 		 number
--- a/lisp/gnus/gnus-win.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/gnus-win.el	Sat Nov 06 17:52:02 2004 +0000
@@ -62,6 +62,7 @@
   "*If non-nil, frames on all displays will be considered useable by Gnus.
 When nil, only frames on the same display as the selected frame will be
 used to display Gnus windows."
+  :version "21.4"
   :group 'gnus-windows
   :type 'boolean)
 
@@ -198,6 +199,7 @@
 
 (defcustom gnus-configure-windows-hook nil
   "*A hook called when configuring windows."
+  :version "21.4"
   :group 'gnus-windows
   :type 'hook)
 
--- a/lisp/gnus/gnus.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/gnus.el	Sat Nov 06 17:52:02 2004 +0000
@@ -1314,6 +1314,7 @@
 			(gnus-replace-in-string name "\\." "-") "-charter.html")))
   "*An alist of (HIERARCHY . FORM) pairs used to construct the URL of a charter.
 When FORM is evaluated `name' is bound to the name of the group."
+  :version "21.4"
   :group 'gnus-group-various
   :type '(repeat (cons (string :tag "Hierarchy") (sexp :tag "Form"))))
 
@@ -1321,6 +1322,7 @@
   "*Non-nil means that control messages are displayed using `browse-url'.
 Otherwise they are fetched with ange-ftp and displayed in an ephemeral
 group."
+  :version "21.4"
   :group 'gnus-group-various
   :type 'boolean)
 
@@ -1788,6 +1790,7 @@
 (defcustom gnus-install-group-spam-parameters t
   "*Disable the group parameters for spam detection.
 Enable if `G c' in XEmacs is giving you trouble, and make sure to submit a bug report."
+  :version "21.4"
   :type 'boolean
   :group 'gnus-start)
 
--- a/lisp/gnus/html2text.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/html2text.el	Sat Nov 06 17:52:02 2004 +0000
@@ -24,11 +24,11 @@
 
 ;; These functions provide a simple way to wash/clean html infected
 ;; mails.  Definitely do not work in all cases, but some improvement
-;; in readability is generally obtained. Formatting is only done in
+;; in readability is generally obtained.  Formatting is only done in
 ;; the buffer, so the next time you enter the article it will be
 ;; "re-htmlized".
 ;;
-;; The main function is "html2text"
+;; The main function is `html2text'.
 
 ;;; Code:
 
@@ -47,9 +47,9 @@
   "The map of entity to text.
 
 This is an alist were each element is a dotted pair consisting of an
-old string, and a replacement string. This replacement is done by the
-function \"html2text-substitute\" which basically performs a
-replace-string operation for every element in the list. This is
+old string, and a replacement string.  This replacement is done by the
+function `html2text-substitute' which basically performs a
+`replace-string' operation for every element in the list.  This is
 completely verbatim - without any use of REGEXP.")
 
 (defvar html2text-remove-tag-list
@@ -57,11 +57,11 @@
   "A list of removable tags.
 
 This is a list of tags which should be removed, without any
-formatting.  Observe that if you the tags in the list are presented
-*without* any \"<\" or \">\". All occurences of a tag appearing in
-this list are removed, irrespective of whether it is a closing or
-opening tag, or if the tag has additional attributes. The actual
-deletion is done by the function \"html2text-remove-tags\".
+formatting.  Note that tags in the list are presented *without*
+any \"<\" or \">\".  All occurences of a tag appearing in this
+list are removed, irrespective of whether it is a closing or
+opening tag, or if the tag has additional attributes.  The
+deletion is done by the function `html2text-remove-tags'.
 
 For instance the text:
 
@@ -75,8 +75,10 @@
 
 (defvar html2text-format-tag-list
   '(("b" 	  . html2text-clean-bold)
+    ("strong"     . html2text-clean-bold)
     ("u" 	  . html2text-clean-underline)
     ("i" 	  . html2text-clean-italic)
+    ("em"         . html2text-clean-italic)
     ("blockquote" . html2text-clean-blockquote)
     ("a"          . html2text-clean-anchor)
     ("ul"         . html2text-clean-ul)
@@ -86,7 +88,7 @@
   "An alist of tags and processing functions.
 
 This is an alist where each dotted pair consists of a tag, and then
-the name of a function to be called when this tag is found. The
+the name of a function to be called when this tag is found.  The
 function is called with the arguments p1, p2, p3 and p4. These are
 demontrated below:
 
@@ -117,17 +119,15 @@
 ;;
 
 
-(defun html2text-replace-string (from-string to-string p1 p2)
-  (goto-char p1)
+(defun html2text-replace-string (from-string to-string min max)
+  "Replace FROM-STRING with TO-STRING in region from MIN to MAX."
+  (goto-char min)
   (let ((delta (- (string-width to-string) (string-width from-string)))
 	(change 0))
-    (while (search-forward from-string p2 t)
+    (while (search-forward from-string max t)
       (replace-match to-string)
-      (setq change (+ change delta))
-      )
-    change
-    )
-  )
+      (setq change (+ change delta)))
+    change))
 
 ;;
 ;; </Utility functions>
@@ -140,11 +140,11 @@
 ;; <Functions related to attributes> i.e. <font size=+3>
 ;;
 
-(defun html2text-attr-value (attr-list attr)
-  (nth 1 (assoc attr attr-list))
-  )
+(defun html2text-attr-value (list attribute)
+  "Get value of ATTRIBUTE from LIST."
+  (nth 1 (assoc attribute list)))
 
-(defun html2text-get-attr (p1 p2 tag)
+(defun html2text-get-attr (p1 p2)
   (goto-char p1)
   (re-search-forward " +[^ ]" p2 t)
   (let* ((attr-string (buffer-substring-no-properties (1- (point)) (1- p2)))
@@ -161,14 +161,10 @@
      ((string-match "[^ ]=[^ ]" prev)
       (let ((attr  (nth 0 (split-string prev "=")))
 	    (value (nth 1 (split-string prev "="))))
-	(setq attr-list (cons (list attr value) attr-list))
-	)
-      )
+	(setq attr-list (cons (list attr value) attr-list))))
      ;; size= 3
      ((string-match "[^ ]=\\'" prev)
-      (setq attr-list (cons (list (substring prev 0 -1) this) attr-list))
-      )
-     )
+      (setq attr-list (cons (list (substring prev 0 -1) this) attr-list))))
 
     (while (< index (length tmp-list))
       (cond
@@ -176,29 +172,20 @@
        ((string-match "[^ ]=[^ ]" this)
 	(let ((attr  (nth 0 (split-string this "=")))
 	      (value (nth 1 (split-string this "="))))
-	  (setq attr-list (cons (list attr value) attr-list))
-	  )
-	)
+	  (setq attr-list (cons (list attr value) attr-list))))
        ;; size =3
        ((string-match "\\`=[^ ]" this)
 	(setq attr-list (cons (list prev (substring this 1)) attr-list)))
-
        ;; size= 3
        ((string-match "[^ ]=\\'" this)
-	(setq attr-list (cons (list (substring this 0 -1) next) attr-list))
-	)
-
+	(setq attr-list (cons (list (substring this 0 -1) next) attr-list)))
        ;; size = 3
        ((string= "=" this)
-	(setq attr-list (cons (list prev next) attr-list))
-	)
-       )
+	(setq attr-list (cons (list prev next) attr-list))))
       (setq index (1+ index))
       (setq prev this)
       (setq this next)
-      (setq next (nth (1+ index) tmp-list))
-      )
-
+      (setq next (nth (1+ index) tmp-list)))
     ;;
     ;; Tags with no accompanying "=" i.e. value=nil
     ;;
@@ -207,41 +194,25 @@
     (setq next (nth 2 tmp-list))
     (setq index 1)
 
-    (if (not (string-match "=" prev))
-	(progn
-	  (if (not (string= (substring this 0 1) "="))
-	      (setq attr-list (cons (list prev nil) attr-list))
-	    )
-	  )
-      )
-
+    (when (and (not (string-match "=" prev))
+	       (not (string= (substring this 0 1) "=")))
+      (setq attr-list (cons (list prev nil) attr-list)))
     (while (< index (1- (length tmp-list)))
-      (if (not (string-match "=" this))
-	  (if (not (or (string= (substring next 0 1) "=")
-		       (string= (substring prev -1) "=")))
-	      (setq attr-list (cons (list this nil) attr-list))
-	    )
-	)
+      (when (and (not (string-match "=" this))
+		 (not (or (string= (substring next 0 1) "=")
+			  (string= (substring prev -1) "="))))
+	(setq attr-list (cons (list this nil) attr-list)))
       (setq index (1+ index))
       (setq prev this)
       (setq this next)
-      (setq next (nth (1+ index) tmp-list))
-      )
+      (setq next (nth (1+ index) tmp-list)))
 
-    (if this
-	(progn
-	  (if (not (string-match "=" this))
-	      (progn
-		(if (not (string= (substring prev -1) "="))
-		    (setq attr-list (cons (list this nil) attr-list))
-		  )
-		)
-	    )
-	  )
-      )
-    attr-list ;; return - value
-    )
-  )
+    (when (and this
+	       (not (string-match "=" this))
+	       (not (string= (substring prev -1) "=")))
+      (setq attr-list (cons (list this nil) attr-list)))
+    ;; return - value
+    attr-list))
 
 ;;
 ;; </Functions related to attributes>
@@ -266,10 +237,7 @@
       (cond
        ((string= list-type "ul") (insert " o "))
        ((string= list-type "ol") (insert (format " %s: " item-nr)))
-       (t (insert " x ")))
-      )
-    )
-  )
+       (t (insert " x "))))))
 
 (defun html2text-clean-dtdd (p1 p2)
   (goto-char p1)
@@ -308,61 +276,51 @@
   (html2text-delete-single-tag p1 p2)
   (goto-char p1)
   (newline 1)
-  (insert (make-string fill-column ?-))
-  )
+  (insert (make-string fill-column ?-)))
 
 (defun html2text-clean-ul (p1 p2 p3 p4)
   (html2text-delete-tags p1 p2 p3 p4)
-  (html2text-clean-list-items p1 (- p3 (- p1 p2)) "ul")
-  )
+  (html2text-clean-list-items p1 (- p3 (- p1 p2)) "ul"))
 
 (defun html2text-clean-ol (p1 p2 p3 p4)
   (html2text-delete-tags p1 p2 p3 p4)
-  (html2text-clean-list-items p1 (- p3 (- p1 p2)) "ol")
-  )
+  (html2text-clean-list-items p1 (- p3 (- p1 p2)) "ol"))
 
 (defun html2text-clean-dl (p1 p2 p3 p4)
   (html2text-delete-tags p1 p2 p3 p4)
-  (html2text-clean-dtdd p1 (- p3 (- p1 p2)))
-  )
+  (html2text-clean-dtdd p1 (- p3 (- p1 p2))))
 
 (defun html2text-clean-center (p1 p2 p3 p4)
   (html2text-delete-tags p1 p2 p3 p4)
-  (center-region p1 (- p3 (- p2 p1)))
-  )
+  (center-region p1 (- p3 (- p2 p1))))
 
 (defun html2text-clean-bold (p1 p2 p3 p4)
   (put-text-property p2 p3 'face 'bold)
-  (html2text-delete-tags p1 p2 p3 p4)
-  )
+  (html2text-delete-tags p1 p2 p3 p4))
 
 (defun html2text-clean-title (p1 p2 p3 p4)
   (put-text-property p2 p3 'face 'bold)
-  (html2text-delete-tags p1 p2 p3 p4)
-  )
+  (html2text-delete-tags p1 p2 p3 p4))
 
 (defun html2text-clean-underline (p1 p2 p3 p4)
   (put-text-property p2 p3 'face 'underline)
-  (html2text-delete-tags p1 p2 p3 p4)
-  )
+  (html2text-delete-tags p1 p2 p3 p4))
 
 (defun html2text-clean-italic (p1 p2 p3 p4)
   (put-text-property p2 p3 'face 'italic)
-  (html2text-delete-tags p1 p2 p3 p4)
-  )
+  (html2text-delete-tags p1 p2 p3 p4))
 
 (defun html2text-clean-font (p1 p2 p3 p4)
-  (html2text-delete-tags p1 p2 p3 p4)
-  )
+  (html2text-delete-tags p1 p2 p3 p4))
 
 (defun html2text-clean-blockquote (p1 p2 p3 p4)
-  (html2text-delete-tags p1 p2 p3 p4)
-  )
+  (html2text-delete-tags p1 p2 p3 p4))
 
 (defun html2text-clean-anchor (p1 p2 p3 p4)
-  ;; If someone can explain how to make the URL clickable I will
-  ;; surely improve upon this.
-  (let* ((attr-list (html2text-get-attr p1 p2 "a"))
+  ;; If someone can explain how to make the URL clickable I will surely
+  ;; improve upon this.
+  ;; Maybe `goto-addr.el' can be used here.
+  (let* ((attr-list (html2text-get-attr p1 p2))
 	 (href (html2text-attr-value attr-list "href")))
     (delete-region p1 p4)
     (when href
@@ -386,38 +344,27 @@
   (let ((has-br-line)
 	(refill-start)
 	(refill-stop))
-    (if (re-search-forward "<br>$" p2 t)
-	(setq has-br-line t)
-      )
-    (if has-br-line
-	(progn
-	  (goto-char p1)
-	  (if (re-search-forward ".+[^<][^b][^r][^>]$" p2 t)
-	      (progn
-		(beginning-of-line)
-		(setq refill-start (point))
-		(goto-char p2)
-		(re-search-backward ".+[^<][^b][^r][^>]$" refill-start t)
-		(next-line 1)
-		(end-of-line)
-		;; refill-stop should ideally be adjusted to
-		;; accomodate the "<br>" strings which are removed
-		;; between refill-start and refill-stop.  Can simply
-		;; be returned from my-replace-string
-		(setq refill-stop (+ (point)
-				     (html2text-replace-string
-				      "<br>" ""
-				      refill-start (point))))
-		;; (message "Point = %s  refill-stop = %s" (point) refill-stop)
-		;; (sleep-for 4)
-		(fill-region refill-start refill-stop)
-		)
-	    )
-	  )
-      )
-    )
-  (html2text-replace-string "<br>" "" p1 p2)
-  )
+    (when (re-search-forward "<br>$" p2 t)
+      (goto-char p1)
+      (when (re-search-forward ".+[^<][^b][^r][^>]$" p2 t)
+	(beginning-of-line)
+	(setq refill-start (point))
+	(goto-char p2)
+	(re-search-backward ".+[^<][^b][^r][^>]$" refill-start t)
+	(next-line 1)
+	(end-of-line)
+	;; refill-stop should ideally be adjusted to
+	;; accomodate the "<br>" strings which are removed
+	;; between refill-start and refill-stop.  Can simply
+	;; be returned from my-replace-string
+	(setq refill-stop (+ (point)
+			     (html2text-replace-string
+			      "<br>" ""
+			      refill-start (point))))
+	;; (message "Point = %s  refill-stop = %s" (point) refill-stop)
+	;; (sleep-for 4)
+	(fill-region refill-start refill-stop))))
+  (html2text-replace-string "<br>" "" p1 p2))
 
 ;;
 ;; This one is interactive ...
@@ -452,7 +399,7 @@
 ;;
 
 (defun html2text-remove-tags (tag-list)
-  "Removes the tags listed in the list \"html2text-remove-tag-list\".
+  "Removes the tags listed in the list `html2text-remove-tag-list'.
 See the documentation for that variable."
   (interactive)
   (dolist (tag tag-list)
@@ -461,7 +408,7 @@
       (delete-region (match-beginning 0) (match-end 0)))))
 
 (defun html2text-format-tags ()
-  "See the variable \"html2text-format-tag-list\" for documentation"
+  "See the variable `html2text-format-tag-list' for documentation."
   (interactive)
   (dolist (tag-and-function html2text-format-tag-list)
     (let ((tag      (car tag-and-function))
@@ -471,8 +418,7 @@
 				(point-max) t)
 	(let ((p1)
 	      (p2 (point))
-	      (p3) (p4)
-	      (attr (match-string 1)))
+	      (p3) (p4))
 	  (search-backward "<" (point-min) t)
 	  (setq p1 (point))
 	  (re-search-forward (format "</%s>" tag) (point-max) t)
@@ -480,27 +426,18 @@
 	  (search-backward "</" (point-min) t)
 	  (setq p3 (point))
 	  (funcall function p1 p2 p3 p4)
-	  (goto-char p1)
-	  )
-	)
-      )
-    )
-  )
+	  (goto-char p1))))))
 
 (defun html2text-substitute ()
-  "See the variable \"html2text-replace-list\" for documentation"
+  "See the variable `html2text-replace-list' for documentation."
   (interactive)
   (dolist (e html2text-replace-list)
     (goto-char (point-min))
     (let ((old-string (car e))
 	  (new-string (cdr e)))
-      (html2text-replace-string old-string new-string (point-min) (point-max))
-      )
-    )
-  )
+      (html2text-replace-string old-string new-string (point-min) (point-max)))))
 
 (defun html2text-format-single-elements ()
-  ""
   (interactive)
   (dolist (tag-and-function html2text-format-single-element-list)
     (let ((tag      (car tag-and-function))
@@ -512,12 +449,7 @@
 	      (p2 (point)))
 	  (search-backward "<" (point-min) t)
 	  (setq p1 (point))
-	  (funcall function p1 p2)
-	  )
-	)
-      )
-    )
-  )
+	  (funcall function p1 p2))))))
 
 ;;
 ;; Main function
@@ -540,6 +472,6 @@
 ;;
 ;; </Interactive functions>
 ;;
-
+(provide 'html2text)
 ;;; arch-tag: e9e57b79-35d4-4de1-a647-e7e01fe56d1e
 ;;; html2text.el ends here
--- a/lisp/gnus/message.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/message.el	Sat Nov 06 17:52:02 2004 +0000
@@ -587,6 +587,7 @@
 		non-word-constituents
 		"]\\)+>+\\|[ \t]*[]>|}+]\\)+"))))
   "*Regexp matching the longest possible citation prefix on a line."
+  :version "21.4"
   :group 'message-insertion
   :link '(custom-manual "(message)Insertion Variables")
   :type 'regexp)
@@ -743,6 +744,7 @@
   "*Envelope-from when sending mail with sendmail.
 If this is nil, use `user-mail-address'.  If it is the symbol
 `header', use the From: header of the message."
+  :version "21.4"
   :type '(choice (string :tag "From name")
 		 (const :tag "Use From: header from message" header)
 		 (const :tag "Use `user-mail-address'" nil))
@@ -855,7 +857,8 @@
   (let ((map (make-sparse-keymap 'message-minibuffer-local-map)))
     (set-keymap-parent map minibuffer-local-map)
     map)
-  "Keymap for `message-read-from-minibuffer'.")
+  "Keymap for `message-read-from-minibuffer'."
+  :version "21.4")
 
 ;;;###autoload
 (defcustom message-citation-line-function 'message-insert-citation-line
@@ -1435,6 +1438,7 @@
 
 (defcustom message-user-fqdn nil
   "*Domain part of Messsage-Ids."
+  :version "21.4"
   :group 'message-headers
   :link '(custom-manual "(message)News Headers")
   :type '(radio (const :format "%v  " nil)
@@ -6590,6 +6594,7 @@
 	'("^\\(Disposition-Notification-To\\|Return-Receipt-To\\):"
 	  . message-expand-name))
   "Alist of (RE . FUN).  Use FUN for completion on header lines matching RE."
+  :version "21.4"
   :group 'message
   :type '(alist :key-type regexp :value-type function))
 
--- a/lisp/gnus/mm-decode.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/mm-decode.el	Sat Nov 06 17:52:02 2004 +0000
@@ -150,12 +150,14 @@
 matches parts embedded to the Multipart/Related type MIME contents and
 Gnus will never connect to the spammer's site arbitrarily.  You may
 set this variable to nil if you consider all urls to be safe."
+  :version "21.4"
   :type '(choice (regexp :tag "Regexp")
 		 (const :tag "All URLs are safe" nil))
   :group 'mime-display)
 
 (defcustom mm-inline-text-html-with-w3m-keymap t
   "If non-nil, use emacs-w3m command keys in the article buffer."
+  :version "21.4"
   :type 'boolean
   :group 'mime-display)
 
@@ -378,6 +380,7 @@
 
 (defcustom mm-attachment-file-modes 384
   "Set the mode bits of saved attachments to this integer."
+  :version "21.4"
   :type 'integer
   :group 'mime-display)
 
@@ -435,6 +438,7 @@
   "Option of decrypting encrypted parts.
 `never', not decrypt; `always', always decrypt;
 `known', only decrypt known protocols.  Otherwise, ask user."
+  :version "21.4"
   :type '(choice (item always)
 		 (item never)
 		 (item :tag "only known protocols" known)
--- a/lisp/gnus/mm-url.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/mm-url.el	Sat Nov 06 17:52:02 2004 +0000
@@ -49,6 +49,7 @@
 				    (require 'url)
 				  (error nil)))
   "*If non-nil, use external grab program `mm-url-program'."
+  :version "21.4"
   :type 'boolean
   :group 'mm-url)
 
@@ -67,6 +68,7 @@
    (t "GET"))
   "The url grab program.
 Likely values are `wget', `w3m', `lynx' and `curl'."
+  :version "21.4"
   :type '(choice
 	  (symbol :tag "wget" wget)
 	  (symbol :tag "w3m" w3m)
@@ -77,6 +79,7 @@
 
 (defcustom mm-url-arguments nil
   "The arguments for `mm-url-program'."
+  :version "21.4"
   :type '(repeat string)
   :group 'mm-url)
 
--- a/lisp/gnus/mm-util.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/mm-util.el	Sat Nov 06 17:52:02 2004 +0000
@@ -123,13 +123,16 @@
 
 (defun mm-coding-system-p (cs)
   "Return non-nil if CS is a symbol naming a coding system.
-In XEmacs, also return non-nil if CS is a coding system object."
+In XEmacs, also return non-nil if CS is a coding system object.
+If CS is available, return CS itself in Emacs, and return a coding
+system object in XEmacs."
   (if (fboundp 'find-coding-system)
       (find-coding-system cs)
     (if (fboundp 'coding-system-p)
-	(coding-system-p cs)
+	(when (coding-system-p cs)
+	  cs)
       ;; Is this branch ever actually useful?
-      (memq cs (mm-get-coding-system-list)))))
+      (car (memq cs (mm-get-coding-system-list))))))
 
 (defvar mm-charset-synonym-alist
   `(
@@ -219,12 +222,12 @@
     (big5 chinese-big5-1 chinese-big5-2)
     (tibetan tibetan)
     (thai-tis620 thai-tis620)
+    (windows-1251 cyrillic-iso8859-5)
     (iso-2022-7bit ethiopic arabic-1-column arabic-2-column)
     (iso-2022-jp-2 latin-iso8859-1 greek-iso8859-7
 		   latin-jisx0201 japanese-jisx0208-1978
 		   chinese-gb2312 japanese-jisx0208
-		   korean-ksc5601 japanese-jisx0212
-		   katakana-jisx0201)
+		   korean-ksc5601 japanese-jisx0212)
     (iso-2022-int-1 latin-iso8859-1 greek-iso8859-7
 		    latin-jisx0201 japanese-jisx0208-1978
 		    chinese-gb2312 japanese-jisx0208
@@ -239,6 +242,9 @@
 		    chinese-cns11643-3 chinese-cns11643-4
 		    chinese-cns11643-5 chinese-cns11643-6
 		    chinese-cns11643-7)
+    (iso-2022-jp-3 latin-jisx0201 japanese-jisx0208-1978 japanese-jisx0208
+		   japanese-jisx0213-1 japanese-jisx0213-2)
+    (shift_jis latin-jisx0201 katakana-jisx0201 japanese-jisx0208)
     ,(if (or (not (fboundp 'charsetp)) ;; non-Mule case
 	     (charsetp 'unicode-a)
 	     (not (mm-coding-system-p 'mule-utf-8)))
@@ -249,24 +255,47 @@
 		       (coding-system-get 'mule-utf-8 'safe-charsets)))))
   "Alist of MIME-charset/MULE-charsets.")
 
-;; Correct by construction, but should be unnecessary:
-;; XEmacs hates it.
-(when (and (not (featurep 'xemacs))
-	   (fboundp 'coding-system-list)
-	   (fboundp 'sort-coding-systems))
-  (setq mm-mime-mule-charset-alist
-	(apply
-	 'nconc
-	 (mapcar
-	  (lambda (cs)
-	    (when (and (or (coding-system-get cs :mime-charset)	; Emacs 22
-			   (coding-system-get cs 'mime-charset))
-		       (not (eq t (coding-system-get cs 'safe-charsets))))
-	      (list (cons (or (coding-system-get cs :mime-charset)
-			      (coding-system-get cs 'mime-charset))
-			  (delq 'ascii
-				(coding-system-get cs 'safe-charsets))))))
-	  (sort-coding-systems (coding-system-list 'base-only))))))
+(defun mm-enrich-utf-8-by-mule-ucs ()
+  "Make the `utf-8' MIME charset usable by the Mule-UCS package.
+This function will run when the `un-define' module is loaded under
+XEmacs, and fill the `utf-8' entry in `mm-mime-mule-charset-alist'
+with Mule charsets.  It is completely useless for Emacs."
+  (unless (cdr (delete '(mm-enrich-utf-8-by-mule-ucs)
+		       (assoc "un-define" after-load-alist)))
+    (setq after-load-alist
+	  (delete '("un-define") after-load-alist)))
+  (when (boundp 'unicode-basic-translation-charset-order-list)
+    (condition-case nil
+	(let ((val (delq
+		    'ascii
+		    (copy-sequence
+		     (symbol-value
+		      'unicode-basic-translation-charset-order-list))))
+	      (elem (assq 'utf-8 mm-mime-mule-charset-alist)))
+	  (if elem
+	      (setcdr elem val)
+	    (setq mm-mime-mule-charset-alist
+		  (nconc mm-mime-mule-charset-alist
+			 (list (cons 'utf-8 val))))))
+      (error))))
+
+;; Correct by construction, but should be unnecessary for Emacs:
+(if (featurep 'xemacs)
+    (eval-after-load "un-define" '(mm-enrich-utf-8-by-mule-ucs))
+  (when (and (fboundp 'coding-system-list)
+	     (fboundp 'sort-coding-systems))
+    (let ((css (sort-coding-systems (coding-system-list 'base-only)))
+	  cs mime mule alist)
+      (while css
+	(setq cs (pop css)
+	      mime (or (coding-system-get cs :mime-charset) ; Emacs 22
+		       (coding-system-get cs 'mime-charset)))
+	(when (and mime
+		   (not (eq t (setq mule
+				    (coding-system-get cs 'safe-charsets))))
+		   (not (assq mime alist)))
+	  (push (cons mime (delq 'ascii mule)) alist)))
+      (setq mm-mime-mule-charset-alist (nreverse alist)))))
 
 (defvar mm-hack-charsets '(iso-8859-15 iso-2022-jp-2)
   "A list of special charsets.
@@ -332,16 +361,20 @@
   "Return the MIME charset corresponding to the given Mule CHARSET."
   (if (and (fboundp 'find-coding-systems-for-charsets)
 	   (fboundp 'sort-coding-systems))
-      (let (mime)
-	(dolist (cs (sort-coding-systems
-		     (copy-sequence
-		      (find-coding-systems-for-charsets (list charset)))))
-	  (unless mime
-	    (when cs
-	      (setq mime (or (coding-system-get cs :mime-charset)
-			     (coding-system-get cs 'mime-charset))))))
+      (let ((css (sort (sort-coding-systems
+			(find-coding-systems-for-charsets (list charset)))
+		       'mm-sort-coding-systems-predicate))
+	    cs mime)
+	(while (and (not mime)
+		    css)
+	  (when (setq cs (pop css))
+	    (setq mime (or (coding-system-get cs :mime-charset)
+			   (coding-system-get cs 'mime-charset)))))
 	mime)
-    (let ((alist mm-mime-mule-charset-alist)
+    (let ((alist (mapcar (lambda (cs)
+			   (assq cs mm-mime-mule-charset-alist))
+			 (sort (mapcar 'car mm-mime-mule-charset-alist)
+			       'mm-sort-coding-systems-predicate)))
 	  out)
       (while alist
 	(when (memq charset (cdar alist))
@@ -534,11 +567,14 @@
   (let ((priorities
 	 (mapcar (lambda (cs)
 		   ;; Note: invalid entries are dropped silently
-		   (and (coding-system-p cs)
+		   (and (setq cs (mm-coding-system-p cs))
 			(coding-system-base cs)))
 		 mm-coding-system-priorities)))
-    (> (length (memq a priorities))
-       (length (memq b priorities)))))
+    (and (setq a (mm-coding-system-p a))
+	 (if (setq b (mm-coding-system-p b))
+	     (> (length (memq (coding-system-base a) priorities))
+		(length (memq (coding-system-base b) priorities)))
+	   t))))
 
 (defun mm-find-mime-charset-region (b e &optional hack-charsets)
   "Return the MIME charsets needed to encode the region between B and E.
--- a/lisp/gnus/mm-uu.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/mm-uu.el	Sat Nov 06 17:52:02 2004 +0000
@@ -80,6 +80,7 @@
 
 (defcustom mm-uu-diff-groups-regexp "gnus\\.commits"
   "*Regexp matching diff groups."
+  :version "21.4"
   :type 'regexp
   :group 'gnus-article-mime)
 
--- a/lisp/gnus/mml-sec.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/mml-sec.el	Sat Nov 06 17:52:02 2004 +0000
@@ -43,6 +43,7 @@
 (defcustom mml-default-sign-method "pgpmime"
   "Default sign method.
 The string must have an entry in `mml-sign-alist'."
+  :version "21.4"
   :type '(choice (const "smime")
 		 (const "pgp")
 		 (const "pgpauto")
@@ -60,6 +61,7 @@
 (defcustom mml-default-encrypt-method "pgpmime"
   "Default encryption method.
 The string must have an entry in `mml-encrypt-alist'."
+  :version "21.4"
   :type '(choice (const "smime")
 		 (const "pgp")
 		 (const "pgpauto")
@@ -83,6 +85,7 @@
 understood by all PGP implementations, in particular PGP version
 2 does not support it!  See Info node `(message)Security' for
 details."
+  :version "21.4"
   :group 'message
   :type '(repeat (list (choice (const :tag "S/MIME" "smime")
 			       (const :tag "PGP" "pgp")
--- a/lisp/gnus/mml2015.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/mml2015.el	Sat Nov 06 17:52:02 2004 +0000
@@ -83,6 +83,7 @@
     ("TRUST_FULLY"     . t)
     ("TRUST_ULTIMATE"  . t))
   "Map GnuPG trust output values to a boolean saying if you trust the key."
+  :version "21.4"
   :group 'mime-security
   :type '(repeat (cons (regexp :tag "GnuPG output regexp")
 		       (boolean :tag "Trust key"))))
--- a/lisp/gnus/nndiary.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/nndiary.el	Sat Nov 06 17:52:02 2004 +0000
@@ -223,6 +223,7 @@
 
 (defgroup nndiary nil
   "The Gnus Diary backend."
+  :version "21.4"
   :group 'gnus-diary)
 
 (defcustom nndiary-mail-sources
--- a/lisp/gnus/nnmail.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/nnmail.el	Sat Nov 06 17:52:02 2004 +0000
@@ -119,6 +119,7 @@
 (defcustom nnmail-split-fancy-with-parent-ignore-groups nil
   "Regexp that matches group names to be ignored when applying `nnmail-split-fancy-with-parent'.
 This can also be a list of regexps."
+  :version "21.4"
   :group 'nnmail-split
   :type '(choice (const :tag "none" nil)
 		 (regexp :value ".*")
@@ -127,6 +128,7 @@
 (defcustom nnmail-cache-ignore-groups nil
   "Regexp that matches group names to be ignored when inserting message ids into the cache (`nnmail-cache-insert').
 This can also be a list of regexps."
+  :version "21.4"
   :group 'nnmail-split
   :type '(choice (const :tag "none" nil)
 		 (regexp :value ".*")
@@ -353,6 +355,7 @@
 
 (defcustom nnmail-spool-hook nil
   "*A hook called when a new article is spooled."
+  :version "21.4"
   :group 'nnmail
   :type 'hook)
 
@@ -575,6 +578,7 @@
 by \"\\=\\<...\\>\".  If this variable is true, they are not implicitly\
  surrounded
 by anything."
+  :version "21.4"
   :group 'nnmail
   :type 'boolean)
 
@@ -582,6 +586,7 @@
   "Whether to lowercase expanded entries (i.e. \\N) when splitting mails.
 This avoids the creation of multiple groups when users send to an address
 using different case (i.e. mailing-list@domain vs Mailing-List@Domain)."
+  :version "21.4"
   :group 'nnmail
   :type 'boolean)
 
--- a/lisp/gnus/pgg-def.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/pgg-def.el	Sat Nov 06 17:52:02 2004 +0000
@@ -29,7 +29,8 @@
 
 (defgroup pgg ()
   "Glue for the various PGP implementations."
-  :group 'mime)
+  :group 'mime
+  :version "21.4")
 
 (defcustom pgg-default-scheme 'gpg
   "Default PGP scheme."
--- a/lisp/gnus/sha1.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/sha1.el	Sat Nov 06 17:52:02 2004 +0000
@@ -60,6 +60,7 @@
 
 (defgroup sha1 nil
   "Elisp interface for SHA1 hash computation."
+  :version "21.4"
   :group 'extensions)
 
 (defcustom sha1-maximum-internal-length 500
@@ -82,7 +83,6 @@
 			       (error))
   "*Use external SHA1 program.
 If this variable is set to nil, use internal function only."
-  :version "21.4"
   :type 'boolean
   :group 'sha1)
 
--- a/lisp/gnus/sieve.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/sieve.el	Sat Nov 06 17:52:02 2004 +0000
@@ -65,6 +65,7 @@
 
 (defgroup sieve nil
   "Manage sieve scripts."
+  :version "21.4"
   :group 'tools)
 
 (defcustom sieve-new-script "<new script>"
--- a/lisp/gnus/spam-stat.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/spam-stat.el	Sat Nov 06 17:52:02 2004 +0000
@@ -128,6 +128,7 @@
 Use the functions to build a dictionary of words and their statistical
 distribution in spam and non-spam mails.  Then use a function to determine
 whether a buffer contains spam or not."
+  :version "21.4"
   :group 'gnus)
 
 (defcustom spam-stat-file "~/.spam-stat.el"
--- a/lisp/gnus/spam.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/spam.el	Sat Nov 06 17:52:02 2004 +0000
@@ -76,7 +76,8 @@
 ;;; Main parameters.
 
 (defgroup spam nil
-  "Spam configuration.")
+  "Spam configuration."
+  :version "21.4")
 
 (defcustom spam-directory (nnheader-concat gnus-directory "spam/")
   "Directory for spam whitelists and blacklists."
--- a/lisp/gnus/starttls.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/gnus/starttls.el	Sat Nov 06 17:52:02 2004 +0000
@@ -126,6 +126,7 @@
   "Name of GNUTLS command line tool.
 This program is used when GNUTLS is used, i.e. when
 `starttls-use-gnutls' is non-nil."
+  :version "21.4"
   :type 'string
   :group 'starttls)
 
@@ -138,6 +139,7 @@
 
 (defcustom starttls-use-gnutls (not (executable-find starttls-program))
   "*Whether to use GNUTLS instead of the `starttls' command."
+  :version "21.4"
   :type 'boolean
   :group 'starttls)
 
@@ -156,11 +158,13 @@
 For example, non-TLS compliant servers may require
 '(\"--protocols\" \"ssl3\").  Invoke \"gnutls-cli --help\" to
 find out which parameters are available."
+  :version "21.4"
   :type '(repeat string)
   :group 'starttls)
 
 (defcustom starttls-process-connection-type nil
   "*Value for `process-connection-type' to use when starting STARTTLS process."
+  :version "21.4"
   :type 'boolean
   :group 'starttls)
 
@@ -170,6 +174,7 @@
   ;; GNUTLS cli.c:main() print this string when it is starting to run
   ;; in the application read/write phase.  If the logic, or the string
   ;; itself, is modified, this must be updated.
+  :version "21.4"
   :type 'regexp
   :group 'starttls)
 
@@ -178,6 +183,7 @@
 The default is what GNUTLS's \"gnutls-cli\" outputs."
   ;; GNUTLS cli.c:do_handshake() print this string on failure.  If the
   ;; logic, or the string itself, is modified, this must be updated.
+  :version "21.4"
   :type 'regexp
   :group 'starttls)
 
@@ -188,6 +194,7 @@
   ;; common.c:print_info(), that unconditionally print this string
   ;; last.  If that logic, or the string itself, is modified, this
   ;; must be updated.
+  :version "21.4"
   :type 'regexp
   :group 'starttls)
 
--- a/lisp/help-at-pt.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/help-at-pt.el	Sat Nov 06 17:52:02 2004 +0000
@@ -1,6 +1,6 @@
 ;;; help-at-pt.el --- local help through the keyboard
 
-;; Copyright (C) 2003 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2004 Free Software Foundation, Inc.
 
 ;; Author: Luc Teirlinck <teirllm@auburn.edu>
 ;; Keywords: help
@@ -98,6 +98,13 @@
 	(message "%s" help)
       (if (not arg) (message "No local help at point")))))
 
+(defvar help-at-pt-timer nil
+  "Non-nil means that a timer is set that checks for local help.
+If non-nil, this is the value returned by the call of
+`run-with-idle-timer' that set that timer.  This variable is used
+internally to enable `help-at-pt-display-when-idle'.  Do not set it
+yourself.")
+
 (defcustom help-at-pt-timer-delay 1
   "*Delay before displaying local help.
 This is used if `help-at-pt-display-when-idle' is enabled.
@@ -112,17 +119,12 @@
 new value."
   :group 'help-at-pt
   :type 'number
+  :initialize 'custom-initialize-default
   :set (lambda (variable value)
 	 (set-default variable value)
-	 (when (and (boundp 'help-at-pt-timer) help-at-pt-timer)
-	   (timer-set-idle-time help-at-pt-timer value t))))
-
-(defvar help-at-pt-timer nil
-  "Non-nil means that a timer is set that checks for local help.
-If non-nil, this is the value returned by the call of
-`run-with-idle-timer' that set that timer.  This variable is used
-internally to enable `help-at-pt-display-when-idle'.  Do not set it
-yourself.")
+	 (and (boundp 'help-at-pt-timer)
+	      help-at-pt-timer
+	      (timer-set-idle-time help-at-pt-timer value t))))
 
 ;;;###autoload
 (defun help-at-pt-cancel-timer ()
@@ -144,7 +146,6 @@
 	  (run-with-idle-timer
 	   help-at-pt-timer-delay t #'help-at-pt-maybe-display))))
 
-;;;###autoload
 (defcustom help-at-pt-display-when-idle 'never
   "*Automatically show local help on point-over.
 If the value is t, the string obtained from any `kbd-help' or
--- a/lisp/help-fns.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/help-fns.el	Sat Nov 06 17:52:02 2004 +0000
@@ -473,7 +473,7 @@
 		(and (symbolp obj) (boundp obj) obj))))
 	(error nil))
       (let* ((str (find-tag-default))
-	     (obj (if str (read str))))
+	     (obj (if str (intern str))))
 	(and (symbolp obj) (boundp obj) obj))
       0))
 
--- a/lisp/help.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/help.el	Sat Nov 06 17:52:02 2004 +0000
@@ -267,7 +267,7 @@
 		      (and (symbolp obj) (fboundp obj) obj))))
 	      (error nil))))
       (let* ((str (find-tag-default))
-	     (obj (if str (read str))))
+	     (obj (if str (intern str))))
 	(and (symbolp obj) (fboundp obj) obj))))
 
 
--- a/lisp/ibuffer.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/ibuffer.el	Sat Nov 06 17:52:02 2004 +0000
@@ -45,6 +45,7 @@
 Ibuffer allows you to operate on buffers in a manner much like Dired.
 Operations include sorting, marking by regular expression, and
 the ability to filter the displayed buffers by various criteria."
+  :version "21.4"
   :group 'convenience)
 
 (defcustom ibuffer-formats '((mark modified read-only " " (name 18 18 :left :elide)
--- a/lisp/ido.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/ido.el	Sat Nov 06 17:52:02 2004 +0000
@@ -338,6 +338,7 @@
   "Switch between files using substrings."
   :group 'extensions
   :group 'convenience
+  :version "21.4"
   :link '(emacs-commentary-link :tag "Commentary" "ido.el")
   :link '(emacs-library-link :tag "Lisp File" "ido.el"))
 
@@ -359,7 +360,6 @@
   :require 'ido
   :link '(emacs-commentary-link "ido.el")
   :set-after '(ido-save-directory-list-file)
-  :version "21.4"
   :type '(choice (const :tag "Turn on only buffer" buffer)
                  (const :tag "Turn on only file" file)
                  (const :tag "Turn on both buffer and file" both)
--- a/lisp/imenu.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/imenu.el	Sat Nov 06 17:52:02 2004 +0000
@@ -126,7 +126,9 @@
 (defcustom imenu-eager-completion-buffer
   (not (eq imenu-always-use-completion-buffer-p 'never))
   "If non-nil, eagerly popup the completion buffer."
-  :type 'boolean)
+  :type 'boolean
+  :group 'imenu
+  :version "21.4")
 
 (defcustom imenu-after-jump-hook nil
   "*Hooks called after jumping to a place in the buffer.
--- a/lisp/info.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/info.el	Sat Nov 06 17:52:02 2004 +0000
@@ -1476,11 +1476,21 @@
       (save-excursion
 	(save-restriction
 	  (widen)
+	  (when backward
+	    ;; Hide Info file header for backward search
+	    (narrow-to-region (save-excursion
+				(goto-char (point-min))
+				(search-forward "\n\^_")
+				(1- (point)))
+			      (point-max)))
 	  (while (and (not give-up)
 		      (or (null found)
 			  (if backward
                               (isearch-range-invisible found beg-found)
-                            (isearch-range-invisible beg-found found))))
+                            (isearch-range-invisible beg-found found))
+                          ;; Skip node header line
+                          (save-excursion (forward-line -1)
+                                          (looking-at "\^_"))))
 	    (if (if backward
                     (re-search-backward regexp bound t)
                   (re-search-forward regexp bound t))
@@ -1531,14 +1541,24 @@
 	      (while list
 		(message "Searching subfile %s..." (cdr (car list)))
 		(Info-read-subfile (car (car list)))
-                (if backward (goto-char (point-max)))
+		(when backward
+		  ;; Hide Info file header for backward search
+		  (narrow-to-region (save-excursion
+				      (goto-char (point-min))
+				      (search-forward "\n\^_")
+				      (1- (point)))
+				    (point-max))
+		  (goto-char (point-max)))
 		(setq list (cdr list))
 		(setq give-up nil found nil)
 		(while (and (not give-up)
 			    (or (null found)
 				(if backward
                                     (isearch-range-invisible found beg-found)
-                                  (isearch-range-invisible beg-found found))))
+                                  (isearch-range-invisible beg-found found))
+                                ;; Skip node header line
+                                (save-excursion (forward-line -1)
+                                                (looking-at "\^_"))))
 		  (if (if backward
                           (re-search-backward regexp nil t)
                         (re-search-forward regexp nil t))
--- a/lisp/international/mule-cmds.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/international/mule-cmds.el	Sat Nov 06 17:52:02 2004 +0000
@@ -1368,12 +1368,14 @@
 	      current-input-method-title nil)
 	(force-mode-line-update)))))
 
-(defun set-input-method (input-method)
+(defun set-input-method (input-method &optional interactive)
   "Select and activate input method INPUT-METHOD for the current buffer.
 This also sets the default input method to the one you specify.
 If INPUT-METHOD is nil, this function turns off the input method, and
 also causes you to be prompted for a name of an input method the next
 time you invoke \\[toggle-input-method].
+When called interactively, the optional arg INTERACTIVE is non-nil,
+which marks the variable `default-input-method' as set for Custom buffers.
 
 To deactivate the input method interactively, use \\[toggle-input-method].
 To deactivate it programmatically, use \\[inactivate-input-method]."
@@ -1381,14 +1383,15 @@
    (let* ((default (or (car input-method-history) default-input-method)))
      (list (read-input-method-name
 	    (if default "Select input method (default %s): " "Select input method: ")
-	    default t))))
+	    default t)
+	   t)))
   (activate-input-method input-method)
   (setq default-input-method input-method)
-  (when (interactive-p)
+  (when interactive
     (customize-mark-as-set 'default-input-method))
   default-input-method)
 
-(defun toggle-input-method (&optional arg)
+(defun toggle-input-method (&optional arg interactive)
   "Enable or disable multilingual text input method for the current buffer.
 Only one input method can be enabled at any time in a given buffer.
 
@@ -1401,9 +1404,12 @@
 
 With a prefix argument, read an input method name with the minibuffer
 and enable that one.  The default is the most recent input method specified
-\(not including the currently active input method, if any)."
+\(not including the currently active input method, if any).
 
-  (interactive "P")
+When called interactively, the optional arg INTERACTIVE is non-nil,
+which marks the variable `default-input-method' as set for Custom buffers."
+
+  (interactive "P\np")
   (if (and current-input-method (not arg))
       (inactivate-input-method)
     (let ((default (or (car input-method-history) default-input-method)))
@@ -1420,7 +1426,7 @@
       (unless default-input-method
 	(prog1
 	    (setq default-input-method current-input-method)
-	  (when (interactive-p)
+	  (when interactive
 	    (customize-mark-as-set 'default-input-method)))))))
 
 (defun describe-input-method (input-method)
--- a/lisp/kmacro.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/kmacro.el	Sat Nov 06 17:52:02 2004 +0000
@@ -1,6 +1,6 @@
 ;;; kmacro.el --- enhanced keyboard macros
 
-;; Copyright (C) 2002  Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004  Free Software Foundation, Inc.
 
 ;; Author: Kim F. Storm <storm@cua.dk>
 ;; Keywords: keyboard convenience
@@ -120,6 +120,7 @@
   "Simplified keyboard macro user interface."
   :group 'keyboard
   :group 'convenience
+  :version "21.4"
   :link '(emacs-commentary-link :tag "Commentary" "kmacro.el")
   :link '(emacs-library-link :tag "Lisp File" "kmacro.el"))
 
@@ -222,6 +223,14 @@
   (global-set-key (vector kmacro-call-mouse-event) 'kmacro-end-call-mouse))
 
 
+;;; Called from keyboard-quit
+
+(defun kmacro-keyboard-quit ()
+  (or (not defining-kbd-macro)
+      (eq defining-kbd-macro 'append)
+      (kmacro-ring-empty-p)
+      (kmacro-pop-ring)))
+
 
 ;;; Keyboard macro counter
 
@@ -585,7 +594,9 @@
 		       (and append
 			    (if kmacro-execute-before-append
 				(> (car arg) 4)
-			      (= (car arg) 4)))))))
+			      (= (car arg) 4))))
+      (if (and defining-kbd-macro append)
+	  (setq defining-kbd-macro 'append)))))
 
 
 ;;;###autoload
--- a/lisp/mail/supercite.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/mail/supercite.el	Sat Nov 06 17:52:02 2004 +0000
@@ -1424,18 +1424,21 @@
   nil)
 
 ;; interactive functions
-(defun sc-cite-region (start end &optional confirm-p)
+(defun sc-cite-region (start end &optional confirm-p interactive)
   "Cite a region delineated by START and END.
 If optional CONFIRM-P is non-nil, the attribution is confirmed before
 its use in the citation string.  This function first runs
-`sc-pre-cite-hook'."
-  (interactive "r\nP")
+`sc-pre-cite-hook'.
+
+When called interactively, the optional arg INTERACTIVE is non-nil,
+and that means call `sc-select-attribution' too."
+  (interactive "r\nP\np")
   (undo-boundary)
   (let ((frame (or (sc-scan-info-alist sc-cite-frame-alist)
 		   sc-default-cite-frame))
 	(sc-confirm-always-p (if confirm-p t sc-confirm-always-p)))
     (run-hooks 'sc-pre-cite-hook)
-    (if (interactive-p)
+    (if interactive
 	(sc-select-attribution))
     (regi-interpret frame start end)))
 
@@ -1978,16 +1981,15 @@
 	(insert (sc-mail-field "sc-citation"))
       (error "Line is already cited"))))
 
-(defun sc-version (arg)
+(defun sc-version (message)
   "Echo the current version of Supercite in the minibuffer.
-With \\[universal-argument] (universal-argument), or if run non-interactively,
+If MESSAGE is non-nil (interactively, with no prefix argument),
 inserts the version string in the current buffer instead."
-  (interactive "P")
+  (interactive (not current-prefix-arg))
   (let ((verstr (format "Using Supercite.el %s" sc-version)))
-    (if (or (consp arg)
-	    (not (interactive-p)))
-	(insert "`sc-version' says: " verstr)
-      (message verstr))))
+    (if message
+	(message verstr)
+      (insert "`sc-version' says: " verstr))))
 
 (defun sc-describe ()
   "
--- a/lisp/makefile.w32-in	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/makefile.w32-in	Sat Nov 06 17:52:02 2004 +0000
@@ -170,7 +170,7 @@
 	touch $@
 custom-deps: cus-load.el doit
 	@echo Directories: $(WINS)
-	-$(emacs) -l cus-dep --eval $(ARGQUOTE)(setq find-file-hooks nil)$(ARGQUOTE) -f custom-make-dependencies $(lisp) $(WINS)
+	-$(emacs) -l cus-dep --eval $(ARGQUOTE)(setq find-file-hook nil)$(ARGQUOTE) -f custom-make-dependencies $(lisp) $(WINS)
 
 finder-data: doit
 	@echo Directories: $(WINS)
@@ -220,7 +220,7 @@
 autoloads: loaddefs.el doit
 	@echo Directories: $(WINS)
 	$(emacs) -l autoload \
-		--eval $(ARGQUOTE)(setq find-file-hooks nil \
+		--eval $(ARGQUOTE)(setq find-file-hook nil \
 			find-file-suppress-same-file-warnings t \
 			generated-autoload-file \
 			  $(DQUOTE)$(lisp)/loaddefs.el$(DQUOTE))$(ARGQUOTE) \
--- a/lisp/man.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/man.el	Sat Nov 06 17:52:02 2004 +0000
@@ -426,7 +426,7 @@
 		      (view-file f)
 		    (error "Cannot read a file: %s" f))
 		(error "Cannot find a file: %s" f))))
-  'help-echo "mouse-2: mouse-2: display this file")
+  'help-echo "mouse-2: display this file")
 
 
 ;; ======================================================================
--- a/lisp/menu-bar.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/menu-bar.el	Sat Nov 06 17:52:02 2004 +0000
@@ -186,10 +186,15 @@
   '(menu-item "Open Directory..." dired
 	      :help "Read a directory, operate on its files"))
 (define-key menu-bar-files-menu [open-file]
-  '(menu-item "Open File..." find-file
+  '(menu-item "Open File..." find-file-existing
 	      :enable (not (window-minibuffer-p
 			    (frame-selected-window menu-updating-frame)))
-	      :help "Read a file into an Emacs buffer"))
+	      :help "Read an existing file into an Emacs buffer"))
+(define-key menu-bar-files-menu [new-file]
+  '(menu-item "New File..." find-file
+	      :enable (not (window-minibuffer-p
+			    (frame-selected-window menu-updating-frame)))
+	      :help "Read or create a file and edit it"))
 
 
 ;; The "Edit" menu items
--- a/lisp/mouse.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/mouse.el	Sat Nov 06 17:52:02 2004 +0000
@@ -1068,8 +1068,7 @@
     (unless ignore
       ;; For certain special keys, delete the region.
       (if (member key mouse-region-delete-keys)
-	  (delete-region (overlay-start mouse-drag-overlay)
-			 (overlay-end mouse-drag-overlay))
+	  (delete-region (mark t) (point))
 	;; Otherwise, unread the key so it gets executed normally.
 	(setq unread-command-events
 	      (nconc events unread-command-events))))
@@ -1112,7 +1111,7 @@
 Prefix arguments are interpreted as with \\[yank].
 If `mouse-yank-at-point' is non-nil, insert at point
 regardless of where you click."
-  (interactive "*e\nP")
+  (interactive "e\nP")
   ;; Give temporary modes such as isearch a chance to turn off.
   (run-hooks 'mouse-leave-buffer-hook)
   (or mouse-yank-at-point (mouse-set-point click))
@@ -1414,7 +1413,7 @@
 Move point to the end of the inserted text.
 If `mouse-yank-at-point' is non-nil, insert at point
 regardless of where you click."
-  (interactive "*e")
+  (interactive "e")
   ;; Give temporary modes such as isearch a chance to turn off.
   (run-hooks 'mouse-leave-buffer-hook)
   (or mouse-yank-at-point (mouse-set-point click))
--- a/lisp/net/browse-url.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/net/browse-url.el	Sat Nov 06 17:52:02 2004 +0000
@@ -596,10 +596,11 @@
 	(not (eq (null browse-url-new-window-flag)
 		 (null current-prefix-arg)))))
 
-;; interactive-p needs to be called at a function's top-level, hence
-;; the macro.
+;; called-interactive-p needs to be called at a function's top-level, hence
+;; this macro.  We use that rather than interactive-p because
+;; use in a keyboard macro should not change this behavior.
 (defmacro browse-url-maybe-new-window (arg)
-  `(if (not (interactive-p))
+  `(if (or noninteractive (not (called-interactively-p)))
        ,arg
      browse-url-new-window-flag))
 
--- a/lisp/net/eudc.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/net/eudc.el	Sat Nov 06 17:52:02 2004 +0000
@@ -462,73 +462,73 @@
   "Display the record list RECORDS in a formatted buffer.
 If RAW-ATTR-NAMES is non-nil, the raw attribute names are displayed
 otherwise they are formatted according to `eudc-user-attribute-names-alist'."
-  (let ((buffer (get-buffer-create "*Directory Query Results*"))
-	inhibit-read-only
+  (let (inhibit-read-only
 	precords
 	(width 0)
 	beg
 	first-record
 	attribute-name)
-    (switch-to-buffer buffer)
-    (setq buffer-read-only t)
-    (setq inhibit-read-only t)
-    (erase-buffer)
-    (insert "Directory Query Result\n")
-    (insert "======================\n\n\n")
-    (if (null records)
-	(insert "No match found.\n"
-		(if eudc-strict-return-matches
-		    "Try setting `eudc-strict-return-matches' to nil or change `eudc-default-return-attributes'.\n"
-		  ""))
-      ;; Replace field names with user names, compute max width
-      (setq precords
-	    (mapcar
-	     (function
-	      (lambda (record)
+    (with-output-to-temp-buffer "*Directory Query Results*"
+      (with-current-buffer standard-output
+	(setq buffer-read-only t)
+	(setq inhibit-read-only t)
+	(erase-buffer)
+	(insert "Directory Query Result\n")
+	(insert "======================\n\n\n")
+	(if (null records)
+	    (insert "No match found.\n"
+		    (if eudc-strict-return-matches
+			"Try setting `eudc-strict-return-matches' to nil or change `eudc-default-return-attributes'.\n"
+		      ""))
+	  ;; Replace field names with user names, compute max width
+	  (setq precords
 		(mapcar
 		 (function
-		  (lambda (field)
-		    (setq attribute-name
-			  (if raw-attr-names
-			      (symbol-name (car field))
-			    (eudc-format-attribute-name-for-display (car field))))
-		    (if (> (length attribute-name) width)
-			(setq width (length attribute-name)))
-		    (cons attribute-name (cdr field))))
-		 record)))
-	     records))
-      ;; Display the records
-      (setq first-record (point))
-      (mapcar
-       (function
-	(lambda (record)
-	  (setq beg (point))
-	  ;; Map over the record fields to print the attribute/value pairs
-	  (mapcar (function
-		   (lambda (field)
-		     (eudc-print-record-field field width)))
-		  record)
-	  ;; Store the record internal format in some convenient place
-	  (overlay-put (make-overlay beg (point))
-		       'eudc-record
-		       (car records))
-	  (setq records (cdr records))
-	  (insert "\n")))
-       precords))
-    (insert "\n")
-    (widget-create 'push-button
-		   :notify (lambda (&rest ignore)
-			     (eudc-query-form))
-		   "New query")
-    (widget-insert " ")
-    (widget-create 'push-button
-		   :notify (lambda (&rest ignore)
-			     (kill-this-buffer))
-		   "Quit")
-    (eudc-mode)
-    (widget-setup)
-    (if first-record
-	(goto-char first-record))))
+		  (lambda (record)
+		    (mapcar
+		     (function
+		      (lambda (field)
+			(setq attribute-name
+			      (if raw-attr-names
+				  (symbol-name (car field))
+				(eudc-format-attribute-name-for-display (car field))))
+			(if (> (length attribute-name) width)
+			    (setq width (length attribute-name)))
+			(cons attribute-name (cdr field))))
+		     record)))
+		 records))
+	  ;; Display the records
+	  (setq first-record (point))
+	  (mapcar
+	   (function
+	    (lambda (record)
+	      (setq beg (point))
+	      ;; Map over the record fields to print the attribute/value pairs
+	      (mapcar (function
+		       (lambda (field)
+			 (eudc-print-record-field field width)))
+		      record)
+	      ;; Store the record internal format in some convenient place
+	      (overlay-put (make-overlay beg (point))
+			   'eudc-record
+			   (car records))
+	      (setq records (cdr records))
+	      (insert "\n")))
+	   precords))
+	(insert "\n")
+	(widget-create 'push-button
+		       :notify (lambda (&rest ignore)
+				 (eudc-query-form))
+		       "New query")
+	(widget-insert " ")
+	(widget-create 'push-button
+		       :notify (lambda (&rest ignore)
+				 (kill-this-buffer))
+		       "Quit")
+	(eudc-mode)
+	(widget-setup)
+	(if first-record
+	    (goto-char first-record))))))
 
 (defun eudc-process-form ()
   "Process the query form in current buffer and display the results."
@@ -709,34 +709,36 @@
       (eudc-save-options)))
 
 ;;;###autoload
-(defun eudc-get-email (name)
-  "Get the email field of NAME from the directory server."
-  (interactive "sName: ")
+(defun eudc-get-email (name &optional error)
+  "Get the email field of NAME from the directory server.
+If ERROR is non-nil, report an error if there is none."
+  (interactive "sName: \np")
   (or eudc-server
       (call-interactively 'eudc-set-server))
   (let ((result (eudc-query (list (cons 'name name)) '(email)))
 	email)
     (if (null (cdr result))
 	(setq email (eudc-cdaar result))
-      (error "Multiple match. Use the query form"))
-    (if (interactive-p)
+      (error "Multiple match--use the query form"))
+    (if error
 	(if email
 	    (message "%s" email)
 	  (error "No record matching %s" name)))
     email))
 
 ;;;###autoload
-(defun eudc-get-phone (name)
-  "Get the phone field of NAME from the directory server."
-  (interactive "sName: ")
+(defun eudc-get-phone (name &optional error)
+  "Get the phone field of NAME from the directory server.
+If ERROR is non-nil, report an error if there is none."
+  (interactive "sName: \np")
   (or eudc-server
       (call-interactively 'eudc-set-server))
   (let ((result (eudc-query (list (cons 'name name)) '(phone)))
 	phone)
     (if (null (cdr result))
 	(setq phone (eudc-cdaar result))
-      (error "Multiple match. Use the query form"))
-    (if (interactive-p)
+      (error "Multiple match--use the query form"))
+    (if error
 	(if phone
 	    (message "%s" phone)
 	  (error "No record matching %s" name)))
--- a/lisp/net/tls.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/net/tls.el	Sat Nov 06 17:52:02 2004 +0000
@@ -67,18 +67,21 @@
 
 (defcustom tls-process-connection-type nil
   "*Value for `process-connection-type' to use when starting TLS process."
+  :version "21.4"
   :type 'boolean
   :group 'tls)
 
 (defcustom tls-success "- Handshake was completed"
   "*Regular expression indicating completed TLS handshakes.
 The default is what GNUTLS's \"gnutls-cli\" outputs."
+  :version "21.4"
   :type 'regexp
   :group 'tls)
 
 (defcustom tls-certtool-program (executable-find "certtool")
   "Name of  GnuTLS certtool.
 Used by `tls-certificate-information'."
+  :version "21.4"
   :type '(repeat string)
   :group 'tls)
 
--- a/lisp/play/5x5.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/play/5x5.el	Sat Nov 06 17:52:02 2004 +0000
@@ -224,9 +224,8 @@
           5x5-y-pos (/ 5x5-grid-size 2)
           5x5-moves 0
           5x5-grid  (5x5-make-move (5x5-make-new-grid) 5x5-y-pos 5x5-x-pos))
-    (when (interactive-p)
-      (5x5-draw-grid (list 5x5-grid))
-      (5x5-position-cursor))))
+    (5x5-draw-grid (list 5x5-grid))
+    (5x5-position-cursor)))
 
 (defun 5x5-quit-game ()
   "Quit the current game of `5x5'."
--- a/lisp/play/fortune.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/play/fortune.el	Sat Nov 06 17:52:02 2004 +0000
@@ -271,7 +271,7 @@
 	 (fortune-ask-file)
        fortune-file)))
    (save-excursion
-    (fortune-in-buffer (interactive-p) file)
+    (fortune-in-buffer t file)
     (set-buffer fortune-buffer-name)
     (let* ((fortune (buffer-string))
 	   (signature (concat fortune-sigstart fortune fortune-sigend)))
@@ -285,7 +285,7 @@
 (defun fortune-in-buffer (interactive &optional file)
   "Put a fortune cookie in the *fortune* buffer.
 
-When INTERACTIVE is nil, don't display it.  Optional argument FILE,
+INTERACTIVE is ignored.  Optional argument FILE,
 when supplied, specifies the file to choose the fortune from."
   (let ((fortune-buffer (or (get-buffer fortune-buffer-name)
 			    (generate-new-buffer fortune-buffer-name)))
--- a/lisp/progmodes/ada-xref.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/progmodes/ada-xref.el	Sat Nov 06 17:52:02 2004 +0000
@@ -2154,17 +2154,17 @@
   adaname
   )
 
-(defun ada-make-body-gnatstub ()
+(defun ada-make-body-gnatstub (&optional interactive)
   "Create an Ada package body in the current buffer.
 This function uses the `gnatstub' program to create the body.
 This function typically is to be hooked into `ff-file-created-hooks'."
-  (interactive)
+  (interactive "p")
 
   (save-some-buffers nil nil)
 
   ;; If the current buffer is the body (as is the case when calling this
   ;; function from ff-file-created-hooks), then kill this temporary buffer
-  (unless (interactive-p)
+  (unless interactive
     (progn
       (set-buffer-modified-p nil)
       (kill-buffer (current-buffer))))
--- a/lisp/progmodes/cperl-mode.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/progmodes/cperl-mode.el	Sat Nov 06 17:52:02 2004 +0000
@@ -6664,11 +6664,11 @@
 =pod		Switch from Perl to POD.
 ")
 
-(defun cperl-switch-to-doc-buffer ()
+(defun cperl-switch-to-doc-buffer (&optional interactive)
   "Go to the perl documentation buffer and insert the documentation."
-  (interactive)
+  (interactive "p")
   (let ((buf (get-buffer-create cperl-doc-buffer)))
-    (if (interactive-p)
+    (if interactive
 	(switch-to-buffer-other-window buf)
       (set-buffer buf))
     (if (= (buffer-size) 0)
--- a/lisp/progmodes/f90.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/progmodes/f90.el	Sat Nov 06 17:52:02 2004 +0000
@@ -1223,14 +1223,16 @@
 With optional argument NUM, go forward that many balanced blocks.
 If NUM is negative, go backward to the start of a block.
 Checks for consistency of block types and labels (if present),
-and completes outermost block if necessary."
+and completes outermost block if necessary.
+Some of these things (which?) are not done if NUM is nil,
+which only happens in a noninteractive call."
   (interactive "p")
   (if (and num (< num 0)) (f90-beginning-of-block (- num)))
   (let ((f90-smart-end nil)             ; for the final `f90-match-end'
         (case-fold-search t)
         (count (or num 1))
         start-list start-this start-type start-label end-type end-label)
-    (if (interactive-p) (push-mark (point) t))
+    (if num (push-mark (point) t))
     (end-of-line)                       ; probably want this
     (while (and (> count 0) (re-search-forward f90-blocks-re nil 'move))
       (beginning-of-line)
@@ -1266,7 +1268,7 @@
       (end-of-line))
     (if (> count 0) (error "Missing block end"))
     ;; Check outermost block.
-    (if (interactive-p)
+    (if num
         (save-excursion
           (beginning-of-line)
           (skip-chars-forward " \t0-9")
--- a/lisp/progmodes/flymake.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/progmodes/flymake.el	Sat Nov 06 17:52:02 2004 +0000
@@ -56,7 +56,7 @@
 (defun flymake-makehash(&optional test)
     (cond
 	((equal flymake-emacs 'xemacs)  (if test (make-hash-table :test test) (make-hash-table)))
-	(t                              (makehash test))
+	(t                              (makehash test))	
     )
 )
 
@@ -370,8 +370,8 @@
     (let* ((init-f  (nth 0 (flymake-get-file-name-mode-and-masks file-name))))
 	;(flymake-log 0 "calling %s" init-f)
 	;(funcall init-f (current-buffer))
+	  init-f
     )
-    (nth 0 (flymake-get-file-name-mode-and-masks file-name))
 )
 
 (defun flymake-get-cleanup-function(file-name)
@@ -846,7 +846,7 @@
 			 (set-buffer source-buffer)
 
 			 (flymake-parse-residual source-buffer)
-			 (flymake-post-syntax-check source-buffer)
+			 (flymake-post-syntax-check source-buffer exit-status command)
 			 (flymake-set-buffer-is-running source-buffer nil)
 		   )
 		)
@@ -863,7 +863,7 @@
    )
 )
 
-(defun flymake-post-syntax-check(source-buffer)
+(defun flymake-post-syntax-check(source-buffer exit-status command)
     ""
    (flymake-set-buffer-err-info source-buffer (flymake-get-buffer-new-err-info source-buffer))
    (flymake-set-buffer-new-err-info source-buffer nil)
@@ -1220,7 +1220,33 @@
     )
 )
 
-(eval-when-compile (require 'compile))
+(defun flymake-reformat-err-line-patterns-from-compile-el(original-list)
+    "grab error line patterns from original list in compile.el format, convert to flymake internal format"
+	(let* ((converted-list '()))
+	(mapcar
+	    (lambda (item)
+			(setq item (cdr item))
+			(let ((regexp (nth 0 item))
+				  (file (nth 1 item))
+				  (line (nth 2 item))
+				  (col (nth 3 item))
+				  end-line)
+			  (if (consp file)	(setq file (car file)))
+			  (if (consp line)	(setq end-line (cdr line) line (car line)))
+			  (if (consp col)	(setq col (car col)))
+
+			  (when (not (functionp line))
+				  (setq converted-list (cons (list regexp file line col) converted-list))
+			  )
+		   )
+		)
+		original-list
+	)
+	converted-list
+   )
+)
+
+(require 'compile)
 (defvar flymake-err-line-patterns  ; regexp file-idx line-idx col-idx (optional) text-idx(optional), match-end to end of string is error text
     (append
      '(
@@ -1243,9 +1269,9 @@
 	   (" *\\(\\[javac\\]\\)? *\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[ \t\n]*\\(.+\\)"
 	2 4 nil 5)
       )
-     ;; compilation-error-regexp-alist)
-     (mapcar (lambda (x) (cdr x)) compilation-error-regexp-alist-alist)) 
-    "patterns for matching error/warning lines, (regexp file-idx line-idx err-text-idx)"
+	 ;; compilation-error-regexp-alist)
+     (flymake-reformat-err-line-patterns-from-compile-el compilation-error-regexp-alist-alist)) 
+    "patterns for matching error/warning lines, (regexp file-idx line-idx err-text-idx). Use flymake-reformat-err-line-patterns-from-compile-el to add patterns from compile.el"
 )
 ;(defcustom flymake-err-line-patterns
 ;  '(
@@ -1452,7 +1478,7 @@
 	    (let* ((dir (nth idx include-dirs)))
 		(setq full-file-name  (concat dir "/" rel-file-name))
 		(when (file-exists-p full-file-name)
-		    (setq done t)
+		    (setq found t)
 		)
 	    )
 	    (setq idx (1+ idx))
@@ -1574,7 +1600,7 @@
 		process
 	    )
 	    (error
-		(let ((err-str (format "Failed to launch syntax check process '%s' with args %s: %s"
+		(let* ((err-str (format "Failed to launch syntax check process '%s' with args %s: %s"
 			     cmd args (error-message-string err)))
 		      (source-file-name (buffer-file-name buffer))
 		      (cleanup-f        (flymake-get-cleanup-function source-file-name)))
@@ -1905,7 +1931,8 @@
 (defun flymake-mode(&optional arg)
     "toggle flymake-mode"
     (interactive)
-    (let ((old-flymake-mode flymake-mode))
+    (let ((old-flymake-mode flymake-mode)
+		  (turn-on nil))
 
 	(setq turn-on
 	    (if (null arg)
--- a/lisp/progmodes/gdb-ui.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/progmodes/gdb-ui.el	Sat Nov 06 17:52:02 2004 +0000
@@ -133,12 +133,14 @@
 (defcustom gdb-enable-debug-log nil
  "Non-nil means record the process input and output in `gdb-debug-log'."
   :type 'boolean
-  :group 'gud)
+  :group 'gud
+  :version "21.4")
 
 (defcustom gdb-use-inferior-io-buffer nil
  "Non-nil means display output from the inferior in a separate buffer."
   :type 'boolean
-  :group 'gud)
+  :group 'gud
+  :version "21.4")
 
 (defun gdb-ann3 ()
   (setq gdb-debug-log nil)
@@ -211,7 +213,8 @@
 (defcustom gdb-use-colon-colon-notation nil
   "If non-nil use FUN::VAR format to display variables in the speedbar." ;
   :type 'boolean
-  :group 'gud)
+  :group 'gud
+  :version "21.4")
 
 (defun gud-watch ()
   "Watch expression at point."
@@ -658,7 +661,8 @@
 (defcustom gud-gdba-command-name "gdb -annotate=3"
   "Default command to execute an executable under the GDB-UI debugger."
   :type 'string
-  :group 'gud)
+  :group 'gud
+  :version "21.4")
 
 (defvar gdb-annotation-rules
   '(("pre-prompt" gdb-pre-prompt)
@@ -1685,7 +1689,8 @@
 (defcustom gdb-show-main nil
   "Nil means don't display source file containing the main routine."
   :type 'boolean
-  :group 'gud)
+  :group 'gud
+  :version "21.4")
 
 (defun gdb-setup-windows ()
   "Layout the window pattern for gdb-many-windows."
@@ -1726,7 +1731,8 @@
 of the inferior.  Non-nil means display the layout shown for
 `gdba'."
   :type 'boolean
-  :group 'gud)
+  :group 'gud
+  :version "21.4")
 
 (defun gdb-many-windows (arg)
 "Toggle the number of windows in the basic arrangement."
--- a/lisp/progmodes/grep.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/progmodes/grep.el	Sat Nov 06 17:52:02 2004 +0000
@@ -436,9 +436,11 @@
 
 (defun grep-default-command ()
   (let ((tag-default
-	 (funcall (or find-tag-default-function
-		      (get major-mode 'find-tag-default-function)
-		      'find-tag-default)))
+         (shell-quote-argument
+          (or (funcall (or find-tag-default-function
+                           (get major-mode 'find-tag-default-function)
+                           'find-tag-default))
+              "")))
 	(sh-arg-re "\\(\\(?:\"\\(?:[^\"]\\|\\\\\"\\)+\"\\|'[^']+'\\|[^\"' \t\n]\\)+\\)")
 	(grep-default (or (car grep-history) grep-command)))
     ;; Replace the thing matching for with that around cursor.
@@ -460,7 +462,7 @@
 					      0 (match-beginning 2))
 				   " *."
 				   (file-name-extension buffer-file-name))))
-      (replace-match (or tag-default "") t t grep-default 1))))
+      (replace-match tag-default t t grep-default 1))))
 
 ;;;###autoload
 (defun grep (command-args &optional highlight-regexp)
--- a/lisp/progmodes/idlw-shell.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/progmodes/idlw-shell.el	Sat Nov 06 17:52:02 2004 +0000
@@ -1137,10 +1137,10 @@
 	(goto-char save-point))
       (set-buffer save-buffer))))
 
-(defun idlwave-shell-send-char (c &optional no-error)
+(defun idlwave-shell-send-char (c &optional error)
   "Send one character to the shell, without a newline."
-  (interactive "cChar to send to IDL: ")
-  (let ((errf (if (interactive-p) 'error 'message))
+  (interactive "cChar to send to IDL: \np")
+  (let ((errf (if error 'error 'message))
 	buf proc)
     (if (or (not (setq buf (get-buffer (idlwave-shell-buffer))))
 	    (not (setq proc (get-buffer-process buf))))
--- a/lisp/progmodes/idlwave.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/progmodes/idlwave.el	Sat Nov 06 17:52:02 2004 +0000
@@ -4231,7 +4231,7 @@
 
 
 (defvar idlwave-load-rinfo-idle-timer)
-(defun idlwave-update-routine-info (&optional arg)
+(defun idlwave-update-routine-info (&optional arg dont-concentrate)
   "Update the internal routine-info lists.
 These lists are used by `idlwave-routine-info' (\\[idlwave-routine-info])
 and by `idlwave-complete' (\\[idlwave-complete]) to provide information
@@ -4248,10 +4248,12 @@
 When an IDL shell is running, this command also queries the IDL program
 for currently compiled routines.
 
+???Document what DONT-CONCENTRATE means???
+
 With prefix ARG, also reload the system and library lists.
 With two prefix ARG's, also rescans the library tree.
 With three prefix args, dispatch asynchronous process to do the update."
-  (interactive "P")
+  (interactive "P\np")
   ;; Stop any idle processing
   (if (or (and (fboundp 'itimerp)
 	       (itimerp idlwave-load-rinfo-idle-timer))
@@ -4300,7 +4302,7 @@
 			     idlwave-query-shell-for-routine-info)))
 
 	(if (or (not ask-shell)
-		(not (interactive-p)))
+		(not dont-concentrate))
 	    ;; 1. If we are not going to ask the shell, we need to do the
 	    ;;    concatenation now.
 	    ;; 2. When this function is called non-interactively, it means
--- a/lisp/progmodes/vhdl-mode.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/progmodes/vhdl-mode.el	Sat Nov 06 17:52:02 2004 +0000
@@ -6120,17 +6120,17 @@
     (vhdl-keep-region-active)
     foundp))
 
-(defun vhdl-beginning-of-statement (&optional count lim)
+(defun vhdl-beginning-of-statement (&optional count lim interactive)
   "Go to the beginning of the innermost VHDL statement.
 With prefix arg, go back N - 1 statements.  If already at the
 beginning of a statement then go to the beginning of the preceding
 one.  If within a string or comment, or next to a comment (only
 whitespace between), move by sentences instead of statements.
 
-When called from a program, this function takes 2 optional args: the
+When called from a program, this function takes 3 optional args: the
 prefix arg, and a buffer position limit which is the farthest back to
-search."
-  (interactive "p")
+search, and something whose meaning I don't understand."
+  (interactive "p\np")
   (let ((count (or count 1))
 	(case-fold-search t)
 	(lim (or lim (point-min)))
@@ -6139,7 +6139,7 @@
     (save-excursion
       (goto-char lim)
       (setq state (parse-partial-sexp (point) here nil nil)))
-    (if (and (interactive-p)
+    (if (and interactive
 	     (or (nth 3 state)
 		 (nth 4 state)
 		 (looking-at (concat "[ \t]*" comment-start-skip))))
@@ -7531,10 +7531,10 @@
 
 (defun vhdl-fill-region (beg end &optional arg)
   "Fill lines for a region of code."
-  (interactive "r")
+  (interactive "r\np")
   (save-excursion
     (goto-char beg)
-    (let ((margin (if (interactive-p) (current-indentation) (current-column))))
+    (let ((margin (if interactive (current-indentation) (current-column))))
       (goto-char end)
       (setq end (point-marker))
       ;; remove inline comments, newlines and whitespace
--- a/lisp/reveal.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/reveal.el	Sat Nov 06 17:52:02 2004 +0000
@@ -1,6 +1,6 @@
 ;;; reveal.el --- Automatically reveal hidden text at point
 
-;; Copyright (C) 2000, 2001  Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2001, 2004  Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <monnier@cs.yale.edu>
 ;; Keywords: outlines
@@ -59,6 +59,9 @@
 (defvar reveal-open-spots nil)
 (make-variable-buffer-local 'reveal-open-spots)
 
+(defvar reveal-last-tick nil)
+(make-variable-buffer-local 'reveal-last-tick)
+
 ;; Actual code
 
 (defun reveal-post-command ()
@@ -90,16 +93,16 @@
 			  (overlays-at (point))))
 	 (push (cons (selected-window) ol) reveal-open-spots)
 	 (setq old-ols (delq ol old-ols))
-	 (let ((open (overlay-get ol 'reveal-toggle-invisible)))
+	 (let ((open (overlay-get ol 'reveal-toggle-invisible)) inv)
 	   (when (or open
-		     (let ((inv (overlay-get ol 'invisible)))
-		       (and inv (symbolp inv)
-			    (or (setq open (or (get inv 'reveal-toggle-invisible)
-					       (overlay-get ol 'isearch-open-invisible-temporary)))
-				(overlay-get ol 'isearch-open-invisible)
-				(and (consp buffer-invisibility-spec)
-				     (assq inv buffer-invisibility-spec)))
-			    (overlay-put ol 'reveal-invisible inv))))
+		     (and (setq inv (overlay-get ol 'invisible))
+			  (symbolp inv)
+			  (or (setq open (or (get inv 'reveal-toggle-invisible)
+					     (overlay-get ol 'isearch-open-invisible-temporary)))
+			      (overlay-get ol 'isearch-open-invisible)
+			      (and (consp buffer-invisibility-spec)
+				   (assq inv buffer-invisibility-spec)))
+			  (overlay-put ol 'reveal-invisible inv)))
 	     (if (null open)
 		 (overlay-put ol 'invisible nil)
 	       ;; Use the provided opening function and repeat (since the
@@ -113,27 +116,39 @@
 			(setq repeat nil)
 			(overlay-put ol 'invisible nil))))))))
      ;; Close old overlays.
-     (dolist (ol old-ols)
-       (when (and (eq (current-buffer) (overlay-buffer ol))
-		  (not (rassq ol reveal-open-spots)))
-	 (if (and (>= (point) (save-excursion
-				(goto-char (overlay-start ol))
-				(line-beginning-position 1)))
-		  (<= (point) (save-excursion
-				(goto-char (overlay-end ol))
-				(line-beginning-position 2))))
-	     ;; Still near the overlay: keep it open.
-	     (push (cons (selected-window) ol) reveal-open-spots)
-	   ;; Really close it.
-	   (let ((open (overlay-get ol 'reveal-toggle-invisible)) inv)
-	     (if (or open
-		     (and (setq inv (overlay-get ol 'reveal-invisible))
-			  (setq open (or (get inv 'reveal-toggle-invisible)
-					 (overlay-get ol 'isearch-open-invisible-temporary)))))
-		 (condition-case err
-		     (funcall open ol t)
-		   (error (message "!!Reveal-hide: %s !!" err)))
-	       (overlay-put ol 'invisible inv)))))))
+     (if (not (eq reveal-last-tick
+		  (setq reveal-last-tick (buffer-modified-tick))))
+	 ;; The buffer was modified since last command: let's refrain from
+	 ;; closing any overlay because it tends to behave poorly when
+	 ;; inserting text at the end of an overlay (basically the overlay
+	 ;; should be rear-advance when it's open, but things like
+	 ;; outline-minor-mode make it non-rear-advance because it's
+	 ;; a better choice when it's closed).
+	 (dolist (ol old-ols)
+	   (push (cons (selected-window) ol) reveal-open-spots))
+       ;; The last command was only a point motion or some such
+       ;; non-buffer-modifying command.  Let's close whatever can be closed.
+       (dolist (ol old-ols)
+	 (when (and (eq (current-buffer) (overlay-buffer ol))
+		    (not (rassq ol reveal-open-spots)))
+	   (if (and (>= (point) (save-excursion
+				  (goto-char (overlay-start ol))
+				  (line-beginning-position 1)))
+		    (<= (point) (save-excursion
+				  (goto-char (overlay-end ol))
+				  (line-beginning-position 2))))
+	       ;; Still near the overlay: keep it open.
+	       (push (cons (selected-window) ol) reveal-open-spots)
+	     ;; Really close it.
+	     (let ((open (overlay-get ol 'reveal-toggle-invisible)) inv)
+	       (if (or open
+		       (and (setq inv (overlay-get ol 'reveal-invisible))
+			    (setq open (or (get inv 'reveal-toggle-invisible)
+					   (overlay-get ol 'isearch-open-invisible-temporary)))))
+		   (condition-case err
+		       (funcall open ol t)
+		     (error (message "!!Reveal-hide: %s !!" err)))
+		 (overlay-put ol 'invisible inv))))))))
    (error (message "Reveal: %s" err)))))
 
 ;;;###autoload
@@ -171,5 +186,5 @@
 
 (provide 'reveal)
 
-;;; arch-tag: 96ba0242-2274-4ed7-8e10-26bc0707b4d8
+;; arch-tag: 96ba0242-2274-4ed7-8e10-26bc0707b4d8
 ;;; reveal.el ends here
--- a/lisp/simple.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/simple.el	Sat Nov 06 17:52:02 2004 +0000
@@ -1,7 +1,7 @@
 ;;; simple.el --- basic editing commands for Emacs
 
 ;; Copyright (C) 1985, 86, 87, 93, 94, 95, 96, 97, 98, 99,
-;;               2000, 01, 02, 03, 04
+;;               2000, 01, 02, 03, 2004
 ;;        Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
@@ -3920,6 +3920,8 @@
 At top-level, as an editor command, this simply beeps."
   (interactive)
   (deactivate-mark)
+  (if (fboundp 'kmacro-keyboard-quit)
+      (kmacro-keyboard-quit))
   (setq defining-kbd-macro nil)
   (signal 'quit nil))
 
--- a/lisp/textmodes/bibtex.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/textmodes/bibtex.el	Sat Nov 06 17:52:02 2004 +0000
@@ -42,6 +42,8 @@
 
 ;;; Code:
 
+(require 'button)
+
 
 ;; User Options:
 
@@ -496,7 +498,7 @@
 
 (defcustom bibtex-string-files nil
   "*List of BibTeX files containing string definitions.
-Those files must be specified using pathnames relative to the
+List elements can be absolute file names or file names relative to the
 directories specified in `bibtex-string-file-path'."
   :group 'bibtex
   :type '(repeat file))
@@ -504,6 +506,18 @@
 (defvar bibtex-string-file-path (getenv "BIBINPUTS")
   "*Colon separated list of paths to search for `bibtex-string-files'.")
 
+(defcustom bibtex-files nil
+  "*List of BibTeX files checked for duplicate keys.
+List elements can be absolute file names or file names relative to the
+directories specified in `bibtex-file-path'.  If an element is a directory,
+check all BibTeX files in this directory.  If an element is the symbol
+`bibtex-file-path', check all BibTeX files in `bibtex-file-path'."
+  :group 'bibtex
+  :type '(repeat file))
+
+(defvar bibtex-file-path (getenv "BIBINPUTS")
+  "*Colon separated list of paths to search for `bibtex-files'.")
+
 (defcustom bibtex-help-message t
   "*If non-nil print help messages in the echo area on entering a new field."
   :group 'bibtex
@@ -557,7 +571,7 @@
     ;; braces, quotes, concatenation.
     ("[`'\"{}#]" . "")
     ;; spaces
-    ("[ \t\n]+" . " "))
+    ("\\\\?[ \t\n]+\\|~" . " "))
   "Alist of (OLD-REGEXP . NEW-STRING) pairs.
 Used by the default values of `bibtex-autokey-name-change-strings' and
 `bibtex-autokey-titleword-change-strings'.  Defaults to translating some
@@ -756,12 +770,22 @@
 
 (defcustom bibtex-autoadd-commas t
   "If non-nil automatically add missing commas at end of BibTeX fields."
+  :group 'bibtex
   :type 'boolean)
 
 (defcustom bibtex-autofill-types '("Proceedings")
   "Automatically fill fields if possible for those BibTeX entry types."
+  :group 'bibtex
   :type '(repeat string))
 
+(defcustom bibtex-summary-function 'bibtex-summary
+  "Function to call for generating a one-line summary of a BibTeX entry.
+It takes one argument, the key of the entry.
+Used by `bibtex-complete-key-cleanup' and `bibtex-copy-summary-as-kill'."
+  :group 'bibtex
+  :type '(choice (const :tag "Default" bibtex-summary)
+                 (function :tag "Personalized function")))
+
 (defcustom bibtex-generate-url-list
   '((("url" . ".*:.*"))
     ;; Example of a complex setup.
@@ -778,7 +802,7 @@
 Each scheme is of the form ((FIELD . REGEXP) STEP...).
 
 FIELD is a field name as returned by `bibtex-parse-entry'.
-REGEXP is matched against the text of FIELD.  If the match succeed, then
+REGEXP is matched against the text of FIELD.  If the match succeeds, then
 this scheme will be used.  If no STEPS are specified the matched text is used
 as the URL, otherwise the URL is built by concatenating the STEPS.
 
@@ -838,6 +862,7 @@
     (define-key km "\C-c\C-c" 'bibtex-clean-entry)
     (define-key km "\C-c\C-q" 'bibtex-fill-entry)
     (define-key km "\C-c\C-s" 'bibtex-find-entry)
+    (define-key km "\C-c\C-t" 'bibtex-copy-summary-as-kill)
     (define-key km "\C-c?" 'bibtex-print-help-message)
     (define-key km "\C-c\C-p" 'bibtex-pop-previous)
     (define-key km "\C-c\C-n" 'bibtex-pop-next)
@@ -892,7 +917,9 @@
     ("Moving in BibTeX Buffer"
      ["Find Entry" bibtex-find-entry t]
      ["Find Crossref Entry" bibtex-find-crossref t])
-     "--"
+    ("Moving between BibTeX Buffers"
+     ["Find Entry Globally" bibtex-find-entry-globally t])
+    "--"
     ("Operating on Current Field"
      ["Fill Field" fill-paragraph t]
      ["Remove Delimiters" bibtex-remove-delimiters t]
@@ -922,6 +949,8 @@
      ["Paste Most Recently Killed Entry" bibtex-yank t]
      ["Paste Previously Killed Entry" bibtex-yank-pop t]
      "--"
+     ["Copy Summary to Kill Ring" bibtex-copy-summary-as-kill t]
+     "--"
      ["Ispell Entry" bibtex-ispell-entry t]
      ["Ispell Entry Abstract" bibtex-ispell-abstract t]
      ["Narrow to Entry" bibtex-narrow-to-entry t]
@@ -934,7 +963,9 @@
      ["Reformat Entries" bibtex-reformat t]
      ["Count Entries" bibtex-count-entries t]
      "--"
-     ["Convert Alien Buffer" bibtex-convert-alien t])))
+     ["Convert Alien Buffer" bibtex-convert-alien t])
+    ("Operating on Multiple Buffers"
+     ["Validate Entries" bibtex-validate-globally t])))
 
 (easy-menu-define
   bibtex-entry-menu bibtex-mode-map "Entry-Types Menu in BibTeX mode"
@@ -955,13 +986,6 @@
         ["String" bibtex-String t]
         ["Preamble" bibtex-Preamble t]))
 
-(defvar bibtex-url-map
-  (let ((km (make-sparse-keymap)))
-    (define-key km [(mouse-2)] 'bibtex-url)
-    km)
-  "Local keymap for clickable URLs.")
-(fset 'bibtex-url-map bibtex-url-map)
-    
 
 ;; Internal Variables
 
@@ -996,8 +1020,9 @@
 (make-variable-buffer-local 'bibtex-strings)
 
 (defvar bibtex-reference-keys
-  (lazy-completion-table bibtex-reference-keys bibtex-parse-keys nil nil t)
-  "Completion table for BibTeX reference keys.")
+  (lazy-completion-table bibtex-reference-keys bibtex-parse-keys nil t)
+  "Completion table for BibTeX reference keys.
+The CDRs of the elements are t for header keys and nil for crossref keys.")
 (make-variable-buffer-local 'bibtex-reference-keys)
 
 (defvar bibtex-buffer-last-parsed-tick nil
@@ -1103,13 +1128,13 @@
     (,(concat "^[ \t]*\\(" bibtex-field-name "\\)[ \t]*=")
      1 font-lock-variable-name-face)
     ;; url
-    (bibtex-font-lock-url 0 '(face nil mouse-face highlight
-                                   keymap bibtex-url-map)))
+    bibtex-font-lock-url bibtex-font-lock-crossref)
   "*Default expressions to highlight in BibTeX mode.")
 
 (defvar bibtex-font-lock-url-regexp
-  (concat "\\<" (regexp-opt (mapcar 'caar bibtex-generate-url-list) t)
-          "\\>[ \t]*=[ \t]*")
+  ;; Assume that field names begin at the beginning of a line.
+  (concat "^[ \t]*" (regexp-opt (mapcar 'caar bibtex-generate-url-list) t)
+          "[ \t]*=[ \t]*")
   "Regexp for `bibtex-font-lock-url'.")
 
 (defvar bibtex-field-name-for-parsing nil
@@ -1128,32 +1153,12 @@
 Used when `bibtex-maintain-sorted-entries' is `entry-class'.")
 
 
-;; Special support taking care of variants
-(defvar zmacs-regions)
-(defalias 'bibtex-mark-active
-  (if (boundp 'mark-active)
-      ;; In Emacs mark-active indicates if mark is active.
-      (lambda () mark-active)
-    ;; In XEmacs (mark) returns nil when not active.
-    (lambda () (if zmacs-regions (mark) (mark t)))))
-
-(defalias 'bibtex-run-with-idle-timer
-  (if (fboundp 'run-with-idle-timer)
-      ;; timer.el is distributed with Emacs
-      'run-with-idle-timer
-    ;; timer.el is not distributed with XEmacs
-    ;; Notice that this does not (yet) pass the arguments, but they
-    ;; are not used (yet) in bibtex.el. Fix if needed.
-    (lambda (secs repeat function &rest args)
-      (start-itimer "bibtex" function secs (if repeat secs nil) t))))
-
-
 ;; Support for hideshow minor mode
 (defun bibtex-hs-forward-sexp (arg)
   "Replacement for `forward-sexp' to be used by `hs-minor-mode'.
 ARG is ignored."
   (if (looking-at "@\\S(*\\s(")
-    (goto-char (1- (match-end 0))))
+      (goto-char (1- (match-end 0))))
   (forward-sexp 1))
 
 (add-to-list
@@ -1471,12 +1476,10 @@
   (buffer-substring-no-properties (1+ (match-beginning bibtex-type-in-head))
                                   (match-end bibtex-type-in-head)))
 
-(defun bibtex-key-in-head (&optional empty)
+(defsubst bibtex-key-in-head (&optional empty)
   "Extract BibTeX key in head.  Return optional arg EMPTY if key is empty."
-  (if (match-beginning bibtex-key-in-head)
-      (buffer-substring-no-properties (match-beginning bibtex-key-in-head)
-                                      (match-end bibtex-key-in-head))
-    empty))
+  (or (match-string-no-properties bibtex-key-in-head)
+      empty))
 
 ;; Helper Functions
 
@@ -1492,7 +1495,7 @@
 (defun bibtex-current-line ()
   "Compute line number of point regardless whether the buffer is narrowed."
   (+ (count-lines 1 (point))
-     (if (equal (current-column) 0) 1 0)))
+     (if (bolp) 1 0)))
 
 (defun bibtex-skip-to-valid-entry (&optional backward)
   "Move point to beginning of the next valid BibTeX entry.
@@ -1525,24 +1528,25 @@
     found))
 
 (defun bibtex-map-entries (fun)
-  "Call FUN for each BibTeX entry starting with the current.
-Do this to the end of the file.  FUN is called with three arguments, the key of
-the entry and the buffer positions (marker) of beginning and end of entry.
-Point is inside the entry.  If `bibtex-sort-ignore-string-entries' is non-nil,
-FUN will not be called for @String entries."
+  "Call FUN for each BibTeX entry in buffer (possibly narrowed).
+FUN is called with three arguments, the key of the entry and the buffer
+positions (marker) of beginning and end of entry.  Point is inside the entry.
+If `bibtex-sort-ignore-string-entries' is non-nil, FUN will not be called for
+@String entries."
   (let ((case-fold-search t))
-    (bibtex-beginning-of-entry)
-    (while (re-search-forward bibtex-entry-head nil t)
-      (let ((entry-type (bibtex-type-in-head))
-            (key (bibtex-key-in-head ""))
-            (beg (copy-marker (match-beginning 0)))
-            (end (copy-marker (save-excursion (bibtex-end-of-entry)))))
-        (save-excursion
-          (if (or (and (not bibtex-sort-ignore-string-entries)
-                       (bibtex-string= entry-type "string"))
-                  (assoc-string entry-type bibtex-entry-field-alist t))
-              (funcall fun key beg end)))
-        (goto-char end)))))
+    (save-excursion
+      (goto-char (point-min))
+      (while (re-search-forward bibtex-entry-head nil t)
+        (let ((entry-type (bibtex-type-in-head))
+              (key (bibtex-key-in-head ""))
+              (beg (copy-marker (match-beginning 0)))
+              (end (copy-marker (save-excursion (bibtex-end-of-entry)))))
+          (save-excursion
+            (if (or (and (not bibtex-sort-ignore-string-entries)
+                         (bibtex-string= entry-type "string"))
+                    (assoc-string entry-type bibtex-entry-field-alist t))
+                (funcall fun key beg end)))
+          (goto-char end))))))
 
 (defun bibtex-progress-message (&optional flag interval)
   "Echo a message about progress of current buffer.
@@ -1581,13 +1585,13 @@
     "\""))
 
 (defun bibtex-entry-left-delimiter ()
-  "Return a string dependent on `bibtex-field-delimiters'."
+  "Return a string dependent on `bibtex-entry-delimiters'."
   (if (equal bibtex-entry-delimiters 'braces)
       "{"
     "("))
 
 (defun bibtex-entry-right-delimiter ()
-  "Return a string dependent on `bibtex-field-delimiters'."
+  "Return a string dependent on `bibtex-entry-delimiters'."
   (if (equal bibtex-entry-delimiters 'braces)
       "}"
     ")"))
@@ -1641,7 +1645,7 @@
                     (setq infix-start (bibtex-end-of-field bounds))
                   (setq finished t))
                 (goto-char infix-start))
-              ;; This matches the infix* part. The AND construction assures
+              ;; This matches the infix* part.  The AND construction assures
               ;; that BOUND is respected.
               (when (and (looking-at bibtex-entry-postfix)
                          (eq (char-before (match-end 0)) entry-closer)
@@ -1826,8 +1830,8 @@
                                                      (cdr field)))
                                   (cdr field))
                 req-field-list (if crossref-key
-                                   (nth 0 (nth 2 entry-list))  ; crossref part
-                                 (nth 0 (nth 1 entry-list))))  ; required part
+                                   (nth 0 (nth 2 entry-list)) ; crossref part
+                                 (nth 0 (nth 1 entry-list)))) ; required part
 
           (dolist (rfield req-field-list)
             (when (nth 3 rfield) ; we should have an alternative
@@ -1864,9 +1868,9 @@
                  deleted)
 
             ;; We have more elegant high-level functions for several
-            ;; tasks done by bibtex-format-entry. However, they contain
+            ;; tasks done by bibtex-format-entry.  However, they contain
             ;; quite some redundancy compared with what we need to do
-            ;; anyway. So for speed-up we avoid using them.
+            ;; anyway.  So for speed-up we avoid using them.
 
             (if (memq 'opts-or-alts format)
                 (cond ((and empty-field
@@ -1875,8 +1879,8 @@
                                               field-name req-field-list t)))
                                   (or (not field)       ; OPT field
                                       (nth 3 field))))) ; ALT field
-                       ;; Either it is an empty ALT field. Then we have checked
-                       ;; already that we have one non-empty alternative. Or it
+                       ;; Either it is an empty ALT field.  Then we have checked
+                       ;; already that we have one non-empty alternative.  Or it
                        ;; is an empty OPT field that we do not miss anyway.
                        ;; So we can safely delete this field.
                        (delete-region beg-field end-field)
@@ -2041,19 +2045,33 @@
     (dolist (pattern change-list content)
       (setq content (replace-regexp-in-string (car pattern)
                                               (cdr pattern)
-                                              content)))))
+                                              content t)))))
 
 (defun bibtex-autokey-get-names ()
   "Get contents of the name field of the current entry.
-Do some modifications based on `bibtex-autokey-name-change-strings'
-and return results as a list."
-  (let ((case-fold-search t)
-        (names (bibtex-autokey-get-field "author\\|editor"
+Do some modifications based on `bibtex-autokey-name-change-strings'.
+Return the names as a concatenated string obeying `bibtex-autokey-names'
+and `bibtex-autokey-names-stretch'."
+  (let ((names (bibtex-autokey-get-field "author\\|editor"
                                          bibtex-autokey-name-change-strings)))
     ;; Some entries do not have a name field.
     (unless (string= "" names)
-      (mapcar 'bibtex-autokey-demangle-name
-              (split-string names "[ \t\n]+and[ \t\n]+")))))
+      (let* ((case-fold-search t)
+             (name-list (mapcar 'bibtex-autokey-demangle-name
+                                (split-string names "[ \t\n]+and[ \t\n]+")))
+             additional-names)
+        (unless (or (not (numberp bibtex-autokey-names))
+                    (<= (length name-list)
+                        (+ bibtex-autokey-names
+                           bibtex-autokey-names-stretch)))
+          ;; Take bibtex-autokey-names elements from beginning of name-list
+          (setq name-list (nreverse (nthcdr (- (length name-list)
+                                               bibtex-autokey-names)
+                                            (nreverse name-list)))
+                additional-names bibtex-autokey-additional-names))
+        (concat (mapconcat 'identity name-list
+                           bibtex-autokey-name-separator)
+                additional-names)))))
 
 (defun bibtex-autokey-demangle-name (fullname)
   "Get the last part from a well-formed FULLNAME and perform abbreviations."
@@ -2082,8 +2100,15 @@
      (funcall bibtex-autokey-name-case-convert name)
      bibtex-autokey-name-length)))
 
+(defun bibtex-autokey-get-year ()
+  "Return year field contents as a string obeying `bibtex-autokey-year-length'."
+  (let ((yearfield (bibtex-autokey-get-field "year")))
+    (substring yearfield (max 0 (- (length yearfield)
+                                   bibtex-autokey-year-length)))))
+
 (defun bibtex-autokey-get-title ()
-  "Get title field contents up to a terminator."
+  "Get title field contents up to a terminator.
+Return the result as a string"
   (let ((case-fold-search t)
         (titlestring
          (bibtex-autokey-get-field "title"
@@ -2092,35 +2117,37 @@
     (dolist (terminator bibtex-autokey-title-terminators)
       (if (string-match terminator titlestring)
           (setq titlestring (substring titlestring 0 (match-beginning 0)))))
-    ;; gather words from titlestring into a list. Ignore
+    ;; gather words from titlestring into a list.  Ignore
     ;; specific words and use only a specific amount of words.
     (let ((counter 0)
-          titlewords titlewords-extra titleword end-match)
+          titlewords titlewords-extra word)
       (while (and (or (not (numberp bibtex-autokey-titlewords))
                       (< counter (+ bibtex-autokey-titlewords
                                     bibtex-autokey-titlewords-stretch)))
                   (string-match "\\b\\w+" titlestring))
-        (setq end-match (match-end 0)
-              titleword (substring titlestring
-                                   (match-beginning 0) end-match))
+        (setq word (match-string 0 titlestring)
+              titlestring (substring titlestring (match-end 0)))
+        ;; Ignore words matched by one of the elements of
+        ;; bibtex-autokey-titleword-ignore
         (unless (let ((lst bibtex-autokey-titleword-ignore))
                   (while (and lst
                               (not (string-match (concat "\\`\\(?:" (car lst)
-                                                         "\\)\\'") titleword)))
+                                                         "\\)\\'") word)))
                     (setq lst (cdr lst)))
                   lst)
-          (setq titleword
-                (funcall bibtex-autokey-titleword-case-convert titleword))
+          (setq word (funcall bibtex-autokey-titleword-case-convert word)
+                counter (1+ counter))
           (if (or (not (numberp bibtex-autokey-titlewords))
                   (< counter bibtex-autokey-titlewords))
-              (setq titlewords (append titlewords (list titleword)))
-            (setq titlewords-extra
-                  (append titlewords-extra (list titleword))))
-          (setq counter (1+ counter)))
-        (setq titlestring (substring titlestring end-match)))
+              (push word titlewords)
+            (push word titlewords-extra))))
+      ;; Obey bibtex-autokey-titlewords-stretch:
+      ;; If by now we have processed all words in titlestring, we include
+      ;; titlewords-extra in titlewords. Otherwise, we ignore titlewords-extra.
       (unless (string-match "\\b\\w+" titlestring)
-        (setq titlewords (append titlewords titlewords-extra)))
-      (mapcar 'bibtex-autokey-demangle-title titlewords))))
+        (setq titlewords (append titlewords-extra titlewords)))
+      (mapconcat 'bibtex-autokey-demangle-title (nreverse titlewords)
+                 bibtex-autokey-titleword-separator))))
 
 (defun bibtex-autokey-demangle-title (titleword)
   "Do some abbreviations on TITLEWORD.
@@ -2211,65 +2238,36 @@
     the key is then presented in the minibuffer to the user,
     where it can be edited.  The key given by the user is then
     used."
-  (let* ((name-etal "")
-         (namelist
-          (let ((nl (bibtex-autokey-get-names))
-                nnl)
-            (if (or (not (numberp bibtex-autokey-names))
-                    (<= (length nl)
-                        (+ bibtex-autokey-names
-                           bibtex-autokey-names-stretch)))
-                nl
-              (setq name-etal bibtex-autokey-additional-names)
-              (while (< (length nnl) bibtex-autokey-names)
-                (setq nnl (append nnl (list (car nl)))
-                      nl (cdr nl)))
-              nnl)))
-         (namepart (concat (mapconcat 'identity
-                                      namelist
-                                      bibtex-autokey-name-separator)
-                           name-etal))
-         (yearfield (bibtex-autokey-get-field "year"))
-         (yearpart (if (equal yearfield "")
-                       ""
-                     (substring yearfield
-                                (- (length yearfield)
-                                   bibtex-autokey-year-length))))
-         (titlepart (mapconcat 'identity
-                               (bibtex-autokey-get-title)
-                               bibtex-autokey-titleword-separator))
+  (let* ((names (bibtex-autokey-get-names))
+         (year (bibtex-autokey-get-year))
+         (title (bibtex-autokey-get-title))
          (autokey (concat bibtex-autokey-prefix-string
-                          namepart
-                          (unless (or (equal namepart "")
-                                      (equal yearpart ""))
+                          names
+                          (unless (or (equal names "")
+                                      (equal year ""))
                             bibtex-autokey-name-year-separator)
-                          yearpart
-                          (unless (or (and (equal namepart "")
-                                           (equal yearpart ""))
-                                      (equal titlepart ""))
+                          year
+                          (unless (or (and (equal names "")
+                                           (equal year ""))
+                                      (equal title ""))
                             bibtex-autokey-year-title-separator)
-                          titlepart)))
+                          title)))
     (if bibtex-autokey-before-presentation-function
         (funcall bibtex-autokey-before-presentation-function autokey)
       autokey)))
 
 
-(defun bibtex-parse-keys (&optional add abortable verbose)
+(defun bibtex-read-key (prompt &optional key)
+  "Read BibTeX key from minibuffer using PROMPT and default KEY."
+  (completing-read prompt bibtex-reference-keys
+                   nil nil key 'bibtex-key-history))
+
+(defun bibtex-parse-keys (&optional abortable verbose)
   "Set `bibtex-reference-keys' to the keys used in the whole buffer.
-The buffer might possibly be restricted.
-Find both entry keys and crossref entries.
-If ADD is non-nil add the new keys to `bibtex-reference-keys' instead of
-simply resetting it.  If ADD is an alist of keys, also add ADD to
-`bibtex-reference-keys'.  If ABORTABLE is non-nil abort on user
-input.  If VERBOSE is non-nil gives messages about progress.
-Return alist of keys if parsing was completed, `aborted' otherwise."
-  (let ((reference-keys (if (and add
-                                 (listp bibtex-reference-keys))
-                            bibtex-reference-keys)))
-    (if (listp add)
-        (dolist (key add)
-          (unless (assoc (car key) reference-keys)
-                      (push key reference-keys))))
+Find both entry keys and crossref entries.  If ABORTABLE is non-nil abort on
+user input.  If VERBOSE is non-nil gives messages about progress.  Return alist
+of keys if parsing was completed, `aborted' otherwise."
+  (let (ref-keys crossref-keys)
     (save-excursion
       (save-match-data
         (if verbose
@@ -2286,22 +2284,24 @@
                   (if (and abortable (input-pending-p))
                       ;; user has aborted by typing a key --> return `aborted'
                       (throw 'userkey 'aborted))
-                  (let ((key (cond ((match-end 3)
-                                    ;; This is a crossref.
-                                    (buffer-substring-no-properties
-                                     (1+ (match-beginning 3)) (1- (match-end 3))))
-                                   ((assoc-string (bibtex-type-in-head)
-						  bibtex-entry-field-alist t)
-                                    ;; This is an entry.
-                                    (match-string-no-properties bibtex-key-in-head)))))
-                    (if (and (stringp key)
-                             (not (assoc key reference-keys)))
-                      (push (list key) reference-keys)))))
+                  (cond ((match-end 3)
+                         ;; This is a crossref.
+                         (let ((key (buffer-substring-no-properties
+                                     (1+ (match-beginning 3)) (1- (match-end 3)))))
+                               (unless (assoc key crossref-keys)
+                                 (push (list key) crossref-keys))))
+                        ;; only keys of known entries
+                        ((assoc-string (bibtex-type-in-head)
+                                       bibtex-entry-field-alist t)
+                         ;; This is an entry.
+                         (let ((key (bibtex-key-in-head)))
+                           (unless (assoc key ref-keys)
+                             (push (cons key t) ref-keys)))))))
 
             (let (;; ignore @String entries because they are handled
                   ;; separately by bibtex-parse-strings
                   (bibtex-sort-ignore-string-entries t)
-                  crossref-key bounds)
+                  bounds)
               (bibtex-map-entries
                (lambda (key beg end)
                  (if (and abortable
@@ -2309,17 +2309,19 @@
                      ;; user has aborted by typing a key --> return `aborted'
                      (throw 'userkey 'aborted))
                  (if verbose (bibtex-progress-message))
-                 (unless (assoc key reference-keys)
-                   (push (list key) reference-keys))
+                 (unless (assoc key ref-keys)
+                   (push (cons key t) ref-keys))
                  (if (and (setq bounds (bibtex-search-forward-field "crossref" end))
-                          (setq crossref-key (bibtex-text-in-field-bounds bounds t))
-                          (not (assoc crossref-key reference-keys)))
-                     (push (list crossref-key) reference-keys))))))
-
+                          (setq key (bibtex-text-in-field-bounds bounds t))
+                          (not (assoc key crossref-keys)))
+                     (push (list key) crossref-keys))))))
+
+          (dolist (key crossref-keys)
+            (unless (assoc (car key) ref-keys) (push key ref-keys)))
           (if verbose
               (bibtex-progress-message 'done))
           ;; successful operation --> return `bibtex-reference-keys'
-          (setq bibtex-reference-keys reference-keys))))))
+          (setq bibtex-reference-keys ref-keys))))))
 
 (defun bibtex-parse-strings (&optional add abortable)
   "Set `bibtex-strings' to the string definitions in the whole buffer.
@@ -2355,39 +2357,44 @@
 
 (defun bibtex-string-files-init ()
   "Return initialization for `bibtex-strings'.
-Use `bibtex-predefined-strings' and bib files `bibtex-string-files'."
+Use `bibtex-predefined-strings' and BibTeX files `bibtex-string-files'."
   (save-match-data
-    ;; collect pathnames
-    (let ((dirlist (split-string (or bibtex-string-file-path ".")
+    (let ((dirlist (split-string (or bibtex-string-file-path default-directory)
                                  ":+"))
           (case-fold-search)
-          compl)
+          string-files fullfilename compl bounds found)
+      ;; collect absolute file names of valid string files
       (dolist (filename bibtex-string-files)
         (unless (string-match "\\.bib\\'" filename)
           (setq filename (concat filename ".bib")))
         ;; test filenames
-        (let (fullfilename bounds found)
+        (if (file-name-absolute-p filename)
+            (if (file-readable-p filename)
+                (push filename string-files)
+              (error "BibTeX strings file %s not found" filename))
           (dolist (dir dirlist)
             (when (file-readable-p
                    (setq fullfilename (expand-file-name filename dir)))
-              ;; file was found
-              (with-temp-buffer
-                (insert-file-contents fullfilename)
-                (goto-char (point-min))
-                (while (setq bounds (bibtex-search-forward-string))
-                  (push (cons (bibtex-reference-key-in-string bounds)
-                              (bibtex-text-in-string bounds t))
-                        compl)
-                  (goto-char (bibtex-end-of-string bounds))))
+              (push fullfilename string-files)
               (setq found t)))
           (unless found
             (error "File %s not in paths defined via bibtex-string-file-path"
                    filename))))
+      ;; parse string files
+      (dolist (filename string-files)
+        (with-temp-buffer
+          (insert-file-contents filename)
+          (goto-char (point-min))
+          (while (setq bounds (bibtex-search-forward-string))
+            (push (cons (bibtex-reference-key-in-string bounds)
+                        (bibtex-text-in-string bounds t))
+                  compl)
+            (goto-char (bibtex-end-of-string bounds)))))
       (append bibtex-predefined-strings (nreverse compl)))))
 
 (defun bibtex-parse-buffers-stealthily ()
   "Parse buffer in the background during idle time.
-Called by `bibtex-run-with-idle-timer'.  Whenever Emacs has been idle
+Called by `run-with-idle-timer'.  Whenever Emacs has been idle
 for `bibtex-parse-keys-timeout' seconds, all BibTeX buffers (starting
 with the current) are parsed."
   (save-excursion
@@ -2402,7 +2409,7 @@
               (widen)
               ;; Output no progress messages in bibtex-parse-keys
               ;; because when in y-or-n-p that can hide the question.
-              (if (and (listp (bibtex-parse-keys nil t))
+              (if (and (listp (bibtex-parse-keys t))
                        ;; update bibtex-strings
                        (listp (bibtex-parse-strings strings-init t)))
 
@@ -2410,6 +2417,51 @@
                   (setq bibtex-buffer-last-parsed-tick (buffer-modified-tick)))))
         (setq buffers (cdr buffers))))))
 
+(defun bibtex-files-expand (&optional current)
+  "Return an expanded list of BibTeX buffers based on `bibtex-files'.
+Initialize in these buffers `bibtex-reference-keys' if not yet set.
+List includes current buffer if CURRENT is non-nil."
+  (let ((file-path (split-string (or bibtex-file-path default-directory) ":+"))
+        file-list dir-list buffer-list)
+    (dolist (file bibtex-files)
+      (cond ((eq file 'bibtex-file-path)
+             (setq dir-list (append dir-list file-path)))
+            ((file-accessible-directory-p file)
+             (push file dir-list))
+            ((progn (unless (string-match "\\.bib\\'" file)
+                      (setq file (concat file ".bib")))
+                    (file-name-absolute-p file))
+             (push file file-list))
+            (t
+             (let (fullfilename found)
+               (dolist (dir file-path)
+                 (when (file-readable-p
+                        (setq fullfilename (expand-file-name file dir)))
+                   (push fullfilename file-list)
+                   (setq found t)))
+               (unless found
+                 (error "File %s not in paths defined via bibtex-file-path"
+                        file))))))
+    (dolist (file file-list)
+      (unless (file-readable-p file)
+        (error "BibTeX file %s not found" file)))
+    ;; expand dir-list
+    (dolist (dir dir-list)
+      (setq file-list
+            (append file-list (directory-files dir t "\\.bib\\'" t))))
+    (delete-dups file-list)
+    (dolist (file file-list)
+      (when (file-readable-p file)
+        (push (find-file-noselect file) buffer-list)
+        (with-current-buffer (car buffer-list)
+          (unless (listp bibtex-reference-keys)
+            (bibtex-parse-keys)))))
+    (cond ((and current (not (memq (current-buffer) buffer-list)))
+           (push (current-buffer) buffer-list))
+          ((and (not current) (memq (current-buffer) buffer-list))
+           (setq buffer-list (delq (current-buffer) buffer-list))))
+    buffer-list))
+
 (defun bibtex-complete-internal (completions)
   "Complete word fragment before point to longest prefix of COMPLETIONS.
 COMPLETIONS should be a list of strings.  If point is not after the part
@@ -2459,58 +2511,59 @@
                 (bibtex-remove-delimiters))))))))
 
 (defun bibtex-complete-key-cleanup (key)
-  "Display message on entry KEY after completion of a crossref key."
+  "Display summary message on entry KEY after completion of a crossref key.
+Use `bibtex-summary-function' to generate summary."
   (save-excursion
     ;; Don't do anything if we completed the key of an entry.
     (let ((pnt (bibtex-beginning-of-entry)))
       (if (and (stringp key)
                (bibtex-find-entry key)
                (/= pnt (point)))
-          (let* ((bibtex-autokey-name-case-convert 'identity)
-                 (bibtex-autokey-name-length 'infty)
-                 (nl (bibtex-autokey-get-names))
-                 (name (concat (nth 0 nl) (if (nth 1 nl) " etal")))
-                 (year (bibtex-autokey-get-field "year"))
-                 (bibtex-autokey-titlewords 5)
-                 (bibtex-autokey-titlewords-stretch 2)
-                 (bibtex-autokey-titleword-case-convert 'identity)
-                 (bibtex-autokey-titleword-length 5)
-                 (title (mapconcat 'identity
-                                   (bibtex-autokey-get-title) " "))
-                 (journal (bibtex-autokey-get-field
-                           "journal" bibtex-autokey-transcriptions))
-                 (volume (bibtex-autokey-get-field "volume"))
-                 (pages (bibtex-autokey-get-field "pages" '(("-.*\\'" . "")))))
-            (message "Ref:%s"
-                     (mapconcat (lambda (arg)
-                                  (if (not (string= "" (cdr arg)))
-                                      (concat (car arg) (cdr arg))))
-                                `((" " . ,name) (" " . ,year)
-                                  (": " . ,title) (", " . ,journal)
-                                  (" " . ,volume) (":" . ,pages))
-                                "")))))))
-
-(defun bibtex-choose-completion-string (choice buffer mini-p base-size)
-  ;; Code borrowed from choose-completion-string:
-  ;; We must duplicate the code from choose-completion-string
-  ;; because it runs the hook choose-completion-string-functions
-  ;; before it inserts the completion. But we want to do something
-  ;; after the completion has been inserted.
-  ;;
-  ;; Insert the completion into the buffer where it was requested.
-  (set-buffer buffer)
-  (if base-size
-      (delete-region (+ base-size (point-min))
-                     (point))
-    ;; Delete the longest partial match for CHOICE
-    ;; that can be found before point.
-   (choose-completion-delete-max-match choice))
-  (insert choice)
-  (remove-text-properties (- (point) (length choice)) (point)
-                          '(mouse-face nil))
-  ;; Update point in the window that BUFFER is showing in.
-  (let ((window (get-buffer-window buffer t)))
-    (set-window-point window (point))))
+          (message "Ref: %s" (funcall bibtex-summary-function key))))))
+
+(defun bibtex-copy-summary-as-kill (key)
+  "Push summery of BibTeX entry KEY to kill ring.
+Use `bibtex-summary-function' to generate summary."
+  (interactive
+   (list (bibtex-read-key
+          "Key: " (save-excursion
+                    (bibtex-beginning-of-entry)
+                    (when (re-search-forward bibtex-entry-head nil t)
+                      (bibtex-key-in-head))))))
+  (kill-new (message "%s" (funcall bibtex-summary-function key))))
+
+(defun bibtex-summary (key)
+  "Return summary of BibTeX entry KEY.
+Used as default value of `bibtex-summary-function'."
+  ;; It would be neat to customize this function.  How?
+  (save-excursion
+    (if (bibtex-find-entry key)
+        (let* ((bibtex-autokey-name-case-convert 'identity)
+               (bibtex-autokey-name-length 'infty)
+               (bibtex-autokey-names 1)
+               (bibtex-autokey-names-stretch 0)
+               (bibtex-autokey-name-separator " ")
+               (bibtex-autokey-additional-names " etal")
+               (names (bibtex-autokey-get-names))
+               (bibtex-autokey-year-length 4)
+               (year (bibtex-autokey-get-year))
+               (bibtex-autokey-titlewords 5)
+               (bibtex-autokey-titlewords-stretch 2)
+               (bibtex-autokey-titleword-case-convert 'identity)
+               (bibtex-autokey-titleword-length 5)
+               (bibtex-autokey-titleword-separator " ")
+               (title (bibtex-autokey-get-title))
+               (journal (bibtex-autokey-get-field
+                         "journal" bibtex-autokey-transcriptions))
+               (volume (bibtex-autokey-get-field "volume"))
+               (pages (bibtex-autokey-get-field "pages" '(("-.*\\'" . "")))))
+          (mapconcat (lambda (arg)
+                       (if (not (string= "" (cdr arg)))
+                           (concat (car arg) (cdr arg))))
+                     `((" " . ,names) (" " . ,year) (": " . ,title)
+                       (", " . ,journal) (" " . ,volume) (":" . ,pages))
+                     ""))
+      (error "Key `%s' not found." key))))
 
 (defun bibtex-pop (arg direction)
   "Fill current field from the ARG'th same field's text in DIRECTION.
@@ -2550,7 +2603,7 @@
         (if failure
             (error "No %s matching BibTeX field"
                    (if (eq direction 'previous) "previous" "next"))
-          ;; Found a matching field. Remember boundaries.
+          ;; Found a matching field.  Remember boundaries.
           (setq bibtex-pop-previous-search-point (bibtex-start-of-field bounds)
                 bibtex-pop-next-search-point (bibtex-end-of-field bounds)
                 new-text (bibtex-text-in-field-bounds bounds))
@@ -2563,10 +2616,82 @@
     (bibtex-find-text nil))
   (setq this-command 'bibtex-pop))
 
-(defsubst bibtex-read-key (prompt &optional key)
-  "Read BibTeX key from minibuffer using PROMPT and default KEY."
-  (completing-read prompt bibtex-reference-keys
-                   nil nil key 'bibtex-key-history))
+(defun bibtex-beginning-of-field ()
+  "Move point backward to beginning of field.
+This function uses a simple, fast algorithm assuming that the field
+begins at the beginning of a line.  We use this function for font-locking."
+  (let ((field-reg (concat "^[ \t]*" bibtex-field-name "[ \t]*=")))
+    (beginning-of-line)
+    (unless (looking-at field-reg)
+      (re-search-backward field-reg nil t))))
+
+(defun bibtex-font-lock-url (bound)
+  "Font-lock for URLs."
+  (let ((case-fold-search t)
+        (pnt (point))
+        field bounds start end found)
+    (bibtex-beginning-of-field)
+    (while (and (not found)
+		(prog1 (re-search-forward bibtex-font-lock-url-regexp bound t)
+		  (setq field (match-string-no-properties 1)))
+		(setq bounds (bibtex-parse-field-text))
+                (progn
+                  (setq start (car bounds) end (cdr bounds))
+                  ;; Always ignore field delimiters
+                  (if (memq (char-before end) '(?\} ?\"))
+                      (setq end (1- end)))
+                  (if (memq (char-after start) '(?\{ ?\"))
+                      (setq start (1+ start)))
+                  (>= bound start)))
+      (let ((lst bibtex-generate-url-list) url)
+        (goto-char start)
+	(while (and (not found)
+		    (setq url (caar lst)))
+	  (setq found (and (bibtex-string= field (car url))
+                           (re-search-forward (cdr url) end t)
+                           (>= (match-beginning 0) pnt))
+                lst (cdr lst))))
+      (goto-char end))
+    (if found (bibtex-button (match-beginning 0) (match-end 0)
+                             'bibtex-url (match-beginning 0)))
+    found))
+
+(defun bibtex-font-lock-crossref (bound)
+  "Font-lock for crossref fields."
+  (let ((case-fold-search t)
+        (pnt (point))
+        (crossref-reg (concat "^[ \t]*crossref[ \t]*=[ \t\n]*"
+                              "\\(\"[^\"]*\"\\|{[^}]*}\\)[ \t\n]*[,})]"))
+	start end found)
+    (bibtex-beginning-of-field)
+    (while (and (not found)
+		(re-search-forward crossref-reg bound t))
+      (setq start (1+ (match-beginning 1))
+            end (1- (match-end 1))
+            found (>= start pnt)))
+    (if found (bibtex-button start end 'bibtex-find-crossref
+                             (buffer-substring-no-properties start end)
+                             start t))
+    found))
+
+(defun bibtex-button-action (button)
+  "Call BUTTON's BibTeX function."
+  (apply (button-get button 'bibtex-function)
+         (button-get button 'bibtex-args)))
+
+(define-button-type 'bibtex-url
+  'action 'bibtex-button-action
+  'bibtex-function 'bibtex-url
+  'help-echo (purecopy "mouse-2, RET: follow URL"))
+
+(define-button-type 'bibtex-find-crossref
+  'action 'bibtex-button-action
+  'bibtex-function 'bibtex-find-crossref
+  'help-echo (purecopy "mouse-2, RET: follow crossref"))
+
+(defun bibtex-button (beg end type &rest args)
+  (make-text-button beg end 'type type 'bibtex-args args))
+
 
 ;; Interactive Functions:
 
@@ -2668,7 +2793,7 @@
   (make-local-variable 'bibtex-buffer-last-parsed-tick)
   ;; Install stealthy parse function if not already installed
   (unless bibtex-parse-idle-timer
-    (setq bibtex-parse-idle-timer (bibtex-run-with-idle-timer
+    (setq bibtex-parse-idle-timer (run-with-idle-timer
                                    bibtex-parse-keys-timeout t
                                    'bibtex-parse-buffers-stealthily)))
   (set (make-local-variable 'paragraph-start) "[ \f\n\t]*$")
@@ -2680,8 +2805,8 @@
   (set (make-local-variable 'outline-regexp) "[ \t]*@")
   (set (make-local-variable 'fill-paragraph-function) 'bibtex-fill-field)
   (set (make-local-variable 'fill-prefix) (make-string (+ bibtex-entry-offset
-                                                         bibtex-contline-indentation)
-                                                      ? ))
+                                                          bibtex-contline-indentation)
+                                                       ? ))
   (set (make-local-variable 'font-lock-defaults)
        '(bibtex-font-lock-keywords
          nil t ((?$ . "\"")
@@ -2693,7 +2818,7 @@
                 )
          nil
          (font-lock-syntactic-keywords . bibtex-font-lock-syntactic-keywords)
-         (font-lock-extra-managed-props . (mouse-face keymap))
+         (font-lock-extra-managed-props . (category))
 	 (font-lock-mark-block-function
 	  . (lambda ()
               (set-mark (bibtex-end-of-entry))
@@ -2776,8 +2901,7 @@
     ;; bibtex-parse-entry moves point to the end of the last field.
     (let* ((fields-alist (bibtex-parse-entry))
            (field-list (bibtex-field-list
-                        (substring (cdr (assoc "=type=" fields-alist))
-                                   1)))) ; don't want @
+                        (cdr (assoc "=type=" fields-alist)))))
       (dolist (field (car field-list))
         (unless (assoc-string (car field) fields-alist t)
           (bibtex-make-field field)))
@@ -2793,8 +2917,8 @@
 Move point to the end of the last field."
   (let (alist bounds)
     (when (looking-at bibtex-entry-maybe-empty-head)
-      (push (cons "=type=" (match-string bibtex-type-in-head)) alist)
-      (push (cons "=key=" (match-string bibtex-key-in-head)) alist)
+      (push (cons "=type=" (bibtex-type-in-head)) alist)
+      (push (cons "=key=" (bibtex-key-in-head)) alist)
       (goto-char (match-end 0))
       (while (setq bounds (bibtex-parse-field bibtex-field-name))
 	(push (cons (bibtex-name-in-field bounds t)
@@ -2809,8 +2933,8 @@
   (undo-boundary)	;So you can easily undo it, if it didn't work right.
   (bibtex-beginning-of-entry)
   (when (looking-at bibtex-entry-head)
-    (let ((type (match-string bibtex-type-in-head))
-	  (key (match-string bibtex-key-in-head))
+    (let ((type (bibtex-type-in-head))
+	  (key (bibtex-key-in-head))
 	  (key-end (match-end bibtex-key-in-head))
           (case-fold-search t)
 	  tmp other-key other bounds)
@@ -2823,9 +2947,9 @@
 	(bibtex-beginning-of-entry)
 	(when (and
 	       (looking-at bibtex-entry-head)
-	       (bibtex-string= type (match-string bibtex-type-in-head))
+	       (bibtex-string= type (bibtex-type-in-head))
 	       ;; In case we found ourselves :-(
-	       (not (equal key (setq tmp (match-string bibtex-key-in-head)))))
+	       (not (equal key (setq tmp (bibtex-key-in-head)))))
 	  (setq other-key tmp)
 	  (setq other (point))))
       (save-excursion
@@ -2833,9 +2957,9 @@
 	(bibtex-skip-to-valid-entry)
 	(when (and
 	       (looking-at bibtex-entry-head)
-	       (bibtex-string= type (match-string bibtex-type-in-head))
+	       (bibtex-string= type (bibtex-type-in-head))
 	       ;; In case we found ourselves :-(
-	       (not (equal key (setq tmp (match-string bibtex-key-in-head))))
+	       (not (equal key (setq tmp (bibtex-key-in-head))))
 	       (or (not other-key)
 		   ;; Check which is the best match.
 		   (< (length (try-completion "" (list key other-key)))
@@ -2883,24 +3007,26 @@
           (message (nth 1 comment))
         (message "No comment available")))))
 
-(defun bibtex-make-field (field &optional called-by-yank)
+(defun bibtex-make-field (field &optional called-by-yank interactive)
   "Make a field named FIELD in current BibTeX entry.
 FIELD is either a string or a list of the form
 \(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG) as in
 `bibtex-entry-field-alist'.
-If CALLED-BY-YANK is non-nil, don't insert delimiters."
+If CALLED-BY-YANK is non-nil, don't insert delimiters.
+In that case, or when called interactively, also don't do (WHAT?)."
   (interactive
    (list (let ((completion-ignore-case t)
                (field-list (bibtex-field-list
-                             (save-excursion
-                               (bibtex-enclosing-entry-maybe-empty-head)
-                               (bibtex-type-in-head)))))
+                            (save-excursion
+                              (bibtex-enclosing-entry-maybe-empty-head)
+                              (bibtex-type-in-head)))))
            (completing-read "BibTeX field name: "
                             (append (car field-list) (cdr field-list))
-                            nil nil nil bibtex-field-history))))
+                            nil nil nil bibtex-field-history))
+	 t))
   (unless (consp field)
     (setq field (list field)))
-  (if (or (interactive-p) called-by-yank)
+  (if (or interactive called-by-yank)
       (let (bibtex-help-message)
         (bibtex-find-text nil t t)
         (if (looking-at "[}\"]")
@@ -2923,7 +3049,7 @@
           ((fboundp init)
            (insert (funcall init)))))
   (unless called-by-yank (insert (bibtex-field-right-delimiter)))
-  (when (interactive-p)
+  (when interactive
     (forward-char -1)
     (bibtex-print-help-message)))
 
@@ -3003,17 +3129,13 @@
          (not count-string-entries)))
     (save-excursion
       (save-restriction
-        (narrow-to-region (if (bibtex-mark-active)
-                              (region-beginning)
+        (narrow-to-region (if mark-active (region-beginning)
                             (bibtex-beginning-of-first-entry))
-                          (if (bibtex-mark-active)
-                              (region-end)
-                            (point-max)))
-        (goto-char (point-min))
+                          (if mark-active (region-end) (point-max)))
         (bibtex-map-entries (lambda (key beg end)
                               (setq number (1+ number))))))
     (message "%s contains %d entries."
-             (if (bibtex-mark-active) "Region" "Buffer")
+             (if mark-active "Region" "Buffer")
              number)))
 
 (defun bibtex-ispell-entry ()
@@ -3110,12 +3232,39 @@
                nil                         ; ENDKEY function
                'bibtex-lessp)))            ; PREDICATE
 
-(defun bibtex-find-crossref (crossref-key)
+(defun bibtex-find-entry-globally (key)
+  "Move point to the beginning of BibTeX entry named KEY in `bibtex-files'."
+  (interactive
+   (list (let (key-alist)
+           (dolist (buffer (bibtex-files-expand t))
+             (with-current-buffer buffer
+               (setq key-alist (append bibtex-reference-keys key-alist))))
+           (completing-read "Find key: " key-alist
+                            nil nil nil 'bibtex-key-history))))
+  (let ((buffer-list (bibtex-files-expand t))
+        buffer found)
+    (while (and (not found)
+                (setq buffer (pop buffer-list)))
+      (with-current-buffer buffer
+        (if (cdr (assoc-string key bibtex-reference-keys))
+            (setq found t))))
+    (if found
+        (progn
+	  (let ((same-window-buffer-names
+		 (cons (buffer-name buffer) same-window-buffer-names)))
+	    (pop-to-buffer buffer))
+	  (bibtex-find-entry key))
+      (message "Key `%s' not found" key))))
+
+(defun bibtex-find-crossref (crossref-key &optional pnt split)
   "Move point to the beginning of BibTeX entry CROSSREF-KEY.
 Return position of entry if CROSSREF-KEY is found and nil otherwise.
 If position of current entry is after CROSSREF-KEY an error is signaled.
+Optional arg PNT is the position of the referencing entry.
+If optional arg SPLIT is non-nil, split window so that both the referencing
+and the crossrefed entry are displayed.
 If called interactively, CROSSREF-KEY defaults to crossref key of current
-entry."
+entry and SPLIT is t."
   (interactive
    (let ((crossref-key
           (save-excursion
@@ -3123,11 +3272,23 @@
             (let ((bounds (bibtex-search-forward-field "crossref" t)))
               (if bounds
                   (bibtex-text-in-field-bounds bounds t))))))
-     (list (bibtex-read-key "Find crossref key: " crossref-key))))
+     (list (bibtex-read-key "Find crossref key: " crossref-key) (point) t)))
   (let ((pos (save-excursion (bibtex-find-entry crossref-key))))
-    (if (and pos (> (point) pos))
-        (error "This entry must not follow the crossrefed entry!"))
-    (goto-char pos)))
+    (unless pnt (setq pnt (point)))
+    (cond ((not pos)
+           (message "Crossref key `%s' not found" crossref-key))
+          (split
+           (goto-char pnt)
+           (select-window (split-window))
+           (goto-char pos)
+           (beginning-of-line)
+           (set-window-start (selected-window) (point))
+           (if (> pnt pos)
+               (error "The referencing entry must preceed the crossrefed entry!")))
+          ((> pnt pos)
+               (error "The referencing entry must preceed the crossrefed entry!"))
+          (t (goto-char pos)))
+    pos))
 
 (defun bibtex-find-entry (key &optional start)
   "Move point to the beginning of BibTeX entry named KEY.
@@ -3212,23 +3373,21 @@
 
 (defun bibtex-validate (&optional test-thoroughly)
   "Validate if buffer or region is syntactically correct.
-Only known entry types are checked, so you can put comments
-outside of entries.
-With optional argument TEST-THOROUGHLY non-nil it checks for absence of
-required fields and questionable month fields as well.
+Check also for duplicate keys and correct sort order provided
+`bibtex-maintain-sorted-entries' is non-nil.
+With optional argument TEST-THOROUGHLY non-nil check also for
+the absence of required fields and for questionable month fields.
 If mark is active, validate current region, if not the whole buffer.
-Returns t if test was successful, nil otherwise."
+Only check known entry types, so you can put comments outside of entries.
+Return t if test was successful, nil otherwise."
   (interactive "P")
   (let* ((case-fold-search t)
          error-list syntax-error)
     (save-excursion
       (save-restriction
-        (narrow-to-region (if (bibtex-mark-active)
-                              (region-beginning)
+        (narrow-to-region (if mark-active (region-beginning)
                             (bibtex-beginning-of-first-entry))
-                          (if (bibtex-mark-active)
-                              (region-end)
-                            (point-max)))
+                          (if mark-active (region-end) (point-max)))
 
         ;; looking if entries fit syntactical structure
         (goto-char (point-min))
@@ -3244,41 +3403,54 @@
                 (if (equal (point) pnt)
                     (forward-char)
                   (goto-char pnt)
-                  (push (list (bibtex-current-line)
+                  (push (cons (bibtex-current-line)
                               "Syntax error (check esp. commas, braces, and quotes)")
                         error-list)
                   (forward-char))))))
         (bibtex-progress-message 'done)
 
         (if error-list
+            ;; proceed only if there were no syntax errors.
             (setq syntax-error t)
-          ;; looking for correct sort order and duplicates (only if
-          ;; there were no syntax errors)
-          (if bibtex-maintain-sorted-entries
-              (let (previous current)
-                (goto-char (point-min))
-                (bibtex-progress-message "Checking correct sort order")
-                (bibtex-map-entries
-                 (lambda (key beg end)
-                   (bibtex-progress-message)
-                   (goto-char beg)
-                   (setq current (bibtex-entry-index))
-                   (cond ((or (not previous)
-                              (bibtex-lessp previous current))
-                          (setq previous current))
-                         ((string-equal (car previous) (car current))
-                          (push (list (bibtex-current-line)
-                                      "Duplicate key with previous")
-                                error-list))
-                         (t
-                          (setq previous current)
-                          (push (list (bibtex-current-line)
-                                      "Entries out of order")
-                                error-list)))))
-                (bibtex-progress-message 'done)))
+
+          ;; looking for duplicate keys and correct sort order
+          (let (previous current key-list)
+            (bibtex-progress-message "Checking for duplicate keys")
+            (bibtex-map-entries
+             (lambda (key beg end)
+               (bibtex-progress-message)
+               (goto-char beg)
+               (setq current (bibtex-entry-index))
+               (cond ((not previous))
+                     ((member key key-list)
+                      (push (cons (bibtex-current-line)
+                                  (format "Duplicate key `%s'" key))
+                            error-list))
+                     ((and bibtex-maintain-sorted-entries
+                           (not (bibtex-lessp previous current)))
+                      (push (cons (bibtex-current-line)
+                                  "Entries out of order")
+                            error-list)))
+               (push key key-list)
+               (setq previous current)))
+            (bibtex-progress-message 'done))
+
+          ;; Check for duplicate keys in `bibtex-files'.
+          (bibtex-parse-keys)
+          (dolist (buffer (bibtex-files-expand))
+            (dolist (key (with-current-buffer buffer
+                           ;; We don't want to be fooled by outdated
+                           ;; bibtex-reference-keys.
+                           (bibtex-parse-keys) bibtex-reference-keys))
+              (when (and (cdr key)
+                         (cdr (assoc-string (car key) bibtex-reference-keys)))
+                (bibtex-find-entry (car key))
+                (push (cons (bibtex-current-line)
+                            (format "Duplicate key `%s' in %s" (car key)
+                                    (abbreviate-file-name (buffer-file-name buffer))))
+                      error-list))))
 
           (when test-thoroughly
-            (goto-char (point-min))
             (bibtex-progress-message
              "Checking required fields and month fields")
             (let ((bibtex-sort-ignore-string-entries t))
@@ -3292,73 +3464,135 @@
 						    bibtex-entry-field-alist t)))
                         (req (copy-sequence (elt (elt entry-list 1) 0)))
                         (creq (copy-sequence (elt (elt entry-list 2) 0)))
-                        crossref-there bounds)
+                        crossref-there bounds alt-there field)
                    (goto-char beg)
                    (while (setq bounds (bibtex-search-forward-field
                                         bibtex-field-name end))
                      (goto-char (bibtex-start-of-text-in-field bounds))
                      (let ((field-name (bibtex-name-in-field bounds)))
                        (if (and (bibtex-string= field-name "month")
-                                (not (assoc-string (bibtex-text-in-field-bounds bounds)
-                                                   bibtex-predefined-month-strings t)))
-                           (push (list (bibtex-current-line)
+                                ;; Check only abbreviated month fields.
+                                (let ((month (bibtex-text-in-field-bounds bounds)))
+                                  (not (or (string-match "\\`[\"{].+[\"}]\\'" month)
+                                           (assoc-string
+                                            month
+                                            bibtex-predefined-month-strings t)))))
+                           (push (cons (bibtex-current-line)
                                        "Questionable month field")
                                  error-list))
-                       (setq req (delete (assoc-string field-name req t) req)
+                       (setq field (assoc-string field-name req t))
+                       (if (nth 3 field)
+                           (if alt-there (push (cons (bibtex-current-line)
+                                                     "More than one non-empty alternative")
+                                               error-list)
+                             (setq alt-there t)))
+                       (setq req (delete field req)
                              creq (delete (assoc-string field-name creq t) creq))
                        (if (bibtex-string= field-name "crossref")
                            (setq crossref-there t))))
                    (if crossref-there
                        (setq req creq))
-                   (if (or (> (length req) 1)
-                           (and (= (length req) 1)
-                                (not (elt (car req) 3))))
-                       ;; two (or more) fields missed or one field
-                       ;; missed and this isn't flagged alternative
-                       ;; (notice that this fails if there are more
-                       ;; than two alternatives in a BibTeX entry,
-                       ;; which isn't the case momentarily)
-                       (push (list (save-excursion
-                                     (bibtex-beginning-of-entry)
-                                     (bibtex-current-line))
-                                   (concat "Required field `" (caar req) "' missing"))
-                             error-list))))))
+                   (let (alt)
+                     (dolist (field req)
+                       (if (nth 3 field)
+                           (push (car field) alt)
+                         (push (cons (save-excursion (goto-char beg)
+                                                     (bibtex-current-line))
+                                     (format "Required field `%s' missing"
+                                             (car field)))
+                               error-list)))
+                     ;; The following fails if there are more than two
+                     ;; alternatives in a BibTeX entry, which isn't
+                     ;; the case momentarily.
+                     (if (cdr alt)
+                         (push (cons (save-excursion (goto-char beg)
+                                                     (bibtex-current-line))
+                                     (format "Alternative fields `%s'/`%s' missing"
+                                             (car alt) (cadr alt)))
+                               error-list)))))))
             (bibtex-progress-message 'done)))))
+
     (if error-list
-        (let ((bufnam (buffer-name))
-              (dir default-directory))
-          (setq error-list
-                (sort error-list
-                      (lambda (a b)
-                        (< (car a) (car b)))))
-          (let ((pop-up-windows t))
-            (pop-to-buffer nil t))
-          (switch-to-buffer
-           (get-buffer-create "*BibTeX validation errors*") t)
-          ;; don't use switch-to-buffer-other-window, since this
-          ;; doesn't allow the second parameter NORECORD
-          (setq default-directory dir)
-          (toggle-read-only -1)
-          (compilation-mode)
-          (delete-region (point-min) (point-max))
-          (goto-char (point-min))
-          (insert "BibTeX mode command `bibtex-validate'\n"
-                  (if syntax-error
-                      "Maybe undetected errors due to syntax errors. Correct and validate again."
-                    "")
-                  "\n")
-          (dolist (err error-list)
-            (insert bufnam ":" (number-to-string (elt err 0))
-                    ": " (elt err 1) "\n"))
-          (set-buffer-modified-p nil)
-          (toggle-read-only 1)
-          (goto-char (point-min))
-          (other-window -1)
+        (let ((file (file-name-nondirectory (buffer-file-name)))
+              (dir default-directory)
+              (err-buf "*BibTeX validation errors*"))
+          (setq error-list (sort error-list 'car-less-than-car))
+          (with-current-buffer (get-buffer-create err-buf)
+            (setq default-directory dir)
+            (unless (eq major-mode 'compilation-mode) (compilation-mode))
+            (toggle-read-only -1)
+            (delete-region (point-min) (point-max))
+            (insert "BibTeX mode command `bibtex-validate'\n"
+                    (if syntax-error
+                        "Maybe undetected errors due to syntax errors. Correct and validate again.\n"
+                      "\n"))
+            (dolist (err error-list)
+              (insert (format "%s:%d: %s\n" file (car err) (cdr err))))
+            (set-buffer-modified-p nil)
+            (toggle-read-only 1)
+            (goto-line 3)) ; first error message
+          (display-buffer err-buf)
           ;; return nil
           nil)
-      (if (bibtex-mark-active)
-          (message "Region is syntactically correct")
-        (message "Buffer is syntactically correct"))
+      (message "%s is syntactically correct"
+               (if mark-active "Region" "Buffer"))
+      t)))
+
+(defun bibtex-validate-globally (&optional strings)
+  "Check for duplicate keys in `bibtex-files'.
+With prefix arg STRINGS, check for duplicate strings, too.
+Return t if test was successful, nil otherwise."
+  (interactive "P")
+  (let ((buffer-list (bibtex-files-expand t))
+        buffer-key-list current-buf current-keys error-list)
+    ;; Check for duplicate keys within BibTeX buffer
+    (dolist (buffer buffer-list)
+      (save-excursion
+        (set-buffer buffer)
+        (let (entry-type key key-list)
+          (goto-char (point-min))
+          (while (re-search-forward bibtex-entry-head nil t)
+            (setq entry-type (bibtex-type-in-head)
+                  key (bibtex-key-in-head))
+            (if (or (and strings (bibtex-string= entry-type "string"))
+                    (assoc-string entry-type bibtex-entry-field-alist t))
+                (if (member key key-list)
+                    (push (format "%s:%d: Duplicate key `%s'\n"
+                                  (buffer-file-name)
+                                  (bibtex-current-line) key)
+                          error-list)
+                  (push key key-list))))
+          (push (cons buffer key-list) buffer-key-list))))
+
+    ;; Check for duplicate keys among BibTeX buffers
+    (while (setq current-buf (pop buffer-list))
+      (setq current-keys (cdr (assq current-buf buffer-key-list)))
+      (with-current-buffer current-buf
+        (dolist (buffer buffer-list)
+          (dolist (key (cdr (assq buffer buffer-key-list)))
+            (when (assoc-string key current-keys)
+              (bibtex-find-entry key)
+              (push (format "%s:%d: Duplicat key `%s' in %s\n"
+                            (buffer-file-name) (bibtex-current-line) key
+                            (abbreviate-file-name (buffer-file-name buffer)))
+                    error-list))))))
+
+    ;; Process error list
+    (if error-list
+        (let ((err-buf "*BibTeX validation errors*"))
+          (with-current-buffer (get-buffer-create err-buf)
+            (unless (eq major-mode 'compilation-mode) (compilation-mode))
+            (toggle-read-only -1)
+            (delete-region (point-min) (point-max))
+            (insert "BibTeX mode command `bibtex-validate-globally'\n\n")
+            (dolist (err (sort error-list 'string-lessp)) (insert err))
+            (set-buffer-modified-p nil)
+            (toggle-read-only 1)
+            (goto-line 3)) ; first error message
+          (display-buffer err-buf)
+          ;; return nil
+          nil)
+      (message "No duplicate keys.")
       t)))
 
 (defun bibtex-next-field (arg)
@@ -3378,10 +3612,9 @@
 
 (defun bibtex-find-text (arg &optional as-if-interactive no-error)
   "Go to end of text of current field; with ARG, go to beginning."
-  (interactive "P")
+  (interactive "P\np")
   (bibtex-inside-field)
-  (let ((bounds (bibtex-enclosing-field (or (interactive-p)
-                                            as-if-interactive))))
+  (let ((bounds (bibtex-enclosing-field as-if-interactive)))
     (if bounds
         (progn (if arg
                    (progn (goto-char (bibtex-start-of-text-in-field bounds))
@@ -3404,7 +3637,7 @@
                           (match-end 0))))
             (t
              (unless no-error
-                 (error "Not on BibTeX field")))))))
+               (error "Not on BibTeX field")))))))
 
 (defun bibtex-remove-OPT-or-ALT ()
   "Remove the string starting optional/alternative fields.
@@ -3470,6 +3703,7 @@
   (setq bibtex-last-kill-command 'field))
 
 (defun bibtex-copy-field-as-kill ()
+  "Copy the field at point to the kill ring."
   (interactive)
   (bibtex-kill-field t))
 
@@ -3492,9 +3726,9 @@
           (setcdr (nthcdr (1- bibtex-entry-kill-ring-max)
                           bibtex-entry-kill-ring)
                   nil))
-    (setq bibtex-entry-kill-ring-yank-pointer bibtex-entry-kill-ring)
-    (unless copy-only
-      (delete-region beg end))))
+      (setq bibtex-entry-kill-ring-yank-pointer bibtex-entry-kill-ring)
+      (unless copy-only
+        (delete-region beg end))))
   (setq bibtex-last-kill-command 'entry))
 
 (defun bibtex-copy-entry-as-kill ()
@@ -3584,7 +3818,7 @@
            ;; (bibtex-format-preamble)
            (error "No clean up of @Preamble entries"))
           ((bibtex-string= entry-type "string"))
-           ;; (bibtex-format-string)
+          ;; (bibtex-format-string)
           (t (bibtex-format-entry)))
     ;; set key
     (when (or new-key (not key))
@@ -3597,7 +3831,7 @@
           (delete-region (match-beginning bibtex-key-in-head)
                          (match-end bibtex-key-in-head)))
       (insert key))
-    ;; sorting
+
     (unless called-by-reformat
       (let* ((start (bibtex-beginning-of-entry))
              (end (progn (bibtex-end-of-entry)
@@ -3606,9 +3840,12 @@
                              (goto-char (match-beginning 0)))
                          (point)))
              (entry (buffer-substring start end))
-             (index (progn (goto-char start)
-                           (bibtex-entry-index)))
+             ;; include the crossref key in index
+             (index (let ((bibtex-maintain-sorted-entries 'crossref))
+                      (goto-char start)
+                      (bibtex-entry-index)))
              error)
+        ;; sorting
         (if (and bibtex-maintain-sorted-entries
                  (not (and bibtex-sort-ignore-string-entries
                            (bibtex-string= entry-type "string"))))
@@ -3623,17 +3860,37 @@
           (setq error (or (/= (point) start)
                           (bibtex-find-entry key end))))
         (if error
-          (error "New inserted entry yields duplicate key"))))
-    ;; final clean up
-    (unless called-by-reformat
-      (save-excursion
-        (save-restriction
-          (bibtex-narrow-to-entry)
-          ;; Only update the list of keys if it has been built already.
-          (cond ((bibtex-string= entry-type "string")
-                 (if (listp bibtex-strings) (bibtex-parse-strings t)))
-                ((listp bibtex-reference-keys) (bibtex-parse-keys t)))
-          (run-hooks 'bibtex-clean-entry-hook))))))
+            (error "New inserted entry yields duplicate key"))
+        (dolist (buffer (bibtex-files-expand))
+          (with-current-buffer buffer
+            (if (cdr (assoc-string key bibtex-reference-keys))
+                (error "Duplicate key in %s" (buffer-file-name)))))
+
+        ;; Only update the list of keys if it has been built already.
+        (cond ((bibtex-string= entry-type "string")
+               (if (and (listp bibtex-strings)
+                        (not (assoc key bibtex-strings)))
+                   (push (list key) bibtex-strings)))
+              ;; We have a normal entry.
+              ((listp bibtex-reference-keys)
+               (cond ((not (assoc key bibtex-reference-keys))
+                      (push (cons key t) bibtex-reference-keys))
+                     ((not (cdr (assoc key bibtex-reference-keys)))
+                      ;; Turn a crossref key into a header key
+                      (setq bibtex-reference-keys
+                            (cons (cons key t)
+                                  (delete (list key) bibtex-reference-keys)))))
+               ;; Handle crossref key.
+               (if (and (nth 1 index)
+                        (not (assoc (nth 1 index) bibtex-reference-keys)))
+                   (push (list (nth 1 index)) bibtex-reference-keys)))))
+
+      ;; final clean up
+      (if bibtex-clean-entry-hook
+          (save-excursion
+            (save-restriction
+              (bibtex-narrow-to-entry)
+              (run-hooks 'bibtex-clean-entry-hook)))))))
 
 (defun bibtex-fill-field-bounds (bounds justify &optional move)
   "Fill BibTeX field delimited by BOUNDS.
@@ -3705,13 +3962,24 @@
   "Realign BibTeX entries such that they are separated by one blank line."
   (goto-char (point-min))
   (let ((case-fold-search t))
+    ;; No blank lines prior to the first valid entry if there no
+    ;; non-white characters in front of it.
     (when (looking-at bibtex-valid-entry-whitespace-re)
       (replace-match "\\1"))
+    ;; Valid entries are separated by one blank line.
     (while (re-search-forward bibtex-valid-entry-whitespace-re nil t)
-      (replace-match "\n\n\\1"))))
+      (replace-match "\n\n\\1"))
+    ;; One blank line past the last valid entry if it is followed by
+    ;; non-white characters, no blank line otherwise.
+    (beginning-of-line)
+    (when (re-search-forward bibtex-valid-entry-re nil t)
+      (bibtex-end-of-entry)
+      (bibtex-delete-whitespace)
+      (open-line (if (eobp) 1 2)))))
 
 (defun bibtex-reformat (&optional read-options)
   "Reformat all BibTeX entries in buffer or region.
+Without prefix argument, reformatting is based on `bibtex-entry-format'.
 With prefix argument, read options for reformatting from minibuffer.
 With \\[universal-argument] \\[universal-argument] prefix argument, reuse previous answers (if any) again.
 If mark is active reformat entries in region, if not in whole buffer."
@@ -3722,55 +3990,54 @@
                (or bibtex-reformat-previous-options
                    bibtex-reformat-previous-reference-keys)))
          (bibtex-entry-format
-          (if read-options
-              (if use-previous-options
-                  bibtex-reformat-previous-options
-                (setq bibtex-reformat-previous-options
-                      (mapcar (lambda (option)
-                                (if (y-or-n-p (car option)) (cdr option)))
-                              `(("Realign entries (recommended)? " . 'realign)
-                                ("Remove empty optional and alternative fields? " . 'opts-or-alts)
-                                ("Remove delimiters around pure numerical fields? " . 'numerical-fields)
-                                (,(concat (if bibtex-comma-after-last-field "Insert" "Remove")
-                                         " comma at end of entry? ") . 'last-comma)
-                                ("Replace double page dashes by single ones? " . 'page-dashes)
-                                ("Force delimiters? " . 'delimiters)
-                                ("Unify case of entry types and field names? " . 'unify-case)))))
-            '(realign)))
+          (cond (read-options
+                 (if use-previous-options
+                     bibtex-reformat-previous-options
+                   (setq bibtex-reformat-previous-options
+                         (mapcar (lambda (option)
+                                   (if (y-or-n-p (car option)) (cdr option)))
+                                 `(("Realign entries (recommended)? " . 'realign)
+                                   ("Remove empty optional and alternative fields? " . 'opts-or-alts)
+                                   ("Remove delimiters around pure numerical fields? " . 'numerical-fields)
+                                   (,(concat (if bibtex-comma-after-last-field "Insert" "Remove")
+                                             " comma at end of entry? ") . 'last-comma)
+                                   ("Replace double page dashes by single ones? " . 'page-dashes)
+                                   ("Inherit booktitle? " . 'inherit-booktitle)
+                                   ("Force delimiters? " . 'delimiters)
+                                   ("Unify case of entry types and field names? " . 'unify-case))))))
+                ;; Do not include required-fields because `bibtex-reformat'
+                ;; cannot handle the error messages of `bibtex-format-entry'.
+                ;; Use `bibtex-validate' to check for required fields.
+                ((eq t bibtex-entry-format)
+                 '(realign opts-or-alts numerical-fields delimiters
+                           last-comma page-dashes unify-case inherit-booktitle))
+                (t
+                 (remove 'required-fields (push 'realign bibtex-entry-format)))))
          (reformat-reference-keys
           (if read-options
               (if use-previous-options
                   bibtex-reformat-previous-reference-keys
                 (setq bibtex-reformat-previous-reference-keys
                       (y-or-n-p "Generate new reference keys automatically? ")))))
-         (start-point (if (bibtex-mark-active)
-                          (region-beginning)
-                        (point-min)))
-         (end-point (if (bibtex-mark-active)
-                        (region-end)
-                      (point-max)))
          (bibtex-sort-ignore-string-entries t)
          bibtex-autokey-edit-before-use)
 
     (save-restriction
-      (narrow-to-region start-point end-point)
+      (narrow-to-region (if mark-active (region-beginning) (point-min))
+                        (if mark-active (region-end) (point-max)))
       (if (memq 'realign bibtex-entry-format)
-        (bibtex-realign))
-      (goto-char start-point)
+          (bibtex-realign))
       (bibtex-progress-message "Formatting" 1)
       (bibtex-map-entries (lambda (key beg end)
                             (bibtex-progress-message)
                             (bibtex-clean-entry reformat-reference-keys t)))
-      (when (memq 'realign bibtex-entry-format)
-        (bibtex-delete-whitespace)
-        (open-line (if (eobp) 1 2)))
       (bibtex-progress-message 'done))
-    (when (and reformat-reference-keys
-               bibtex-maintain-sorted-entries)
-      (bibtex-progress-message "Sorting" 1)
-      (bibtex-sort-buffer)
+    (when reformat-reference-keys
       (kill-local-variable 'bibtex-reference-keys)
-      (bibtex-progress-message 'done))
+      (when bibtex-maintain-sorted-entries
+        (bibtex-progress-message "Sorting" 1)
+        (bibtex-sort-buffer)
+        (bibtex-progress-message 'done)))
     (goto-char pnt)))
 
 (defun bibtex-convert-alien (&optional read-options)
@@ -3837,21 +4104,23 @@
            ;; key completion
            (setq choose-completion-string-functions
                  (lambda (choice buffer mini-p base-size)
-                    (bibtex-choose-completion-string choice buffer mini-p base-size)
+                   (let ((choose-completion-string-functions nil))
+                     (choose-completion-string choice buffer base-size))
                    (bibtex-complete-key-cleanup choice)
                    ;; return t (required by choose-completion-string-functions)
                    t))
-           (bibtex-complete-key-cleanup (bibtex-complete-internal 
+           (bibtex-complete-key-cleanup (bibtex-complete-internal
                                          bibtex-reference-keys)))
 
           (compl
            ;; string completion
            (setq choose-completion-string-functions
                  `(lambda (choice buffer mini-p base-size)
-                   (bibtex-choose-completion-string choice buffer mini-p base-size)
-                   (bibtex-complete-string-cleanup choice ',compl)
-                   ;; return t (required by choose-completion-string-functions)
-                   t))
+                    (let ((choose-completion-string-functions nil))
+                      (choose-completion-string choice buffer base-size))
+                    (bibtex-complete-string-cleanup choice ',compl)
+                    ;; return t (required by choose-completion-string-functions)
+                    t))
            (bibtex-complete-string-cleanup (bibtex-complete-internal compl)
                                            compl))
 
@@ -3960,80 +4229,56 @@
             "\n")
     (goto-char endpos)))
 
-(defun bibtex-url (&optional event)
-  "Browse a URL for the BibTeX entry at position PNT.
+(defun bibtex-url (&optional pos)
+  "Browse a URL for the BibTeX entry at point.
+Optional POS is the location of the BibTeX entry.
 The URL is generated using the schemes defined in `bibtex-generate-url-list'
 \(see there\).  Then the URL is passed to `browse-url'."
-  (interactive (list last-input-event))
+  (interactive)
   (save-excursion
-    (if event (posn-set-point (event-end event)))
+    (if pos (goto-char pos))
     (bibtex-beginning-of-entry)
     (let ((fields-alist (bibtex-parse-entry))
+          ;; Always ignore case,
           (case-fold-search t)
           (lst bibtex-generate-url-list)
+          (delim-regexp "\\`[{\"]\\(.*\\)[}\"]\\'")
           field url scheme)
-      (while (setq scheme (car lst))
+      (while (setq scheme (pop lst))
         (when (and (setq field (cdr (assoc-string (caar scheme)
 						  fields-alist t)))
-		   (progn
-		     (if (string-match "\\`[{\"]\\(.*\\)[}\"]\\'" field)
-			 (setq field (match-string 1 field)))
-		     (string-match (cdar scheme) field)))
-	  (setq lst nil)
+                   ;; Always remove field delimiters
+                   (progn (if (string-match delim-regexp field)
+                              (setq field (match-string 1 field)))
+                          (string-match (cdar scheme) field)))
+          (setq lst nil)
 	  (if (null (cdr scheme))
 	      (setq url (match-string 0 field)))
           (dolist (step (cdr scheme))
-	    (cond ((stringp step)
-		   (setq url (concat url step)))
-		  ((setq field (assoc-string (car step) fields-alist t))
-		   ;; always remove field delimiters
-		   (let* ((text (if (string-match "\\`[{\"]\\(.*\\)[}\"]\\'" 
-						  (cdr field))
-				    (match-string 1 (cdr field))
-				  (cdr field)))
-			  (str (if (string-match (nth 1 step) text)
-				   (cond
-				    ((functionp (nth 2 step))
-				     (funcall (nth 2 step) text))
-				    ((numberp (nth 2 step))
-				     (match-string (nth 2 step) text))
-				    (t
-				     (replace-match (nth 2 step) nil nil text)))
-				 ;; If the scheme is set up correctly,
-				 ;; we should never reach this point
-				 (error "Match failed: %s" text))))
-                     (setq url (concat url str))))
-		  ;; If the scheme is set up correctly,
-		  ;; we should never reach this point
-		  (t (error "Step failed: %s" step))))
-	  (message "%s" url)
-          (browse-url url))
-        (setq lst (cdr lst)))
-    (unless url (message "No URL known.")))))
-
-(defun bibtex-font-lock-url (bound)
-  "Font-lock for URLs."
-  (let ((case-fold-search t)
-        (bounds (bibtex-enclosing-field t))
-        (pnt (point))
-	found field)
-    ;; We use start-of-field as syntax-begin
-    (goto-char (if bounds (bibtex-start-of-field bounds) pnt))
-    (while (and (not found)
-		(prog1 (re-search-forward bibtex-font-lock-url-regexp bound t)
-		  (setq field (match-string-no-properties 1)))
-		(setq bounds (bibtex-parse-field-text))
-		(>= bound (car bounds))
-		(>= (car bounds) pnt))
-      (let ((lst bibtex-generate-url-list) url)
-	(goto-char (car bounds))
-	(while (and (not found)
-		    (setq url (caar lst)))
-	  (when (bibtex-string= field (car url))
-	    (setq found (re-search-forward (cdr url) (cdr bounds) t)))
-	  (setq lst (cdr lst))))
-      (goto-char (cdr bounds)))
-    found))
+            (cond ((stringp step)
+                   (setq url (concat url step)))
+                  ((setq field (cdr (assoc-string (car step) fields-alist t)))
+                   ;; Always remove field delimiters
+                   (if (string-match delim-regexp field)
+                       (setq field (match-string 1 field)))
+                   (if (string-match (nth 1 step) field)
+                       (setq field (cond
+                                    ((functionp (nth 2 step))
+                                     (funcall (nth 2 step) field))
+                                    ((numberp (nth 2 step))
+                                     (match-string (nth 2 step) field))
+                                    (t
+                                     (replace-match (nth 2 step) nil nil field))))
+                     ;; If the scheme is set up correctly,
+                     ;; we should never reach this point
+                     (error "Match failed: %s" field))
+                   (setq url (concat url field)))
+                  ;; If the scheme is set up correctly,
+                  ;; we should never reach this point
+                  (t (error "Step failed: %s" step))))
+          (message "%s" url)
+          (browse-url url)))
+      (unless url (message "No URL known.")))))
 
 
 ;; Make BibTeX a Feature
--- a/lisp/textmodes/flyspell.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/textmodes/flyspell.el	Sat Nov 06 17:52:02 2004 +0000
@@ -956,9 +956,7 @@
 ;*---------------------------------------------------------------------*/
 (defun flyspell-word (&optional following)
   "Spell check a word."
-  (interactive (list current-prefix-arg))
-  (if (interactive-p)
-      (setq following ispell-following-word))
+  (interactive (list ispell-following-word))
   (save-excursion
     ;; use the correct dictionary
     (flyspell-accept-buffer-local-defs)
--- a/lisp/textmodes/ispell.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/textmodes/ispell.el	Sat Nov 06 17:52:02 2004 +0000
@@ -1410,12 +1410,9 @@
 \(\"word\" arg\)  word is hand entered.
 quit          spell session exited."
 
-  (interactive (list nil nil current-prefix-arg))
+  (interactive (list ispell-following-word ispell-quietly current-prefix-arg))
   (if continue
       (ispell-continue)
-    (if (interactive-p)
-	(setq following ispell-following-word
-	      quietly ispell-quietly))
     (ispell-accept-buffer-local-defs)	; use the correct dictionary
     (let ((cursor-location (point))	; retain cursor location
 	  (word (ispell-get-word following))
--- a/lisp/textmodes/table.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/textmodes/table.el	Sat Nov 06 17:52:02 2004 +0000
@@ -645,7 +645,8 @@
   :group 'editing
   :group 'wp
   :group 'paragraphs
-  :group 'fill)
+  :group 'fill
+  :version "21.4")
 
 (defgroup table-hooks nil
   "Hooks for table manipulation utilities"
--- a/lisp/textmodes/texinfo.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/textmodes/texinfo.el	Sat Nov 06 17:52:02 2004 +0000
@@ -1,7 +1,7 @@
 ;;; texinfo.el --- major mode for editing Texinfo files
 
-;; Copyright (C) 1985,88,89,90,91,92,93,96,97,2000,01,03,04
-;;           Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1988, 1989, 1990, 1991, 1992, 1993, 1996, 1997,
+;;           2000, 2001, 2003, 2004 Free Software Foundation, Inc.
 
 ;; Author: Robert J. Chassell
 ;; Date:   [See date below for texinfo-version]
--- a/lisp/thumbs.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/thumbs.el	Sat Nov 06 17:52:02 2004 +0000
@@ -30,8 +30,8 @@
 ;;; Commentary:
 
 ;; This package create two new mode: thumbs-mode and
-;; thumbs-view-image-mode. It is used for images browsing and viewing
-;; from within emacs. Minimal image manipulation functions are also
+;; thumbs-view-image-mode.  It is used for images browsing and viewing
+;; from within Emacs.  Minimal image manipulation functions are also
 ;; available via external programs.
 ;;
 ;; The 'convert' program from 'ImageMagick'
@@ -62,6 +62,7 @@
 
 (defgroup thumbs nil
   "Thumbnails previewer."
+  :version "21.4"
   :group 'multimedia)
 
 (defcustom thumbs-thumbsdir
@@ -416,7 +417,7 @@
 (defalias 'thumbs 'thumbs-show-all-from-dir)
 
 (defun thumbs-find-image (img &optional num otherwin)
-  (funcall 
+  (funcall
    (if otherwin 'switch-to-buffer-other-window 'switch-to-buffer)
    (concat "*Image: " (file-name-nondirectory img) " - "
 	   (number-to-string (or num 0)) "*"))
Binary file lisp/toolbar/diropen.pbm has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/toolbar/diropen.xpm	Sat Nov 06 17:52:02 2004 +0000
@@ -0,0 +1,215 @@
+/* XPM */
+static char * diropen_xpm[] = {
+"24 24 188 2",
+"  	c None",
+". 	c #000000",
+"+ 	c #010100",
+"@ 	c #B5B8A5",
+"# 	c #E4E7D2",
+"$ 	c #878A76",
+"% 	c #33342B",
+"& 	c #0B0B0B",
+"* 	c #E2E5CF",
+"= 	c #CFD4AF",
+"- 	c #CED3AE",
+"; 	c #B2B696",
+"> 	c #2D2D25",
+", 	c #23241D",
+"' 	c #9D9F90",
+") 	c #C6CAA6",
+"! 	c #C4C9A5",
+"~ 	c #C6CBA7",
+"{ 	c #C7CCA8",
+"] 	c #C9CEA9",
+"^ 	c #555847",
+"/ 	c #1A1B15",
+"( 	c #20201A",
+"_ 	c #D4D6C2",
+": 	c #BEC2A0",
+"< 	c #B3B896",
+"[ 	c #B0B595",
+"} 	c #B3B797",
+"| 	c #B6BB99",
+"1 	c #BBC09E",
+"2 	c #BCC19F",
+"3 	c #81856C",
+"4 	c #3E3F32",
+"5 	c #010101",
+"6 	c #DADDC8",
+"7 	c #AFB494",
+"8 	c #AAAF8F",
+"9 	c #A3A789",
+"0 	c #A6AA8B",
+"a 	c #A9AD8E",
+"b 	c #A7AB8D",
+"c 	c #A4A88A",
+"d 	c #A1A588",
+"e 	c #AAAD96",
+"f 	c #B3B5A5",
+"g 	c #B8BBAA",
+"h 	c #BABCAB",
+"i 	c #40413B",
+"j 	c #CACDBB",
+"k 	c #BABDA8",
+"l 	c #0C0C09",
+"m 	c #DDDFCB",
+"n 	c #969B7E",
+"o 	c #9DA286",
+"p 	c #95987C",
+"q 	c #96997E",
+"r 	c #9A9D81",
+"s 	c #999D80",
+"t 	c #9DA184",
+"u 	c #A5AA8B",
+"v 	c #A4A98A",
+"w 	c #A3A889",
+"x 	c #A2A588",
+"y 	c #33352B",
+"z 	c #9B9E83",
+"A 	c #898D74",
+"B 	c #D8DBC9",
+"C 	c #84866E",
+"D 	c #7D8169",
+"E 	c #151612",
+"F 	c #D7DAC9",
+"G 	c #797D67",
+"H 	c #3D3F34",
+"I 	c #E0E0D9",
+"J 	c #EBEDDD",
+"K 	c #E8EBD9",
+"L 	c #D8DBCA",
+"M 	c #1A1A18",
+"N 	c #0A0A09",
+"O 	c #6E7067",
+"P 	c #8D8F84",
+"Q 	c #4A4B45",
+"R 	c #2C2D29",
+"S 	c #4B4C46",
+"T 	c #E7EAD8",
+"U 	c #E3E6D4",
+"V 	c #DEE1D0",
+"W 	c #DADCCC",
+"X 	c #DADCD1",
+"Y 	c #2B2C28",
+"Z 	c #D7DAC6",
+"` 	c #6F735E",
+" .	c #0D0D0D",
+"..	c #F4F4EC",
+"+.	c #606251",
+"@.	c #92957B",
+"#.	c #4A4C3E",
+"$.	c #434438",
+"%.	c #CACFAB",
+"&.	c #C6CBA8",
+"*.	c #C2C6A4",
+"=.	c #ABB091",
+"-.	c #23251E",
+";.	c #494B3D",
+">.	c #DCDCD4",
+",.	c #EAECDD",
+"'.	c #CDD2AD",
+").	c #20201B",
+"!.	c #1C1C17",
+"~.	c #A4A88B",
+"{.	c #414337",
+"].	c #BABF9D",
+"^.	c #B5B999",
+"/.	c #81836C",
+"(.	c #070806",
+"_.	c #D5D8C4",
+":.	c #161616",
+"<.	c #F2F2EA",
+"[.	c #CACFAA",
+"}.	c #050504",
+"|.	c #3C3D32",
+"1.	c #C9CEAA",
+"2.	c #C8CDA9",
+"3.	c #BFC4A2",
+"4.	c #3E4035",
+"5.	c #BCC09F",
+"6.	c #B6BB9A",
+"7.	c #B0B494",
+"8.	c #9DA185",
+"9.	c #535445",
+"0.	c #B6B8A7",
+"a.	c #747470",
+"b.	c #ECECE2",
+"c.	c #C3C8A5",
+"d.	c #C2C7A4",
+"e.	c #393B30",
+"f.	c #BFC4A1",
+"g.	c #BDC2A0",
+"h.	c #C0C5A2",
+"i.	c #3A3B31",
+"j.	c #A9AD8F",
+"k.	c #A3A78A",
+"l.	c #80836D",
+"m.	c #020201",
+"n.	c #A6A998",
+"o.	c #B8BC9B",
+"p.	c #1B1C17",
+"q.	c #181814",
+"r.	c #AFB394",
+"s.	c #ACB091",
+"t.	c #878A72",
+"u.	c #9B9F83",
+"v.	c #9A9D82",
+"w.	c #8A8D75",
+"x.	c #4F5243",
+"y.	c #070705",
+"z.	c #9E9F91",
+"A.	c #E5E6DA",
+"B.	c #ADB192",
+"C.	c #A6AA8C",
+"D.	c #A5A98C",
+"E.	c #4B4D3F",
+"F.	c #70735F",
+"G.	c #9FA286",
+"H.	c #999D81",
+"I.	c #35362D",
+"J.	c #2D2E26",
+"K.	c #8A8D74",
+"L.	c #71735F",
+"M.	c #080908",
+"N.	c #E3E5D9",
+"O.	c #C0C3AF",
+"P.	c #94987C",
+"Q.	c #8F9379",
+"R.	c #8B8F75",
+"S.	c #8A8E74",
+"T.	c #888C73",
+"U.	c #7D816A",
+"V.	c #0E0F0C",
+"W.	c #3E4034",
+"X.	c #4E5042",
+"Y.	c #282922",
+"Z.	c #121310",
+"`.	c #24251F",
+" +	c #71745F",
+".+	c #6A6D59",
+"++	c #434538",
+"@+	c #080907",
+"                                                ",
+"                                                ",
+"                                                ",
+"    . . . . . . .                               ",
+"  + @ # # # # # $ %                             ",
+"  & * = = = - - ; >                             ",
+", ' * ) ! ~ { ] ] ^ /         . .               ",
+"( _ : < [ } | 1 2 3 4 5 . . . . . . .           ",
+", 6 7 8 9 0 8 a b c d e f g h . i j k .         ",
+"l m n o p q r s q t u v w x 9 . y z A .         ",
+". B C D E . . . . . . . . . . . . . . . 5 5     ",
+". F G H I J K K L M N O P Q R . S T U V W X Y   ",
+". Z `  ...= = = +.. @.= = = #.. $.%.&.*.1 =.-.  ",
+". Z ;.>.,.'.- - ).!.'.'.'.'.~.. {.&.*.].^./.(.  ",
+". _.:.<.%.[.%.[.}.|.1.{ 2.2.3.. 4.5.6.7.8.9.l   ",
+". 0.a.b.c.d.d.*.}.e.f.g.h.g.} . i.[ j.k.l.m.    ",
+". n.>.o.o.^.} } p.q.r.r.r.s.t.. % u.v.w.x.y.    ",
+". z.A.B.j.C.D.k.E.. F.G.u.H.I.. J.K.K.L.M.      ",
+". N.O.P.Q.R.S.T.U.V.}.W.X.Y.Z.. `. +.+++@+      ",
+"  . . . . . . . . . . . . . . . . . . }.        ",
+"                                                ",
+"                                                ",
+"                                                ",
+"                                                "};
--- a/lisp/toolbar/tool-bar.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/toolbar/tool-bar.el	Sat Nov 06 17:52:02 2004 +0000
@@ -223,7 +223,8 @@
   ;; might inadvertently click that button.
   ;;(tool-bar-add-item-from-menu 'save-buffers-kill-emacs "exit")
   (tool-bar-add-item-from-menu 'find-file "new")
-  (tool-bar-add-item-from-menu 'dired "open")
+  (tool-bar-add-item-from-menu 'find-file-existing "open")
+  (tool-bar-add-item-from-menu 'dired "diropen")
   (tool-bar-add-item-from-menu 'kill-this-buffer "close")
   (tool-bar-add-item-from-menu 'save-buffer "save" nil
 			       :visible '(or buffer-file-name
--- a/lisp/url/ChangeLog	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/url/ChangeLog	Sat Nov 06 17:52:02 2004 +0000
@@ -1,3 +1,15 @@
+2004-11-02  Masatake YAMATO  <jet@gyve.org>
+
+	* url-imap.el (url-imap-open-host): Don't use
+	`string-to-int'. The port returned by `url-port'
+	is expected to be an integer.
+
+	* url-irc.el (url-irc): Ditto.
+
+	* url-news.el (url-news-open-host): Ditto.
+
+	* url-nfs.el (url-nfs-build-filename): Ditto.
+
 2004-10-20  John Paul Wallington  <jpw@gnu.org>
 
 	* url-gw.el (url-gateway-nslookup-host):
--- a/lisp/url/url-imap.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/url/url-imap.el	Sat Nov 06 17:52:02 2004 +0000
@@ -47,8 +47,6 @@
   (let ((imap-username user)
 	(imap-password pass)
 	(authenticator (if user 'login 'anonymous)))
-    (if (stringp port)
-	(setq port (string-to-int port)))
     (nnimap-open-server host
 			`((nnimap-server-port ,port)
 			  (nnimap-stream 'network)
--- a/lisp/url/url-irc.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/url/url-irc.el	Sat Nov 06 17:52:02 2004 +0000
@@ -61,7 +61,7 @@
 ;;;###autoload
 (defun url-irc (url)
   (let* ((host (url-host url))
-	 (port (string-to-int (url-port url)))
+	 (port (url-port url))
 	 (pass (url-password url))
 	 (user (url-user url))
 	 (chan (url-filename url)))
--- a/lisp/url/url-news.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/url/url-news.el	Sat Nov 06 17:52:02 2004 +0000
@@ -38,7 +38,7 @@
 (defun url-news-open-host (host port user pass)
   (if (fboundp 'nnheader-init-server-buffer)
       (nnheader-init-server-buffer))
-  (nntp-open-server host (list (string-to-int port)))
+  (nntp-open-server host (list port))
   (if (and user pass)
       (progn
 	(nntp-send-command "^.*\r?\n" "AUTHINFO USER" user)
--- a/lisp/url/url-nfs.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/url/url-nfs.el	Sat Nov 06 17:52:02 2004 +0000
@@ -62,7 +62,7 @@
 
 (defun url-nfs-build-filename (url)
   (let* ((host (url-host url))
-	 (port (string-to-int (url-port url)))
+	 (port (url-port url))
 	 (pass (url-password url))
 	 (user (url-user url))
 	 (file (url-filename url)))
--- a/lisp/vc-cvs.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/vc-cvs.el	Sat Nov 06 17:52:02 2004 +0000
@@ -89,12 +89,12 @@
 The value can also be a regular expression or list of regular
 expressions to match against the host name of a repository; then VC
 only stays local for hosts that match it.  Alternatively, the value
-can be a list of regular expressions where the first element is the 
-symbol `except'; then VC always stays local except for hosts matched 
+can be a list of regular expressions where the first element is the
+symbol `except'; then VC always stays local except for hosts matched
 by these regular expressions."
   :type '(choice (const :tag "Always stay local" t)
                 (const :tag "Don't stay local" nil)
-                 (list :format "\nExamine hostname and %v" :tag "Examine hostname ..." 
+                 (list :format "\nExamine hostname and %v" :tag "Examine hostname ..."
                        (set :format "%v" :inline t (const :format "%t" :tag "don't" except))
                        (regexp :format " stay local,\n%t: %v" :tag "if it matches")
                        (repeat :format "%v%i\n" :inline t (regexp :tag "or"))))
@@ -152,12 +152,6 @@
 ;;; Internal variables
 ;;;
 
-(defvar vc-cvs-local-month-numbers
-  '(("Jan" . 1) ("Feb" .  2) ("Mar" .  3) ("Apr" .  4)
-    ("May" . 5) ("Jun" .  6) ("Jul" .  7) ("Aug" .  8)
-    ("Sep" . 9) ("Oct" . 10) ("Nov" . 11) ("Dec" . 12))
-  "Local association list of month numbers.")
-
 
 ;;;
 ;;; State-querying functions
@@ -590,7 +584,11 @@
 (defun vc-cvs-annotate-command (file buffer &optional version)
   "Execute \"cvs annotate\" on FILE, inserting the contents in BUFFER.
 Optional arg VERSION is a version to annotate from."
-  (vc-cvs-command buffer 0 file "annotate" (if version (concat "-r" version))))
+  (vc-cvs-command buffer 0 file "annotate" (if version (concat "-r" version)))
+  (with-current-buffer buffer
+    (goto-char (point-min))
+    (re-search-forward "^[0-9]")
+    (delete-region (point-min) (1- (point)))))
 
 (defun vc-cvs-annotate-current-time ()
   "Return the current time, based at midnight of the current day, and
@@ -601,29 +599,36 @@
 (defun vc-cvs-annotate-time ()
   "Return the time of the next annotation (as fraction of days)
 systime, or nil if there is none."
-  (let ((time-stamp
-	 "^\\S-+\\s-+\\S-+\\s-+\\([0-9]+\\)-\\(\\sw+\\)-\\([0-9]+\\)): "))
-    (if (looking-at time-stamp)
-      (progn
-	(let* ((day (string-to-number (match-string 1)))
-		 (month (cdr (assoc (match-string 2)
-				    vc-cvs-local-month-numbers)))
-	       (year-tmp (string-to-number (match-string 3)))
-	       ;; Years 0..68 are 2000..2068.
-	       ;; Years 69..99 are 1969..1999.
-	       (year (+ (cond ((> 69 year-tmp) 2000)
-			      ((> 100 year-tmp) 1900)
-			      (t 0))
-			year-tmp)))
-	  (goto-char (match-end 0)) ; Position at end makes for nicer overlay result
-	    (vc-annotate-convert-time (encode-time 0 0 0 day month year))))
-    ;; If we did not look directly at an annotation, there might be
-    ;; some further down.  This is the case if we are positioned at
-    ;; the very top of the buffer, for instance.
-      (if (re-search-forward time-stamp nil t)
-	(progn
-	  (beginning-of-line nil)
-	    (vc-cvs-annotate-time))))))
+  (let* ((bol (point))
+         (cache (get-text-property bol 'vc-cvs-annotate-time))
+         buffer-read-only)
+    (cond
+     (cache)
+     ((looking-at
+       "^\\S-+\\s-+\\S-+\\s-+\\([0-9]+\\)-\\(\\sw+\\)-\\([0-9]+\\)): ")
+      (let ((day (string-to-number (match-string 1)))
+            (month (cdr (assq (intern (match-string 2))
+                              '((Jan .  1) (Feb .  2) (Mar .  3)
+                                (Apr .  4) (May .  5) (Jun .  6)
+                                (Jul .  7) (Aug .  8) (Sep .  9)
+                                (Oct . 10) (Nov . 11) (Dec . 12)))))
+            (year (let ((tmp (string-to-number (match-string 3))))
+                    ;; Years 0..68 are 2000..2068.
+                    ;; Years 69..99 are 1969..1999.
+                    (+ (cond ((> 69 tmp) 2000)
+                             ((> 100 tmp) 1900)
+                             (t 0))
+                       tmp))))
+        (put-text-property
+         bol (1+ bol) 'vc-cvs-annotate-time
+         (setq cache (cons
+                      ;; Position at end makes for nicer overlay result.
+                      (match-end 0)
+                      (vc-annotate-convert-time
+                       (encode-time 0 0 0 day month year))))))))
+    (when cache
+      (goto-char (car cache))           ; fontify from here to eol
+      (cdr cache))))                    ; days (float)
 
 (defun vc-cvs-annotate-extract-revision-at-line ()
   (save-excursion
@@ -839,7 +844,7 @@
   (let ((coding-system-for-read (or file-name-coding-system
                                     default-file-name-coding-system)))
     (vc-insert-file (expand-file-name "CVS/Entries" dir))))
-     
+
 (defun vc-cvs-valid-symbolic-tag-name-p (tag)
   "Return non-nil if TAG is a valid symbolic tag name."
   ;; According to the CVS manual, a valid symbolic tag must start with
@@ -929,7 +934,7 @@
 	     "\\(.*\\)"))		;Sticky tag
     (vc-file-setprop file 'vc-workfile-version (match-string 1))
     (vc-file-setprop file 'vc-cvs-sticky-tag
-		     (vc-cvs-parse-sticky-tag (match-string 4) 
+		     (vc-cvs-parse-sticky-tag (match-string 4)
                                               (match-string 5)))
     ;; Compare checkout time and modification time.
     ;; This is intentionally different from the algorithm that CVS uses
--- a/lisp/vc-mcvs.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/vc-mcvs.el	Sat Nov 06 17:52:02 2004 +0000
@@ -26,9 +26,9 @@
 ;;; Commentary:
 
 ;; The home page of the Meta-CVS version control system is at
-;; 
+;;
 ;;      http://users.footprints.net/~kaz/mcvs.html
-;; 
+;;
 ;; This is derived from vc-cvs.el as follows:
 ;; - cp vc-cvs.el vc-mcvs.el
 ;; - Replace CVS/ with MCVS/CVS/
@@ -478,7 +478,11 @@
   (vc-mcvs-command
    buffer
    (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0)
-   file "annotate" (if version (concat "-r" version))))
+   file "annotate" (if version (concat "-r" version)))
+  (with-current-buffer buffer
+    (goto-char (point-min))
+    (re-search-forward "^[0-9]")
+    (delete-region (point-min) (1- (point)))))
 
 (defalias 'vc-mcvs-annotate-current-time 'vc-cvs-annotate-current-time)
 (defalias 'vc-mcvs-annotate-time 'vc-cvs-annotate-time)
--- a/lisp/vc.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/vc.el	Sat Nov 06 17:52:02 2004 +0000
@@ -2896,9 +2896,9 @@
 (defun vc-annotate-display-autoscale (&optional full)
   "Highlight the output of \\[vc-annotate] using an autoscaled color map.
 Autoscaling means that the map is scaled from the current time to the
-oldest annotation in the buffer, or, with argument FULL non-nil, to
+oldest annotation in the buffer, or, with prefix argument FULL, to
 cover the range from the oldest annotation to the newest."
-  (interactive)
+  (interactive "P")
   (let ((newest 0.0)
 	(oldest 999999.)		;Any CVS users at the founding of Rome?
 	(current (vc-annotate-convert-time (current-time)))
@@ -2907,7 +2907,9 @@
     ;; Run through this file and find the oldest and newest dates annotated.
     (save-excursion
       (goto-char (point-min))
-      (while (setq date (vc-call-backend vc-annotate-backend 'annotate-time))
+      (while (setq date (prog1 (vc-call-backend vc-annotate-backend
+                                                'annotate-time)
+                          (forward-line 1)))
 	(if (> date newest)
 	    (setq newest date))
 	(if (< date oldest)
--- a/lisp/x-dnd.el	Sun Oct 31 02:05:24 2004 +0000
+++ b/lisp/x-dnd.el	Sat Nov 06 17:52:02 2004 +0000
@@ -47,6 +47,7 @@
 the wanted action as car and the wanted type as cdr.  The wanted action
 can be copy, move, link, ask or private.
 The default value for this variable is `x-dnd-default-test-function'."
+  :version "21.4"
   :type 'symbol
   :group 'x)
 
@@ -69,6 +70,7 @@
 for that.
 The function shall return the action done (move, copy, link or private)
 if some action was made, or nil if the URL is ignored."
+  :version "21.4"
   :type 'alist
   :group 'x)
 
@@ -96,11 +98,13 @@
 call to `x-dnd-test-function'.  DATA is the drop data.
 The function shall return the action used (copy, move, link or private) if drop
 is successful, nil if not."
+  :version "21.4"
   :type 'alist
   :group 'x)
 
 (defcustom x-dnd-open-file-other-window nil
   "If non-nil, always use find-file-other-window to open dropped files."
+  :version "21.4"
   :type 'boolean
   :group 'x)
 
@@ -120,6 +124,7 @@
     )
   "The types accepted by default for dropped data.
 The types are chosen in the order they appear in the list."
+  :version "21.4"
   :type '(repeat string)
   :group 'x
 )
--- a/lispref/ChangeLog	Sun Oct 31 02:05:24 2004 +0000
+++ b/lispref/ChangeLog	Sat Nov 06 17:52:02 2004 +0000
@@ -1,3 +1,7 @@
+2004-11-01  Richard M. Stallman  <rms@gnu.org>
+
+	* commands.texi (Interactive Call): Add called-interactively-p.
+
 2004-10-29  Simon Josefsson  <jas@extundo.com>
 
 	* minibuf.texi (Reading a Password): Revert.
--- a/lispref/commands.texi	Sun Oct 31 02:05:24 2004 +0000
+++ b/lispref/commands.texi	Sat Nov 06 17:52:02 2004 +0000
@@ -617,7 +617,7 @@
 whose code includes the call to @code{interactive-p}) was called in
 direct response to user input.  This means that it was called with the
 function @code{call-interactively}, and that a keyboard macro is
-not running.
+not running, and that Emacs is not running in batch mode.
 
 If the containing function was called by Lisp evaluation (or with
 @code{apply} or @code{funcall}), then it was not called interactively.
@@ -679,6 +679,15 @@
 from a keyboard macro.  We use @code{"p"} because the numeric prefix
 argument is never @code{nil}.
 
+@defun called-interactively-p
+This function returns @code{t} when the calling function was called
+using @code{call-interactively}.
+
+When possible, instead of using this function, you should use the
+method in the example above; that method makes it possible for a
+caller to ``pretend'' that the function was called interactively.
+@end defun
+
 @node Command Loop Info
 @comment  node-name,  next,  previous,  up
 @section Information from the Command Loop
--- a/lwlib/ChangeLog	Sun Oct 31 02:05:24 2004 +0000
+++ b/lwlib/ChangeLog	Sat Nov 06 17:52:02 2004 +0000
@@ -1,3 +1,10 @@
+2004-11-01  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* xlwmenu.c (find_first_selectable, find_next_selectable)
+	(find_prev_selectable): Rename parameter skip_no_call_data to
+	skip_titles.  Recognize titles as having no call_data and no contents.
+	(Down, Up): Comment update.
+
 2004-08-30  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
 	* lwlib.h (_widget_value): Added lname and lkey.
--- a/lwlib/xlwmenu.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/lwlib/xlwmenu.c	Sat Nov 06 17:52:02 2004 +0000
@@ -2054,26 +2054,26 @@
 }
 
 static widget_value *
-find_first_selectable (mw, item, skip_no_call_data)
+find_first_selectable (mw, item, skip_titles)
      XlwMenuWidget mw;
      widget_value *item;
-     int skip_no_call_data;
+     int skip_titles;
 {
   widget_value *current = item;
   enum menu_separator separator;
 
   while (lw_separator_p (current->name, &separator, 0) || !current->enabled
-         || (skip_no_call_data && !current->call_data))
+         || (skip_titles && !current->call_data && !current->contents))
     if (current->next)
       current=current->next;
     else
-	return NULL;
+      return NULL;
 
   return current;
 }
 
 static widget_value *
-find_next_selectable (mw, item, skip_no_call_data)
+find_next_selectable (mw, item, skip_titles)
      XlwMenuWidget mw;
      widget_value *item;
 {
@@ -2082,7 +2082,7 @@
 
   while (current->next && (current=current->next) &&
 	 (lw_separator_p (current->name, &separator, 0) || !current->enabled
-          || (skip_no_call_data && !current->call_data)))
+          || (skip_titles && !current->call_data && !current->contents)))
     ;
 
   if (current == item)
@@ -2093,7 +2093,8 @@
 
       while (lw_separator_p (current->name, &separator, 0)
              || !current->enabled
-             || (skip_no_call_data && !current->call_data))
+             || (skip_titles && !current->call_data
+                 && !current->contents))
 	{
 	  if (current->next)
 	    current=current->next;
@@ -2108,14 +2109,14 @@
 }
 
 static widget_value *
-find_prev_selectable (mw, item, skip_no_call_data)
+find_prev_selectable (mw, item, skip_titles)
      XlwMenuWidget mw;
      widget_value *item;
 {
   widget_value *current = item;
   widget_value *prev = item;
 
-  while ((current=find_next_selectable (mw, current, skip_no_call_data))
+  while ((current=find_next_selectable (mw, current, skip_titles))
          != item)
     {
       if (prev == current)
@@ -2141,8 +2142,7 @@
   if (mw->menu.old_depth == mw->menu.top_depth)
     /* When <down> in the menu-bar is pressed, display the corresponding
        sub-menu and select the first selectable menu item there.
-       If this is a popup menu, skip items with zero call data (title of
-       the popup).  */
+       If this is a popup menu, skip title item of the popup.  */
     set_new_state (mw,
                    find_first_selectable (mw,
                                           selected_item->contents,
@@ -2174,8 +2174,7 @@
 	 last selectable item in the list.  So we select the first
 	 selectable one and find the previous selectable item.  Is there
 	 a better way?  */
-      /* If this is a popup menu, skip items with zero call data (title of
-         the popup).  */
+      /* If this is a popup menu, skip title item of the popup.  */
       set_new_state (mw,
                      find_first_selectable (mw,
                                             selected_item->contents,
--- a/man/ChangeLog	Sun Oct 31 02:05:24 2004 +0000
+++ b/man/ChangeLog	Sat Nov 06 17:52:02 2004 +0000
@@ -1,3 +1,21 @@
+2004-11-02  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* emacs-mime.texi (Encoding Customization): Fix
+	mm-coding-system-priorities entry.
+
+2004-11-03  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* frames.texi (Dialog Boxes): 
+	* idlwave.texi (Continued Statement Indentation): 
+	* reftex.texi (Options (Index Support)):
+	(Displaying and Editing the Index, Table of Contents): 
+	* speedbar.texi (Creating a display, Major Display Modes): Replace
+	non-nil with non-@code{nil}.
+
+2004-11-02  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* frames.texi (Dialog Boxes): Document use-old-gtk-file-dialog.
+
 2004-10-23  Eli Zaretskii  <eliz@gnu.org>
 
 	* text.texi (Text Based Tables, Table Definition)
--- a/man/emacs-mime.texi	Sun Oct 31 02:05:24 2004 +0000
+++ b/man/emacs-mime.texi	Sat Nov 06 17:52:02 2004 +0000
@@ -814,12 +814,12 @@
 @vindex mm-coding-system-priorities
 Prioritize coding systems to use for outgoing messages.  The default
 is @code{nil}, which means to use the defaults in Emacs.  It is a list of
-coding system symbols (aliases of coding systems does not work, use
-@kbd{M-x describe-coding-system} to make sure you are not specifying
-an alias in this variable).  For example, if you have configured Emacs
+coding system symbols (aliases of coding systems are also allowed, use
+@kbd{M-x describe-coding-system} to make sure you are specifying correct
+coding system names).  For example, if you have configured Emacs
 to prefer UTF-8, but wish that outgoing messages should be sent in
 ISO-8859-1 if possible, you can set this variable to
-@code{(iso-latin-1)}.  You can override this setting on a per-message
+@code{(iso-8859-1)}.  You can override this setting on a per-message
 basis by using the @code{charset} @acronym{MML} tag (@pxref{MML Definition}).
 
 @item mm-content-transfer-encoding-defaults
--- a/man/frames.texi	Sun Oct 31 02:05:24 2004 +0000
+++ b/man/frames.texi	Sat Nov 06 17:52:02 2004 +0000
@@ -910,6 +910,11 @@
 of dialogs.  This option has no effect if you have suppressed all dialog
 boxes with the option @code{use-dialog-box}.
 
+@vindex use-old-gtk-file-dialog
+  For Gtk+ version 2.4, you can make Emacs use the old file dialog
+by setting the variable @code{use-old-gtk-file-dialog} to a non-@code{nil}
+value.  If Emacs is built with a Gtk+ version that has only one file dialog,
+the setting of this variable has no effect.
 
 @node Tooltips
 @section Tooltips (or ``Balloon Help'')
--- a/man/idlwave.texi	Sun Oct 31 02:05:24 2004 +0000
+++ b/man/idlwave.texi	Sat Nov 06 17:52:02 2004 +0000
@@ -832,7 +832,7 @@
 continuation indentation, especially if
 @code{idlwave-max-extra-continuation-indent} is small, the key
 @kbd{C-u @key{TAB}} will re-indent all lines in the current statement.
-Note that @code{idlwave-indent-to-open-paren}, if non-nil, overrides
+Note that @code{idlwave-indent-to-open-paren}, if non-@code{nil}, overrides
 the @code{idlwave-max-extra-continuation-indent} limit, for
 parentheses only, forcing them always to line up.
 
--- a/man/reftex.texi	Sun Oct 31 02:05:24 2004 +0000
+++ b/man/reftex.texi	Sat Nov 06 17:52:02 2004 +0000
@@ -568,7 +568,7 @@
 @item r
 @vindex reftex-enable-partial-scans
 Reparse the LaTeX document and rebuild the @file{*toc*} buffer.  When
-@code{reftex-enable-partial-scans} is non-nil, rescan only the file this
+@code{reftex-enable-partial-scans} is non-@code{nil}, rescan only the file this
 location is defined in, not the entire document.@refill
 
 @item C-u r
@@ -2355,7 +2355,7 @@
 @item r
 @vindex reftex-enable-partial-scans
 Reparse the LaTeX document and rebuild the @file{*Index*} buffer.  When
-@code{reftex-enable-partial-scans} is non-nil, rescan only the file this
+@code{reftex-enable-partial-scans} is non-@code{nil}, rescan only the file this
 location is defined in, not the entire document.@refill
 
 @item C-u r
@@ -4348,7 +4348,7 @@
 should be @samp{Molecules!}.@refill
 
 @var{exclude} can be a function.  If this function exists and returns a
-non-nil value, the index entry at point is ignored.  This was
+non-@code{nil} value, the index entry at point is ignored.  This was
 implemented to support the (deprecated) @samp{^} and @samp{_} shortcuts
 in the LaTeX2e @code{index} package.@refill
 
--- a/man/speedbar.texi	Sun Oct 31 02:05:24 2004 +0000
+++ b/man/speedbar.texi	Sat Nov 06 17:52:02 2004 +0000
@@ -1066,7 +1066,7 @@
 
 There are several helper functions you can use if you are going to use
 built in tagging.  These functions can be @code{or}ed since each one
-returns non-nil if it displays a message.  They are:
+returns non-@code{nil} if it displays a message.  They are:
 
 @table @code
 @cindex @code{speedbar-item-info-file-helper}
@@ -1165,7 +1165,7 @@
 user clicks on the text.
 
 The optional argument @var{token} is extra data to associated with the
-text.  Lastly @var{prevline} should be non-nil if you want this line to
+text.  Lastly @var{prevline} should be non-@code{nil} if you want this line to
 appear directly after the last button which was created instead of on
 the next line.
 @end defun
--- a/src/.gdbinit	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/.gdbinit	Sat Nov 06 17:52:02 2004 +0000
@@ -70,6 +70,34 @@
 Works only when an inferior emacs is executing.
 end
 
+# Print out current buffer point and boundaries
+define ppt
+  set $b = current_buffer
+  set $t = $b->text
+  printf "BUF PT: %d", $b->pt
+  if ($b->pt != $b->pt_byte)
+    printf "[%d]", $b->pt_byte
+  end
+  printf " of 1..%d", $t->z
+  if ($t->z != $t->z_byte)
+    printf "[%d]", $t->z_byte
+  end
+  if ($b->begv != 1 || $b->zv != $t->z)
+    printf " NARROW=%d..%d", $b->begv, $b->zv
+    if ($b->begv != $b->begv_byte || $b->zv != $b->zv_byte)
+      printf " [%d..%d]", $b->begv_byte, $b->zv_byte
+    end
+  end
+  printf " GAP: %d", $t->gpt
+  if ($t->gpt != $t->gpt_byte)
+    printf "[%d]", $t->gpt_byte
+  end
+  printf " SZ=%d\n", $t->gap_size
+end
+document ppt
+Print point, beg, end, narrow, and gap for current buffer.
+end
+
 define xtype
   xgettype $
   output $type
--- a/src/ChangeLog	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/ChangeLog	Sat Nov 06 17:52:02 2004 +0000
@@ -1,3 +1,206 @@
+2004-11-05  Kim F. Storm  <storm@cua.dk>
+
+	* fileio.c (Ffile_modes): Doc fix.
+	(auto_save_1): Check for Ffile_modes nil value.
+
+2004-11-05  Kim F. Storm  <storm@cua.dk>
+
+	* xselect.c (struct selection_event_queue, selection_queue)
+	(x_queue_selection_requests, x_queue_event)
+	(x_start_queuing_selection_requests)
+	(x_stop_queuing_selection_requests): Add new queue for selection
+	input events to replace previous XEvent queue in xterm.c.
+	(queue_selection_requests_unwind): Adapt to new queue.
+	(x_reply_selection_request): Adapt to new queue.  Unexpect
+	wait_object in case of x errors (memory leak).
+	(x_handle_selection_request, x_handle_selection_clear): Make static.
+	(x_handle_selection_event): New function.  May queue selection events.
+	(wait_for_property_change_unwind): Use save_value instead of cons.
+	Clear property_change_reply_object.
+	(wait_for_property_change): Abort if already waiting.
+	Use save_value instead of cons for unwind data.
+	(x_handle_property_notify): Skip events already arrived, but don't
+	free them, as "arrived" field is checked by wait_for_property_change,
+	and it will be freed by unwind or explicit unexpect_property_change.
+	(x_get_foreign_selection): Add to new queue.
+	(receive_incremental_selection): Don't unexpect wait_object when done
+	as it has already been freed by previous wait_for_property_change.
+
+	* xterm.h (x_start_queuing_selection_requests)
+	(x_stop_queuing_selection_requests, x_handle_selection_request)
+	(x_handle_selection_clear): Remove prototypes.
+	(x_handle_selection_event): Add prototype.
+
+	* xterm.c (handle_one_xevent): Don't queue X selection events
+	here, it may be too late if we start queuing after we have already
+	stored some selection events into the kbd buffer.
+	(struct selection_event_queue, queue, x_queue_selection_requests)
+	(x_queue_event, x_unqueue_events, x_start_queuing_selection_requests)
+	(x_stop_queuing_selection_requests): Remove/move to xselect.c.
+	(x_catch_errors_unwind): Block input around final XSync.
+
+	* keyboard.h (kbd_buffer_unget_event): Add prototype.
+
+	* keyboard.c (kbd_buffer_store_event_hold): Remove obsolete code.
+	(kbd_buffer_unget_event): New function.
+	(kbd_buffer_get_event, swallow_events): Combine SELECTION events
+	and use x_handle_selection_event.
+	(mark_kboards): Don't mark x and y of SELECTION_CLEAR_EVENT.
+
+2004-11-05  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* xselect.c (TRACE3): New debug macro.
+	(x_reply_selection_request): Use it.
+	(receive_incremental_selection): In call to TRACE0, the name of
+	a symbol is in xname.
+
+2004-11-05  Kim F. Storm  <storm@cua.dk>
+
+	* fontset.c (fontset_pattern_regexp): Use unsigned char.
+
+2004-11-04  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* fileio.c (Fnext_read_file_uses_dialog_p): New function.
+
+	* gtkutil.h: Declare use_old_gtk_file_dialog.
+
+	* gtkutil.c: Make use_old_gtk_file_dialog non-static.
+	(xg_initialize): Moved DEFVAR_BOOL for use_old_gtk_file_dialog ...
+	* xfns.c (syms_of_xfns): ... to here.
+
+	* gtkutil.c (xg_get_file_with_chooser): Expand DEFAULT_FILENAME if
+	it doesn't start with /.
+
+2004-11-04  Kenichi Handa  <handa@m17n.org>
+
+	* fontset.c (fontset_pattern_regexp): If '*' is preceded by '\',
+	treat it as a literal character.
+
+2004-11-03  Kim F. Storm  <storm@cua.dk>
+
+	* .gdbinit (ppt): New function.
+
+2004-11-02  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* xterm.c (x_window_to_scroll_bar): Only call
+	xg_get_scroll_id_for_window if toolkit scroll bars are used.
+
+	* gtkutil.c (xg_get_file_with_chooser): Use GTK_STOCK_OK instead
+	of save.
+
+2004-11-02  Andreas Schwab  <schwab@suse.de>
+
+	* window.c (Fscroll_right): Fix last change.
+
+2004-11-02  Kim F. Storm  <storm@cua.dk>
+
+	* Makefile.in (callproc.o): Depend on blockinput.h atimer.h systime.h.
+
+2004-11-02  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* callproc.c (Fcall_process): Block input around vfork.
+
+2004-11-02  Kim F. Storm  <storm@cua.dk>
+
+	* eval.c (Fcalled_interactively_p): Rename from Fcall_interactive_p.
+	(syms_of_eval): Defsubr it.
+
+2004-11-02  Richard M. Stallman  <rms@gnu.org>
+
+	* insdel.c (replace_range_2): New function.
+
+	* casefiddle.c (casify_region): Handle changes in byte-length
+	using replace_range_2.
+
+	* emacs.c (USAGE3): Delete --horizontal-scroll-bars, -hb.
+
+	* xdisp.c (back_to_previous_visible_line_start):
+	Subtract 1 from pos when checking previous newline for invisibility.
+
+	* window.c (window_scroll_pixel_based): Update preserve_y
+	for header line if any.
+	(Fscroll_left, Fscroll_right): Don't call interactive_p;
+	use a new second argument instead.
+
+	* eval.c (Fcall_interactive_p): New function.
+	(interactive_p): Don't test INTERACTIVE here.
+	(Finteractive_p): Doc fix.
+
+	* eval.c (Feval): Abort if INPUT_BLOCKED_P.
+
+2004-11-02  KOBAYASHI Yasuhiro  <kobayays@otsukakj.co.jp>
+
+	* w32fns.c (w32_font_match): Use fast_string_match_ignore_case for
+	comparing font names.
+
+2004-11-02  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
+	Fx_file_dialog if only directories should be read.
+
+	* lisp.h: Fx_file_dialog takes 5 parameters.
+
+	* xfns.c (Fx_file_dialog): Both Motif and GTK version:  Add
+	parameter only_dir_p.
+	In Motif version, don't put DEFAULT_FILENAME in filter part of the
+	dialog, just text field part.  Do not add DEFAULT_FILENAME
+	to list of files if it isn't there.
+	In GTK version, pass only_dir_p parameter to xg_get_file_name.
+
+	* macfns.c (Fx_file_dialog): Add parameter only_dir_p.  Check
+	only_dir_p instead of comparing prompt to "Dired".  When using
+	a save dialog, add option kNavDontConfirmReplacement, change title
+	to "Enter name", change text for save button to "Ok".
+
+	* w32fns.c (Fx_file_dialog): Add parameter only_dir_p.  Check
+	only_dir_p instead of comparing prompt to "Dired".
+
+	* gtkutil.c (xg_get_file_with_chooser)
+	(xg_get_file_with_selection): New functions, only defined ifdef
+	HAVE_GTK_FILE_CHOOSER_DIALOG_NEW and HAVE_GTK_FILE_SELECTION_NEW
+	respectively.
+	(xg_get_file_name): Add parameter only_dir_p.
+	Call xg_get_file_with_chooser or xg_get_file_with_selection
+	depending on HAVE_GTK_FILE* and the value of use_old_gtk_file_dialog.
+	(xg_initialize): New DEFVAR_BOOL use_old_gtk_file_dialog.
+
+	* gtkutil.h (xg_get_file_name): Add parameter only_dir_p.
+
+	* config.in: Rebuild (added HAVE_GTK_FILE_*).
+
+2004-11-01  Kim F. Storm  <storm@cua.dk>
+
+	* process.c (connect_wait_mask, num_pending_connects): Only
+	declare and use them if NON_BLOCKING_CONNECT is defined.
+	(init_process): Initialize them if NON_BLOCKING_CONNECT defined.
+	(IF_NON_BLOCKING_CONNECT): New helper macro.
+	(wait_reading_process_output): Only declare and use local vars
+	Connecting and check_connect when NON_BLOCKING_CONNECT is defined.
+
+2004-11-01  Andy Petrusenco  <Igrek@star-sw.com>  (tiny change)
+
+	* w32term.c (x_scroll_run): Delete region objects after use.
+
+2004-10-31  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* xmenu.c: Add prototypes for forward function declarations.
+	(popup_get_selection): Remove parameter do_timers, remove call to
+	timer_check.
+	(create_and_show_popup_menu, create_and_show_dialog): Remove
+	parameter do_timers from call to popup_get_selection.
+
+	* xdisp.c (update_tool_bar): Pass a copy of f->tool_bar_items to
+	tool_bar_items and assign the result to f->tool_bar_items if
+	not equal.  Move BLOCK/UNBLOCK_INPUT from around call to
+	tool_bar_items to assignment of result.
+
+	* atimer.c (alarm_signal_handler): Do not call set_alarm if
+	pending_atmers is non-zero.
+
+2004-10-31  Kim F. Storm  <storm@cua.dk>
+
+	* dispnew.c (margin_glyphs_to_reserve): Don't use ncols_scale_factor.
+
 2004-10-28  Will  <will@glozer.net>
 
 	* macterm.c: allow user to assign key modifiers to the Mac Option
@@ -387,7 +590,7 @@
 	compositions to encode.
 	(encode_coding_string): Likewise.  Free composition data.
 
-2004-09-30  Florian Weimer <fw@deneb.enyo.de>	(tiny change)
+2004-09-30  Florian Weimer <fw@deneb.enyo.de>
 
 	* coding.c (code_convert_region): Free composition data.
 
@@ -961,7 +1164,7 @@
 	(Fsave_window_excursion, Fset_window_vscroll)
 	(syms_of_window) <window-size-fixed>: Doc fixes.
 
-2004-07-19  KOBAYASHI Yasuhiro  <kobayays@otsukakj.co.jp>  (tiny change)
+2004-07-19  KOBAYASHI Yasuhiro  <kobayays@otsukakj.co.jp>
 
 	* w32fns.c (Fx_file_dialog): Use ENCODE_FILE instead of
 	ENCODE_SYSTEM for filenames.
@@ -1020,7 +1223,7 @@
 
 	* buffer.c (syms_of_buffer) <transient-mark-mode>: Doc fix.
 
-2004-07-15  KOBAYASHI Yasuhiro  <kobayays@otsukakj.co.jp>  (tiny change)
+2004-07-15  KOBAYASHI Yasuhiro  <kobayays@otsukakj.co.jp>
 
 	* w32fns.c (Fx_file_dialog): Encode strings in system coding
 	system before passing them to OS functions for display.
@@ -1684,7 +1887,7 @@
 	before actually accepting connection in case it has already been
 	accepted due to recursion.
 
-2004-05-23  K,Ba(Broly L,Bu(Brentey  <lorentey@elte.hu>  (tiny change)
+2004-05-23  K,Ba(Broly L,Bu(Brentey  <lorentey@elte.hu>
 
 	* coding.c (Fset_safe_terminal_coding_system_internal):
 	Set suppress_error in safe_terminal_coding, not terminal_coding.
@@ -1998,7 +2201,7 @@
 	* w32fns.c (Vw32_ansi_code_page): New Lisp variable.
 	(globals_of_w32fns): Set it.
 
-2004-05-09  Piet van Oostrum  <piet@cs.uu.nl>  (tiny change)
+2004-05-09  Piet van Oostrum  <piet@cs.uu.nl>
 
 	* data.c (Fquo): Simplify.
 
@@ -2047,7 +2250,7 @@
 
 	* emacs.c (main) [VMS]: Fix var ref.
 
-2004-05-06  Romain Francoise  <romain@orebokech.com>  (tiny change)
+2004-05-06  Romain Francoise  <romain@orebokech.com>
 
 	* data.c (Fsetq_default): Fix docstring.
 
@@ -2087,7 +2290,7 @@
 
 	* Makefile.in (region-cache.o): Depend on config.h.
 
-2004-05-02  Romain Francoise  <romain@orebokech.com>  (tiny change)
+2004-05-02  Romain Francoise  <romain@orebokech.com>
 
 	* indent.c (compute_motion): Save vpos in prev_vpos when dealing
 	with continuation lines, too.
@@ -3330,7 +3533,7 @@
 	entries that were used before we return.
 	(init_keyboard): Initialize read_avail_input_buf here.
 
-2004-02-16  Jesper Harder  <harder@ifa.au.dk>  (tiny change)
+2004-02-16  Jesper Harder  <harder@ifa.au.dk>
 
 	* cmds.c (Fend_of_line): Doc fix.
 
@@ -3998,7 +4201,7 @@
 	to the definition of `signal' in the Elisp manual.
 	* eval.c (Fsignal): Ditto.
 
-2003-12-29  James Clark  <jjc@jclark.com>  (tiny change)
+2003-12-29  James Clark  <jjc@jclark.com>
 
 	* fns.c (internal_equal): Return t for two NaN arguments.
 
@@ -5058,7 +5261,7 @@
 	* fileio.c (Fwrite_region): Fix conditional expression to issue
 	the right message.
 
-2003-08-16  Juri Linkov  <juri@jurta.org>  (tiny change)
+2003-08-16  Juri Linkov  <juri@jurta.org>
 
 	* syntax.c (Fforward_word): Argument changed to optional.
 	Set default value to 1.
@@ -5117,7 +5320,7 @@
 	* fns.c (Fclear_string): New function.
 	(syms_of_fns): defsubr it.
 
-2003-07-28  KOBAYASHI Yasuhiro  <kobayays@otsukakj.co.jp> (tiny change)
+2003-07-28  KOBAYASHI Yasuhiro  <kobayays@otsukakj.co.jp>
 
 	* xfns.c (xic_set_preeditarea): Add the left fringe width to spot.x.
 
@@ -5345,7 +5548,7 @@
 
 	* alloc.c (Fgarbage_collect): Doc fix.
 
-2003-07-07  Nozomu Ando  <nand@mac.com>  (tiny change)
+2003-07-07  Nozomu Ando  <nand@mac.com>
 
 	* buffer.c (Fkill_buffer): Clear charpos cache if necessary.
 
@@ -6555,7 +6758,7 @@
 	* alloc.c (Fgarbage_collect): Cast pointers into specpdl
 	to avoid GCC warning.
 
-2003-05-16  Ralph Schleicher  <rs@nunatak.allgaeu.org>  (tiny change)
+2003-05-16  Ralph Schleicher  <rs@nunatak.allgaeu.org>
 
 	* fileio.c (Fdelete_file): Handle symlinks pointing to directories.
 
@@ -8278,7 +8481,7 @@
 	(w32_init_class): Use it.
 	(x_put_x_image): Declare all args.
 
-2003-01-21  Richard Dawe  <rich@phekda.freeserve.co.uk>  (tiny change)
+2003-01-21  Richard Dawe  <rich@phekda.freeserve.co.uk>
 
 	* Makefile.in (ALL_CFLAGS): Include MYCPPFLAGS, not MYCPPFLAG.
 
@@ -8650,7 +8853,7 @@
 	in direct action cases for Qforward_char and Qbackward_char.
 	Set already_adjusted so it won't be done twice.
 
-2002-12-30  Richard Dawe  <rich@phekda.freeserve.co.uk>  (tiny change)
+2002-12-30  Richard Dawe  <rich@phekda.freeserve.co.uk>
 
 	* src/config.in (!HAVE_SIZE_T): Fix order of arguments in
 	type definition of size_t.
@@ -8748,7 +8951,7 @@
 	* dired.c (file_name_completion): Fix that change.
 	Delete special quit-handling code; just use QUIT.
 
-2002-12-21  Tak Ota  <Takaaki.Ota@am.sony.com>  (tiny change)
+2002-12-21  Tak Ota  <Takaaki.Ota@am.sony.com>
 
 	* dired.c (file_name_completion): Close directory on error
 	just as in directory_files_internal.
@@ -10088,8 +10291,8 @@
 
 2002-08-26  Kim F. Storm  <storm@cua.dk>
 
-	* frame.c (make_terminal_frame) [CANNOT_DUMP]: Initialize foreground
-	and background colors.  From Joe Buehler (tiny change).
+	* frame.c (make_terminal_frame) [CANNOT_DUMP]: Initialize
+	foreground and background colors.  From Joe Buehler.
 
 2002-08-26  Miles Bader  <miles@gnu.org>
 
--- a/src/Makefile.in	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/Makefile.in	Sat Nov 06 17:52:02 2004 +0000
@@ -1056,7 +1056,7 @@
    keyboard.h dispextern.h $(config_h)
 callproc.o: callproc.c epaths.h buffer.h commands.h $(config_h) \
 	process.h systty.h syssignal.h charset.h coding.h ccl.h msdos.h \
-        composite.h
+        composite.h w32.h blockinput.h atimer.h systime.h
 casefiddle.o: casefiddle.c syntax.h commands.h buffer.h composite.h \
 	charset.h keymap.h $(config_h)
 casetab.o: casetab.c buffer.h $(config_h)
--- a/src/atimer.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/atimer.c	Sat Nov 06 17:52:02 2004 +0000
@@ -397,7 +397,8 @@
       EMACS_GET_TIME (now);
     }
 
-  set_alarm ();
+  if (! pending_atimers)
+    set_alarm ();
 }
 
 
--- a/src/callproc.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/callproc.c	Sat Nov 06 17:52:02 2004 +0000
@@ -83,6 +83,7 @@
 #include "process.h"
 #include "syssignal.h"
 #include "systty.h"
+#include "blockinput.h"
 
 #ifdef MSDOS
 #include "msdos.h"
@@ -624,6 +625,8 @@
     pid = child_setup (filefd, fd1, fd_error, (char **) new_argv,
 		       0, current_dir);
 #else  /* not WINDOWSNT */
+    BLOCK_INPUT;
+
     pid = vfork ();
 
     if (pid == 0)
@@ -641,6 +644,8 @@
 	child_setup (filefd, fd1, fd_error, (char **) new_argv,
 		     0, current_dir);
       }
+
+    UNBLOCK_INPUT;
 #endif /* not WINDOWSNT */
 
     /* The MSDOS case did this already.  */
--- a/src/casefiddle.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/casefiddle.c	Sat Nov 06 17:52:02 2004 +0000
@@ -235,6 +235,10 @@
       else if (!UPPERCASEP (c)
 	       && (!inword || flag != CASE_CAPITALIZE_UP))
 	c = UPCASE1 (c);
+      if (multibyte && c >= 0x80)
+	/* A multibyte result character can't be handled in this
+	   simple loop.  */
+	break;
       FETCH_BYTE (i) = c;
       if (c != c2)
 	changed = 1;
@@ -272,22 +276,17 @@
 		       tolen = CHAR_STRING (c2, str),
 		       fromlen == tolen)
 		{
+		  /* Length is unchanged.  */
 		  for (j = 0; j < tolen; ++j)
 		    FETCH_BYTE (i + j) = str[j];
 		}
 	      else
-		{
-		  error ("Can't casify letters that change length");
-#if 0 /* This is approximately what we'd like to be able to do here */
-		  if (tolen < fromlen)
-		    del_range_1 (i + tolen, i + fromlen, 0, 0);
-		  else if (tolen > fromlen)
-		    {
-		      TEMP_SET_PT (i + fromlen);
-		      insert_1 (str + fromlen, tolen - fromlen, 1, 0, 0);
-		    }
-#endif
-		}
+		/* Replace one character with the other,
+		   keeping text properties the same.  */
+		replace_range_2 (start + 1, i + tolen,
+				 start + 2, i + tolen + fromlen,
+				 str, 1, tolen,
+				 0);
 	    }
 	  if ((int) flag >= (int) CASE_CAPITALIZE)
 	    inword = SYNTAX (c2) == Sword;
--- a/src/config.in	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/config.in	Sat Nov 06 17:52:02 2004 +0000
@@ -217,6 +217,15 @@
 /* Define to 1 if using GTK. */
 #undef HAVE_GTK
 
+/* Define to 1 if GTK has both file selection and chooser dialog. */
+#undef HAVE_GTK_FILE_BOTH
+
+/* Define to 1 if you have the `gtk_file_chooser_dialog_new' function. */
+#undef HAVE_GTK_FILE_CHOOSER_DIALOG_NEW
+
+/* Define to 1 if you have the `gtk_file_selection_new' function. */
+#undef HAVE_GTK_FILE_SELECTION_NEW
+
 /* Define to 1 if GTK can handle more than one display. */
 #undef HAVE_GTK_MULTIDISPLAY
 
--- a/src/dispnew.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/dispnew.c	Sat Nov 06 17:52:02 2004 +0000
@@ -566,7 +566,7 @@
       int width = XFASTINT (w->total_cols);
       double d = max (0, XFLOATINT (margin));
       d = min (width / 2 - 1, d);
-      n = (int) ((double) total_glyphs / width * d) * w->ncols_scale_factor;
+      n = (int) ((double) total_glyphs / width * d);
     }
   else
     n = 0;
--- a/src/emacs.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/emacs.c	Sat Nov 06 17:52:02 2004 +0000
@@ -306,7 +306,6 @@
 --fullscreen, -fs               make first frame fullscreen\n\
 --fullwidth, -fw                make the first frame wide as the screen\n\
 --geometry, -g GEOMETRY         window geometry\n\
---horizontal-scroll-bars, -hb   enable horizontal scroll bars\n\
 --icon-type, -i                 use picture of gnu for Emacs icon\n\
 --iconic                        start Emacs in iconified state\n\
 --internal-border, -ib WIDTH    width between text and main border\n\
--- a/src/eval.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/eval.c	Sat Nov 06 17:52:02 2004 +0000
@@ -540,21 +540,45 @@
 
 
 DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0,
-       doc: /* Return t if function in which this appears was called interactively.
+       doc: /* Return t if the function was run directly by user input.
 This means that the function was called with call-interactively (which
 includes being called as the binding of a key)
-and input is currently coming from the keyboard (not in keyboard macro).  */)
+and input is currently coming from the keyboard (not in keyboard macro),
+and Emacs is not running in batch mode (`noninteractive' is nil).
+
+The only known proper use of `interactive-p' is in deciding whether to
+display a helpful message, or how to display it.  If you're thinking
+of using it for any other purpose, it is quite likely that you're
+making a mistake.  Think: what do you want to do when the command is
+called from a keyboard macro?
+
+If you want to test whether your function was called with
+`call-interactively', the way to do that is by adding an extra
+optional argument, and making the `interactive' spec specify non-nil
+unconditionally for that argument.  (`p' is a good way to do this.)  */)
      ()
 {
-  return interactive_p (1) ? Qt : Qnil;
+  return (INTERACTIVE && interactive_p (1)) ? Qt : Qnil;
 }
 
 
-/*  Return 1 if function in which this appears was called
-    interactively.  This means that the function was called with
-    call-interactively (which includes being called as the binding of
-    a key) and input is currently coming from the keyboard (not in
-    keyboard macro).
+DEFUN ("called-interactively-p", Fcalled_interactively_p, Scalled_interactively_p, 0, 0, 0,
+       doc: /* Return t if the function using this was called with call-interactively.
+This is used for implementing advice and other function-modifying
+features of Emacs.
+
+The cleanest way to test whether your function was called with
+`call-interactively', the way to do that is by adding an extra
+optional argument, and making the `interactive' spec specify non-nil
+unconditionally for that argument.  (`p' is a good way to do this.)  */)
+     ()
+{
+  return (INTERACTIVE && interactive_p (1)) ? Qt : Qnil;
+}
+
+
+/*  Return 1 if function in which this appears was called using
+    call-interactively.
 
     EXCLUDE_SUBRS_P non-zero means always return 0 if the function
     called is a built-in.  */
@@ -566,9 +590,6 @@
   struct backtrace *btp;
   Lisp_Object fun;
 
-  if (!INTERACTIVE)
-    return 0;
-
   btp = backtrace_list;
 
   /* If this isn't a byte-compiled function, there may be a frame at
@@ -1975,7 +1996,7 @@
   struct backtrace backtrace;
   struct gcpro gcpro1, gcpro2, gcpro3;
 
-  if (handling_signal)
+  if (handling_signal || INPUT_BLOCKED_P)
     abort ();
 
   if (SYMBOLP (form))
@@ -3449,6 +3470,7 @@
   defsubr (&Scondition_case);
   defsubr (&Ssignal);
   defsubr (&Sinteractive_p);
+  defsubr (&Scalled_interactively_p);
   defsubr (&Scommandp);
   defsubr (&Sautoload);
   defsubr (&Seval);
--- a/src/fileio.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/fileio.c	Sat Nov 06 17:52:02 2004 +0000
@@ -3368,7 +3368,8 @@
 }
 
 DEFUN ("file-modes", Ffile_modes, Sfile_modes, 1, 1, 0,
-       doc: /* Return mode bits of file named FILENAME, as an integer.  */)
+       doc: /* Return mode bits of file named FILENAME, as an integer.
+Return nil, if file does not exist or is not accessible.  */)
      (filename)
      Lisp_Object filename;
 {
@@ -5714,17 +5715,21 @@
 auto_save_1 ()
 {
   struct stat st;
+  Lisp_Object modes;
+
+  auto_save_mode_bits = 0666;
 
   /* Get visited file's mode to become the auto save file's mode.  */
-  if (! NILP (current_buffer->filename)
-      && stat (SDATA (current_buffer->filename), &st) >= 0)
-    /* But make sure we can overwrite it later!  */
-    auto_save_mode_bits = st.st_mode | 0600;
-  else if (! NILP (current_buffer->filename))
-    /* Remote files don't cooperate with stat.  */
-    auto_save_mode_bits = XINT (Ffile_modes (current_buffer->filename)) | 0600;
-  else
-    auto_save_mode_bits = 0666;
+  if (! NILP (current_buffer->filename))
+    {
+      if (stat (SDATA (current_buffer->filename), &st) >= 0)
+	/* But make sure we can overwrite it later!  */
+	auto_save_mode_bits = st.st_mode | 0600;
+      else if ((modes = Ffile_modes (current_buffer->filename),
+		INTEGERP (modes)))
+	/* Remote files don't cooperate with stat.  */
+	auto_save_mode_bits = XINT (modes) | 0600;
+    }
 
   return
     Fwrite_region (Qnil, Qnil,
@@ -6176,6 +6181,23 @@
   return Ffile_exists_p (string);
 }
 
+DEFUN ("next-read-file-uses-dialog-p", Fnext_read_file_uses_dialog_p,
+       Snext_read_file_uses_dialog_p, 0, 0, 0,
+       doc: /* Return t if a call to `read-file-name' will use a dialog.
+The return value is only relevant for a call to `read-file-name' that happens
+before any other event (mouse or keypress) is handeled.  */)
+  ()
+{
+#if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) || defined (TARGET_API_MAC_CARBON)
+  if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
+      && use_dialog_box
+      && use_file_dialog
+      && have_menus_p ())
+    return Qt;
+#endif
+  return Qnil;
+}
+
 DEFUN ("read-file-name", Fread_file_name, Sread_file_name, 1, 6, 0,
        doc: /* Read file name, prompting with PROMPT and completing in directory DIR.
 Value is not expanded---you must call `expand-file-name' yourself.
@@ -6308,10 +6330,7 @@
   GCPRO2 (insdef, default_filename);
 
 #if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) || defined (TARGET_API_MAC_CARBON)
-  if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
-      && use_dialog_box
-      && use_file_dialog
-      && have_menus_p ())
+  if (! NILP (Fnext_read_file_uses_dialog_p ()))
     {
       /* If DIR contains a file name, split it.  */
       Lisp_Object file;
@@ -6323,7 +6342,8 @@
 	}
       if (!NILP(default_filename))
         default_filename = Fexpand_file_name (default_filename, dir);
-      val = Fx_file_dialog (prompt, dir, default_filename, mustmatch);
+      val = Fx_file_dialog (prompt, dir, default_filename, mustmatch,
+                            EQ (predicate, Qfile_directory_p) ? Qt : Qnil);
       add_to_history = 1;
     }
   else
@@ -6695,6 +6715,7 @@
 
   defsubr (&Sread_file_name_internal);
   defsubr (&Sread_file_name);
+  defsubr (&Snext_read_file_uses_dialog_p);
 
 #ifdef unix
   defsubr (&Sunix_sync);
--- a/src/fontset.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/fontset.c	Sat Nov 06 17:52:02 2004 +0000
@@ -790,14 +790,14 @@
       || strcmp (SDATA (pattern), CACHED_FONTSET_NAME))
     {
       /* We must at first update the cached data.  */
-      char *regex, *p0, *p1;
+      unsigned char *regex, *p0, *p1;
       int ndashes = 0, nstars = 0;
-      
+
       for (p0 = SDATA (pattern); *p0; p0++)
 	{
 	  if (*p0 == '-')
 	    ndashes++;
-	  else if (*p0 == '*')
+	  else if (*p0 == '*' && p0 > SDATA (pattern) && p0[-1] != '\\')
 	    nstars++;
 	}
 
@@ -805,14 +805,14 @@
 	 we convert "*" to "[^-]*" which is much faster in regular
 	 expression matching.  */
       if (ndashes < 14)
-	p1 = regex = (char *) alloca (SBYTES (pattern) + 2 * nstars + 1);
+	p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 2 * nstars + 1);
       else
-	p1 = regex = (char *) alloca (SBYTES (pattern) + 5 * nstars + 1);
+	p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 5 * nstars + 1);
 
       *p1++ = '^';
-      for (p0 = (char *) SDATA (pattern); *p0; p0++)
+      for (p0 = SDATA (pattern); *p0; p0++)
 	{
-	  if (*p0 == '*')
+	  if (*p0 == '*' && p0 > SDATA (pattern) && p0[-1] != '\\')
 	    {
 	      if (ndashes < 14)
 		*p1++ = '.';
--- a/src/gtkutil.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/gtkutil.c	Sat Nov 06 17:52:02 2004 +0000
@@ -1118,6 +1118,10 @@
 }
 
 
+
+/***********************************************************************
+                      File dialog functions
+ ***********************************************************************/
 enum
 {
   XG_FILE_NOT_DONE,
@@ -1126,6 +1130,85 @@
   XG_FILE_DESTROYED,
 };
 
+#ifdef HAVE_GTK_FILE_BOTH
+int use_old_gtk_file_dialog;
+#endif
+
+
+#ifdef HAVE_GTK_FILE_CHOOSER_DIALOG_NEW
+/* Read a file name from the user using a file chooser dialog.
+   F is the current frame.
+   PROMPT is a prompt to show to the user.  May not be NULL.
+   DEFAULT_FILENAME is a default selection to be displayed.  May be NULL.
+   If MUSTMATCH_P is non-zero, the returned file name must be an existing
+   file.
+
+   Returns a file name or NULL if no file was selected.
+   The returned string must be freed by the caller.  */
+
+static char *
+xg_get_file_with_chooser (f, prompt, default_filename, mustmatch_p, only_dir_p)
+     FRAME_PTR f;
+     char *prompt;
+     char *default_filename;
+     int mustmatch_p, only_dir_p;
+{
+  GtkWidget *filewin;
+  GtkWindow *gwin = GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f));
+
+  char *fn = 0;
+  GtkFileChooserAction action = (mustmatch_p ?
+                                 GTK_FILE_CHOOSER_ACTION_OPEN :
+                                 GTK_FILE_CHOOSER_ACTION_SAVE);
+
+  if (only_dir_p)
+    action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
+
+  filewin = gtk_file_chooser_dialog_new (prompt, gwin, action,
+                                         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                                         (mustmatch_p || only_dir_p ?
+                                          GTK_STOCK_OPEN : GTK_STOCK_OK),
+                                         GTK_RESPONSE_OK,
+                                         NULL);
+
+  xg_set_screen (filewin, f);
+  gtk_widget_set_name (filewin, "emacs-filedialog");
+  gtk_window_set_transient_for (GTK_WINDOW (filewin), gwin);
+  gtk_window_set_destroy_with_parent (GTK_WINDOW (filewin), TRUE);
+
+
+  if (default_filename)
+    {
+      Lisp_Object file;
+      struct gcpro gcpro1;
+      GCPRO1 (file);
+
+      /* File chooser does not understand ~/... in the file name.  It must be
+         an absolute name starting with /.  */
+      if (default_filename[0] != '/')
+        {
+          file = Fexpand_file_name (build_string (default_filename), Qnil);
+          default_filename = SDATA (file);
+        }
+
+      gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filewin),
+                                     default_filename);
+
+      UNGCPRO;
+    }
+
+  gtk_widget_show (filewin);
+
+  if (gtk_dialog_run (GTK_DIALOG (filewin)) == GTK_RESPONSE_OK)
+    fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filewin));
+
+  gtk_widget_destroy (filewin);
+
+  return fn;
+}
+#endif /* HAVE_GTK_FILE_CHOOSER_DIALOG_NEW */
+
+#ifdef HAVE_GTK_FILE_SELECTION_NEW
 /* Callback function invoked when the Ok button is pressed in
    a file dialog.
    W is the file dialog widget,
@@ -1167,7 +1250,7 @@
   *(int*)arg = XG_FILE_DESTROYED;
 }
 
-/* Read a file name from the user using a file dialog.
+/* Read a file name from the user using a file selection dialog.
    F is the current frame.
    PROMPT is a prompt to show to the user.  May not be NULL.
    DEFAULT_FILENAME is a default selection to be displayed.  May be NULL.
@@ -1177,12 +1260,13 @@
    Returns a file name or NULL if no file was selected.
    The returned string must be freed by the caller.  */
 
-char *
-xg_get_file_name (f, prompt, default_filename, mustmatch_p)
+static char *
+xg_get_file_with_selection (f, prompt, default_filename,
+                            mustmatch_p, only_dir_p)
      FRAME_PTR f;
      char *prompt;
      char *default_filename;
-     int mustmatch_p;
+     int mustmatch_p, only_dir_p;
 {
   GtkWidget *filewin;
   GtkFileSelection *filesel;
@@ -1193,9 +1277,7 @@
   filesel = GTK_FILE_SELECTION (filewin);
 
   xg_set_screen (filewin, f);
-
   gtk_widget_set_name (filewin, "emacs-filedialog");
-
   gtk_window_set_transient_for (GTK_WINDOW (filewin),
                                 GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)));
   gtk_window_set_destroy_with_parent (GTK_WINDOW (filewin), TRUE);
@@ -1237,6 +1319,49 @@
 
   return fn;
 }
+#endif /* HAVE_GTK_FILE_SELECTION_NEW */
+
+/* Read a file name from the user using a file dialog, either the old
+   file selection dialog, or the new file chooser dialog.  Which to use
+   depends on what the GTK version used has, and what the value of
+   gtk-use-old-file-dialog.
+   F is the current frame.
+   PROMPT is a prompt to show to the user.  May not be NULL.
+   DEFAULT_FILENAME is a default selection to be displayed.  May be NULL.
+   If MUSTMATCH_P is non-zero, the returned file name must be an existing
+   file.
+
+   Returns a file name or NULL if no file was selected.
+   The returned string must be freed by the caller.  */
+
+char *
+xg_get_file_name (f, prompt, default_filename, mustmatch_p, only_dir_p)
+     FRAME_PTR f;
+     char *prompt;
+     char *default_filename;
+     int mustmatch_p, only_dir_p;
+{
+#ifdef HAVE_GTK_FILE_BOTH
+  if (use_old_gtk_file_dialog)
+    return xg_get_file_with_selection (f, prompt, default_filename,
+                                       mustmatch_p, only_dir_p);
+  return xg_get_file_with_chooser (f, prompt, default_filename,
+                                   mustmatch_p, only_dir_p);
+
+#else /* not HAVE_GTK_FILE_BOTH */
+
+#ifdef HAVE_GTK_FILE_SELECTION_DIALOG_NEW
+  return xg_get_file_with_selection (f, prompt, default_filename,
+                                     mustmatch_p, only_dir_p);
+#endif
+#ifdef HAVE_GTK_FILE_CHOOSER_DIALOG_NEW
+  return xg_get_file_with_chooser (f, prompt, default_filename,
+                                   mustmatch_p, only_dir_p);
+#endif
+
+#endif /* HAVE_GTK_FILE_BOTH */
+  return 0;
+}
 
 
 /***********************************************************************
--- a/src/gtkutil.h	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/gtkutil.h	Sat Nov 06 17:52:02 2004 +0000
@@ -126,13 +126,18 @@
   struct _widget_value *free_list;
 } widget_value;
 
+#ifdef HAVE_GTK_FILE_BOTH
+extern int use_old_gtk_file_dialog;
+#endif
+
 extern widget_value *malloc_widget_value P_ ((void));
 extern void free_widget_value P_ ((widget_value *));
 
 extern char *xg_get_file_name P_ ((FRAME_PTR f,
                                    char *prompt,
                                    char *default_filename,
-                                   int mustmatch_p));
+                                   int mustmatch_p,
+                                   int only_dir_p));
 
 extern GtkWidget *xg_create_widget P_ ((char *type,
                                         char *name,
--- a/src/insdel.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/insdel.c	Sat Nov 06 17:52:02 2004 +0000
@@ -1464,7 +1464,7 @@
   Z -= len; Z_BYTE -= len_byte;
   adjust_after_replace (from, from_byte, Qnil, newlen, len_byte);
 }
-
+
 /* Replace the text from character positions FROM to TO with NEW,
    If PREPARE is nonzero, call prepare_to_modify_buffer.
    If INHERIT, the newly inserted text should inherit text properties
@@ -1641,6 +1641,122 @@
   update_compositions (from, GPT, CHECK_BORDER);
 }
 
+/* Replace the text from character positions FROM to TO with
+   the text in INS of length INSCHARS.
+   Keep the text properties that applied to the old characters
+   (extending them to all the new chars if there are more new chars).
+
+   Note that this does not yet handle markers quite right.
+
+   If MARKERS is nonzero, relocate markers.
+
+   Unlike most functions at this level, never call
+   prepare_to_modify_buffer and never call signal_after_change.  */
+
+void
+replace_range_2 (from, from_byte, to, to_byte, ins, inschars, insbytes, markers)
+     int from, from_byte, to, to_byte;
+     char *ins;
+     int inschars, insbytes, markers;
+{
+  int nbytes_del, nchars_del;
+  Lisp_Object temp;
+
+  CHECK_MARKERS ();
+
+  nchars_del = to - from;
+  nbytes_del = to_byte - from_byte;
+
+  if (nbytes_del <= 0 && insbytes == 0)
+    return;
+
+  /* Make sure point-max won't overflow after this insertion.  */
+  XSETINT (temp, Z_BYTE - nbytes_del + insbytes);
+  if (Z_BYTE - nbytes_del + insbytes != XINT (temp))
+    error ("Maximum buffer size exceeded");
+
+  /* Make sure the gap is somewhere in or next to what we are deleting.  */
+  if (from > GPT)
+    gap_right (from, from_byte);
+  if (to < GPT)
+    gap_left (to, to_byte, 0);
+
+  GAP_SIZE += nbytes_del;
+  ZV -= nchars_del;
+  Z -= nchars_del;
+  ZV_BYTE -= nbytes_del;
+  Z_BYTE -= nbytes_del;
+  GPT = from;
+  GPT_BYTE = from_byte;
+  if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
+
+  if (GPT_BYTE < GPT)
+    abort ();
+
+  if (GPT - BEG < BEG_UNCHANGED)
+    BEG_UNCHANGED = GPT - BEG;
+  if (Z - GPT < END_UNCHANGED)
+    END_UNCHANGED = Z - GPT;
+
+  if (GAP_SIZE < insbytes)
+    make_gap (insbytes - GAP_SIZE);
+
+  /* Copy the replacement text into the buffer.  */
+  bcopy (ins, GPT_ADDR, insbytes);
+
+#ifdef BYTE_COMBINING_DEBUG
+  /* We have copied text into the gap, but we have not marked
+     it as part of the buffer.  So we can use the old FROM and FROM_BYTE
+     here, for both the previous text and the following text.
+     Meanwhile, GPT_ADDR does point to
+     the text that has been stored by copy_text.  */
+  if (count_combining_before (GPT_ADDR, insbytes, from, from_byte)
+      || count_combining_after (GPT_ADDR, insbytes, from, from_byte))
+    abort ();
+#endif
+
+  GAP_SIZE -= insbytes;
+  GPT += inschars;
+  ZV += inschars;
+  Z += inschars;
+  GPT_BYTE += insbytes;
+  ZV_BYTE += insbytes;
+  Z_BYTE += insbytes;
+  if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor.  */
+
+  if (GPT_BYTE < GPT)
+    abort ();
+
+  /* Adjust the overlay center as needed.  This must be done after
+     adjusting the markers that bound the overlays.  */
+  if (nchars_del != inschars)
+    {
+      adjust_overlays_for_insert (from, inschars);
+      adjust_overlays_for_delete (from + inschars, nchars_del);
+    }
+
+  /* Adjust markers for the deletion and the insertion.  */
+  if (markers
+      && ! (nchars_del == 1 && inschars == 1))
+    adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
+				inschars, insbytes);
+
+  offset_intervals (current_buffer, from, inschars - nchars_del);
+
+  /* Relocate point as if it were a marker.  */
+  if (from < PT && nchars_del != inschars)
+    adjust_point ((from + inschars - (PT < to ? PT : to)),
+		  (from_byte + insbytes
+		   - (PT_BYTE < to_byte ? PT_BYTE : to_byte)));
+
+  if (insbytes == 0)
+    evaporate_overlays (from);
+
+  CHECK_MARKERS ();
+
+  MODIFF++;
+}
+
 /* Delete characters in current buffer
    from FROM up to (but not including) TO.
    If TO comes before FROM, we delete nothing.  */
--- a/src/keyboard.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/keyboard.c	Sat Nov 06 17:52:02 2004 +0000
@@ -3694,40 +3694,30 @@
      Discard the event if it would fill the last slot.  */
   if (kbd_fetch_ptr - 1 != kbd_store_ptr)
     {
-
-#if 0 /* The SELECTION_REQUEST_EVENT case looks bogus, and it's error
-	 prone to assign individual members for other events, in case
-	 the input_event structure is changed.  --2000-07-13, gerd.  */
-      struct input_event *sp = kbd_store_ptr;
-      sp->kind = event->kind;
-      if (event->kind == SELECTION_REQUEST_EVENT)
-	{
-	  /* We must not use the ordinary copying code for this case,
-	     since `part' is an enum and copying it might not copy enough
-	     in this case.  */
-	  bcopy (event, (char *) sp, sizeof (*event));
-	}
-      else
-
-	{
-	  sp->code = event->code;
-	  sp->part = event->part;
-	  sp->frame_or_window = event->frame_or_window;
-	  sp->arg = event->arg;
-	  sp->modifiers = event->modifiers;
-	  sp->x = event->x;
-	  sp->y = event->y;
-	  sp->timestamp = event->timestamp;
-	}
-#else
       *kbd_store_ptr = *event;
-#endif
-
       ++kbd_store_ptr;
     }
 }
 
 
+/* Put an input event back in the head of the event queue.  */
+
+void
+kbd_buffer_unget_event (event)
+     register struct input_event *event;
+{
+  if (kbd_fetch_ptr == kbd_buffer)
+    kbd_fetch_ptr = kbd_buffer + KBD_BUFFER_SIZE;
+
+  /* Don't let the very last slot in the buffer become full,  */
+  if (kbd_fetch_ptr - 1 != kbd_store_ptr)
+    {
+      --kbd_fetch_ptr;
+      *kbd_fetch_ptr = *event;
+    }
+}
+
+
 /* Generate HELP_EVENT input_events in BUFP which has room for
    SIZE events.  If there's not enough room in BUFP, ignore this
    event.
@@ -3938,7 +3928,8 @@
       /* These two kinds of events get special handling
 	 and don't actually appear to the command loop.
 	 We return nil for them.  */
-      if (event->kind == SELECTION_REQUEST_EVENT)
+      if (event->kind == SELECTION_REQUEST_EVENT
+	  || event->kind == SELECTION_CLEAR_EVENT)
 	{
 #ifdef HAVE_X11
 	  struct input_event copy;
@@ -3949,7 +3940,7 @@
 	  copy = *event;
 	  kbd_fetch_ptr = event + 1;
 	  input_pending = readable_events (0);
-	  x_handle_selection_request (&copy);
+	  x_handle_selection_event (&copy);
 #else
 	  /* We're getting selection request events, but we don't have
              a window system.  */
@@ -3957,22 +3948,6 @@
 #endif
 	}
 
-      else if (event->kind == SELECTION_CLEAR_EVENT)
-	{
-#ifdef HAVE_X11
-	  struct input_event copy;
-
-	  /* Remove it from the buffer before processing it.  */
-	  copy = *event;
-	  kbd_fetch_ptr = event + 1;
-	  input_pending = readable_events (0);
-	  x_handle_selection_clear (&copy);
-#else
-	  /* We're getting selection request events, but we don't have
-             a window system.  */
-	  abort ();
-#endif
-	}
 #if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (MAC_OS)
       else if (event->kind == DELETE_WINDOW_EVENT)
 	{
@@ -4201,7 +4176,8 @@
 
       /* These two kinds of events get special handling
 	 and don't actually appear to the command loop.  */
-      if (event->kind == SELECTION_REQUEST_EVENT)
+      if (event->kind == SELECTION_REQUEST_EVENT
+	  || event->kind == SELECTION_CLEAR_EVENT)
 	{
 #ifdef HAVE_X11
 	  struct input_event copy;
@@ -4212,25 +4188,7 @@
 	  copy = *event;
 	  kbd_fetch_ptr = event + 1;
 	  input_pending = readable_events (0);
-	  x_handle_selection_request (&copy);
-#else
-	  /* We're getting selection request events, but we don't have
-             a window system.  */
-	  abort ();
-#endif
-	}
-
-      else if (event->kind == SELECTION_CLEAR_EVENT)
-	{
-#ifdef HAVE_X11
-	  struct input_event copy;
-
-	  /* Remove it from the buffer before processing it,  */
-	  copy = *event;
-
-	  kbd_fetch_ptr = event + 1;
-	  input_pending = readable_events (0);
-	  x_handle_selection_clear (&copy);
+	  x_handle_selection_event (&copy);
 #else
 	  /* We're getting selection request events, but we don't have
              a window system.  */
@@ -11590,7 +11548,8 @@
       {
 	if (event == kbd_buffer + KBD_BUFFER_SIZE)
 	  event = kbd_buffer;
-	if (event->kind != SELECTION_REQUEST_EVENT)
+	if (event->kind != SELECTION_REQUEST_EVENT
+	    && event->kind != SELECTION_CLEAR_EVENT)
 	  {
 	    mark_object (event->x);
 	    mark_object (event->y);
--- a/src/keyboard.h	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/keyboard.h	Sat Nov 06 17:52:02 2004 +0000
@@ -330,6 +330,7 @@
 extern void kbd_buffer_store_event P_ ((struct input_event *));
 extern void kbd_buffer_store_event_hold P_ ((struct input_event *,
 					     struct input_event *));
+extern void kbd_buffer_unget_event P_ ((struct input_event *));
 #ifdef POLL_FOR_INPUT
 extern void poll_for_input_1 P_ ((void));
 #endif
--- a/src/lisp.h	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/lisp.h	Sat Nov 06 17:52:02 2004 +0000
@@ -3123,7 +3123,7 @@
 #ifdef HAVE_WINDOW_SYSTEM
 /* Defined in xfns.c, w32fns.c, or macfns.c */
 EXFUN (Fxw_display_color_p, 1);
-EXFUN (Fx_file_dialog, 4);
+EXFUN (Fx_file_dialog, 5);
 #endif /* HAVE_WINDOW_SYSTEM */
 
 /* Defined in xsmfns.c */
--- a/src/macfns.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/macfns.c	Sat Nov 06 17:52:02 2004 +0000
@@ -4216,22 +4216,23 @@
 
 extern Lisp_Object Qfile_name_history;
 
-DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 4, 0,
+DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,
        doc: /* Read file name, prompting with PROMPT in directory DIR.
 Use a file selection dialog.
 Select DEFAULT-FILENAME in the dialog's file selection box, if
-specified.  Ensure that file exists if MUSTMATCH is non-nil.  */)
-  (prompt, dir, default_filename, mustmatch)
-     Lisp_Object prompt, dir, default_filename, mustmatch;
+specified.  Ensure that file exists if MUSTMATCH is non-nil.
+If ONLY-DIR-P is non-nil, the user can only select directories.  */)
+  (prompt, dir, default_filename, mustmatch, only_dir_p)
+     Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p;
 {
   struct frame *f = SELECTED_FRAME ();
   Lisp_Object file = Qnil;
   int count = SPECPDL_INDEX ();
-  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
+  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
   char filename[1001];
   int default_filter_index = 1; /* 1: All Files, 2: Directories only  */
 
-  GCPRO5 (prompt, dir, default_filename, mustmatch, file);
+  GCPRO6 (prompt, dir, default_filename, mustmatch, file, only_dir_p);
   CHECK_STRING (prompt);
   CHECK_STRING (dir);
 
@@ -4245,7 +4246,8 @@
     NavDialogRef dialogRef;
     NavTypeListHandle fileTypes = NULL;
     NavUserAction userAction;
-    CFStringRef message=NULL, client=NULL, saveName = NULL;
+    CFStringRef message=NULL, client=NULL, saveName = NULL, ok = NULL;
+    CFStringRef title = NULL;
     
     BLOCK_INPUT;
     /* No need for a callback function because we are modal */
@@ -4268,13 +4270,19 @@
     options.clientName = client;
     */
 
-    /* Do Dired hack copied from w32fns.c */ 
-    if (!NILP(prompt) && strncmp (SDATA(prompt), "Dired", 5) == 0)
+    if (!NILP (only_dir_p))
       status = NavCreateChooseFolderDialog(&options, NULL, NULL, NULL,
 					   &dialogRef);
     else if (NILP (mustmatch)) 
       { 
 	/* This is a save dialog */
+	ok = CFStringCreateWithCString (NULL, "Ok", kCFStringEncodingUTF8);
+	title = CFStringCreateWithCString (NULL, "Enter name",
+	                                   kCFStringEncodingUTF8);
+	options.optionFlags |= kNavDontConfirmReplacement;
+	options.actionButtonLabel = ok;
+	options.windowTitle = title;
+
 	if (!NILP(default_filename))
 	  {
 	    saveName = CFStringCreateWithCString(NULL, SDATA(default_filename),
@@ -4282,20 +4290,10 @@
 	    options.saveFileName = saveName;
 	    options.optionFlags |= kNavSelectDefaultLocation;
 	  }
-	/* MAC_TODO: Find a better way to determine if this is a save
-	   or load dialog than comparing dir with default_filename */
-	if (EQ(dir, default_filename)) 
-	  {
-	    status = NavCreateChooseFileDialog(&options, fileTypes,
-					       NULL, NULL, NULL, NULL, 
-					       &dialogRef);
-	  }
-	else {
 	  status = NavCreatePutFileDialog(&options, 
 					  'TEXT', kNavGenericSignature,
 					  NULL, NULL, &dialogRef);
 	}
-      }
     else
       {
 	/* This is an open dialog*/
@@ -4324,6 +4322,8 @@
     if (saveName) CFRelease(saveName);
     if (client) CFRelease(client);
     if (message) CFRelease(message);
+    if (ok) CFRelease(ok);
+    if (title) CFRelease(title);
 
     if (status == noErr) {
       userAction = NavDialogGetUserAction(dialogRef);
--- a/src/process.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/process.c	Sat Nov 06 17:52:02 2004 +0000
@@ -310,6 +310,7 @@
 
 static SELECT_TYPE non_process_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
    and added to the input_wait_mask and non_keyboard_wait_mask.  */
@@ -319,6 +320,11 @@
 /* Number of bits set in connect_wait_mask.  */
 static int num_pending_connects;
 
+#define IF_NON_BLOCKING_CONNECT(s) s
+#else
+#define IF_NON_BLOCKING_CONNECT(s)
+#endif
+
 /* The largest descriptor currently in use for a process object.  */
 static int max_process_desc;
 
@@ -3672,12 +3678,14 @@
       chan_process[inchannel] = Qnil;
       FD_CLR (inchannel, &input_wait_mask);
       FD_CLR (inchannel, &non_keyboard_wait_mask);
+#ifdef NON_BLOCKING_CONNECT
       if (FD_ISSET (inchannel, &connect_wait_mask))
 	{
 	  FD_CLR (inchannel, &connect_wait_mask);
 	  if (--num_pending_connects < 0)
 	    abort ();
 	}
+#endif
       if (inchannel == max_process_desc)
 	{
 	  int i;
@@ -4038,8 +4046,11 @@
 {
   register int channel, nfds;
   SELECT_TYPE Available;
+#ifdef NON_BLOCKING_CONNECT
   SELECT_TYPE Connecting;
-  int check_connect, check_delay, no_avail;
+  int check_connect;
+#endif
+  int check_delay, no_avail;
   int xerrno;
   Lisp_Object proc;
   EMACS_TIME timeout, end_time;
@@ -4050,7 +4061,9 @@
   int saved_waiting_for_user_input_p = waiting_for_user_input_p;
 
   FD_ZERO (&Available);
+#ifdef NON_BLOCKING_CONNECT
   FD_ZERO (&Connecting);
+#endif
 
   /* If wait_proc is a process to watch, set wait_channel accordingly.  */
   if (wait_proc != NULL)
@@ -4187,7 +4200,10 @@
 	 timeout to get our attention.  */
       if (update_tick != process_tick && do_display)
 	{
-	  SELECT_TYPE Atemp, Ctemp;
+	  SELECT_TYPE Atemp;
+#ifdef NON_BLOCKING_CONNECT
+	  SELECT_TYPE Ctemp;
+#endif
 
 	  Atemp = input_wait_mask;
 #if 0
@@ -4199,11 +4215,16 @@
 	  */
           FD_CLR (0, &Atemp);
 #endif
-	  Ctemp = connect_wait_mask;
+	  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,
 		       &Atemp,
+#ifdef NON_BLOCKING_CONNECT
 		       (num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0),
+#else
+		       (SELECT_TYPE *)0,
+#endif
 		       (SELECT_TYPE *)0, &timeout)
 	       <= 0))
 	    {
@@ -4263,12 +4284,14 @@
 	  if (XINT (wait_proc->infd) < 0)  /* Terminated */
 	    break;
 	  FD_SET (XINT (wait_proc->infd), &Available);
-	  check_connect = check_delay = 0;
+	  check_delay = 0;
+	  IF_NON_BLOCKING_CONNECT (check_connect = 0);
 	}
       else if (!NILP (wait_for_cell))
 	{
 	  Available = non_process_wait_mask;
-	  check_connect = check_delay = 0;
+	  check_delay = 0;
+	  IF_NON_BLOCKING_CONNECT (check_connect = 0);
 	}
       else
 	{
@@ -4276,7 +4299,7 @@
 	    Available = non_keyboard_wait_mask;
 	  else
 	    Available = input_wait_mask;
-	  check_connect = (num_pending_connects > 0);
+	  IF_NON_BLOCKING_CONNECT (check_connect = (num_pending_connects > 0));
  	  check_delay = wait_channel >= 0 ? 0 : process_output_delay_count;
 	}
 
@@ -4301,8 +4324,10 @@
 	}
       else
 	{
+#ifdef NON_BLOCKING_CONNECT
 	  if (check_connect)
 	    Connecting = connect_wait_mask;
+#endif
 
 #ifdef ADAPTIVE_READ_BUFFERING
 	  if (process_output_skip && check_delay > 0)
@@ -4333,7 +4358,11 @@
 
 	  nfds = select (max (max_process_desc, max_keyboard_desc) + 1,
 			 &Available,
+#ifdef NON_BLOCKING_CONNECT
 			 (check_connect ? &Connecting : (SELECT_TYPE *)0),
+#else
+			 (SELECT_TYPE *)0,
+#endif
 			 (SELECT_TYPE *)0, &timeout);
 	}
 
@@ -4389,7 +4418,7 @@
       if (no_avail)
 	{
 	  FD_ZERO (&Available);
-	  check_connect = 0;
+	  IF_NON_BLOCKING_CONNECT (check_connect = 0);
 	}
 
 #if defined(sun) && !defined(USG5_4)
@@ -6620,6 +6649,11 @@
   FD_ZERO (&non_process_wait_mask);
   max_process_desc = 0;
 
+#ifdef NON_BLOCKING_CONNECT
+  FD_ZERO (&connect_wait_mask);
+  num_pending_connects = 0;
+#endif
+
 #ifdef ADAPTIVE_READ_BUFFERING
   process_output_delay_count = 0;
   process_output_skip = 0;
--- a/src/w32fns.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/w32fns.c	Sat Nov 06 17:52:02 2004 +0000
@@ -5607,14 +5607,12 @@
     char * fontname;
     char * pattern;
 {
+  char *ptr;
   char *font_name_copy;
-  char *ptr;
-  Lisp_Object encoded_font_name;
   char *regex = alloca (strlen (pattern) * 2 + 3);
 
-  /* Convert fontname to unibyte for match.  */
-  encoded_font_name = string_make_unibyte (build_string (fontname));
-  font_name_copy = SDATA (encoded_font_name);
+  font_name_copy = alloca (strlen (fontname) + 1);
+  strcpy (font_name_copy, fontname);
 
   ptr = regex;
   *ptr++ = '^';
@@ -5652,8 +5650,8 @@
       return FALSE;
   }
 
-  return (fast_c_string_match_ignore_case (build_string (regex),
-                                           font_name_copy) >= 0);
+  return (fast_string_match_ignore_case (build_string (regex),
+                                         build_string(font_name_copy)) >= 0);
 }
 
 /* Callback functions, and a structure holding info they need, for
@@ -7742,23 +7740,24 @@
   return 0;
 }
 
-DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 4, 0,
+DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,
        doc: /* Read file name, prompting with PROMPT in directory DIR.
 Use a file selection dialog.
 Select DEFAULT-FILENAME in the dialog's file selection box, if
-specified.  Ensure that file exists if MUSTMATCH is non-nil.  */)
-  (prompt, dir, default_filename, mustmatch)
-     Lisp_Object prompt, dir, default_filename, mustmatch;
+specified.  Ensure that file exists if MUSTMATCH is non-nil.
+If ONLY-DIR-P is non-nil, the user can only select directories.  */)
+  (prompt, dir, default_filename, mustmatch, only_dir_p)
+     Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p;
 {
   struct frame *f = SELECTED_FRAME ();
   Lisp_Object file = Qnil;
   int count = SPECPDL_INDEX ();
-  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
+  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
   char filename[MAX_PATH + 1];
   char init_dir[MAX_PATH + 1];
   int default_filter_index = 1; /* 1: All Files, 2: Directories only  */
 
-  GCPRO5 (prompt, dir, default_filename, mustmatch, file);
+  GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file);
   CHECK_STRING (prompt);
   CHECK_STRING (dir);
 
@@ -7806,10 +7805,7 @@
     file_details.lpstrInitialDir = init_dir;
     file_details.lpstrTitle = SDATA (prompt);
 
-    /* If prompt starts with Dired, default to directories only.  */
-    /* A bit hacky, but there doesn't seem to be a better way to
-       DTRT for dired.  */
-    if (strncmp (file_details.lpstrTitle, "Dired", 5) == 0)
+    if (! NILP (only_dir_p))
       default_filter_index = 2;
 
     file_details.nFilterIndex = default_filter_index;
--- a/src/w32term.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/w32term.c	Sat Nov 06 17:52:02 2004 +0000
@@ -2763,9 +2763,13 @@
     /* If the dirty region is not what we expected, redraw the entire frame.  */
     if (!EqualRgn (combined, expect_dirty))
       SET_FRAME_GARBAGED (f);
+
+    DeleteObject (dirty);
+    DeleteObject (combined);
   }
 
   UNBLOCK_INPUT;
+  DeleteObject (expect_dirty);
 }
 
 
--- a/src/window.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/window.c	Sat Nov 06 17:52:02 2004 +0000
@@ -4627,17 +4627,25 @@
       w->force_start = Qt;
     }
 
+  /* The rest of this function uses current_y in a nonstandard way,
+     not including the height of the header line if any.  */
   it.current_y = it.vpos = 0;
 
-  /* Preserve the screen position if we must.  */
+  /* Preserve the screen position if we should.  */
   if (preserve_y >= 0)
     {
+      /* If we have a header line, take account of it.  */
+      if (WINDOW_WANTS_HEADER_LINE_P (w))
+	preserve_y -= CURRENT_HEADER_LINE_HEIGHT (w);
+
       move_it_to (&it, -1, -1, preserve_y, -1, MOVE_TO_Y);
       SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
     }
   else
     {
-      /* Move PT out of scroll margins.  */
+      /* Move PT out of scroll margins.
+	 This code wants current_y to be zero at the window start position
+	 even if there is a header line.  */
       this_scroll_margin = max (0, scroll_margin);
       this_scroll_margin = min (this_scroll_margin, XFASTINT (w->total_lines) / 4);
       this_scroll_margin *= FRAME_LINE_HEIGHT (it.f);
@@ -4992,17 +5000,17 @@
   return Qnil;
 }
 
-DEFUN ("scroll-left", Fscroll_left, Sscroll_left, 0, 1, "P",
+DEFUN ("scroll-left", Fscroll_left, Sscroll_left, 0, 2, "P\np",
        doc: /* Scroll selected window display ARG columns left.
 Default for ARG is window width minus 2.
 Value is the total amount of leftward horizontal scrolling in
 effect after the change.
-If `automatic-hscrolling' is non-nil, the argument ARG modifies
-a lower bound for automatic scrolling, i.e. automatic scrolling
+If SET_MINIMUM is non-nil, the new scroll amount becomes the
+lower bound for automatic scrolling, i.e. automatic scrolling
 will not scroll a window to a column less than the value returned
-by this function.  */)
-     (arg)
-     register Lisp_Object arg;
+by this function.  This happens in an interactive call.  */)
+     (arg, set_minimum)
+     register Lisp_Object arg, set_minimum;
 {
   Lisp_Object result;
   int hscroll;
@@ -5016,23 +5024,23 @@
   hscroll = XINT (w->hscroll) + XINT (arg);
   result = Fset_window_hscroll (selected_window, make_number (hscroll));
 
-  if (interactive_p (0))
+  if (!NILP (set_minimum))
     w->min_hscroll = w->hscroll;
 
   return result;
 }
 
-DEFUN ("scroll-right", Fscroll_right, Sscroll_right, 0, 1, "P",
+DEFUN ("scroll-right", Fscroll_right, Sscroll_right, 0, 2, "P\np",
        doc: /* Scroll selected window display ARG columns right.
 Default for ARG is window width minus 2.
 Value is the total amount of leftward horizontal scrolling in
 effect after the change.
-If `automatic-hscrolling' is non-nil, the argument ARG modifies
-a lower bound for automatic scrolling, i.e. automatic scrolling
+If SET_MINIMUM is non-nil, the new scroll amount becomes the
+lower bound for automatic scrolling, i.e. automatic scrolling
 will not scroll a window to a column less than the value returned
-by this function.  */)
-     (arg)
-     register Lisp_Object arg;
+by this function.  This happens in an interactive call.  */)
+     (arg, set_minimum)
+     register Lisp_Object arg, set_minimum;
 {
   Lisp_Object result;
   int hscroll;
@@ -5046,7 +5054,7 @@
   hscroll = XINT (w->hscroll) - XINT (arg);
   result = Fset_window_hscroll (selected_window, make_number (hscroll));
 
-  if (interactive_p (0))
+  if (!NILP (set_minimum))
     w->min_hscroll = w->hscroll;
 
   return result;
--- a/src/xdisp.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/xdisp.c	Sat Nov 06 17:52:02 2004 +0000
@@ -4554,7 +4554,8 @@
 	{
 	  Lisp_Object prop;
 
-	  prop = Fget_char_property (make_number (IT_CHARPOS (*it)),
+	  /* Check the newline before point for invisibility.  */
+	  prop = Fget_char_property (make_number (IT_CHARPOS (*it) - 1),
 				     Qinvisible, it->window);
 	  if (TEXT_PROP_MEANS_INVISIBLE (prop))
 	    visible_p = 0;
@@ -8414,7 +8415,8 @@
 	{
 	  struct buffer *prev = current_buffer;
 	  int count = SPECPDL_INDEX ();
-	  Lisp_Object old_tool_bar;
+	  Lisp_Object new_tool_bar;
+          int new_n_tool_bar;
 	  struct gcpro gcpro1;
 
 	  /* Set current_buffer to the buffer of the selected
@@ -8433,18 +8435,24 @@
 	      specbind (Qoverriding_local_map, Qnil);
 	    }
 
-	  old_tool_bar = f->tool_bar_items;
-	  GCPRO1 (old_tool_bar);
+	  GCPRO1 (new_tool_bar);
 
 	  /* Build desired tool-bar items from keymaps.  */
-          BLOCK_INPUT;
-	  f->tool_bar_items
-	    = tool_bar_items (f->tool_bar_items, &f->n_tool_bar_items);
-          UNBLOCK_INPUT;
+          new_tool_bar = tool_bar_items (Fcopy_sequence (f->tool_bar_items),
+                                         &new_n_tool_bar);
 
 	  /* Redisplay the tool-bar if we changed it.  */
-	  if (! NILP (Fequal (old_tool_bar, f->tool_bar_items)))
-	    w->update_mode_line = Qt;
+	  if (NILP (Fequal (new_tool_bar, f->tool_bar_items)))
+            {
+              /* Redisplay that happens asynchronously due to an expose event
+                 may access f->tool_bar_items.  Make sure we update both
+                 variables within BLOCK_INPUT so no such event interrupts.  */
+              BLOCK_INPUT;
+              f->tool_bar_items = new_tool_bar;
+              f->n_tool_bar_items = new_n_tool_bar;
+              w->update_mode_line = Qt;
+              UNBLOCK_INPUT;
+            }
 
 	  UNGCPRO;
 
--- a/src/xfns.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/xfns.c	Sat Nov 06 17:52:02 2004 +0000
@@ -5130,27 +5130,26 @@
 }
 
 
-DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 4, 0,
+DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,
        doc: /* Read file name, prompting with PROMPT in directory DIR.
-Use a file selection dialog.
-Select DEFAULT-FILENAME in the dialog's file selection box, if
-specified.  Don't let the user enter a file name in the file
-selection dialog's entry field, if MUSTMATCH is non-nil.  */)
-     (prompt, dir, default_filename, mustmatch)
-     Lisp_Object prompt, dir, default_filename, mustmatch;
+Use a file selection dialog.  Select DEFAULT-FILENAME in the dialog's file
+selection box, if specified.  If MUSTMATCH is non-nil, the returned file
+or directory must exist.  ONLY-DIR-P is ignored."  */)
+  (prompt, dir, default_filename, mustmatch, only_dir_p)
+     Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p;
 {
   int result;
   struct frame *f = SELECTED_FRAME ();
   Lisp_Object file = Qnil;
-  Widget dialog, text, list, help;
+  Widget dialog, text, help;
   Arg al[10];
   int ac = 0;
   extern XtAppContext Xt_app_con;
   XmString dir_xmstring, pattern_xmstring;
   int count = SPECPDL_INDEX ();
-  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
-
-  GCPRO5 (prompt, dir, default_filename, mustmatch, file);
+  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
+
+  GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file);
   CHECK_STRING (prompt);
   CHECK_STRING (dir);
 
@@ -5183,9 +5182,9 @@
   XtAddCallback (dialog, XmNunmapCallback, file_dialog_unmap_cb,
 		 (XtPointer) &result);
 
-  /* Disable the help button since we can't display help.  */
+  /* Remove the help button since we can't display help.  */
   help = XmFileSelectionBoxGetChild (dialog, XmDIALOG_HELP_BUTTON);
-  XtSetSensitive (help, False);
+  XtUnmanageChild (help);
 
   /* Mark OK button as default.  */
   XtVaSetValues (XmFileSelectionBoxGetChild (dialog, XmDIALOG_OK_BUTTON),
@@ -5207,30 +5206,30 @@
   /* Manage the dialog, so that list boxes get filled.  */
   XtManageChild (dialog);
 
-  /* Select DEFAULT_FILENAME in the files list box.  DEFAULT_FILENAME
-     must include the path for this to work.  */
-  list = XmFileSelectionBoxGetChild (dialog, XmDIALOG_LIST);
   if (STRINGP (default_filename))
     {
       XmString default_xmstring;
-      int item_pos;
-
-      default_xmstring
-	= XmStringCreateLocalized (SDATA (default_filename));
-
-      if (!XmListItemExists (list, default_xmstring))
-	{
-	  /* Add a new item if DEFAULT_FILENAME is not in the list.  */
-	  XmListAddItem (list, default_xmstring, 0);
-	  item_pos = 0;
-	}
-      else
-	item_pos = XmListItemPos (list, default_xmstring);
+      Widget wtext = XmFileSelectionBoxGetChild (dialog, XmDIALOG_TEXT);
+      Widget list = XmFileSelectionBoxGetChild (dialog, XmDIALOG_LIST);
+
+      XmTextPosition last_pos = XmTextFieldGetLastPosition (wtext);
+      XmTextFieldReplace (wtext, 0, last_pos,
+                          (SDATA (Ffile_name_nondirectory (default_filename))));
+
+      /* Select DEFAULT_FILENAME in the files list box.  DEFAULT_FILENAME
+         must include the path for this to work.  */
+
+      default_xmstring = XmStringCreateLocalized (SDATA (default_filename));
+
+      if (XmListItemExists (list, default_xmstring))
+        {
+          int item_pos = XmListItemPos (list, default_xmstring);
+          /* Select the item and scroll it into view.  */
+          XmListSelectPos (list, item_pos, True);
+          XmListSetPos (list, item_pos);
+        }
+
       XmStringFree (default_xmstring);
-
-      /* Select the item and scroll it into view.  */
-      XmListSelectPos (list, item_pos, True);
-      XmListSetPos (list, item_pos);
     }
 
   /* Process events until the user presses Cancel or OK.  */
@@ -5274,23 +5273,23 @@
 
 #ifdef USE_GTK
 
-DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 4, 0,
-  "Read file name, prompting with PROMPT in directory DIR.\n\
-Use a file selection dialog.\n\
-Select DEFAULT-FILENAME in the dialog's file selection box, if\n\
-specified.  Don't let the user enter a file name in the file\n\
-selection dialog's entry field, if MUSTMATCH is non-nil.")
-  (prompt, dir, default_filename, mustmatch)
-     Lisp_Object prompt, dir, default_filename, mustmatch;
+DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,
+       doc: /* Read file name, prompting with PROMPT in directory DIR.
+Use a file selection dialog.  Select DEFAULT-FILENAME in the dialog's file
+selection box, if specified.  If MUSTMATCH is non-nil, the returned file
+or directory must exist.  If ONLY-DIR-P is non-nil, the user can only select
+directories.  */)
+  (prompt, dir, default_filename, mustmatch, only_dir_p)
+     Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p;
 {
   FRAME_PTR f = SELECTED_FRAME ();
   char *fn;
   Lisp_Object file = Qnil;
   int count = specpdl_ptr - specpdl;
-  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
+  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
   char *cdef_file;
 
-  GCPRO5 (prompt, dir, default_filename, mustmatch, file);
+  GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file);
   CHECK_STRING (prompt);
   CHECK_STRING (dir);
 
@@ -5304,7 +5303,9 @@
   else
     cdef_file = SDATA (dir);
 
-  fn = xg_get_file_name (f, SDATA (prompt), cdef_file, ! NILP (mustmatch));
+  fn = xg_get_file_name (f, SDATA (prompt), cdef_file,
+                         ! NILP (mustmatch),
+                         ! NILP (only_dir_p));
 
   if (fn)
     {
@@ -5580,6 +5581,14 @@
   Fprovide (intern ("x-toolkit"), Qnil);
   Fprovide (intern ("gtk"), Qnil);
 
+#ifdef HAVE_GTK_FILE_BOTH
+  DEFVAR_BOOL ("use-old-gtk-file-dialog", &use_old_gtk_file_dialog,
+    doc: /* *Non-nil means that the old GTK file selection dialog is used.
+If nil the new GTK file chooser is used instead.  To turn off
+all file dialogs set the variable `use-file-dialog'.  */);
+  use_old_gtk_file_dialog = 0;
+#endif
+
   DEFVAR_LISP ("gtk-version-string", &Vgtk_version_string,
                doc: /* Version info for GTK+.  */);
   {
--- a/src/xmenu.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/xmenu.c	Sat Nov 06 17:52:02 2004 +0000
@@ -110,11 +110,12 @@
 extern Lisp_Object Qmenu_bar_update_hook;
 
 #ifdef USE_X_TOOLKIT
-extern void set_frame_menubar ();
+extern void set_frame_menubar P_ ((FRAME_PTR, int, int));
 extern XtAppContext Xt_app_con;
 
-static Lisp_Object xdialog_show ();
-static void popup_get_selection ();
+static Lisp_Object xdialog_show P_ ((FRAME_PTR, int, Lisp_Object, char **));
+static void popup_get_selection P_ ((XEvent *, struct x_display_info *,
+                                     LWLIB_ID, int));
 
 /* Define HAVE_BOXES if menus can handle radio and toggle buttons.  */
 
@@ -124,8 +125,8 @@
 #ifdef USE_GTK
 #include "gtkutil.h"
 #define HAVE_BOXES 1
-extern void set_frame_menubar ();
-static Lisp_Object xdialog_show ();
+extern void set_frame_menubar P_ ((FRAME_PTR, int, int));
+static Lisp_Object xdialog_show P_ ((FRAME_PTR, int, Lisp_Object, char **));
 #endif
 
 /* This is how to deal with multibyte text if HAVE_MULTILINGUAL_MENU
@@ -156,7 +157,6 @@
 static void list_of_panes P_ ((Lisp_Object));
 static void list_of_items P_ ((Lisp_Object));
 
-extern EMACS_TIME timer_check P_ ((int));
 
 /* This holds a Lisp vector that holds the results of decoding
    the keymaps or alist-of-alists that specify a menu.
@@ -1120,29 +1120,28 @@
    popped down (deactivated).  This is used for x-popup-menu
    and x-popup-dialog; it is not used for the menu bar.
 
-   If DO_TIMERS is nonzero, run timers.
    If DOWN_ON_KEYPRESS is nonzero, pop down if a key is pressed.
 
+   This function used to have a DO_TIMERS argument which was
+   1 in the dialog case, and caused it to run Lisp-level timers.
+   That was unsafe so we removed it, but does anyone remember
+   why menus and dialogs were treated differently?
+
    NOTE: All calls to popup_get_selection should be protected
    with BLOCK_INPUT, UNBLOCK_INPUT wrappers.  */
 
 #ifdef USE_X_TOOLKIT
 static void
-popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress)
+popup_get_selection (initial_event, dpyinfo, id, down_on_keypress)
      XEvent *initial_event;
      struct x_display_info *dpyinfo;
      LWLIB_ID id;
-     int do_timers;
      int down_on_keypress;
 {
   XEvent event;
 
   while (popup_activated_flag)
     {
-      /* If we have no events to run, consider timers.  */
-      if (do_timers && !XtAppPending (Xt_app_con))
-        timer_check (1);
-
       if (initial_event)
         {
           event = *initial_event;
@@ -2489,7 +2488,7 @@
   popup_activated_flag = 1;
 
   /* Process events that apply to the menu.  */
-  popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), menu_id, 0, 0);
+  popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), menu_id, 0);
 
   /* fp turned off the following statement and wrote a comment
      that it is unnecessary--that the menu has already disappeared.
@@ -2883,8 +2882,7 @@
                            Fcons (make_number (dialog_id >> (fact)),
                                   make_number (dialog_id & ~(-1 << (fact)))));
 
-    popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f),
-                         dialog_id, 1, 1);
+    popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), dialog_id, 1);
 
     unbind_to (count, Qnil);
   }
--- a/src/xselect.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/xselect.c	Sat Nov 06 17:52:02 2004 +0000
@@ -32,6 +32,7 @@
 #include "buffer.h"
 #include "process.h"
 #include "termhooks.h"
+#include "keyboard.h"
 
 #include <X11/Xproto.h>
 
@@ -85,10 +86,13 @@
   fprintf (stderr, "%d: " fmt "\n", getpid (), a0)
 #define TRACE2(fmt, a0, a1) \
   fprintf (stderr, "%d: " fmt "\n", getpid (), a0, a1)
+#define TRACE3(fmt, a0, a1, a2) \
+  fprintf (stderr, "%d: " fmt "\n", getpid (), a0, a1, a2)
 #else
 #define TRACE0(fmt)		(void) 0
 #define TRACE1(fmt, a0)		(void) 0
 #define TRACE2(fmt, a0, a1)	(void) 0
+#define TRACE3(fmt, a0, a1)	(void) 0
 #endif
 
 
@@ -168,6 +172,86 @@
 static Lisp_Object selection_data_to_lisp_data ();
 static Lisp_Object x_get_window_property_as_lisp_data ();
 
+
+
+/* Define a queue to save up SelectionRequest events for later handling.  */
+
+struct selection_event_queue
+  {
+    struct input_event event;
+    struct selection_event_queue *next;
+  };
+
+static struct selection_event_queue *selection_queue;
+
+/* Nonzero means queue up certain events--don't process them yet.  */
+
+static int x_queue_selection_requests;
+
+/* Queue up an X event *EVENT, to be processed later.  */
+
+static void
+x_queue_event (event)
+     struct input_event *event;
+{
+  struct selection_event_queue *queue_tmp;
+
+  /* Don't queue repeated requests */
+  for (queue_tmp = selection_queue; queue_tmp; queue_tmp = queue_tmp->next)
+    {
+      if (!bcmp (&queue_tmp->event, event, sizeof (*event)))
+	{
+	  TRACE1 ("IGNORE DUP SELECTION EVENT %08x", (unsigned long)queue_tmp);
+	  return;
+	}
+    }
+
+  queue_tmp
+    = (struct selection_event_queue *) xmalloc (sizeof (struct selection_event_queue));
+
+  if (queue_tmp != NULL)
+    {
+      TRACE1 ("QUEUE SELECTION EVENT %08x", (unsigned long)queue_tmp);
+      queue_tmp->event = *event;
+      queue_tmp->next = selection_queue;
+      selection_queue = queue_tmp;
+    }
+}
+
+/* Start queuing SelectionRequest events.  */
+
+static void
+x_start_queuing_selection_requests ()
+{
+  if (x_queue_selection_requests)
+    abort ();
+
+  x_queue_selection_requests++;
+  TRACE1 ("x_start_queuing_selection_requests %d", x_queue_selection_requests);
+}
+
+/* Stop queuing SelectionRequest events.  */
+
+static void
+x_stop_queuing_selection_requests ()
+{
+  TRACE1 ("x_stop_queuing_selection_requests %d", x_queue_selection_requests);
+  --x_queue_selection_requests;
+
+  /* Take all the queued events and put them back
+     so that they get processed afresh.  */
+
+  while (selection_queue != NULL)
+    {
+      struct selection_event_queue *queue_tmp = selection_queue;
+      TRACE1 ("RESTORE SELECTION EVENT %08x", (unsigned long)queue_tmp);
+      kbd_buffer_unget_event (&queue_tmp->event);
+      selection_queue = queue_tmp->next;
+      xfree ((char *)queue_tmp);
+    }
+}
+
+
 /* This converts a Lisp symbol to a server Atom, avoiding a server
    roundtrip whenever possible.  */
 
@@ -564,13 +648,10 @@
 static struct prop_location *property_change_wait_list;
 
 static Lisp_Object
-queue_selection_requests_unwind (frame)
-     Lisp_Object frame;
+queue_selection_requests_unwind (tem)
+     Lisp_Object tem;
 {
-  FRAME_PTR f = XFRAME (frame);
-
-  if (! NILP (frame))
-    x_stop_queuing_selection_requests (FRAME_X_DISPLAY (f));
+  x_stop_queuing_selection_requests ();
   return Qnil;
 }
 
@@ -631,6 +712,17 @@
   BLOCK_INPUT;
   count = x_catch_errors (display);
 
+#ifdef TRACE_SELECTION
+  {
+    static int cnt;
+    char *sel = XGetAtomName (display, reply.selection);
+    char *tgt = XGetAtomName (display, reply.target);
+    TRACE3 ("%s, target %s (%d)", sel, tgt, ++cnt);
+    if (sel) XFree (sel);
+    if (tgt) XFree (tgt);
+  }
+#endif /* TRACE_SELECTION */
+
   /* Store the data on the requested property.
      If the selection is large, only store the first N bytes of it.
    */
@@ -658,10 +750,10 @@
 	 bother trying to queue them.  */
       if (!NILP (frame))
 	{
-	  x_start_queuing_selection_requests (display);
+	  x_start_queuing_selection_requests ();
 
 	  record_unwind_protect (queue_selection_requests_unwind,
-				 frame);
+				 Qnil);
 	}
 
       if (x_window_to_frame (dpyinfo, window)) /* #### debug */
@@ -695,6 +787,8 @@
 		  XGetAtomName (display, reply.property));
 	  wait_for_property_change (wait_object);
 	}
+      else
+	unexpect_property_change (wait_object);
 
       TRACE0 ("Got ACK");
       while (bytes_remaining)
@@ -768,7 +862,7 @@
 /* Handle a SelectionRequest event EVENT.
    This is called from keyboard.c when such an event is found in the queue.  */
 
-void
+static void
 x_handle_selection_request (event)
      struct input_event *event;
 {
@@ -783,6 +877,8 @@
   struct x_display_info *dpyinfo
     = x_display_info_for_display (SELECTION_EVENT_DISPLAY (event));
 
+  TRACE0 ("x_handle_selection_request");
+
   local_selection_data = Qnil;
   target_symbol = Qnil;
   converted_selection = Qnil;
@@ -877,7 +973,7 @@
    client cleared out our previously asserted selection.
    This is called from keyboard.c when such an event is found in the queue.  */
 
-void
+static void
 x_handle_selection_clear (event)
      struct input_event *event;
 {
@@ -890,6 +986,8 @@
   struct x_display_info *dpyinfo = x_display_info_for_display (display);
   struct x_display_info *t_dpyinfo;
 
+  TRACE0 ("x_handle_selection_clear");
+
   /* If the new selection owner is also Emacs,
      don't clear the new selection.  */
   BLOCK_INPUT;
@@ -958,6 +1056,24 @@
   }
 }
 
+void
+x_handle_selection_event (event)
+     struct input_event *event;
+{
+  TRACE0 ("x_handle_selection_event");
+
+  if (event->kind == SELECTION_REQUEST_EVENT)
+    {
+      if (x_queue_selection_requests)
+	x_queue_event (event);
+      else
+	x_handle_selection_request (event);
+    }
+  else
+    x_handle_selection_clear (event);
+}
+
+
 /* Clear all selections that were made from frame F.
    We do this when about to delete a frame.  */
 
@@ -1088,12 +1204,14 @@
 /* Remove the property change expectation element for IDENTIFIER.  */
 
 static Lisp_Object
-wait_for_property_change_unwind (identifierval)
-     Lisp_Object identifierval;
+wait_for_property_change_unwind (loc)
+     Lisp_Object loc;
 {
-  unexpect_property_change ((struct prop_location *)
-			    (XFASTINT (XCAR (identifierval)) << 16
-			     | XFASTINT (XCDR (identifierval))));
+  struct prop_location *location = XSAVE_VALUE (loc)->pointer;
+
+  unexpect_property_change (location);
+  if (location == property_change_reply_object)
+    property_change_reply_object = 0;
   return Qnil;
 }
 
@@ -1106,18 +1224,17 @@
 {
   int secs, usecs;
   int count = SPECPDL_INDEX ();
-  Lisp_Object tem;
-
-  tem = Fcons (Qnil, Qnil);
-  XSETCARFASTINT (tem, (EMACS_UINT)location >> 16);
-  XSETCDRFASTINT (tem, (EMACS_UINT)location & 0xffff);
+
+  if (property_change_reply_object)
+    abort ();
 
   /* Make sure to do unexpect_property_change if we quit or err.  */
-  record_unwind_protect (wait_for_property_change_unwind, tem);
+  record_unwind_protect (wait_for_property_change_unwind,
+			 make_save_value (location, 0));
 
   XSETCAR (property_change_reply, Qnil);
-
   property_change_reply_object = location;
+
   /* If the event we are waiting for arrives beyond here, it will set
      property_change_reply, because property_change_reply_object says so.  */
   if (! location->arrived)
@@ -1148,7 +1265,8 @@
 
   while (rest)
     {
-      if (rest->property == event->atom
+      if (!rest->arrived
+	  && rest->property == event->atom
 	  && rest->window == event->window
 	  && rest->display == event->display
 	  && rest->desired_state == event->state)
@@ -1164,11 +1282,6 @@
 	  if (rest == property_change_reply_object)
 	    XSETCAR (property_change_reply, Qt);
 
-	  if (prev)
-	    prev->next = rest->next;
-	  else
-	    property_change_wait_list = rest->next;
-	  xfree (rest);
 	  return;
 	}
 
@@ -1303,10 +1416,10 @@
      bother trying to queue them.  */
   if (!NILP (frame))
     {
-      x_start_queuing_selection_requests (display);
+      x_start_queuing_selection_requests ();
 
       record_unwind_protect (queue_selection_requests_unwind,
-			     frame);
+			     Qnil);
     }
   UNBLOCK_INPUT;
 
@@ -1462,10 +1575,10 @@
   BLOCK_INPUT;
   XSelectInput (display, window, STANDARD_EVENT_SET | PropertyChangeMask);
   TRACE1 ("  Delete property %s",
-	  XSYMBOL (x_atom_to_symbol (display, property))->name->data);
+	  SDATA (SYMBOL_NAME (x_atom_to_symbol (display, property))));
   XDeleteProperty (display, window, property);
   TRACE1 ("  Expect new value of property %s",
-	  XSYMBOL (x_atom_to_symbol (display, property))->name->data);
+	  SDATA (SYMBOL_NAME (x_atom_to_symbol (display, property))));
   wait_object = expect_property_change (display, window, property,
 					PropertyNewValue);
   XFlush (display);
@@ -1495,7 +1608,6 @@
 
 	  if (! waiting_for_other_props_on_window (display, window))
 	    XSelectInput (display, window, STANDARD_EVENT_SET);
-	  unexpect_property_change (wait_object);
 	  /* Use xfree, not XFree, because x_get_window_property
 	     calls xmalloc itself.  */
 	  if (tmp_data) xfree (tmp_data);
--- a/src/xterm.c	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/xterm.c	Sat Nov 06 17:52:02 2004 +0000
@@ -3922,9 +3922,9 @@
 {
   Lisp_Object tail;
 
-#ifdef USE_GTK
+#if defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS)
   window_id = (Window) xg_get_scroll_id_for_window (display, window_id);
-#endif /* USE_GTK */
+#endif /* USE_GTK  && USE_TOOLKIT_SCROLL_BARS */
 
   for (tail = Vframe_list;
        XGCTYPE (tail) == Lisp_Cons;
@@ -5579,73 +5579,6 @@
 }
 
 
-/* Define a queue to save up SelectionRequest events for later handling.  */
-
-struct selection_event_queue
-  {
-    XEvent event;
-    struct selection_event_queue *next;
-  };
-
-static struct selection_event_queue *queue;
-
-/* Nonzero means queue up certain events--don't process them yet.  */
-
-static int x_queue_selection_requests;
-
-/* Queue up an X event *EVENT, to be processed later.  */
-
-static void
-x_queue_event (f, event)
-     FRAME_PTR f;
-     XEvent *event;
-{
-  struct selection_event_queue *queue_tmp
-    = (struct selection_event_queue *) xmalloc (sizeof (struct selection_event_queue));
-
-  if (queue_tmp != NULL)
-    {
-      queue_tmp->event = *event;
-      queue_tmp->next = queue;
-      queue = queue_tmp;
-    }
-}
-
-/* Take all the queued events and put them back
-   so that they get processed afresh.  */
-
-static void
-x_unqueue_events (display)
-     Display *display;
-{
-  while (queue != NULL)
-    {
-      struct selection_event_queue *queue_tmp = queue;
-      XPutBackEvent (display, &queue_tmp->event);
-      queue = queue_tmp->next;
-      xfree ((char *)queue_tmp);
-    }
-}
-
-/* Start queuing SelectionRequest events.  */
-
-void
-x_start_queuing_selection_requests (display)
-     Display *display;
-{
-  x_queue_selection_requests++;
-}
-
-/* Stop queuing SelectionRequest events.  */
-
-void
-x_stop_queuing_selection_requests (display)
-     Display *display;
-{
-  x_queue_selection_requests--;
-  x_unqueue_events (display);
-}
-
 /* The main X event-reading loop - XTread_socket.  */
 
 #if 0
@@ -6023,11 +5956,7 @@
       if (!x_window_to_frame (dpyinfo, event.xselectionrequest.owner))
         goto OTHER;
 #endif /* USE_X_TOOLKIT */
-      if (x_queue_selection_requests)
-        x_queue_event (x_window_to_frame (dpyinfo, event.xselectionrequest.owner),
-                       &event);
-      else
-        {
+      {
           XSelectionRequestEvent *eventp
             = (XSelectionRequestEvent *) &event;
 
@@ -6039,7 +5968,7 @@
           SELECTION_EVENT_PROPERTY (&inev) = eventp->property;
           SELECTION_EVENT_TIME (&inev) = eventp->time;
           inev.frame_or_window = Qnil;
-        }
+      }
       break;
 
     case PropertyNotify:
@@ -7623,7 +7552,11 @@
   /* The display may have been closed before this function is called.
      Check if it is still open before calling XSync.  */
   if (x_display_info_for_display (dpy) != 0)
-    XSync (dpy, False);
+    {
+      BLOCK_INPUT;
+      XSync (dpy, False);
+      UNBLOCK_INPUT;
+    }
 
   x_error_message_string = XCDR (old_val);
   return Qnil;
--- a/src/xterm.h	Sun Oct 31 02:05:24 2004 +0000
+++ b/src/xterm.h	Sat Nov 06 17:52:02 2004 +0000
@@ -52,7 +52,7 @@
 #undef XSync
 #define XSync(d, b) do { gdk_window_process_all_updates (); \
                          XSync (d, b);  } while (0)
-     
+
 
 #endif /* USE_GTK */
 
@@ -976,8 +976,6 @@
 
 extern void cancel_mouse_face P_ ((struct frame *));
 extern void x_scroll_bar_clear P_ ((struct frame *));
-extern void x_start_queuing_selection_requests P_ ((Display *));
-extern void x_stop_queuing_selection_requests P_ ((Display *));
 extern int x_text_icon P_ ((struct frame *, char *));
 extern int x_bitmap_icon P_ ((struct frame *, Lisp_Object));
 extern int x_catch_errors P_ ((Display *));
@@ -1013,8 +1011,7 @@
 
 extern void x_handle_property_notify P_ ((XPropertyEvent *));
 extern void x_handle_selection_notify P_ ((XSelectionEvent *));
-extern void x_handle_selection_request P_ ((struct input_event *));
-extern void x_handle_selection_clear P_ ((struct input_event *));
+extern void x_handle_selection_event P_ ((struct input_event *));
 extern void x_clear_frame_selections P_ ((struct frame *));
 
 extern int x_handle_dnd_message P_ ((struct frame *,