changeset 83037:03a73693678e

Merged in changes from CVS HEAD Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-71 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-72 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-73 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-74 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-75 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-76 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-77 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-78 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-79 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-80 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-81 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-82 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-83 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-84 Add lisp/emacs-lisp/macroexp.el * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-85 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-86 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-87 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-88 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-89 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-90 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-91 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-92 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-93 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-94 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-95 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-96 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-97 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-77
author Karoly Lorentey <lorentey@elte.hu>
date Tue, 17 Feb 2004 01:52:25 +0000
parents fc638739c70f (current diff) cc5e51e26b0c (diff)
children 30ccd595ccb0
files ChangeLog lib-src/emacsclient.c lib-src/rcs2log lisp/ChangeLog lisp/loadup.el lisp/term/x-win.el lisp/vc.el src/Makefile.in src/buffer.c src/dispextern.h src/dispnew.c src/emacs.c src/frame.h src/fringe.c src/keyboard.c src/keymap.c src/lisp.h src/macterm.c src/minibuf.c src/process.c src/sysdep.c src/w32term.c src/window.c src/xdisp.c src/xfaces.c src/xfns.c src/xselect.c src/xterm.c src/xterm.h
diffstat 105 files changed, 5834 insertions(+), 2272 deletions(-) [+]
line wrap: on
line diff
--- a/AUTHORS	Tue Feb 10 13:52:03 2004 +0000
+++ b/AUTHORS	Tue Feb 17 01:52:25 2004 +0000
@@ -882,7 +882,7 @@
 
 Jonathan Vail: changed vc.el
 
-Jonathan Yavner: wrote ses.el testcover-ses.el testcover-unsafep.el
+Jonathan Yavner: wrote ses.el tcover-ses.el tcover-unsafep.el
   testcover.el unsafep.el
 and changed Makefile.in files.el ses-example.ses ses.texi
 
--- a/ChangeLog	Tue Feb 10 13:52:03 2004 +0000
+++ b/ChangeLog	Tue Feb 17 01:52:25 2004 +0000
@@ -1,3 +1,12 @@
+2004-02-14  Jonathan Yavner  <jyavner@member.fsf.org>
+
+	* AUTHORS (JonathanYavner): Rename testcover-*.el to tcover-*.el
+	to match previous changes by Eli Zaretskii.
+
+2004-02-09  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* Makefile.in: Set CDPATH to an empty string.
+
 2004-01-27  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* configure.in <darwin>: Use fink packages if available.
--- a/Makefile.in	Tue Feb 10 13:52:03 2004 +0000
+++ b/Makefile.in	Tue Feb 17 01:52:25 2004 +0000
@@ -53,6 +53,10 @@
 
 SHELL = /bin/sh
 
+# This may not work with certain non-GNU make's.  It only matters when
+# inheriting a CDPATH not starting with the current directory.
+CDPATH=
+
 # If Make doesn't predefine MAKE, set it here.
 @SET_MAKE@
 
--- a/etc/ChangeLog	Tue Feb 10 13:52:03 2004 +0000
+++ b/etc/ChangeLog	Tue Feb 17 01:52:25 2004 +0000
@@ -1,3 +1,7 @@
+2004-02-08  Andreas Schwab  <schwab@suse.de>
+
+	* NEWS: Fix typo.
+
 2003-12-29  Ognyan Kulev <ogi@fmi.uni-sofia.bg>
 
 	* TUTORIAL.bg: Use windows-1251 encoding.  Fix punctuation errors.
--- a/etc/NEWS	Tue Feb 10 13:52:03 2004 +0000
+++ b/etc/NEWS	Tue Feb 17 01:52:25 2004 +0000
@@ -97,16 +97,28 @@
 The new user option 'overflow-newline-into-fringe' may be set to nil to
 revert to the old behaviour of continuing such lines.
 
-** The buffer boundaries (i.e. first and last line in the buffer) may now
-be marked with bitmaps in the fringes.  In addition, up and down
-arrow bitmaps may be shown at the top and bottom of the right fringe
-if the window can be scrolled in either direction.
+** The buffer boundaries (i.e. first and last line in the buffer) may
+now be marked with angle bitmaps in the fringes.  In addition, up and
+down arrow bitmaps may be shown at the top and bottom of the left or
+right fringe if the window can be scrolled in either direction.
 
 This behavior is activated by setting the buffer-local variable
-`indicate-buffer-boundaries' to a non-nil value.  If value is t, both
-boundaries and scrolling arrows are shown; any other non-nil value
-shows only the buffer boundaries.  The default value of this variable
-is found in `default-indicate-buffer-boundaries'.
+`indicate-buffer-boundaries' to a non-nil value.  The default value of
+this variable is found in `default-indicate-buffer-boundaries'.
+
+If value is `left' or `right', both angle and arrow bitmaps are
+displayed in the left or right fringe, resp.  Any other non-nil value
+causes the bitmap on the top line to be displayed in the left fringe,
+and the bitmap on the bottom line in the right fringe.
+
+If value is a cons (ANGLES . ARROWS), the car specifies the position
+of the angle bitmaps, and the cdr specifies the position of the arrow
+bitmaps.  
+
+For example, (t .  right) places the top angle bitmap in left fringe,
+the bottom angle bitmap in right fringe, and both arrow bitmaps in
+right fringe.  To show just the angle bitmaps in the left fringe, but
+no arrow bitmaps, use (left . nil).  
 
 ** New command `display-local-help' displays any local help at point
 in the echo area.  It is bound to `C-h .'.  It normally displays the
@@ -283,7 +295,12 @@
 ** New functions frame-current-scroll-bars and window-current-scroll-bars.
 
 These functions return the current locations of the vertical and
-horisontal scroll bars in a frame or window.
+horizontal scroll bars in a frame or window.
+
+---
+** Emacs now supports drag and drop for X.  Dropping a file on a window
+   opens it, dropping text inserts the text.  Dropping a file on a dired
+   buffer copies or moves the file to that directory.
 
 ** Under X, mouse-wheel-mode is turned on by default.
 
@@ -968,7 +985,7 @@
 +++
 ** Diary sexp entries can have custom marking in the calendar.
 Diary sexp functions which only apply to certain days (such as
-`diary-block' or `diary-cyclic' now take an optional parameter MARK,
+`diary-block' or `diary-cyclic') now take an optional parameter MARK,
 which is the name of a face or a single-character string indicating
 how to highlight the day in the calendar display.  Specifying a
 single-character string as @var{mark} places the character next to the
@@ -1797,6 +1814,40 @@
 
 * Lisp Changes in Emacs 21.4
 
+** New function 'define-fringe-bitmap' can now be used to change the
+built-in fringe bitmaps, as well as create new fringe bitmaps.
+The return value is a number identifying the new fringe bitmap.
+
+To change a built-in bitmap, do (require 'fringe) and identify the
+bitmap to change with the value of the corresponding symbol, like
+`left-truncation-fringe-bitmap' or `continued-line-fringe-bitmap'.
+
+** New function 'destroy-fringe-bitmap' may be used to destroy a
+previously created bitmap, or restore a built-in bitmap.
+
+** New function 'set-fringe-bitmap-face' can now be used to set a
+specific face to be used for a specific fringe bitmap.  Normally,
+this should be a face derived from the `fringe' face, specifying
+the foreground color as the desired color of the bitmap.
+
+** There are new display properties, left-fringe and right-fringe,
+that can be used to show a specific bitmap in the left or right fringe
+bitmap of the display line.
+
+Format is 'display '(left-fringe BITMAP [FACE]), where BITMAP is a
+number identifying a fringe bitmap, either built-in or as returned by
+`define-fringe-bitmap', and FACE is an optional face name to be used
+for displaying the bitmap.
+
+** New function `fringe-bitmaps-at-pos' returns a cons (LEFT . RIGHT)
+identifying the current fringe bitmaps in the display line at a given
+buffer position.  A nil value means no bitmap.
+
++++
+** New function `line-number-at-pos' returns line number of current
+line in current buffer, or if optional buffer position is given, line
+number of corresponding line in current buffer.
+
 ** The default value of `sentence-end' is now defined using the new
 variable `sentence-end-without-space' which contains such characters
 that end a sentence without following spaces.
--- a/leim/ChangeLog	Tue Feb 10 13:52:03 2004 +0000
+++ b/leim/ChangeLog	Tue Feb 17 01:52:25 2004 +0000
@@ -1,3 +1,7 @@
+2004-02-16  J,bi(Br,bt(Bme Marant  <jmarant@nerim.net>  (tiny change)
+
+	* Makefile.in (distclean maintainer-clean): Depend on clean.
+
 2004-01-27  Ognyan Kulev  <ogi@fmi.uni-sofia.bg>  (tiny change)
 
 	* quail/cyrillic.el ("bulgarian-bds"): Docstring fixed.
--- a/leim/Makefile.in	Tue Feb 10 13:52:03 2004 +0000
+++ b/leim/Makefile.in	Tue Feb 17 01:52:25 2004 +0000
@@ -226,7 +226,7 @@
 	rm -f ${TIT} ${NON-TIT} ${WORLD} ${TIT:.elc=.el} \
 	  ${MISC-DIC} ${MISC-DIC:.elc=.el} leim-list.el
 
-distclean maintainer-clean:
+distclean maintainer-clean: clean
 	if test -f stamp-subdir; then rm -rf ${SUBDIRS} stamp-subdir; fi
 	rm -f Makefile
 
--- a/lib-src/ChangeLog	Tue Feb 10 13:52:03 2004 +0000
+++ b/lib-src/ChangeLog	Tue Feb 17 01:52:25 2004 +0000
@@ -1,3 +1,18 @@
+2004-02-14  Paul Eggert  <eggert@twinsun.com>
+
+	* rcs2log: Work correctly if CVSROOT specifies :fork: or
+	:local: methods, or omits the colon between the hostname
+	and the path.  Allow :/ in repository path, since CVS does.
+	Fix typo: "pository" should be set from $CVSROOT, not $repository.
+	This fixes a bug reported by Wolfgang Scherer in
+	<http://mail.gnu.org/archive/html/bug-gnu-emacs/2004-02/msg00085.html>,
+	along with some related bugs I discovered by inspecting how
+	CVS itself parses $CVSROOT.
+
+2004-02-04  J,bi(Br,bt(Bme Marant <jmarant@nerim.net> (tiny)
+
+	* emacsclient.c (decode_options): Fix handling of alternate editor.
+
 2004-01-27  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* emacsclient.c (main): Don't use the hostname in the socket name.
@@ -14,6 +29,12 @@
 	Only try su-fallback if the socket name was not explicit.
 	Check socket name length in su-fallback case as well.
 
+2004-01-20  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* emacsclient.c (main): Stop if socket name too long.
+	Only try su-fallback if the socket name was not explicit.
+	Check socket name length in su-fallback case as well.
+
 2004-01-08  Andreas Schwab  <schwab@suse.de>
 
 	* emacsclient.c (main): Save errno from socket_status.
@@ -54,7 +75,7 @@
 
 2003-08-25  Takaaki Ota  <Takaaki.Ota@am.sony.com>  (tiny change)
 
-	* etags.c (consider_token): check C++ `operator' only when the
+	* etags.c (consider_token): Check C++ `operator' only when the
 	token len is long enough.
 
 2003-08-20  Dave Love  <fx@gnu.org>
@@ -5493,7 +5514,8 @@
 ;; coding: iso-2022-7bit
 ;; End:
 
-    Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003
+    Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+	1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004
 	Free Software Foundation, Inc.
   Copying and distribution of this file, with or without modification,
   are permitted provided the copyright notice and this notice are preserved.
--- a/lib-src/emacsclient.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/lib-src/emacsclient.c	Tue Feb 17 01:52:25 2004 +0000
@@ -106,6 +106,8 @@
      int argc;
      char **argv;
 {
+  alternate_editor = getenv ("ALTERNATE_EDITOR");
+
   while (1)
     {
       int opt = getopt_long (argc, argv,
@@ -114,8 +116,6 @@
       if (opt == EOF)
 	break;
 
-      alternate_editor = getenv ("ALTERNATE_EDITOR");
-
       switch (opt)
 	{
 	case 0:
--- a/lib-src/rcs2log	Tue Feb 10 13:52:03 2004 +0000
+++ b/lib-src/rcs2log	Tue Feb 17 01:52:25 2004 +0000
@@ -29,10 +29,10 @@
 
 Report bugs to <bug-gnu-emacs@gnu.org>.'
 
-Id='$Id: rcs2log,v 1.52 2003/12/27 08:18:08 uid65632 Exp $'
+Id='$Id: rcs2log,v 1.53 2004/02/15 07:41:58 uid65632 Exp $'
 
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2001, 2002, 2003
-#  Free Software Foundation, Inc.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2001, 2002, 2003,
+# 2004 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -49,7 +49,7 @@
 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-Copyright='Copyright (C) 2003 Free Software Foundation, Inc.
+Copyright='Copyright (C) 2004 Free Software Foundation, Inc.
 This program comes with NO WARRANTY, to the extent permitted by law.
 You may redistribute copies of this program
 under the terms of the GNU General Public License.
@@ -251,18 +251,24 @@
 		rlog='cvs -q log'
 		repository=`sed 1q <CVS/Repository` || exit
 		test ! -f CVS/Root || CVSROOT=`cat <CVS/Root` || exit
+		pository=
 		case $CVSROOT in
-		*:/*:/*)
-			echo >&2 "$0: $CVSROOT: CVSROOT has multiple ':/'s"
-			exit 1;;
-		*:/*)
+		/* | :fork:* | :local:*) ;;
+		*/*)
 			# remote repository
-			pository=`expr "X$repository" : '.*:\(/.*\)'`;;
-		*)
+			pository=`expr "X$CVSROOT" : '[^/]*\(.*\)'`;;
+		esac
+		case $pository in
+		'')
 			# local repository
 			case $repository in
 			/*) ;;
-			*) repository=${CVSROOT?}/$repository;;
+			*)
+				repository=${CVSROOT?}/$repository
+				case $repository in
+				:fork:* | :local:*)
+					repository=`expr "$repository" : ':[^:]*:\(.*\)'`;;
+				esac;;
 			esac
 			if test ! -d "$repository"
 			then
--- a/lisp/ChangeLog	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/ChangeLog	Tue Feb 17 01:52:25 2004 +0000
@@ -1,3 +1,312 @@
+2004-02-16  Jari Aalto  <jari.aalto@poboxes.com>  (tiny change)
+
+	* filecache.el: All message and error commands now use prefix
+	"Filecache:" to make it easy to read *Messages* buffer.
+
+2004-02-16  Jari Aalto  <jari.aalto@poboxes.com>
+
+	Autorevert: Add support to detect changed dired buffers.
+	* autorevert.el (auto-revert-active-p, auto-revert-list-diff)
+	(auto-revert-dired-file-list, auto-revert-dired-changed-p)
+	(auto-revert-handler, auto-revert-active-p): New functions.
+	(auto-revert-buffers): Moved revert logic to `auto-revert-handler'
+	and `auto-revert-active-p'.
+	(eval-when-compile): Defvar dired-directory.
+
+2004-02-16  Alfred M. Szmidt  <ams@kemisten.nu>  (tiny change)
+
+	* progmodes/compile.el (compilation-directory): New defvar.
+	(compile): Save current directory in compilation-directory.
+	(recompile): Bind default-directory to compilation-directory if
+	that is non-nil.
+
+2004-02-16  Dave Love  <fx@gnu.org>
+
+	* newcomment.el (comment-insert-comment-function) 
+	(comment-region-function, uncomment-region-function): New.
+	(comment-indent): Use comment-insert-comment-function.
+	(uncomment-region): Use uncomment-region-function.
+	(comment-region): Use comment-region-function.
+
+	* emacs-lisp/rx.el (rx-not): Bind case-fold-search to nil.
+
+2004-02-16  Richard Stallman  <rms@gnu.org>
+
+	* Makefile.in (TAGS, TAGS-LISP): Filter out of `els' only
+	loaddefs* and ldefs-boot*.
+
+2004-02-16  Eli Zaretskii  <eliz@elta.co.il>
+
+	* mail/mail-utils.el (rmail-dont-reply-to): Anchor user login name
+	and email address at the beginning and end of the address.
+
+	* mail/rmail.el (rmail-default-dont-reply-to-names): Make "info-"
+	anchored at the beginning of the email address.
+
+2004-02-16  TAKAI Kousuke  <tak@kmc.gr.jp>  (tiny change)
+
+	* international/ccl.el (ccl-compile-write): Pass `left' to
+	ccl-embed-code to generate correct code of write-expr-register.
+
+2004-02-15  Dan Nicolaescu  <dann@ics.uci.edu>  (tiny change)
+
+	* progmodes/grep.el (grep-compute-defaults): Fix typos.
+
+2004-02-15  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* x-dnd.el: Mention support for Motif in commentary.
+	(x-dnd-handle-drag-n-drop-event): Ditto.
+
+2004-02-14  Jonathan Yavner  <jyavner@member.fsf.org>
+
+	* ses.el: Use "ses--" prefixes for buffer-local variables.
+	Use (point-min) instead of 1, even when we know the buffer
+	is unnarrowed.
+	(ses-build-load-map): Delete.  Distribute its content to defconst's for
+	the three maps.
+	(ses-menu, ses-header-line-menu): New menus.
+	(ses-mode-map): Use them.
+	(ses-read-number) New fun.  Duplicates code from interactive "N" spec.
+
+2004-02-14  Martin Stjernholm  <bug-cc-mode@gnu.org>
+
+	* Makefile.in: Fixed the CC Mode recompile kludge so it works
+	when building in a different directory.
+
+2004-02-13  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* simple.el (kill-new): Put yank-handler property on the entire string.
+
+2004-02-11  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* pcvs-defs.el (cvs-menu): Add `tag'.
+
+2004-02-11  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* simple.el (kill-append): Doc fix.
+
+	* emacs-lisp/lisp-mode.el (lisp-mode-variables):
+	Adapt outline-regexp to the new conventions for commenting out code.
+
+2004-02-11  John Paul Wallington  <jpw@gnu.org>
+
+	* mail/smtpmail.el (smtpmail-try-auth-methods): Fix typo.
+
+2004-02-10  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* diff.el (diff-switches): New fun.
+	(diff, diff-backup): Use it.
+	(diff): Clean up the args construction.  Use backquote.
+	Use listp instead of consp to avoid putting a nil arg.
+
+2004-02-10  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* x-dnd.el (x-dnd-types-alist): Add COMPOUND_TEXT,  FILE_NAME
+	handeled by x-dnd-handle-file-name.
+	(x-dnd-known-types): Add COMPOUND_TEXT.
+	(x-dnd-init-frame): Call x-dnd-init-motif-for-frame.
+	(x-dnd-get-state-cons-for-frame): Must do copy-sequence on
+	x-dnd-empty-state.
+	(x-dnd-forget-drop): Ditto.
+	(x-dnd-save-state): Add optional parameter extra-data (for Motif).
+	(x-dnd-handle-one-url): Return private when inserting text.
+	(x-dnd-insert-ctext): New function.
+	(x-dnd-handle-file-name): New function for FILE_NAME.
+	(x-dnd-handle-drag-n-drop-event): Add Motif, remove call to error.
+	(x-dnd-init-motif-for-frame, x-dnd-get-motif-value)
+	(x-dnd-motif-value-to-list, x-dnd-handle-motif): New functions.
+
+2004-02-10  Kenichi Handa  <handa@m17n.org>
+
+	* term/x-win.el (x-select-utf8-or-ctext): Use compare-strings
+	instead of while loop.
+
+2004-02-10  Miles Bader  <miles@gnu.org>
+
+	* emacs-lisp/macroexp.el: New file, implements `macroexpand-all'.
+
+2004-02-09  Kenichi Handa  <handa@m17n.org>
+
+	* tar-mode.el (tar-extract): Fix for the case that a file doesn't
+	have end-of-line.
+
+2004-02-09  Martin Stjernholm  <bug-cc-mode@gnu.org>
+
+	* Makefile.in: Added extra dependencies in the recompile target
+	needed to cope with the compile time macro expansions in CC Mode.
+
+2004-02-09  Kim F. Storm  <storm@cua.dk>
+
+	* fringe.el (no-fringe-bitmap, undef-fringe-bitmap)
+	(left-truncation-fringe-bitmap, right-truncation-fringe-bitmap)
+	(up-arrow-fringe-bitmap, down-arrow-fringe-bitmap)
+	(continued-line-fringe-bitmap, continuation-line-fringe-bitmap)
+	(overlay-arrow-fringe-bitmap, top-left-angle-fringe-bitmap)
+	(top-right-angle-fringe-bitmap, bottom-left-angle-fringe-bitmap)
+	(bottom-right-angle-fringe-bitmap, left-bracket-fringe-bitmap)
+	(right-bracket-fringe-bitmap, filled-box-cursor-fringe-bitmap)
+	(hollow-box-cursor-fringe-bitmap, hollow-square-fringe-bitmap)
+	(bar-cursor-fringe-bitmap, hbar-cursor-fringe-bitmap)
+	(empty-line-fringe-bitmap): Define standard fringe bitmaps id's.
+
+2004-02-08  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* window.el (window-safely-shrinkable-p): Don't change the buffer-list.
+	Don't allow shrink if there's a window on our right.
+
+	* progmodes/prolog.el (prolog-program-name): Use gprolog if available.
+	(prolog-mode-syntax-table, prolog-mode-abbrev-table, prolog-mode-map):
+	Bring together declaration and initialization.
+	(prolog-mode-variables): Don't set the syntax table.
+	Don't set paragraph-start and comment-indent-function.
+	Add /*..*/ to the comment regexps.
+	(prolog-mode-commands): Remove.  Do it during init of prolog-mode-map.
+	(prolog-mode-map): Don't bind TAB.
+	(prolog-mode): Set the syntax table.
+	(prolog-comment-indent): Remove.
+	(inferior-prolog-mode-map): Initialize in the declaration.
+	(inferior-prolog-mode-syntax-table)
+	(inferior-prolog-mode-abbrev-table): New vars.
+	(inferior-prolog-mode): Derive from comint-mode.
+	(run-prolog): Avoid switch-to-buffer which can fail in dedicated and
+	minibuffer windows.
+
+	* progmodes/grep.el (grep-regexp-alist): Allow :, \t and (
+	in file names, as long as it is unabmiguous.
+
+2004-02-08  Andreas Schwab  <schwab@suse.de>
+
+	* textmodes/reftex-toc.el
+	(reftex-toc-load-all-files-for-promotion): Remove useless use of
+	format.  Doc fix.
+
+	* textmodes/refer.el (refer-find-entry-internal): Remove extra
+	format string arguments.
+
+	* tar-mode.el (tar-parse-octal-integer-safe): Add missing format
+	string argument.
+
+	* progmodes/xscheme.el (verify-xscheme-buffer): Fix format strings.
+
+	* play/zone.el (zone-call): Fix format string.
+
+	* net/webjump.el (webjump-builtin): Add missing format string argument.
+
+	* midnight.el (midnight-delay-set): Remove extra format string argument.
+
+	* mail/rmail.el (rmail-get-new-mail): Remove useless use of format.
+
+	* hexl.el (hexl-insert-char): Add missing format string argument.
+
+	* format.el (format-decode): Fix format string.
+
+	* emulation/vi.el (vi-mode): Remove extra format string argument.
+	(vi-repeat-last-search): Likewise.
+	(vi-reverse-last-search): Likewise.
+	(vi-goto-mark): Likewise.
+	(vi-reverse-last-find-char): Likewise.
+	(vi-repeat-last-find-char): Likewise.
+	(vi-locate-def): Likewise.
+
+	* emacs-lisp/lisp-mnt.el (lm-verify): Remove useless use of format.
+
+	* ediff-util.el (ediff-toggle-read-only): Remove extra format
+	string argument.
+	(ediff-toggle-regexp-match): Likewise.
+
+	* dired-aux.el (dired-do-query-replace-regexp): Add missing
+	format string argument.
+
+	* calc/calc-map.el (calc-get-operator): Remove extra format
+	string argument.
+
+	* calc/calc-forms.el (calc-convert-time-zones): Fix format string.
+
+	* calc/calc-ext.el (calc-do-prefix-help): Remove extra format
+	string argument.
+
+	* eshell/esh-mode.el (eshell-send-invisible): Fix format string.
+
+	* eshell/em-hist.el (eshell-hist-word-reference): Fix format string.
+
+	* emulation/viper-ex.el (ex-mark): Remove extra format string argument.
+
+	* emacs-lisp/cl-macs.el (defstruct): Remove extra format string arg.
+	(cl-struct-setf-expander): Likewise.
+
+	* vc.el (with-vc-file): Fix unsafe uses of error.
+	(vc-cancel-version): Likewise.
+
+2004-02-08  Jan Nieuwenhuizen  <jan.nieuwenhuizen@aspiratie.nl>  (tiny change)
+
+	* progmodes/gud.el (gud-jdb-marker-filter): Add period as optional
+	thousands separator; fixes <class>:<line-number> regexp for
+	non-english locales.
+
+2004-02-08  Andreas Schwab  <schwab@suse.de>
+
+	* view.el (view-mode-enable): Revert previous change.
+
+2004-02-07  Kim F. Storm  <storm@cua.dk>
+
+	* simple.el (line-number-at-pos): Rename from line-at-pos.
+	Uses changed (what-line and vc-annotate-warp-version).
+
+2004-02-06  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* diff-mode.el (diff-file-regexp-alist, diff-error-regexp-alist)
+	(diff-mode): Remove aborted attempt at support for compile.el.
+	(diff-mode, diff-minor-mode): Avoid obsolete write-contents-hooks.
+
+2004-02-06  Andreas Schwab  <schwab@suse.de>
+
+	* view.el (view-mode-enable): Add view-mode-map to
+	minor-mode-overriding-map-alist.
+
+2004-02-05  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* x-dnd.el (x-dnd-get-local-file-name): Fix byte compiler warning
+
+2004-02-04  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* progmodes/cperl-mode.el (cperl-fill-paragraph): Call fill-paragraph
+	with point inside rather than after the paragraph.
+
+2004-02-04  Sam Steingold  <sds@gnu.org>
+
+	* mail/smtpmail.el (smtpmail-try-auth-methods):
+	Do not try authentication when no mechanism is available.
+	Pass port-name as defaultport to `netrc-machine'.
+
+2004-02-04  Stephen Eglen  <stephen@gnu.org>
+
+	* iswitchb.el (iswitchb-minibuffer-setup-hook): Update doc string
+	to show how minibuffer height can be constrained.
+
+2004-02-04  John Paul Wallington  <jpw@gnu.org>
+
+	* files.el (auto-mode-alist): Fix .scm, .stk, .ss, .sch entry.
+
+2004-02-03  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* x-dnd.el: New file for drag and drop.
+
+	* term/x-win.el: require x-dnd, set after-make-frame-functions
+	to x-dnd-init-frame, let x-dnd-handle-drag-n-drop-event handle
+	drag-n-drop event.
+
+	* dired.el (dired-dnd-test-function, dired-dnd-popup-notice)
+	(dired-dnd-do-ask-action, dired-dnd-handle-local-file)
+	(dired-dnd-handle-file): New functions for drag and drop support.
+	(dired-mode): Initialize drag and drop if x-dnd present.
+
+2004-02-02  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* progmodes/cperl-mode.el (cperl-mode-map, cperl-do-auto-fill)
+	(cperl-menu): Use fill-paragraph, not cperl-fill-paragraph.
+	(cperl-mode): Set fill-paragraph-function.
+	(cperl-fill-paragraph): Make it non-interactive.
+
 2004-02-02  Benjamin Rutt  <brutt@bloomington.in.us>
 
 	* diff-mode.el (diff-mode-shared-map): Bind q to `quit-window'.
@@ -10,8 +319,7 @@
 
 2004-02-01  Andreas Schwab  <schwab@suse.de>
 
-	* progmodes/executable.el (executable-command-find-posix-p): Doc
-	fix.
+	* progmodes/executable.el (executable-command-find-posix-p): Doc fix.
 
 2004-02-01  Stephen Eglen  <stephen@gnu.org>
 
--- a/lisp/Makefile.in	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/Makefile.in	Tue Feb 17 01:52:25 2004 +0000
@@ -188,11 +188,11 @@
 	$(emacs) -f batch-update-authors $(srcdir)/AUTHORS $(srcdir)
 
 TAGS: $(lisptagsfiles1) $(lisptagsfiles2)
-	els=`echo $(lisptagsfiles1) $(lisptagsfiles2) | sed -e "s,$(lisp)/loaddefs.*\.el,,"`; \
+	els=`echo $(lisptagsfiles1) $(lisptagsfiles2) | sed -e "s,$(lisp)/loaddefs[^ ]*,," -e "s,$(lisp)/ldefs-boot[^ ]*,,"`; \
 	${ETAGS} $$els
 
 TAGS-LISP: $(lisptagsfiles1) $(lisptagsfiles2)
-	els=`echo $(lisptagsfiles1) $(lisptagsfiles2) | sed -e "s,$(lisp)/loaddefs.*\.el,,"`; \
+	els=`echo $(lisptagsfiles1) $(lisptagsfiles2) | sed -e "s,$(lisp)/loaddefs[^ ]*,," -e "s,$(lisp)/ldefs-boot[^ ]*,,"`; \
 	${ETAGS} -o TAGS-LISP $$els
 
 .SUFFIXES: .elc .el
@@ -273,9 +273,18 @@
 # Note that this doesn't create .elc files.  It only recompiles if an
 # .elc is present.
 
-recompile: doit
+recompile: doit $(lisp)/progmodes/cc-mode.elc
 	$(EMACS) $(EMACSOPT) -f batch-byte-recompile-directory $(lisp)
 
+# CC Mode uses a compile time macro system which causes a compile time
+# dependency in cc-mode.elc on the macros in cc-langs.el and the
+# version string in cc-defs.el.
+$(lisp)/progmodes/cc-mode.elc: \
+	$(lisp)/progmodes/cc-mode.el \
+	$(lisp)/progmodes/cc-langs.el \
+	$(lisp)/progmodes/cc-defs.el
+	$(EMACS) $(EMACSOPT) -f batch-byte-compile $(lisp)/progmodes/cc-mode.el
+
 # Prepare a bootstrap in the lisp subdirectory.
 #
 # Build loaddefs.el, because it's not sure it's up-to-date, and if it's not,
--- a/lisp/autorevert.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/autorevert.el	Tue Feb 17 01:52:25 2004 +0000
@@ -70,7 +70,11 @@
 ;; Dependencies:
 
 (require 'timer)
-(eval-when-compile (require 'cl))
+(autoload 'dired-get-filename "dired")
+
+(eval-when-compile
+  (defvar dired-directory)
+  (require 'cl))
 
 
 ;; Custom Group:
@@ -244,6 +248,82 @@
 			    'auto-revert-buffers)
 	  nil)))
 
+(defun auto-revert-active-p ()
+  "Check if auto-revert is active (in current buffer or globally)."
+  (or auto-revert-mode
+      (and
+       global-auto-revert-mode
+       (not global-auto-revert-ignore-buffer)
+       (not (memq major-mode
+		  global-auto-revert-ignore-modes)))))
+
+(defun auto-revert-list-diff (a b)
+  "Check if strings in list A differ from list B."
+  (when (and a b)
+    (setq a (sort a 'string-lessp))
+    (setq b (sort b 'string-lessp))
+    (let (elt1 elt2)
+      (catch 'break
+	(while (and (setq elt1 (and a (pop a)))
+		    (setq elt2 (and b (pop b))))
+	  (if (not (string= elt1 elt2))
+	      (throw 'break t)))))))
+
+(defun auto-revert-dired-file-list ()
+  "Return list of dired files."
+  (let (file list)
+    (save-excursion
+      (goto-char (point-min))
+      (while (not (eobp))
+	(if (setq file (dired-get-filename t t))
+	    (push file list))
+	(forward-line 1)))
+    list))
+
+(defun auto-revert-dired-changed-p ()
+  "Check if dired buffer has changed."
+  (when (and (stringp dired-directory)
+	     ;;	  Exclude remote buffers, would be too slow for user
+	     ;;	  modem, timeouts, network lag ... all is possible
+	     (not (string-match "@" dired-directory))
+	     (file-directory-p dired-directory))
+    (let ((files (directory-files dired-directory))
+	  (dired (auto-revert-dired-file-list)))
+      (or (not (eq (length files) (length dired)))
+	  (auto-revert-list-diff files dired)))))
+
+(defun auto-revert-buffer-p ()
+  "Check if current buffer should be reverted."
+  ;;  Always include dired buffers to list. It would be too expensive
+  ;;  to test the "revert" status here each time timer launches.
+  (or (eq major-mode 'dired-mode)
+      (and (not (buffer-modified-p))
+	   (if (buffer-file-name)
+	       (and (file-readable-p (buffer-file-name))
+		    (not (verify-visited-file-modtime (current-buffer))))
+	     (and revert-buffer-function
+		  (or (and global-auto-revert-mode
+			   global-auto-revert-non-file-buffers)
+		      auto-revert-mode))))))
+
+(defun auto-revert-handler ()
+  "Revert current buffer."
+  (let (done)
+    (cond
+     ((eq major-mode 'dired-mode)
+      ;;  Dired includes revert-buffer-function
+      (when (and revert-buffer-function
+		 (auto-revert-dired-changed-p))
+	(setq done t)
+	(revert-buffer t t t)))
+     ((or (buffer-file-name)
+	  revert-buffer-function)
+      (setq done t)
+      (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes)))
+    (if (and done
+	     auto-revert-verbose)
+	(message "Reverting buffer `%s'." (buffer-name)))))
+
 (defun auto-revert-buffers ()
   "Revert buffers as specified by Auto-Revert and Global Auto-Revert Mode.
 
@@ -294,24 +374,9 @@
 		       (memq buf auto-revert-buffer-list))
 		  (setq auto-revert-buffer-list
 			(delq buf auto-revert-buffer-list)))
-	      (when (and
-		     (or auto-revert-mode
-			 (and
-			  global-auto-revert-mode
-			  (not global-auto-revert-ignore-buffer)
-			  (not (memq major-mode
-				     global-auto-revert-ignore-modes))))
-		     (not (buffer-modified-p))
-		     (if (buffer-file-name)
-			 (and (file-readable-p (buffer-file-name))
-			      (not (verify-visited-file-modtime buf)))
-		       (and revert-buffer-function
-			    (or (and global-auto-revert-mode
-				     global-auto-revert-non-file-buffers)
-				auto-revert-mode))))
-		(if auto-revert-verbose
-		    (message "Reverting buffer `%s'." buf))
-		(revert-buffer 'ignore-auto 'dont-ask 'preserve-modes)
+	      (when (and (auto-revert-active-p)
+			 (auto-revert-buffer-p))
+		(auto-revert-handler)
 		;; `preserve-modes' avoids changing the (minor) modes.  But we
 		;; do want to reset the mode for VC, so we do it explicitly.
 		(vc-find-file-hook)))
--- a/lisp/calc/calc-ext.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/calc/calc-ext.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; calc-ext.el --- various extension functions for Calc
 
-;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002 Free Software Foundation, Inc.
+;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2004 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <daveg@synaptics.com>
 ;; Maintainers: D. Goel <deego@gnufans.org>
@@ -1262,7 +1262,7 @@
       (if key
 	  (if msgs
 	      (message "%s: %s: %c-" group (car msgs) key)
-	    (message "%s: (none)  %c-" group (car msgs) key))
+	    (message "%s: (none)  %c-" group key))
 	(message "%s: %s" group (car msgs))))
     (and key (calc-unread-command key))))
 
--- a/lisp/calc/calc-forms.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/calc/calc-forms.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; calc-forms.el --- data format conversion functions for Calc
 
-;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2004 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <daveg@synaptics.com>
 ;; Maintainers: D. Goel <deego@gnufans.org>
@@ -212,11 +212,11 @@
 					", to zone: "))))
      (if (stringp old) (setq old (math-read-expr old)))
      (if (eq (car-safe old) 'error)
-	 (error "Error in expression: " (nth 1 old)))
+	 (error "Error in expression: %S" (nth 1 old)))
      (if (equal new "") (setq new "local"))
      (if (stringp new) (setq new (math-read-expr new)))
      (if (eq (car-safe new) 'error)
-	 (error "Error in expression: " (nth 1 new)))
+	 (error "Error in expression: %S" (nth 1 new)))
      (calc-enter-result 1 "tzcv" (list 'calcFunc-tzconv
 				       (calc-top-n 1) old new)))))
 
--- a/lisp/calc/calc-map.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/calc/calc-map.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; calc-map.el --- higher-order functions for Calc
 
-;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2004 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <daveg@synaptics.com>
 ;; Maintainers: D. Goel <deego@gnufans.org>
@@ -700,10 +700,7 @@
 					       (calcFunc-afixp   . 2))))))
 			  (oper3 (if (eq (nth 2 oper) 'calcFunc-inner)
 				     (calc-get-operator
-				      (format "%s%s, inner (add)" msg dir
-					      (substring
-					       (symbol-name (nth 2 oper))
-					       9)))
+				      (format "%s%s, inner (add)" msg dir))
 				   '(0 0 0)))
 			  (args nil)
 			  (nargs (if (> (nth 1 oper) 0)
--- a/lisp/diff-mode.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/diff-mode.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; diff-mode.el --- a mode for viewing/editing context diffs
 
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002  Free Software Foundation, Inc.
+;; Copyright (C) 1998,1999,2000,01,02,03,2004  Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <monnier@cs.yale.edu>
 ;; Keywords: convenience patch diff
@@ -28,7 +28,7 @@
 ;; commands, editing and various conversions as well as jumping
 ;; to the corresponding source file.
 
-;; Inspired by Pavel Machek's patch-mode.el (<pavel@atrey.karlin.mff.cuni.cz>)
+;; Inspired by Pavel Machek's patch-mode.el (<pavel@@atrey.karlin.mff.cuni.cz>)
 ;; Some efforts were spent to have it somewhat compatible with XEmacs'
 ;; diff-mode as well as with compilation-minor-mode
 
@@ -272,18 +272,6 @@
     (nil "^--- \\([^\t\n]+\\)\t.*\n\\*" 1))) ; context diffs
 
 ;;;;
-;;;; Compile support
-;;;;
-
-(defvar diff-file-regexp-alist
-  '(("Index: \\(.+\\)" 1)))
-
-(defvar diff-error-regexp-alist
-  '(("@@ -\\([0-9]+\\),[0-9]+ \\+\\([0-9]+\\),[0-9]+ @@" nil 2)
-    ("--- \\([0-9]+\\),[0-9]+ ----" nil 1)
-    ("\\([0-9]+\\)\\(,[0-9]+\\)?[adc]\\([0-9]+\\)" nil 3)))
-
-;;;;
 ;;;; Movement
 ;;;;
 
@@ -879,31 +867,11 @@
   ;;   (set (make-local-variable 'page-delimiter) "--- [^\t]+\t")
   ;; compile support
 
-  ;;;; compile support is not good enough yet.  It should be merged
-  ;;;; with diff.el's support.
-  (set (make-local-variable 'compilation-file-regexp-alist)
-       diff-file-regexp-alist)
-  (set (make-local-variable 'compilation-error-regexp-alist)
-       diff-error-regexp-alist)
-  (when (string-match "\\.rej\\'" (or buffer-file-name ""))
-    (set (make-local-variable 'compilation-current-file)
-  	 (substring buffer-file-name 0 (match-beginning 0))))
-  ;; Be careful not to change compilation-last-buffer when we're just
-  ;; doing a C-x v = (for example).
-  (if (boundp 'compilation-last-buffer)
-      (let ((compilation-last-buffer compilation-last-buffer))
-	(compilation-minor-mode 1))
-    (compilation-minor-mode 1))
-  ;; M-RET and RET should be done by diff-mode because the `compile'
-  ;; support is significantly less good.
-  (add-to-list 'minor-mode-overriding-map-alist
-  	       (cons 'compilation-minor-mode (make-sparse-keymap)))
-
   (when (and (> (point-max) (point-min)) diff-default-read-only)
     (toggle-read-only t))
   ;; setup change hooks
   (if (not diff-update-on-the-fly)
-      (add-hook 'write-contents-hooks 'diff-write-contents-hooks)
+      (add-hook 'write-contents-functions 'diff-write-contents-hooks nil t)
     (make-local-variable 'diff-unhandled-changes)
     (add-hook 'after-change-functions 'diff-after-change-function nil t)
     (add-hook 'post-command-hook 'diff-post-command-hook nil t))
@@ -924,7 +892,7 @@
   ;; FIXME: setup font-lock
   ;; setup change hooks
   (if (not diff-update-on-the-fly)
-      (add-hook 'write-contents-hooks 'diff-write-contents-hooks)
+      (add-hook 'write-contents-functions 'diff-write-contents-hooks nil t)
     (make-local-variable 'diff-unhandled-changes)
     (add-hook 'after-change-functions 'diff-after-change-function nil t)
     (add-hook 'post-command-hook 'diff-post-command-hook nil t)))
--- a/lisp/diff.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/diff.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; diff.el --- run `diff' in compilation-mode
 
-;; Copyright (C) 1992, 1994, 1996, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1994, 1996, 2001, 2004 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: unix, tools
@@ -30,8 +30,6 @@
 
 ;;; Code:
 
-(require 'compile)
-
 (defgroup diff nil
   "Comparing files with `diff'."
   :group 'tools)
@@ -48,237 +46,109 @@
   :type 'string
   :group 'diff)
 
-(defvar diff-regexp-alist
-  '(
-    ;; -u format: @@ -OLDSTART,OLDEND +NEWSTART,NEWEND @@
-    ("^@@ -\\([0-9]+\\),[0-9]+ \\+\\([0-9]+\\),[0-9]+ @@$" 1 2)
-
-    ;; -c format: *** OLDSTART,OLDEND ****
-    ("^\\*\\*\\* \\([0-9]+\\),[0-9]+ \\*\\*\\*\\*$" 1 nil)
-    ;;            --- NEWSTART,NEWEND ----
-    ("^--- \\([0-9]+\\),[0-9]+ ----$" nil 1)
-
-    ;; plain diff format: OLDSTART[,OLDEND]{a,d,c}NEWSTART[,NEWEND]
-    ("^\\([0-9]+\\)\\(,[0-9]+\\)?[adc]\\([0-9]+\\)\\(,[0-9]+\\)?$" 1 3)
-
-    ;; -e (ed) format: OLDSTART[,OLDEND]{a,d,c}
-    ("^\\([0-9]+\\)\\(,[0-9]+\\)?[adc]$" 1)
-
-    ;; -f format: {a,d,c}OLDSTART[ OLDEND]
-    ;; -n format: {a,d,c}OLDSTART LINES-CHANGED
-    ("^[adc]\\([0-9]+\\)\\( [0-9]+\\)?$" 1)
-    )
-  "Alist of regular expressions to match difference sections in \\[diff] output.
-Each element has the form (REGEXP OLD-IDX NEW-IDX).
-Any text that REGEXP matches identifies one difference hunk
-or the header of a hunk.
-
-The OLD-IDX'th subexpression of REGEXP gives the line number
-in the old file, and NEW-IDX'th subexpression gives the line number
-in the new file.  If OLD-IDX or NEW-IDX
-is nil, REGEXP matches only half a hunk.")
-
-(defvar diff-old-file nil
-  "This is the old file name in the comparison in this buffer.")
-(defvar diff-new-file nil
-  "This is the new file name in the comparison in this buffer.")
 (defvar diff-old-temp-file nil
   "This is the name of a temp file to be deleted after diff finishes.")
 (defvar diff-new-temp-file nil
   "This is the name of a temp file to be deleted after diff finishes.")
 
-;; See compilation-parse-errors-function (compile.el).
-(defun diff-parse-differences (limit-search find-at-least)
-  (setq compilation-error-list nil)
-  (message "Parsing differences...")
-
-  ;; Don't reparse diffs already seen at last parse.
-  (if compilation-parsing-end (goto-char compilation-parsing-end))
-
-  ;; Construct in REGEXP a regexp composed of all those in dired-regexp-alist.
-  (let ((regexp (mapconcat (lambda (elt)
-			     (concat "\\(" (car elt) "\\)"))
-			   diff-regexp-alist
-			   "\\|"))
-	;; (GROUP-IDX OLD-IDX NEW-IDX)
-	(groups (let ((subexpr 1))
-		  (mapcar (lambda (elt)
-			    (prog1
-				(cons subexpr
-				      (mapcar (lambda (n)
-						(and n
-						     (+ subexpr n)))
-					      (cdr elt)))
-			      (setq subexpr (+ subexpr 1
-					       (count-regexp-groupings
-						(car elt))))))
-			  diff-regexp-alist)))
-
-	(new-error
-	 (function (lambda (file subexpr)
-		     (setq compilation-error-list
-			   (cons
-			    (list (save-excursion
-				    ;; Report location of message
-				    ;; at beginning of line.
-				    (goto-char
-				     (match-beginning subexpr))
-				    (beginning-of-line)
-				    (point-marker))
-				  ;; Report location of corresponding text.
-				  (list file nil)
-				  (string-to-int
-				   (buffer-substring
-				    (match-beginning subexpr)
-				    (match-end subexpr)))
-				  nil)
-			    compilation-error-list)))))
+;; prompt if prefix arg present
+(defun diff-switches ()
+  (if current-prefix-arg
+      (read-string "Diff switches: "
+		   (if (stringp diff-switches)
+		       diff-switches
+		     (mapconcat 'identity diff-switches " ")))))
 
-	(found-desired nil)
-	(num-loci-found 0)
-	g)
-
-    (while (and (not found-desired)
-		;; We don't just pass LIMIT-SEARCH to re-search-forward
-		;; because we want to find matches containing LIMIT-SEARCH
-		;; but which extend past it.
-		(re-search-forward regexp nil t))
-
-      ;; Find which individual regexp matched.
-      (setq g groups)
-      (while (and g (null (match-beginning (car (car g)))))
-	(setq g (cdr g)))
-      (setq g (car g))
-
-      (if (nth 1 g)			;OLD-IDX
-	  (funcall new-error diff-old-file (nth 1 g)))
-      (if (nth 2 g)			;NEW-IDX
-	  (funcall new-error diff-new-file (nth 2 g)))
-
-      (setq num-loci-found (1+ num-loci-found))
-      (if (or (and find-at-least
-		   (>= num-loci-found find-at-least))
-	      (and limit-search (>= (point) limit-search)))
-	      ;; We have found as many new loci as the user wants,
-	      ;; or the user wanted a specific diff, and we're past it.
-	  (setq found-desired t)))
-    (set-marker compilation-parsing-end
-		(if found-desired (point)
-		  ;; Set to point-max, not point, so we don't perpetually
-		  ;; parse the last bit of text when it isn't a diff header.
-		  (point-max)))
-    (message "Parsing differences...done"))
-  (setq compilation-error-list (nreverse compilation-error-list)))
-
-(defun diff-process-setup ()
-  "Set up \`compilation-exit-message-function' for \`diff'."
-  ;; Avoid frightening people with "abnormally terminated"
-  ;; if diff finds differences.
-  (set (make-local-variable 'compilation-exit-message-function)
-       (lambda (status code msg)
-	 (cond ((not (eq status 'exit))
-		(cons msg code))
-	       ((zerop code)
-		'("finished (no differences)\n" . "no differences"))
-	       ((= code 1)
-		'("finished\n" . "differences found"))
-	       (t
-		(cons msg code))))))
+(defun diff-sentinel (code)
+  "Code run when the diff process exits.
+CODE is the exit code of the process.  It should be 0 iff no diffs were found."
+  (if diff-old-temp-file (delete-file diff-old-temp-file))
+  (if diff-new-temp-file (delete-file diff-new-temp-file))
+  (save-excursion
+    (goto-char (point-max))
+    (insert (format "\nDiff finished%s.  %s\n"
+		    (if (equal 0 code) " (no differences)" "")
+		    (current-time-string)))))
 
 ;;;###autoload
 (defun diff (old new &optional switches no-async)
   "Find and display the differences between OLD and NEW files.
 Interactively the current buffer's file name is the default for NEW
 and a backup file for NEW is the default for OLD.
-With prefix arg, prompt for diff switches.
-If NO-ASYNC is non-nil, call diff synchronously."
+If NO-ASYNC is non-nil, call diff synchronously.
+With prefix arg, prompt for diff switches."
   (interactive
-   (nconc
-    (let (oldf newf)
-      (nreverse
-       (list
-	(setq newf (buffer-file-name)
-	      newf (if (and newf (file-exists-p newf))
-		       (read-file-name
-			(concat "Diff new file: (default "
-				(file-name-nondirectory newf) ") ")
-			nil newf t)
-		     (read-file-name "Diff new file: " nil nil t)))
-	(setq oldf (file-newest-backup newf)
-	      oldf (if (and oldf (file-exists-p oldf))
-		       (read-file-name
-			(concat "Diff original file: (default "
-				(file-name-nondirectory oldf) ") ")
-			(file-name-directory oldf) oldf t)
-		     (read-file-name "Diff original file: "
-				     (file-name-directory newf) nil t))))))
-    (if current-prefix-arg
-	(list (read-string "Diff switches: "
-			   (if (stringp diff-switches)
-			       diff-switches
-			     (mapconcat 'identity diff-switches " "))))
-      nil)))
+   (let (oldf newf)
+     (setq newf (buffer-file-name)
+	   newf (if (and newf (file-exists-p newf))
+		    (read-file-name
+		     (concat "Diff new file: (default "
+			     (file-name-nondirectory newf) ") ")
+		     nil newf t)
+		  (read-file-name "Diff new file: " nil nil t)))
+     (setq oldf (file-newest-backup newf)
+	   oldf (if (and oldf (file-exists-p oldf))
+		    (read-file-name
+		     (concat "Diff original file: (default "
+			     (file-name-nondirectory oldf) ") ")
+		     (file-name-directory oldf) oldf t)
+		  (read-file-name "Diff original file: "
+				  (file-name-directory newf) nil t)))
+     (list oldf newf (diff-switches))))
   (setq new (expand-file-name new)
 	old (expand-file-name old))
-  (let ((old-alt (file-local-copy old))
+  (or switches (setq switches diff-switches)) ; If not specified, use default.
+  (let* ((old-alt (file-local-copy old))
 	(new-alt (file-local-copy new))
-	buf)
+	 (command
+	  (mapconcat 'identity
+		     `(,diff-command
+		       ;; Use explicitly specified switches
+		       ,@(if (listp switches) switches (list switches))
+		       ,@(if (or old-alt new-alt)
+			     (list "-L" old "-L" new))
+		       ,(shell-quote-argument (or old-alt old))
+		       ,(shell-quote-argument (or new-alt new)))
+		     " "))
+	 (buf (get-buffer-create "*Diff*"))
+	 proc)
     (save-excursion
-	(let ((compilation-process-setup-function 'diff-process-setup)
-	      (command
-	       (mapconcat 'identity
-			  (append (list diff-command)
-				  ;; Use explicitly specified switches
-				  (if switches
-				      (if (consp switches)
-					  switches (list switches))
-				    ;; If not specified, use default.
-				    (if (consp diff-switches)
-					diff-switches
-				      (list diff-switches)))
-				  (if (or old-alt new-alt)
-				      (list "-L" old "-L" new))
-				  (list
-				   (shell-quote-argument (or old-alt old)))
-				  (list
-				   (shell-quote-argument (or new-alt new))))
-			  " ")))
-	  (setq buf
-		(compile-internal command
-				  "No more differences" "Diff"
-				  'diff-parse-differences
-				  nil nil nil nil nil nil no-async))
-	  (set-buffer buf)
-	  (set (make-local-variable 'diff-old-file) old)
-	  (set (make-local-variable 'diff-new-file) new)
-	  (set (make-local-variable 'diff-old-temp-file) old-alt)
-	  (set (make-local-variable 'diff-new-temp-file) new-alt)
-	  (set (make-local-variable 'compilation-finish-function)
-	       (function (lambda (buff msg)
-			   (if diff-old-temp-file
-			       (delete-file diff-old-temp-file))
-			   (if diff-new-temp-file
-			       (delete-file diff-new-temp-file)))))
-	  ;; When async processes aren't available, the compilation finish
-	  ;; function doesn't get chance to run.  Invoke it by hand.
-	  (or (fboundp 'start-process)
-	      (funcall compilation-finish-function nil nil))
-	  buf))))
+      (display-buffer buf)
+      (set-buffer buf)
+      (setq buffer-read-only nil)
+      (buffer-disable-undo (current-buffer))
+      (erase-buffer)
+      (buffer-enable-undo (current-buffer))
+      (diff-mode)
+      (set (make-local-variable 'revert-buffer-function)
+	   `(lambda (ignore-auto noconfirm)
+	      (diff ',old ',new ',switches ',no-async)))
+      (set (make-local-variable 'diff-old-temp-file) old-alt)
+      (set (make-local-variable 'diff-new-temp-file) new-alt)
+      (insert command "\n")
+      (if (and (not no-async) (fboundp 'start-process))
+	  (progn
+	    (setq proc (start-process "Diff" buf shell-file-name
+				      shell-command-switch command))
+	    (set-process-sentinel
+	     proc (lambda (proc msg)
+		    (with-current-buffer (process-buffer proc)
+		      (diff-sentinel (process-exit-status proc))))))
+	;; Async processes aren't available.
+	(diff-sentinel
+	 (call-process shell-file-name nil buf nil
+		       shell-command-switch command))))
+    buf))
 
 ;;;###autoload
 (defun diff-backup (file &optional switches)
   "Diff this file with its backup file or vice versa.
 Uses the latest backup, if there are several numerical backups.
 If this file is a backup, diff it with its original.
-The backup file is the first file given to `diff'."
+The backup file is the first file given to `diff'.
+With prefix arg, prompt for diff switches."
   (interactive (list (read-file-name "Diff (file with backup): ")
-		     (if current-prefix-arg
-			 (read-string "Diff switches: "
-				      (if (stringp diff-switches)
-					  diff-switches
-					(mapconcat 'identity
-						   diff-switches " ")))
-		       nil)))
+		     (diff-switches)))
   (let (bak ori)
     (if (backup-file-name-p file)
 	(setq bak file
--- a/lisp/dired-aux.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/dired-aux.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; dired-aux.el --- less commonly used parts of dired  -*-byte-compile-dynamic: t;-*-
 
-;; Copyright (C) 1985, 1986, 1992, 1994, 1998, 2000, 2001
+;; Copyright (C) 1985, 1986, 1992, 1994, 1998, 2000, 2001, 2004
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Sebastian Kremer <sk@thp.uni-koeln.de>.
@@ -2114,7 +2114,7 @@
     (let ((buffer (get-file-buffer file)))
       (if (and buffer (with-current-buffer buffer
 			buffer-read-only))
-	  (error "File `%s' is visited read-only"))))
+	  (error "File `%s' is visited read-only" file))))
   (tags-query-replace from to delimited
 		      '(dired-get-marked-files nil nil 'dired-nondirectory-p)))
 
--- a/lisp/dired.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/dired.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1292,7 +1292,16 @@
        (or switches dired-listing-switches))
   (set (make-local-variable 'font-lock-defaults) '(dired-font-lock-keywords t))
   (dired-sort-other dired-actual-switches t)
-  (run-hooks 'dired-mode-hook))
+  (run-hooks 'dired-mode-hook)
+  (when (featurep 'x-dnd)
+    (make-variable-buffer-local 'x-dnd-test-function)
+    (make-variable-buffer-local 'x-dnd-protocol-alist)
+    (setq x-dnd-test-function 'dired-dnd-test-function)
+    (setq x-dnd-protocol-alist
+	  (append '(("^file:///" . dired-dnd-handle-local-file)
+		    ("^file://"  . dired-dnd-handle-file)
+		    ("^file:"    . dired-dnd-handle-local-file))
+		  x-dnd-protocol-alist))))
 
 ;; Idiosyncratic dired commands that don't deal with marks.
 
@@ -3131,6 +3140,93 @@
 
 (autoload 'dired-query "dired-aux")
 
+
+;;;;  Drag and drop support
+
+(defun dired-dnd-test-function (window action types)
+  "The test function for drag and drop into dired buffers.
+WINDOW is where the mouse is when this function is called.  It may be a frame
+if the mouse is over the menu bar, scroll bar or tool bar.
+ACTION is the suggested action from the source, and TYPES are the
+types the drop data can have.  This function only accepts drops with
+types in `x-dnd-known-types'.  It returns the action suggested by the source."
+  (let ((type (x-dnd-choose-type types)))
+    (if type
+	(cons action type)
+      nil)))
+
+(defun dired-dnd-popup-notice ()
+  (x-popup-dialog 
+   t
+   '("Recursive copies not enabled.\nSee variable dired-recursive-copies." 
+     ("Ok" . nil))))
+
+
+(defun dired-dnd-do-ask-action (uri)
+  ;; No need to get actions and descriptions from the source,
+  ;; we only have three actions anyway.
+  (let ((action (x-popup-menu 
+		 t
+		 (list "What action?"
+		       (cons ""
+			     '(("Copy here" . copy)
+			       ("Move here" . move)
+			       ("Link here" . link)
+			       "--"
+			       ("Cancel" . nil)))))))
+    (if action
+	(dired-dnd-handle-local-file uri action)
+      nil)))
+
+(defun dired-dnd-handle-local-file (uri action)
+  "Copy, move or link a file to the dired directory.
+URI is the file to handle, ACTION is one of copy, move, link or ask.
+Ask means pop up a menu for the user to select one of copy, move or link."
+  (require 'dired-aux)
+  (let* ((from (x-dnd-get-local-file-name uri t))
+	 (to (if from (concat (dired-current-directory)
+			   (file-name-nondirectory from))
+	       nil)))
+    (if from
+	(cond ((or (eq action 'copy)
+		   (eq action 'private))	; Treat private as copy.
+
+	       ;; If copying a directory and dired-recursive-copies is nil,
+	       ;; dired-copy-file silently fails.  Pop up a notice.
+	       (if (and (file-directory-p from)
+			(not dired-recursive-copies))
+		   (dired-dnd-popup-notice)
+		 (progn
+		   (dired-copy-file from to 1)
+		   (dired-relist-entry to)
+		   action)))
+
+	       ((eq action 'move)
+		(dired-rename-file from to 1)
+		(dired-relist-entry to)
+		action)
+
+	       ((eq action 'link)
+		(make-symbolic-link from to 1)
+		(dired-relist-entry to)
+		action)
+
+	       ((eq action 'ask)
+		(dired-dnd-do-ask-action uri))
+
+	       (t nil)))))
+
+(defun dired-dnd-handle-file (uri action)
+  "Copy, move or link a file to the dired directory if it is a local file.
+URI is the file to handle.  If the hostname in the URI isn't local, do nothing.
+ACTION is one of copy, move, link or ask.
+Ask means pop up a menu for the user to select one of copy, move or link."
+  (let ((local-file (x-dnd-get-local-file-uri uri)))
+    (if local-file (dired-dnd-handle-local-file local-file action)
+      nil)))
+
+
+
 (if (eq system-type 'vax-vms)
     (load "dired-vms"))
 
--- a/lisp/ediff-util.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/ediff-util.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; ediff-util.el --- the core commands and utilities of ediff
 
-;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02, 04 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 
@@ -1080,8 +1080,10 @@
 		 (eq this-command 'ediff-toggle-read-only)
 		 (file-exists-p file)
 		 (not (file-writable-p file)))
-	    (message "Warning: file %s is read-only"
-		     (ediff-abbreviate-file-name file) (beep 1)))
+	    (progn
+	      (beep 1)
+	      (message "Warning: file %s is read-only"
+		       (ediff-abbreviate-file-name file))))
 	))))
 
 ;; checkout if visited file is checked in
@@ -2233,7 +2235,7 @@
       (if (y-or-n-p
 	   (format
 	    "Ignore regions that match %s regexps, OK? "
-	    msg-connective alt-msg-connective))
+	    msg-connective))
 	  (message "Will ignore regions that match %s regexps" msg-connective)
 	(setq ediff-hide-regexp-connective alt-connective)
 	(message "Will ignore regions that match %s regexps"
@@ -2272,7 +2274,7 @@
       (if (y-or-n-p
 	   (format
 	    "Focus on regions that match %s regexps, OK? "
-	    msg-connective alt-msg-connective))
+	    msg-connective))
 	  (message "Will focus on regions that match %s regexps"
 		   msg-connective)
 	(setq ediff-focus-regexp-connective alt-connective)
--- a/lisp/emacs-lisp/cl-macs.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/emacs-lisp/cl-macs.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; cl-macs.el --- Common Lisp macros -*-byte-compile-dynamic: t;-*-
 
-;; Copyright (C) 1993, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 2003, 2004 Free Software Foundation, Inc.
 
 ;; Author: Dave Gillespie <daveg@synaptics.com>
 ;; Version: 2.02
@@ -2261,8 +2261,7 @@
 			      (list (list 'or pred-check
 					  (list 'error
 						(format "%s accessing a non-%s"
-							accessor name)
-						'cl-x))))
+							accessor name)))))
 			 (list (if (eq type 'vector) (list 'aref 'cl-x pos)
 				 (if (= pos 0) '(car cl-x)
 				   (list 'nth pos 'cl-x)))))) forms)
@@ -2340,8 +2339,7 @@
 		       (list (list 'or (subst temp 'cl-x pred-form)
 				   (list 'error
 					 (format
-					  "%s storing a non-%s" accessor name)
-					 temp))))
+					  "%s storing a non-%s" accessor name)))))
 		  (list (if (eq (car (get name 'cl-struct-type)) 'vector)
 			    (list 'aset temp pos store)
 			  (list 'setcar
--- a/lisp/emacs-lisp/lisp-mnt.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/emacs-lisp/lisp-mnt.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; lisp-mnt.el --- utility functions for Emacs Lisp maintainers
 
-;; Copyright (C) 1992, 1994, 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1994, 1997, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
 
 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
 ;; Maintainer: FSF
@@ -522,7 +522,7 @@
 	(setq ret
 	      (cond
 	       ((null name)
-		(format "Package %s does not exist"))
+		"Can't find package name")
 	       ((not (lm-authors))
 		"`Author:' tag missing")
 	       ((not (lm-maintainer))
@@ -546,7 +546,7 @@
 		    (concat "^;;;[ \t]+" name "[ \t]+ends here[ \t]*$"
 			    "\\|^;;;[ \t]+ End of file[ \t]+" name)
 		    nil t)))
-		(format "Can't find the footer line"))
+		"Can't find the footer line")
 	       ((not (and (lm-copyright-mark) (lm-crack-copyright)))
 		"Can't find a valid copyright notice")
 	       ((not (or non-fsf-ok
--- a/lisp/emacs-lisp/lisp-mode.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/emacs-lisp/lisp-mode.el	Tue Feb 17 01:52:25 2004 +0000
@@ -182,7 +182,7 @@
   (make-local-variable 'parse-sexp-ignore-comments)
   (setq parse-sexp-ignore-comments t)
   (make-local-variable 'outline-regexp)
-  (setq outline-regexp ";;;;* \\|(")
+  (setq outline-regexp ";;;;* [^ \t\n]\\|(")
   (make-local-variable 'outline-level)
   (setq outline-level 'lisp-outline-level)
   (make-local-variable 'comment-start)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/emacs-lisp/macroexp.el	Tue Feb 17 01:52:25 2004 +0000
@@ -0,0 +1,197 @@
+;;; macroexp.el --- Additional macro-expansion support
+;;
+;; Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+;;
+;; Author: Miles Bader <miles@gnu.org>
+;; Keywords: lisp, compiler, macros
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+;;
+;; This file contains macro-expansions functions that are not defined in
+;; the Lisp core, namely `macroexpand-all', which expands all macros in
+;; a form, not just a top-level one.
+;;
+
+;;; Code:
+
+;; Bound by the top-level `macroexpand-all', and modified to include any
+;; macros defined by `defmacro'.
+(defvar macroexpand-all-environment nil)
+
+(defun maybe-cons (car cdr original-cons)
+  "Return (CAR . CDR), using ORIGINAL-CONS if possible."
+  (if (and (eq car (car original-cons)) (eq cdr (cdr original-cons)))
+      original-cons
+    (cons car cdr)))
+
+;; We use this special macro to iteratively process forms and share list
+;; structure of the result with the input.  Doing so recursively using
+;; `maybe-cons' results in excessively deep recursion for very long
+;; input forms.
+(defmacro macroexp-accumulate (#1=#:\(var\ list\) &rest body)
+  "Return a list of the results of evaluating BODY for each element of LIST.
+Evaluate BODY with VAR bound to each `car' from LIST, in turn.
+Return a list of the values of the final form in BODY.
+The list structure of the result will share as much with LIST as
+possible (for instance, when BODY just returns VAR unchanged, the
+result will be eq to LIST)."
+  (let ((var (car #1#))
+	(list (cadr #1#))
+	(shared (make-symbol "shared"))
+	(unshared (make-symbol "unshared"))
+	(tail (make-symbol "tail"))
+	(new-el (make-symbol "new-el")))
+    `(let* ((,shared ,list)
+	    (,unshared nil)
+	    (,tail ,shared)
+	    ,var ,new-el)
+       (while ,tail
+	 (setq ,var (car ,tail)
+	       ,new-el (progn ,@body))
+	 (unless (eq ,var ,new-el)
+	   (while (not (eq ,shared ,tail))
+	     (push (pop ,shared) ,unshared))
+	   (setq ,shared (cdr ,shared))
+	   (push ,new-el ,unshared))
+	 (setq ,tail (cdr ,tail)))
+       (nconc (nreverse ,unshared) ,shared))))
+(put 'macroexp-accumulate 'lisp-indent-function 1)
+
+(defun macroexpand-all-forms (forms &optional skip)
+  "Return FORMS with macros expanded.  FORMS is a list of forms.
+If SKIP is non-nil, then don't expand that many elements at the start of
+FORMS."
+  (macroexp-accumulate (form forms)
+    (if (or (null skip) (zerop skip))
+	(macroexpand-all-1 form)
+      (setq skip (1- skip))
+      form)))
+
+(defun macroexpand-all-clauses (clauses &optional skip)
+  "Return CLAUSES with macros expanded.
+CLAUSES is a list of lists of forms; any clause that's not a list is ignored.
+If SKIP is non-nil, then don't expand that many elements at the start of
+each clause."
+  (macroexp-accumulate (clause clauses) 
+    (if (listp clause)
+	(macroexpand-all-forms clause skip)
+      clause)))
+
+(defun macroexpand-all-1 (form)
+  "Expand all macros in FORM.
+This is an internal version of `macroexpand-all'.
+Assumes the caller has bound `macroexpand-all-environment'."
+  (if (and (listp form) (eq (car form) 'backquote-list*))
+      ;; Special-case `backquote-list*', as it is normally a macro that
+      ;; generates exceedingly deep expansions from relatively shallow input
+      ;; forms.  We just process it `in reverse' -- first we expand all the
+      ;; arguments, _then_ we expand the top-level definition.
+      (macroexpand (macroexpand-all-forms form 1)
+		   macroexpand-all-environment)
+    ;; Normal form; get its expansion, and then expand arguments.
+    (setq form (macroexpand form macroexpand-all-environment))
+    (if (consp form)
+	(let ((fun (car form)))
+	  (cond
+	   ((eq fun 'cond)
+	    (maybe-cons fun (macroexpand-all-clauses (cdr form)) form))
+	   ((eq fun 'condition-case)
+	    (maybe-cons
+	     fun
+	     (maybe-cons (cadr form)
+			 (maybe-cons (macroexpand-all-1 (nth 2 form))
+				     (macroexpand-all-clauses (nthcdr 3 form) 1)
+				     (cddr form))
+			 (cdr form))
+	     form))
+	   ((eq fun 'defmacro)
+	    (push (cons (cadr form) (cons 'lambda (cddr form)))
+		  macroexpand-all-environment)
+	    (macroexpand-all-forms form 3))
+	   ((eq fun 'defun)
+	    (macroexpand-all-forms form 3))
+	   ((memq fun '(defvar defconst))
+	    (macroexpand-all-forms form 2))
+	   ((eq fun 'function)
+	    (if (and (consp (cadr form)) (eq (car (cadr form)) 'lambda))
+		(maybe-cons fun
+			    (maybe-cons (macroexpand-all-forms (cadr form) 2)
+					nil
+					(cadr form))
+			    form)
+	      form))
+	   ((memq fun '(let let*))
+	    (maybe-cons fun
+			(maybe-cons (macroexpand-all-clauses (cadr form) 1)
+				    (macroexpand-all-forms (cddr form))
+				    (cdr form))
+			form))
+	   ((eq fun 'quote)
+	    form)
+	   ((and (consp fun) (eq (car fun) 'lambda))
+	    ;; embedded lambda
+	    (maybe-cons (macroexpand-all-forms fun 2)
+			(macroexpand-all-forms (cdr form))
+			form))
+	   ;; The following few cases are for normal function calls that
+	   ;; are known to funcall one of their arguments.  The byte
+	   ;; compiler has traditionally handled these functions specially
+	   ;; by treating a lambda expression quoted by `quote' as if it
+	   ;; were quoted by `function'.  We make the same transformation
+	   ;; here, so that any code that cares about the difference will
+	   ;; see the same transformation.
+	   ;; First arg is a function:
+	   ((and (memq fun '(apply mapcar mapatoms mapconcat mapc))
+		 (consp (cadr form))
+		 (eq (car (cadr form)) 'quote))
+	    ;; We don't use `maybe-cons' since there's clearly a change.
+	    (cons fun
+		  (cons (macroexpand-all-1 (cons 'function (cdr (cadr form))))
+			(macroexpand-all-forms (cddr form)))))
+	   ;; Second arg is a function:
+	   ((and (eq fun 'sort)
+		 (consp (nth 2 form))
+		 (eq (car (nth 2 form)) 'quote))
+	    ;; We don't use `maybe-cons' since there's clearly a change.
+	    (cons fun
+		  (cons (macroexpand-all-1 (cadr form))
+			(cons (macroexpand-all-1
+			       (cons 'function (cdr (nth 2 form))))
+			      (macroexpand-all-forms (nthcdr 3 form))))))
+	   (t
+	    ;; For everything else, we just expand each argument (for
+	    ;; setq/setq-default this works alright because the variable names
+	    ;; are symbols).
+	    (macroexpand-all-forms form 1))))
+      form)))
+
+;;;###autoload
+(defun macroexpand-all (form &optional environment)
+  "Return result of expanding macros at all levels in FORM.
+If no macros are expanded, FORM is returned unchanged.
+The second optional arg ENVIRONMENT specifies an environment of macro
+definitions to shadow the loaded ones for use in file byte-compilation."
+  (let ((macroexpand-all-environment environment))
+    (macroexpand-all-1 form)))
+
+(provide 'macroexp)
+
+;;; arch-tag: af9b8c24-c196-43bc-91e1-a3570790fa5a
+;;; macroexp.el ends here
--- a/lisp/emacs-lisp/rx.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/emacs-lisp/rx.el	Tue Feb 17 01:52:25 2004 +0000
@@ -345,7 +345,8 @@
 (defun rx-not (form)
   "Parse and produce code from FORM.  FORM is `(not ...)'."
   (rx-check form)
-  (let ((result (rx-to-string (cadr form) 'no-group)))
+  (let ((result (rx-to-string (cadr form) 'no-group))
+	case-fold-search)
     (cond ((string-match "\\`\\[^" result)
 	   (if (= (length result) 4)
 	       (substring result 2 3)
--- a/lisp/emulation/vi.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/emulation/vi.el	Tue Feb 17 01:52:25 2004 +0000
@@ -455,7 +455,7 @@
        (vi-mode-setup))
 
    (if (eq major-mode 'vi-mode)
-       (message "Already in vi-mode." (ding))
+       (progn (ding) (message "Already in vi-mode."))
      (setq vi-mode-old-local-map (current-local-map))
      (setq vi-mode-old-mode-name mode-name)
      (setq vi-mode-old-major-mode major-mode)
@@ -703,7 +703,7 @@
 		     regexp-search-ring
 		   search-ring))))
   (if (null search-command)
-      (message "No last search command to repeat." (ding))
+      (progn (ding) (message "No last search command to repeat."))
     (funcall search-command search-string nil nil arg)))
 
 (defun vi-reverse-last-search (arg &optional search-command search-string)
@@ -718,7 +718,7 @@
 		     regexp-search-ring
 		   search-ring))))
   (if (null search-command)
-      (message "No last search command to repeat." (ding))
+      (progn (ding) (message "No last search command to repeat."))
     (funcall (cond ((eq search-command 're-search-forward) 're-search-backward)
 		   ((eq search-command 're-search-backward) 're-search-forward)
 		   ((eq search-command 'search-forward) 'search-backward)
@@ -838,7 +838,7 @@
 	(t
 	 (let ((mark (vi-get-mark mark-char)))
 	   (if (null mark)
-	       (message "Mark register undefined." (vi-ding))
+	       (progn (vi-ding) (message "Mark register undefined."))
 	     (set-mark-command nil)
 	     (goto-char mark)
 	     (if line-flag (back-to-indentation)))))))
@@ -881,7 +881,7 @@
   (interactive "p")
   (if (null find-arg) (setq find-arg vi-last-find-char))
   (if (null find-arg)
-      (message "No last find char to repeat." (ding))
+      (progn (ding) (message "No last find char to repeat."))
     (vi-find-char (cons (* (car find-arg) -1) (cdr find-arg)) count))) ;6/13/86
 
 (defun vi-find-char (arg count)
@@ -909,7 +909,7 @@
   (interactive "p")
   (if (null find-arg) (setq find-arg vi-last-find-char))
   (if (null find-arg)
-      (message "No last find char to repeat." (ding))
+      (progn (ding) (message "No last find char to repeat."))
     (vi-find-char find-arg count)))
 
 (defun vi-backward-find-char (count char)
@@ -1465,7 +1465,8 @@
     (goto-char (point-min))
     (if (re-search-forward (concat "^(def[unvarconst ]*" name) nil t)
 	nil
-      (message "No definition for \"%s\" in current file." name (ding))
+      (ding)
+      (message "No definition for \"%s\" in current file." name)
       (set-mark-command t))))
 
 (defun vi-split-open-line (arg)
--- a/lisp/emulation/viper-ex.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/emulation/viper-ex.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; viper-ex.el --- functions implementing the Ex commands for Viper
 
-;; Copyright (C) 1994, 95, 96, 97, 98, 2000, 01, 02 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 95, 96, 97, 98, 2000, 01, 02, 04 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 
@@ -1458,7 +1458,7 @@
 	(if (eq 1 (length name))
 	    (setq char (string-to-char name))
 	  (error "`%s': Spurious text \"%s\" after mark name"
-		 name (substring name 1) viper-SpuriousText))
+		 name (substring name 1)))
     (save-window-excursion
       (setq viper-ex-work-buf (get-buffer-create viper-ex-work-buf-name))
       (set-buffer viper-ex-work-buf)
--- a/lisp/eshell/em-hist.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/eshell/em-hist.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; em-hist.el --- history list management
 
-;; Copyright (C) 1999, 2000 Free Software Foundation
+;; Copyright (C) 1999, 2000, 2004 Free Software Foundation
 
 ;; Author: John Wiegley <johnw@gnu.org>
 
@@ -523,7 +523,7 @@
    ((string= "^" ref) 1)
    ((string= "$" ref) nil)
    ((string= "%" ref)
-    (error "`%' history word designator not yet implemented"))))
+    (error "`%%' history word designator not yet implemented"))))
 
 (defun eshell-hist-parse-arguments (&optional silent b e)
   "Parse current command arguments in a history-code-friendly way."
--- a/lisp/eshell/esh-mode.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/eshell/esh-mode.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; esh-mode.el --- user interface
 
-;; Copyright (C) 1999, 2000, 2001 Free Software Foundation
+;; Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation
 
 ;; Author: John Wiegley <johnw@gnu.org>
 
@@ -1017,7 +1017,7 @@
 Then send it to the process running in the current buffer."
   (interactive "P")                     ; Defeat snooping via C-x ESC ESC
   (let ((str (read-passwd
-	      (format "Password: "
+	      (format "%s Password: "
 		      (process-name (eshell-interactive-process))))))
     (if (stringp str)
 	(process-send-string (eshell-interactive-process)
--- a/lisp/filecache.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/filecache.el	Tue Feb 17 01:52:25 2004 +0000
@@ -310,7 +310,7 @@
   "Add FILE to the file cache."
   (interactive "fAdd File: ")
   (if (not (file-exists-p file))
-      (message "File %s does not exist" file)
+      (message "Filecache: file %s does not exist" file)
     (let* ((file-name (file-name-nondirectory file))
 	   (dir-name  (file-name-directory    file))
 	   (the-entry (assoc-string
@@ -441,7 +441,8 @@
 		    (setq delete-list (cons (car elt) delete-list))))
 	    file-cache-alist)
     (file-cache-delete-file-list delete-list)
-    (message "Deleted %d files from file cache" (length delete-list))))
+    (message "Filecache: deleted %d files from file cache"
+             (length delete-list))))
 
 (defun file-cache-delete-directory (directory)
   "Delete DIRECTORY from the file cache."
@@ -454,8 +455,8 @@
 	    (setq result (1+ result))))
      file-cache-alist)
     (if (zerop result)
-	(error "No entries containing %s found in cache" directory)
-      (message "Deleted %d entries" result))))
+	(error "Filecache: no entries containing %s found in cache" directory)
+      (message "Filecache: deleted %d entries" result))))
 
 (defun file-cache-do-delete-directory (dir entry)
   (let ((directory-list (cdr entry))
@@ -488,14 +489,14 @@
 	 (num)
 	 )
     (if (not (listp directory-list))
-	(error "Unknown type in file-cache-alist for key %s" file))
+	(error "Filecache: unknown type in file-cache-alist for key %s" file))
     (cond
      ;; Single element
      ((eq 1 len)
       (setq directory (elt directory-list 0)))
      ;; No elements
      ((eq 0 len)
-      (error "No directory found for key %s" file))
+      (error "Filecache: no directory found for key %s" file))
      ;; Multiple elements
      (t
       (let* ((minibuffer-dir (file-name-directory (minibuffer-contents)))
--- a/lisp/files.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/files.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1619,7 +1619,7 @@
      ("\\.ltx\\'" . latex-mode)
      ("\\.dtx\\'" . doctex-mode)
      ("\\.el\\'" . emacs-lisp-mode)
-     ("\\.scm\\|\\.stk\\|\\.ss\\|\\.sch\\'" . scheme-mode)
+     ("\\.\\(scm\\|stk\\|ss\\|sch\\)\\'" . scheme-mode)
      ("\\.l\\'" . lisp-mode)
      ("\\.lisp\\'" . lisp-mode)
      ("\\.f\\'" . fortran-mode)
--- a/lisp/format.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/format.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; format.el --- read and save files in multiple formats
 
-;; Copyright (c) 1994, 1995, 1997, 1999 Free Software Foundation
+;; Copyright (c) 1994, 1995, 1997, 1999, 2004 Free Software Foundation
 
 ;; Author: Boris Goldowsky <boris@gnu.org>
 
@@ -287,7 +287,7 @@
 	    (let ((do format) f)
 	      (while do
 		(or (setq f (assq (car do) format-alist))
-		    (error "Unknown format" (car do)))
+		    (error "Unknown format %s" (car do)))
 		;; Decode:
 		(if (nth 3 f)
 		    (setq end (format-decode-run-method (nth 3 f) begin end)))
--- a/lisp/fringe.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/fringe.el	Tue Feb 17 01:52:25 2004 +0000
@@ -35,6 +35,33 @@
 
 ;;; Code:
 
+;; Standard fringe bitmaps
+
+(defconst no-fringe-bitmap 0)
+(defconst undef-fringe-bitmap 1)
+(defconst left-truncation-fringe-bitmap 2)
+(defconst right-truncation-fringe-bitmap 3)
+(defconst up-arrow-fringe-bitmap 4)
+(defconst down-arrow-fringe-bitmap 5)
+(defconst continued-line-fringe-bitmap 6)
+(defconst continuation-line-fringe-bitmap 7)
+(defconst overlay-arrow-fringe-bitmap 8)
+(defconst top-left-angle-fringe-bitmap 9)
+(defconst top-right-angle-fringe-bitmap 10)
+(defconst bottom-left-angle-fringe-bitmap 11)
+(defconst bottom-right-angle-fringe-bitmap 12)
+(defconst left-bracket-fringe-bitmap 13)
+(defconst right-bracket-fringe-bitmap 14)
+(defconst filled-box-cursor-fringe-bitmap 15)
+(defconst hollow-box-cursor-fringe-bitmap 16)
+(defconst hollow-square-fringe-bitmap 17)
+(defconst bar-cursor-fringe-bitmap 18)
+(defconst hbar-cursor-fringe-bitmap 19)
+(defconst empty-line-fringe-bitmap 20)
+
+
+;; Control presence of fringes
+
 (defvar fringe-mode)
 
 (defun set-fringe-mode-1 (ignore value)
--- a/lisp/gnus/ChangeLog	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/gnus/ChangeLog	Tue Feb 17 01:52:25 2004 +0000
@@ -1,3 +1,9 @@
+2004-02-08  Andreas Schwab  <schwab@suse.de>
+
+	* nnlistserv.el (nnlistserv-kk-wash-article): Fix paren nesting.
+
+	* gnus-score.el (gnus-summary-increase-score): Fix format string.
+
 2003-06-25  Sam Steingold  <sds@gnu.org>
 
 	* gnus-group.el (gnus-group-suspend): Avoid some consing.
--- a/lisp/gnus/gnus-score.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/gnus/gnus-score.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,5 +1,5 @@
 ;;; gnus-score.el --- scoring code for Gnus
-;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2004
 ;;        Free Software Foundation, Inc.
 
 ;; Author: Per Abrahamsen <amanda@iesd.auc.dk>
@@ -616,7 +616,7 @@
 	      (gnus-score-insert-help "Match permanence" char-to-perm 2)))
 
 	  (gnus-score-kill-help-buffer)
-	  (if mimic (message "%c %c %c" prefix hchar tchar pchar)
+	  (if mimic (message "%c %c %c %c" prefix hchar tchar pchar)
 	    (message ""))
 	  (unless (setq temporary (cadr (assq pchar char-to-perm)))
 	    ;; Deal with der(r)ided superannuated paradigms.
--- a/lisp/gnus/nnlistserv.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/gnus/nnlistserv.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; nnlistserv.el --- retrieving articles via web mailing list archives
 
-;; Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1998, 1999, 2000, 2004 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: news, mail
@@ -127,7 +127,7 @@
     (nnweb-decode-entities)
     (while headers
       (goto-char (point-min))
-      (re-search-forward (format "<!-- %s=\"\\([^\"]+\\)" (car headers) nil t))
+      (re-search-forward (format "<!-- %s=\"\\([^\"]+\\)" (car headers)) nil t)
       (set (pop headers) (match-string 1)))
     (goto-char (point-min))
     (search-forward "<!-- body" nil t)
--- a/lisp/hexl.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/hexl.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; hexl.el --- edit a file in a hex dump format using the hexl filter
 
-;; Copyright (C) 1989, 1994, 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 1994, 1998, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
 ;; Author: Keith Gabryelski <ag@wheaties.ai.mit.edu>
 ;; Maintainer: FSF
@@ -742,7 +742,7 @@
 
 CH must be a unibyte character whose value is between 0 and 255."
   (if (or (< ch 0) (> ch 255))
-      (error "Invalid character 0x%x -- must be in the range [0..255]"))
+      (error "Invalid character 0x%x -- must be in the range [0..255]" ch))
   (let ((address (hexl-current-address t)))
     (while (> num 0)
       (let ((hex-position
--- a/lisp/international/ccl.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/international/ccl.el	Tue Feb 17 01:52:25 2004 +0000
@@ -774,7 +774,8 @@
 	       (ccl-check-register right rrr)
 	       (ccl-embed-code 'write-expr-register 0
 			       (logior (ash op 3)
-				       (get right 'ccl-register-number))))))
+				       (get right 'ccl-register-number))
+			       left))))
 
 	  (t
 	   (error "CCL: Invalid argument: %s" cmd))))
--- a/lisp/iswitchb.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/iswitchb.el	Tue Feb 17 01:52:25 2004 +0000
@@ -377,18 +377,11 @@
   "Iswitchb-specific customization of minibuffer setup.
 
 This hook is run during minibuffer setup iff `iswitchb' will be active.
-It is intended for use in customizing iswitchb for interoperation
-with other packages."
-;;;   For instance:
-
-;;;   \(add-hook 'iswitchb-minibuffer-setup-hook
-;;; 	    \(function
-;;; 	     \(lambda ()
-;;; 	       \(make-local-variable 'resize-minibuffer-window-max-height)
-;;; 	       \(setq resize-minibuffer-window-max-height 3))))
-
-;;; will constrain rsz-mini to a maximum minibuffer height of 3 lines when
-;;; iswitchb is running.  Copied from `icomplete-minibuffer-setup-hook'."
+For instance:
+\(add-hook 'iswitchb-minibuffer-setup-hook
+	  '\(lambda () (set (make-local-variable 'max-mini-window-height) 3)))
+will constrain the minibuffer to a maximum height of 3 lines when
+iswitchb is running."
   :type 'hook
   :group 'iswitchb)
 
--- a/lisp/loadup.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/loadup.el	Tue Feb 17 01:52:25 2004 +0000
@@ -194,6 +194,7 @@
 (when (fboundp 'x-create-frame)
   (load "mouse")
   (load "international/fontset")
+  (load "x-dnd")
   (load "term/x-win"))
 
 (message "%s" (garbage-collect))
--- a/lisp/mail/mail-utils.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/mail/mail-utils.el	Tue Feb 17 01:52:25 2004 +0000
@@ -227,9 +227,15 @@
                       "")
                     (if (and user-mail-address
                              (not (equal user-mail-address user-login-name)))
-                        (concat (regexp-quote user-mail-address) "\\|")
+			;; Anchor the login name and email address so
+			;; that we don't match substrings: if the
+			;; login name is "foo", we shouldn't match
+			;; "barfoo@baz.com".
+                        (concat "\\`"
+				(regexp-quote user-mail-address)
+				"\\'\\|")
                       "")
-                    (concat (regexp-quote user-login-name) "\\>"))))
+                    (concat "\\`" (regexp-quote user-login-name) "@"))))
   ;; Split up DESTINATIONS and match each element separately.
   (let ((start-pos 0) (cur-pos 0)
 	(case-fold-search t))
--- a/lisp/mail/rmail.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/mail/rmail.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; rmail.el --- main code of "RMAIL" mail reader for Emacs
 
-;; Copyright (C) 1985,86,87,88,93,94,95,96,97,98,2000, 2001
+;; Copyright (C) 1985,86,87,88,93,94,95,96,97,98,2000, 01, 2004
 ;;		Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
@@ -139,9 +139,9 @@
   :group 'rmail-reply)
 
 ;;;###autoload
-(defvar rmail-default-dont-reply-to-names "info-" "\
-A regular expression specifying part of the value of the default value of
-the variable `rmail-dont-reply-to-names', for when the user does not set
+(defvar rmail-default-dont-reply-to-names "\\`info-" "\
+A regular expression specifying part of the default value of the
+variable `rmail-dont-reply-to-names', for when the user does not set
 `rmail-dont-reply-to-names' explicitly.  (The other part of the default
 value is the user's email address and name.)
 It is useful to set this variable in the site customization file.")
@@ -1488,13 +1488,11 @@
 			 ;; print out a message on number of spam messages found:
 			 (if (and rmail-use-spam-filter (> rsf-number-of-spam 0))
 			     (if (= 1 new-messages)
-				 (format ", and found to be a spam message"
-					 rsf-number-of-spam)
+				 ", and found to be a spam message"
 			       (if (> rsf-number-of-spam 1)
 				   (format ", %d of which found to be spam messages"
 					   rsf-number-of-spam)
-				 (format ", one of which found to be a spam message"
-					 rsf-number-of-spam)))
+				 ", one of which found to be a spam message"))
 			   ""))
 		(if (and rmail-use-spam-filter (> rsf-number-of-spam 0))
 		    (progn (if rmail-spam-filter-beep (beep t))
--- a/lisp/mail/smtpmail.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/mail/smtpmail.el	Tue Feb 17 01:52:25 2004 +0000
@@ -488,9 +488,9 @@
 	 (mech (car (smtpmail-intersection smtpmail-auth-supported mechs)))
 	 (cred (if (stringp smtpmail-auth-credentials)
 		   (let* ((netrc (netrc-parse smtpmail-auth-credentials))
-			  (hostentry (netrc-machine
-				      netrc host (format "%s" (or port "smtp"))
-				      "smtp")))
+                          (port-name (format "%s" (or port "smtp")))
+			  (hostentry (netrc-machine netrc host port-name
+                                                    port-name)))
                      (when hostentry
                        (list host port
                              (netrc-get hostentry "login")
@@ -504,7 +504,7 @@
 				(smtpmail-cred-server cred)
 				(smtpmail-cred-port cred))))))
 	 ret)
-    (when cred
+    (when (and cred mech)
       (cond
        ((eq mech 'cram-md5)
 	(smtpmail-send-command process (format "AUTH %s" mech))
--- a/lisp/midnight.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/midnight.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; midnight.el --- run something every midnight, e.g., kill old buffers
 
-;;; Copyright (C) 1998 Free Software Foundation, Inc.
+;;; Copyright (C) 1998, 2004 Free Software Foundation, Inc.
 
 ;; Author: Sam Steingold <sds@usa.net>
 ;; Maintainer: Sam Steingold <sds@usa.net>
@@ -215,7 +215,7 @@
 Sets the first argument SYMB (which must be symbol `midnight-delay')
 to its second argument TM."
   (assert (eq symb 'midnight-delay) t
-          "Illegal argument to `midnight-delay-set': `%s'" symb)
+          "Illegal argument to `midnight-delay-set': `%s'")
   (set symb tm)
   (when (timerp midnight-timer) (cancel-timer midnight-timer))
   (setq midnight-timer
--- a/lisp/net/webjump.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/net/webjump.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; webjump.el --- programmable Web hotlist
 
-;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1997, 2004 Free Software Foundation, Inc.
 
 ;; Author:    Neil W. Van Dyke <nwv@acm.org>
 ;; Created:   09-Aug-1996
@@ -300,7 +300,8 @@
      ((eq builtin 'mirrors)
       (if (= (length expr) 1)
           (error
-           "WebJump URL builtin \"mirrors\" for \"%s\" needs at least 1 arg"))
+           "WebJump URL builtin \"mirrors\" for \"%s\" needs at least 1 arg"
+	   name))
       (webjump-choose-mirror name (cdr (append expr nil))))
      ((eq builtin 'name)
       name)
--- a/lisp/newcomment.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/newcomment.el	Tue Feb 17 01:52:25 2004 +0000
@@ -129,6 +129,31 @@
 column indentation or nil.
 If nil is returned, indentation is delegated to `indent-according-to-mode'.")
 
+;;;###autoload
+(defvar comment-insert-comment-function nil
+  "Function to insert a comment when a line doesn't contain one.
+The function has no args.
+
+Applicable at least in modes for languages like fixed-format Fortran where
+comments always start in column zero.")
+
+(defvar comment-region-function nil
+  "Function to comment a region.
+Its args are the same as those of `comment-region', but BEG and END are
+guaranteed to be correctly ordered.  It is called within `save-excursion'.
+
+Applicable at least in modes for languages like fixed-format Fortran where
+comments always start in column zero.")
+
+(defvar uncomment-region-function nil
+  "Function to uncomment a region.
+Its args are the same as those of `uncomment-region', but BEG and END are
+guaranteed to be correctly ordered.  It is called within `save-excursion'.
+
+Applicable at least in modes for languages like fixed-format Fortran where
+comments always start in column zero.")
+
+;; ?? never set
 (defvar block-comment-start nil)
 (defvar block-comment-end nil)
 
@@ -460,7 +485,7 @@
 
 ;;;###autoload
 (defun comment-indent (&optional continue)
-  "Indent this line's comment to comment column, or insert an empty comment.
+  "Indent this line's comment to `comment-column', or insert an empty comment.
 If CONTINUE is non-nil, use the `comment-continue' markers if any."
   (interactive "*")
   (comment-normalize-vars)
@@ -486,9 +511,12 @@
 		(forward-char (/ (skip-chars-backward " \t") -2)))
 	    (setq cpos (point-marker)))
 	  ;; If none, insert one.
+	(if comment-insert-comment-function
+	    (funcall comment-insert-comment-function)
 	  (save-excursion
-	    ;; Some comment-indent-function insist on not moving comments that
-	    ;; are in column 0, so we first go to the likely target column.
+	    ;; Some `comment-indent-function's insist on not moving
+	    ;; comments that are in column 0, so we first go to the
+	    ;; likely target column.
 	    (indent-to comment-column)
 	    ;; Ensure there's a space before the comment for things
 	    ;; like sh where it matters (as well as being neater).
@@ -497,7 +525,7 @@
 	    (setq begpos (point))
 	    (insert starter)
 	    (setq cpos (point-marker))
-	    (insert ender)))
+	    (insert ender))))
       (goto-char begpos)
       ;; Compute desired indent.
       (setq indent (save-excursion (funcall comment-indent-function)))
@@ -672,30 +700,32 @@
   (comment-normalize-vars)
   (if (> beg end) (let (mid) (setq mid beg beg end end mid)))
   (save-excursion
-    (goto-char beg)
-    (setq end (copy-marker end))
-    (let* ((numarg (prefix-numeric-value arg))
-           (ccs comment-continue)
-           (srei (comment-padright ccs 're))
-           (csre (comment-padright comment-start 're))
-           (sre (and srei (concat "^\\s-*?\\(" srei "\\)")))
-           spt)
-      (while (and (< (point) end)
-		  (setq spt (comment-search-forward end t)))
-	(let ((ipt (point))
-              ;; Find the end of the comment.
-              (ept (progn
-                     (goto-char spt)
-                     (unless (comment-forward)
-                       (error "Can't find the comment end"))
-                     (point)))
-              (box nil)
-              (box-equal nil))     ;Whether we might be using `=' for boxes.
-	  (save-restriction
-	    (narrow-to-region spt ept)
+    (if uncomment-region-function
+	(funcall uncomment-region-function beg end arg)
+      (goto-char beg)
+      (setq end (copy-marker end))
+      (let* ((numarg (prefix-numeric-value arg))
+	     (ccs comment-continue)
+	     (srei (comment-padright ccs 're))
+	     (csre (comment-padright comment-start 're))
+	     (sre (and srei (concat "^\\s-*?\\(" srei "\\)")))
+	     spt)
+	(while (and (< (point) end)
+		    (setq spt (comment-search-forward end t)))
+	  (let ((ipt (point))
+		;; Find the end of the comment.
+		(ept (progn
+		       (goto-char spt)
+		       (unless (comment-forward)
+			 (error "Can't find the comment end"))
+		       (point)))
+		(box nil)
+		(box-equal nil)) ;Whether we might be using `=' for boxes.
+	    (save-restriction
+	      (narrow-to-region spt ept)
 
-	    ;; Remove the comment-start.
-	    (goto-char ipt)
+	      ;; Remove the comment-start.
+	      (goto-char ipt)
 	    (skip-syntax-backward " ")
 	    ;; A box-comment starts with a looong comment-start marker.
 	    (when (and (or (and (= (- (point) (point-min)) 1)
@@ -715,52 +745,52 @@
 	      (goto-char (match-end 0)))
 	    (if (null arg) (delete-region (point-min) (point))
 	      (skip-syntax-backward " ")
-	      (delete-char (- numarg))
-	      (unless (or (bobp)
-			  (save-excursion (goto-char (point-min))
-					  (looking-at comment-start-skip)))
-		;; If there's something left but it doesn't look like
-		;; a comment-start any more, just remove it.
-		(delete-region (point-min) (point))))
+		  (delete-char (- numarg))
+		  (unless (or (bobp)
+			      (save-excursion (goto-char (point-min))
+					      (looking-at comment-start-skip)))
+		    ;; If there's something left but it doesn't look like
+		    ;; a comment-start any more, just remove it.
+		    (delete-region (point-min) (point))))
 
-	    ;; Remove the end-comment (and leading padding and such).
-	    (goto-char (point-max)) (comment-enter-backward)
-	    ;; Check for special `=' used sometimes in comment-box.
-	    (when (and box-equal (not (eq (char-before (point-max)) ?\n)))
-	      (let ((pos (point)))
-		;; skip `=' but only if there are at least 7.
-		(when (> (skip-chars-backward "=") -7) (goto-char pos))))
-	    (unless (looking-at "\\(\n\\|\\s-\\)*\\'")
-	      (when (and (bolp) (not (bobp))) (backward-char))
-	      (if (null arg) (delete-region (point) (point-max))
-		(skip-syntax-forward " ")
-		(delete-char numarg)
-		(unless (or (eobp) (looking-at comment-end-skip))
-		  ;; If there's something left but it doesn't look like
-		  ;; a comment-end any more, just remove it.
-		  (delete-region (point) (point-max)))))
+		;; Remove the end-comment (and leading padding and such).
+		(goto-char (point-max)) (comment-enter-backward)
+		;; Check for special `=' used sometimes in comment-box.
+		(when (and box-equal (not (eq (char-before (point-max)) ?\n)))
+		  (let ((pos (point)))
+		    ;; skip `=' but only if there are at least 7.
+		    (when (> (skip-chars-backward "=") -7) (goto-char pos))))
+		(unless (looking-at "\\(\n\\|\\s-\\)*\\'")
+		  (when (and (bolp) (not (bobp))) (backward-char))
+		  (if (null arg) (delete-region (point) (point-max))
+		    (skip-syntax-forward " ")
+		    (delete-char numarg)
+		    (unless (or (eobp) (looking-at comment-end-skip))
+		      ;; If there's something left but it doesn't look like
+		      ;; a comment-end any more, just remove it.
+		      (delete-region (point) (point-max)))))
 
-	    ;; Unquote any nested end-comment.
-	    (comment-quote-nested comment-start comment-end t)
+		;; Unquote any nested end-comment.
+		(comment-quote-nested comment-start comment-end t)
 
-	    ;; Eliminate continuation markers as well.
-	    (when sre
-	      (let* ((cce (comment-string-reverse (or comment-continue
-						      comment-start)))
-		     (erei (and box (comment-padleft cce 're)))
-		     (ere (and erei (concat "\\(" erei "\\)\\s-*$"))))
-		(goto-char (point-min))
-		(while (progn
-			 (if (and ere (re-search-forward
-				       ere (line-end-position) t))
-			     (replace-match "" t t nil (if (match-end 2) 2 1))
-			   (setq ere nil))
-			 (forward-line 1)
-			 (re-search-forward sre (line-end-position) t))
-		  (replace-match "" t t nil (if (match-end 2) 2 1)))))
-	    ;; Go to the end for the next comment.
-	    (goto-char (point-max)))))
-      (set-marker end nil))))
+		;; Eliminate continuation markers as well.
+		(when sre
+		  (let* ((cce (comment-string-reverse (or comment-continue
+							  comment-start)))
+			 (erei (and box (comment-padleft cce 're)))
+			 (ere (and erei (concat "\\(" erei "\\)\\s-*$"))))
+		    (goto-char (point-min))
+		    (while (progn
+			     (if (and ere (re-search-forward
+					   ere (line-end-position) t))
+				 (replace-match "" t t nil (if (match-end 2) 2 1))
+			       (setq ere nil))
+			     (forward-line 1)
+			     (re-search-forward sre (line-end-position) t))
+		      (replace-match "" t t nil (if (match-end 2) 2 1)))))
+		;; Go to the end for the next comment.
+		(goto-char (point-max)))))))
+      (set-marker end nil)))
 
 (defun comment-make-extra-lines (cs ce ccs cce min-indent max-indent &optional block)
   "Make the leading and trailing extra lines.
@@ -930,49 +960,52 @@
 	 (block (nth 1 style))
 	 (multi (nth 0 style)))
     (save-excursion
-      ;; we use `chars' instead of `syntax' because `\n' might be
-      ;; of end-comment syntax rather than of whitespace syntax.
-      ;; sanitize BEG and END
-      (goto-char beg) (skip-chars-forward " \t\n\r") (beginning-of-line)
-      (setq beg (max beg (point)))
-      (goto-char end) (skip-chars-backward " \t\n\r") (end-of-line)
-      (setq end (min end (point)))
-      (if (>= beg end) (error "Nothing to comment"))
+      (if comment-region-function
+	  (funcall comment-region-function beg end arg)
+	;; we use `chars' instead of `syntax' because `\n' might be
+	;; of end-comment syntax rather than of whitespace syntax.
+	;; sanitize BEG and END
+	(goto-char beg) (skip-chars-forward " \t\n\r") (beginning-of-line)
+	(setq beg (max beg (point)))
+	(goto-char end) (skip-chars-backward " \t\n\r") (end-of-line)
+	(setq end (min end (point)))
+	(if (>= beg end) (error "Nothing to comment"))
 
-      ;; sanitize LINES
-      (setq lines
-	    (and
-	     lines ;; multi
-	     (progn (goto-char beg) (beginning-of-line)
-		    (skip-syntax-forward " ")
-		    (>= (point) beg))
-	     (progn (goto-char end) (end-of-line) (skip-syntax-backward " ")
-		    (<= (point) end))
-	     (or block (not (string= "" comment-end)))
-	     (or block (progn (goto-char beg) (search-forward "\n" end t))))))
+	;; sanitize LINES
+	(setq lines
+	      (and
+	       lines ;; multi
+	       (progn (goto-char beg) (beginning-of-line)
+		      (skip-syntax-forward " ")
+		      (>= (point) beg))
+	       (progn (goto-char end) (end-of-line) (skip-syntax-backward " ")
+		      (<= (point) end))
+	       (or block (not (string= "" comment-end)))
+	       (or block (progn (goto-char beg) (search-forward "\n" end t))))))
 
-    ;; don't add end-markers just because the user asked for `block'
-    (unless (or lines (string= "" comment-end)) (setq block nil))
+      ;; don't add end-markers just because the user asked for `block'
+      (unless (or lines (string= "" comment-end)) (setq block nil))
 
-    (cond
-     ((consp arg) (uncomment-region beg end))
-     ((< numarg 0) (uncomment-region beg end (- numarg)))
-     (t
-      (setq numarg (if (and (null arg) (= (length comment-start) 1))
-		       add (1- numarg)))
-      (comment-region-internal
-       beg end
-       (let ((s (comment-padright comment-start numarg)))
-	 (if (string-match comment-start-skip s) s
-	   (comment-padright comment-start)))
-       (let ((s (comment-padleft comment-end numarg)))
-	 (and s (if (string-match comment-end-skip s) s
-		  (comment-padright comment-end))))
-       (if multi (comment-padright comment-continue numarg))
-       (if multi (comment-padleft (comment-string-reverse comment-continue) numarg))
-       block
-       lines
-       (nth 3 style))))))
+      (cond
+       ((consp arg) (uncomment-region beg end))
+       ((< numarg 0) (uncomment-region beg end (- numarg)))
+       (t
+	(setq numarg (if (and (null arg) (= (length comment-start) 1))
+			 add (1- numarg)))
+	(comment-region-internal
+	 beg end
+	 (let ((s (comment-padright comment-start numarg)))
+	   (if (string-match comment-start-skip s) s
+	     (comment-padright comment-start)))
+	 (let ((s (comment-padleft comment-end numarg)))
+	   (and s (if (string-match comment-end-skip s) s
+		    (comment-padright comment-end))))
+	 (if multi (comment-padright comment-continue numarg))
+	 (if multi
+	     (comment-padleft (comment-string-reverse comment-continue) numarg))
+	 block
+	 lines
+	 (nth 3 style)))))))
 
 (defun comment-box (beg end &optional arg)
   "Comment out the BEG .. END region, putting it inside a box.
--- a/lisp/pcvs-defs.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/pcvs-defs.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; pcvs-defs.el --- variable definitions for PCL-CVS
 
-;; Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2003
+;; Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 03, 2004
 ;;           Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <monnier@cs.yale.edu>
@@ -413,6 +413,7 @@
     ["Update"			cvs-mode-update		(cvs-enabledp 'update)]
     ["Re-examine"		cvs-mode-examine	t]
     ["Commit"			cvs-mode-commit-setup	(cvs-enabledp 'commit)]
+    ["Tag"			cvs-mode-tag		(cvs-enabledp (when cvs-force-dir-tag 'tag))]
     ["Undo changes"		cvs-mode-undo		(cvs-enabledp 'undo)]
     ["Add"			cvs-mode-add		(cvs-enabledp 'add)]
     ["Remove"			cvs-mode-remove		(cvs-enabledp 'remove)]
--- a/lisp/play/zone.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/play/zone.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; zone.el --- idle display hacks
 
-;; Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2001, 2004 Free Software Foundation, Inc.
 
 ;; Author: Victor Zandy <zandy@cs.wisc.edu>
 ;; Maintainer: Thien-Thi Nguyen <ttn@gnu.org>
@@ -125,7 +125,7 @@
                                (functionp (car elem))
                                (numberp (cadr elem)))
                           (apply 'zone-call elem))
-                         (t (error "bad `zone-call' elem:" elem))))
+                         (t (error "bad `zone-call' elem: %S" elem))))
                  program))))
 
 ;;;###autoload
--- a/lisp/progmodes/compile.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/progmodes/compile.el	Tue Feb 17 01:52:25 2004 +0000
@@ -386,6 +386,9 @@
 try; %s in the string is replaced by the text matching the FILE-IDX'th
 subexpression.")
 
+(defvar compilation-directory nil
+  "Directory to restore to when doing `recompile'.")
+
 (defvar compilation-enter-directory-regexp-alist
   '(
     ;; Matches lines printed by the `-w' option of GNU Make.
@@ -578,6 +581,7 @@
   (unless (equal command (eval compile-command))
     (setq compile-command command))
   (save-some-buffers (not compilation-ask-about-save) nil)
+  (setq compilation-directory default-directory)
   (compile-internal command "No more errors"))
 
 ;; run compile with the default command line
@@ -587,8 +591,10 @@
 original use.  Otherwise, it recompiles using `compile-command'."
   (interactive)
   (save-some-buffers (not compilation-ask-about-save) nil)
-  (apply 'compile-internal (or compilation-arguments
-			      `(,(eval compile-command) "No more errors"))))
+  (let ((default-directory (or compilation-directory default-directory)))
+    (apply 'compile-internal (or compilation-arguments
+				 `(,(eval compile-command)
+				   "No more errors")))))
 
 (defcustom compilation-scroll-output nil
   "*Non-nil to scroll the *compilation* buffer window as output appears.
--- a/lisp/progmodes/cperl-mode.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/progmodes/cperl-mode.el	Tue Feb 17 01:52:25 2004 +0000
@@ -4313,11 +4313,12 @@
 			 (looking-at "^[ \t]*#+[ \t]*[^ \t\n#]")))
 	   (point)))
 	;; Remove existing hashes
-	(goto-char (point-min))
-	(while (progn (forward-line 1) (< (point) (point-max)))
-	  (skip-chars-forward " \t")
-	  (and (looking-at "#+")
-	       (delete-char (- (match-end 0) (match-beginning 0)))))
+	(save-excursion
+	  (goto-char (point-min))
+	  (while (progn (forward-line 1) (< (point) (point-max)))
+	    (skip-chars-forward " \t")
+	    (and (looking-at "#+")
+		 (delete-char (- (match-end 0) (match-beginning 0))))))
 
 	;; Lines with only hashes on them can be paragraph boundaries.
 	(let ((paragraph-start (concat paragraph-start "\\|^[ \t#]*$"))
--- a/lisp/progmodes/grep.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/progmodes/grep.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; grep.el --- run compiler as inferior of Emacs, parse error messages
 
-;; Copyright (C) 1985, 86, 87, 93, 94, 95, 96, 97, 98, 1999, 2001, 2002
+;; Copyright (C) 1985, 86, 87, 93, 94, 95, 96, 97, 98, 1999, 2001, 02, 2004
 ;;  Free Software Foundation, Inc.
 
 ;; Author: Roland McGrath <roland@gnu.org>
@@ -216,7 +216,7 @@
 ;; Note: the character class after the optional drive letter does not
 ;; include a space to support file names with blanks.
 (defvar grep-regexp-alist
-  '(("\\([a-zA-Z]?:?[^:(\t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 2))
+  '(("\\([a-zA-Z]?:?.+?\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 2))
   "Regexp used to match grep hits.  See `compilation-error-regexp-alist'.")
 
 (defvar grep-program
@@ -318,9 +318,9 @@
 	      'gnu)))
   (unless grep-find-command
     (setq grep-find-command
-          (cond ((not (executable-command-find-unix-p "find"))
+          (cond ((not (executable-command-find-posix-p "find"))
 		 (message
-		  (concat "compile.el: Unix type find(1) not found. "
+		  (concat "compile.el: Posix-style find(1) not found. "
 			  "Please set `grep-find-command'."))
 		 nil)
 		((eq grep-find-use-xargs 'gnu)
@@ -542,6 +542,5 @@
 
 (provide 'grep)
 
+;;; arch-tag: 5a5b9169-a79d-4f38-9c38-f69615f39c4d
 ;;; grep.el ends here
- 
-;;; arch-tag: 5a5b9169-a79d-4f38-9c38-f69615f39c4d
--- a/lisp/progmodes/gud.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/progmodes/gud.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1967,14 +1967,14 @@
 	 ;; FIXME: Java ID's are UNICODE strings, this matches ASCII
 	 ;; ID's only.
          ;;
-         ;; The "," in the last square-bracket is necessary because of
-         ;; Sun's total disrespect for backwards compatibility in
+         ;; The ".," in the last square-bracket are necessary because
+         ;; of Sun's total disrespect for backwards compatibility in
          ;; reported line numbers from jdb - starting in 1.4.0 they
-         ;; introduced a comma at the thousands position (how
-         ;; ingenious!)
+         ;; print line numbers using LOCALE, inserting a comma or a
+         ;; period at the thousands positions (how ingenious!).
 
 	 "\\(\[[0-9]+\] \\)*\\([a-zA-Z0-9.$_]+\\)\\.[a-zA-Z0-9$_<>(),]+ \
-\\(([a-zA-Z0-9.$_]+:\\|line=\\)\\([0-9,]+\\)"
+\\(([a-zA-Z0-9.$_]+:\\|line=\\)\\([0-9.,]+\\)"
 	 gud-marker-acc)
 
       ;; A good marker is one that:
@@ -2001,7 +2001,7 @@
 			  (string-to-int
 			   (let
                                ((numstr (match-string 4 gud-marker-acc)))
-                             (if (string-match "," numstr)
+                             (if (string-match "[.,]" numstr)
                                  (replace-match "" nil nil numstr)
                                numstr)))))
 	    (message "Could not find source file.")))
--- a/lisp/progmodes/prolog.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/progmodes/prolog.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; prolog.el --- major mode for editing and running Prolog under Emacs
 
-;; Copyright (C) 1986, 1987 Free Software Foundation, Inc.
+;; Copyright (C) 1986, 1987, 2003, 2004 Free Software Foundation, Inc.
 
 ;; Author: Masanobu UMEDA <umerin@mse.kyutech.ac.jp>
 ;; Keywords: languages
@@ -30,16 +30,17 @@
 
 ;;; Code:
 
-(defvar prolog-mode-syntax-table nil)
-(defvar prolog-mode-abbrev-table nil)
-(defvar prolog-mode-map nil)
-
 (defgroup prolog nil
   "Major mode for editing and running Prolog under Emacs"
   :group 'languages)
 
 
-(defcustom prolog-program-name "prolog"
+(defcustom prolog-program-name
+  (let ((names '("prolog" "gprolog")))
+    (while (and names
+		(not (executable-find (car names))))
+      (setq names (cdr names)))
+    (or (car names) "prolog"))
   "*Program name for invoking an inferior Prolog with `run-prolog'."
   :type 'string
   :group 'prolog)
@@ -75,8 +76,7 @@
      (3 font-lock-variable-name-face)))
   "Font-lock keywords for Prolog mode.")
 
-(if prolog-mode-syntax-table
-    ()
+(defvar prolog-mode-syntax-table
   (let ((table (make-syntax-table)))
     (modify-syntax-entry ?_ "w" table)
     (modify-syntax-entry ?\\ "\\" table)
@@ -90,17 +90,14 @@
     (modify-syntax-entry ?< "." table)
     (modify-syntax-entry ?> "." table)
     (modify-syntax-entry ?\' "\"" table)
-    (setq prolog-mode-syntax-table table)))
+    table))
 
+(defvar prolog-mode-abbrev-table nil)
 (define-abbrev-table 'prolog-mode-abbrev-table ())
 
 (defun prolog-mode-variables ()
-  (set-syntax-table prolog-mode-syntax-table)
-  (setq local-abbrev-table prolog-mode-abbrev-table)
-  (make-local-variable 'paragraph-start)
-  (setq paragraph-start (concat "%%\\|$\\|" page-delimiter)) ;'%%..'
   (make-local-variable 'paragraph-separate)
-  (setq paragraph-separate paragraph-start)
+  (setq paragraph-separate (concat "%%\\|$\\|" page-delimiter)) ;'%%..'
   (make-local-variable 'paragraph-ignore-fill-prefix)
   (setq paragraph-ignore-fill-prefix t)
   (make-local-variable 'imenu-generic-expression)
@@ -110,20 +107,16 @@
   (make-local-variable 'comment-start)
   (setq comment-start "%")
   (make-local-variable 'comment-start-skip)
-  (setq comment-start-skip "%+ *")
+  (setq comment-start-skip "\\(?:%+\\|/\\*+\\)[ \t]*")
+  (make-local-variable 'comment-end-skip)
+  (setq comment-end-skip "[ \t]*\\(\n\\|\\*+/\\)")
   (make-local-variable 'comment-column)
-  (setq comment-column 48)
-  (make-local-variable 'comment-indent-function)
-  (setq comment-indent-function 'prolog-comment-indent))
+  (setq comment-column 48))
 
-(defun prolog-mode-commands (map)
-  (define-key map "\t" 'prolog-indent-line)
-  (define-key map "\e\C-x" 'prolog-consult-region))
-
-(if prolog-mode-map
-    nil
-  (setq prolog-mode-map (make-sparse-keymap))
-  (prolog-mode-commands prolog-mode-map))
+(defvar prolog-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\e\C-x" 'prolog-consult-region)
+    map))
 
 ;;;###autoload
 (defun prolog-mode ()
@@ -136,6 +129,7 @@
   (interactive)
   (kill-all-local-variables)
   (use-local-map prolog-mode-map)
+  (set-syntax-table prolog-mode-syntax-table)
   (setq major-mode 'prolog-mode)
   (setq mode-name "Prolog")
   (prolog-mode-variables)
@@ -143,7 +137,7 @@
   (setq font-lock-defaults '(prolog-font-lock-keywords
                              nil nil nil
                              beginning-of-line))
-  (run-hooks 'prolog-mode-hook))
+  (run-mode-hooks 'prolog-mode-hook))
 
 (defun prolog-indent-line (&optional whole-exp)
   "Indent current line as Prolog code.
@@ -217,26 +211,20 @@
     (if (re-search-forward comment-start-skip eolpos 'move)
 	(goto-char (match-beginning 0)))
     (skip-chars-backward " \t")))
-
-(defun prolog-comment-indent ()
-  "Compute prolog comment indentation."
-  (cond ((looking-at "%%%") 0)
-	((looking-at "%%") (prolog-indent-level))
-	(t
-	 (save-excursion
-	       (skip-chars-backward " \t")
-	       ;; Insert one space at least, except at left margin.
-	       (max (+ (current-column) (if (bolp) 0 1))
-		    comment-column)))
-	))
-
 
 ;;;
 ;;; Inferior prolog mode
 ;;;
-(defvar inferior-prolog-mode-map nil)
+(defvar inferior-prolog-mode-map
+  (let ((map (make-sparse-keymap)))
+    ;; This map will inherit from `comint-mode-map' when entering
+    ;; inferior-prolog-mode.
+    map))
 
-(defun inferior-prolog-mode ()
+(defvar inferior-prolog-mode-syntax-table prolog-mode-syntax-table)
+(defvar inferior-prolog-mode-abbrev-table prolog-mode-abbrev-table)
+
+(define-derived-mode inferior-prolog-mode comint-mode "Inferior Prolog"
   "Major mode for interacting with an inferior Prolog process.
 
 The following commands are available:
@@ -260,25 +248,15 @@
 \\[comint-kill-input] and \\[backward-kill-word] are kill commands, imitating normal Unix input editing.
 \\[comint-interrupt-subjob] interrupts the shell or its current subjob if any.
 \\[comint-stop-subjob] stops. \\[comint-quit-subjob] sends quit signal."
-  (interactive)
-  (require 'comint)
-  (comint-mode)
-  (setq major-mode 'inferior-prolog-mode
-	mode-name "Inferior Prolog"
-	comint-prompt-regexp "^| [ ?][- ] *")
-  (prolog-mode-variables)
-  (if inferior-prolog-mode-map nil
-    (setq inferior-prolog-mode-map (copy-keymap comint-mode-map))
-    (prolog-mode-commands inferior-prolog-mode-map))
-  (use-local-map inferior-prolog-mode-map)
-  (run-hooks 'prolog-mode-hook))
+  (setq comint-prompt-regexp "^| [ ?][- ] *")
+  (prolog-mode-variables))
 
 ;;;###autoload
 (defun run-prolog ()
   "Run an inferior Prolog process, input and output via buffer *prolog*."
   (interactive)
   (require 'comint)
-  (switch-to-buffer (make-comint "prolog" prolog-program-name))
+  (pop-to-buffer (make-comint "prolog" prolog-program-name))
   (inferior-prolog-mode))
 
 (defun prolog-consult-region (compile beg end)
--- a/lisp/progmodes/xscheme.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/progmodes/xscheme.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; xscheme.el --- run MIT Scheme under Emacs
 
-;; Copyright (C) 1986, 1987, 1989, 1990, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1986, 1987, 1989, 1990, 2001, 2004 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: languages, lisp
@@ -222,14 +222,14 @@
   (let* ((buffer (get-buffer buffer-name))
 	 (process (and buffer (get-buffer-process buffer))))
     (cond ((not buffer)
-	   (error "Buffer does not exist" buffer-name))
+	   (error "Buffer `%s' does not exist" buffer-name))
 	  ((not process)
-	   (error "Buffer is not a scheme interaction buffer" buffer-name))
+	   (error "Buffer `%s' is not a scheme interaction buffer" buffer-name))
 	  (t
 	   (save-excursion
 	     (set-buffer buffer)
 	     (if (not (xscheme-process-buffer-current-p))
-		 (error "Buffer is not a scheme interaction buffer"
+		 (error "Buffer `%s' is not a scheme interaction buffer"
 			buffer-name)))
 	   (process-name process)))))
 
--- a/lisp/ses.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/ses.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,4 +1,4 @@
-;;;; ses.el -- Simple Emacs Spreadsheet
+;;; ses.el -- Simple Emacs Spreadsheet
 
 ;; Copyright (C) 2002,03,04  Free Software Foundation, Inc.
 
@@ -24,11 +24,12 @@
 ;; Boston, MA 02111-1307, USA.
 
 ;;; To-do list:
+;; * Use $ or … for truncated fields
+;; * Add command to make a range of columns be temporarily invisible.
+;; * Allow paste of one cell to a range of cells -- copy formula to each.
 ;; * Do something about control characters & octal codes in cell print
-;;   areas. Currently they distort the columnar appearance, but fixing them
-;;   seems like too much work?  Use text-char-description?
+;;   areas.  Use string-width?
 ;; * Input validation functions.  How specified?
-;; * Menubar and popup menus.
 ;; * Faces (colors & styles) in print cells.
 ;; * Move a column by dragging its letter in the header line.
 ;; * Left-margin column for row number.
@@ -87,16 +88,119 @@
 (defvar ses-read-printer-history nil
   "List of printer functions that have been typed in.")
 
-(defvar ses-mode-map nil
+(easy-menu-define ses-header-line-menu nil
+  "Context menu when mouse-3 is used on the header-line in an SES buffer."
+  '("SES header row"
+    ["Set current row" ses-set-header-row t]
+    ["Unset row" ses-unset-header-row (> header-row 0)]))
+
+(defconst ses-mode-map
+  (let ((keys `("\C-c\M-\C-l" ses-reconstruct-all
+		"\C-c\C-l"    ses-recalculate-all
+		"\C-c\C-n"    ses-renarrow-buffer
+		"\C-c\C-c"    ses-recalculate-cell
+		"\C-c\M-\C-s" ses-sort-column
+		"\C-c\M-\C-h" ses-set-header-row
+		"\C-c\C-t"    ses-truncate-cell
+		"\C-c\C-j"    ses-jump
+		"\C-c\C-p"    ses-read-default-printer
+		"\M-\C-l"     ses-reprint-all
+		[?\S-\C-l]    ses-reprint-all
+		[header-line down-mouse-3] ,ses-header-line-menu
+		[header-line mouse-2] ses-sort-column-click))
+	(newmap (make-sparse-keymap)))
+    (while keys
+      (define-key (1value newmap) (car keys) (cadr keys))
+      (setq keys (cddr keys)))
+    newmap)
   "Local keymap for Simple Emacs Spreadsheet.")
 
-(defvar ses-mode-print-map nil
-  "Local keymap for SES print area.")
+(easy-menu-define ses-menu ses-mode-map
+  "Menu bar menu for SES."
+  '("SES"
+    ["Insert row" ses-insert-row (ses-in-print-area)]
+    ["Delete row" ses-delete-row (ses-in-print-area)]
+    ["Insert column" ses-insert-column (ses-in-print-area)]
+    ["Delete column" ses-delete-column (ses-in-print-area)]
+    ["Set column printer" ses-read-column-printer t]
+    ["Set column width" ses-set-column-width t]
+    ["Set default printer" ses-read-default-printer t]
+    ["Jump to cell" ses-jump t]
+    ["Set cell printer" ses-read-cell-printer t]
+    ["Recalculate cell" ses-recalculate-cell t]
+    ["Truncate cell display" ses-truncate-cell t]
+    ["Export values" ses-export-tsv t]
+    ["Export formulas" ses-export-tsf t]))
 
-(defvar ses-mode-edit-map nil
+(defconst ses-mode-edit-map
+  (let ((keys '("\C-c\C-r"    ses-insert-range
+		"\C-c\C-s"    ses-insert-ses-range
+		[S-mouse-3]   ses-insert-range-click
+		[C-S-mouse-3] ses-insert-ses-range-click
+		"\M-\C-i"     lisp-complete-symbol))
+	(newmap (make-sparse-keymap)))
+    (set-keymap-parent newmap minibuffer-local-map)
+    (while keys
+      (define-key newmap (car keys) (cadr keys))
+      (setq keys (cddr keys)))
+    newmap)
   "Local keymap for SES minibuffer cell-editing.")
 
-;Key map used for 'x' key.
+;Local keymap for SES print area
+(defalias 'ses-mode-print-map
+  (let ((keys '([backtab] backward-char
+		[tab]     ses-forward-or-insert
+		"\C-i"	  ses-forward-or-insert  ;Needed for ses-coverage.el?
+		"\M-o"    ses-insert-column
+		"\C-o"	  ses-insert-row
+		"\C-m"    ses-edit-cell
+		"\M-k"    ses-delete-column
+		"\M-y"	  ses-yank-pop
+		"\C-k"    ses-delete-row
+		"\C-j"    ses-append-row-jump-first-column
+		"\M-h"    ses-mark-row
+		"\M-H"	  ses-mark-column
+		"\C-d"	  ses-clear-cell-forward
+		"\C-?"	  ses-clear-cell-backward
+		"("       ses-read-cell
+		"\""      ses-read-cell
+		"'"       ses-read-symbol
+		"="	  ses-edit-cell
+		"j"	  ses-jump
+		"p"	  ses-read-cell-printer
+		"w"	  ses-set-column-width
+		"x"	  ses-export-keymap
+		"\M-p"	  ses-read-column-printer))
+	(repl '(;;We'll replace these wherever they appear in the keymap
+		clipboard-kill-region ses-kill-override
+		end-of-line	      ses-end-of-line
+		kill-line	      ses-delete-row
+		kill-region           ses-kill-override
+		open-line	      ses-insert-row))
+	(numeric "0123456789.-")
+	(newmap (make-keymap)))
+    ;;Get rid of printables
+    (suppress-keymap newmap t)
+    ;;These keys insert themselves as the beginning of a numeric value
+    (dotimes (x (length numeric))
+      (define-key newmap (substring numeric x (1+ x)) 'ses-read-cell))
+    ;;Override these global functions wherever they're bound
+    (while repl
+      (substitute-key-definition (car repl) (cadr repl) newmap
+				 (current-global-map))
+      (setq repl (cddr repl)))
+    ;;Apparently substitute-key-definition doesn't catch this?
+    (define-key newmap [(menu-bar) edit cut] 'ses-kill-override)
+    ;;Define our other local keys
+    (while keys
+      (define-key newmap (car keys) (cadr keys))
+      (setq keys (cddr keys)))
+    newmap))
+
+;;Helptext for ses-mode wants keymap as variable, not function
+(defconst ses-mode-print-map (symbol-function 'ses-mode-print-map))
+
+;;Key map used for 'x' key.
 (defalias 'ses-export-keymap
   (let ((map (make-sparse-keymap "SES export")))
     (define-key map "T" (cons " tab-formulas" 'ses-export-tsf))
@@ -132,8 +236,9 @@
 REFERENCES.")
 
 (defconst ses-paramlines-plist
-  '(column-widths 2 col-printers 3 default-printer 4 header-row 5
-    file-format   8 numrows      9 numcols        10)
+  '(ses--col-widths  2 ses--col-printers  3 ses--default-printer  4
+    ses--header-row  5 ses--file-format   8 ses--numrows          9
+    ses--numcols    10)
   "Offsets from last cell line to various parameter lines in the data area
 of a spreadsheet.")
 
@@ -150,11 +255,13 @@
 
 (eval-and-compile
   (defconst ses-localvars
-    '(blank-line cells col-printers column-widths curcell curcell-overlay
-      default-printer deferred-narrow deferred-recalc deferred-write
-      file-format header-hscroll header-row header-string linewidth
-      mode-line-process next-line-add-newlines numcols numrows
-      symbolic-formulas transient-mark-mode)
+    '(ses--blank-line ses--cells ses--col-printers ses--col-widths ses--curcell
+      ses--curcell-overlay ses--default-printer ses--deferred-narrow
+      ses--deferred-recalc ses--deferred-write ses--file-format
+      ses--header-hscroll ses--header-row ses--header-string ses--linewidth
+      ses--numcols ses--numrows ses--symbolic-formulas
+      ;;Global variables that we override
+      mode-line-process next-line-add-newlines transient-mark-mode)
     "Buffer-local variables used by SES."))
 
 ;;When compiling, create all the buffer locals and give them values
@@ -195,7 +302,7 @@
 
 (defmacro ses-get-cell (row col)
   "Return the cell structure that stores information about cell (ROW,COL)."
-  `(aref (aref cells ,row) ,col))
+  `(aref (aref ses--cells ,row) ,col))
 
 (defmacro ses-cell-symbol (row &optional col)
   "From a CELL or a pair (ROW,COL), get the symbol that names the local-variable holding its value.  (0,0) => A1."
@@ -220,11 +327,11 @@
 
 (defmacro ses-col-width (col)
   "Return the width for column COL."
-  `(aref column-widths ,col))
+  `(aref ses--col-widths ,col))
 
 (defmacro ses-col-printer (col)
   "Return the default printer for column COL."
-  `(aref col-printers ,col))
+  `(aref ses--col-printers ,col))
 
 (defmacro ses-sym-rowcol (sym)
   "From a cell-symbol SYM, gets the cons (row . col).  A1 => (0 . 0).  Result
@@ -246,7 +353,7 @@
 	(stringp printer)
 	(eq safe-functions t)
 	(setq printer `(ses-safe-printer ,printer)))
-    (aset (aref cells (car rowcol))
+    (aset (aref ses--cells (car rowcol))
 	  (cdr rowcol)
 	  (vector sym formula printer references)))
   (set sym value)
@@ -255,39 +362,39 @@
 (defmacro ses-column-widths (widths)
   "Load the vector of column widths from the spreadsheet file.  This is a
 macro to prevent propagate-on-load viruses."
-  (or (and (vectorp widths) (= (length widths) numcols))
+  (or (and (vectorp widths) (= (length widths) ses--numcols))
       (error "Bad column-width vector"))
   ;;To save time later, we also calculate the total width of each line in the
   ;;print area (excluding the terminating newline)
-  (setq column-widths widths
-	linewidth     (apply '+ -1 (mapcar '1+ widths))
-	blank-line    (concat (make-string linewidth ? ) "\n"))
+  (setq ses--col-widths widths
+	ses--linewidth  (apply '+ -1 (mapcar '1+ widths))
+	ses--blank-line (concat (make-string ses--linewidth ? ) "\n"))
   t)
 
 (defmacro ses-column-printers (printers)
   "Load the vector of column printers from the spreadsheet file and checks
 them for safety.  This is a macro to prevent propagate-on-load viruses."
-  (or (and (vectorp printers) (= (length printers) numcols))
+  (or (and (vectorp printers) (= (length printers) ses--numcols))
       (error "Bad column-printers vector"))
-  (dotimes (x numcols)
+  (dotimes (x ses--numcols)
     (aset printers x (ses-safe-printer (aref printers x))))
-  (setq col-printers printers)
+  (setq ses--col-printers printers)
   (mapc 'ses-printer-record printers)
   t)
 
 (defmacro ses-default-printer (def)
   "Load the global default printer from the spreadsheet file and checks it
 for safety.  This is a macro to prevent propagate-on-load viruses."
-  (setq default-printer (ses-safe-printer def))
+  (setq ses--default-printer (ses-safe-printer def))
   (ses-printer-record def)
   t)
 
 (defmacro ses-header-row (row)
   "Load the header row from the spreadsheet file and checks it
 for safety.  This is a macro to prevent propagate-on-load viruses."
-  (or (and (wholenump row) (< row numrows))
+  (or (and (wholenump row) (< row ses--numrows))
       (error "Bad header-row"))
-  (setq header-row row)
+  (setq ses--header-row row)
   t)
 
 (defmacro ses-dotimes-msg (spec msg &rest body)
@@ -405,7 +512,7 @@
 for this spreadsheet."
   (when (and (eq (car-safe formula) 'quote)
 	     (symbolp (cadr formula)))
-    (add-to-list 'symbolic-formulas
+    (add-to-list 'ses--symbolic-formulas
 		 (list (symbol-name (cadr formula))))))
 
 (defun ses-column-letter (col)
@@ -451,7 +558,7 @@
   "Flags the header string for update.  Upon undo, the header string will be
 updated again."
   (push '(ses-reset-header-string) buffer-undo-list)
-  (setq header-hscroll -1))
+  (setq ses--header-hscroll -1))
 
 ;;Split this code off into a function to avoid coverage-testing difficulties
 (defun ses-time-check (format arg)
@@ -480,7 +587,7 @@
 		     (ses-set-with-undo (ses-cell-symbol cell) val)
 		   (ses-aset-with-undo cell elt val)))
     (if change
-	(add-to-list 'deferred-write (cons row col))))
+	(add-to-list 'ses--deferred-write (cons row col))))
   nil) ;Make coverage-tester happy
 
 (defun ses-cell-set-formula (row col formula)
@@ -496,7 +603,7 @@
 	  (newref (ses-formula-references formula))
 	  (inhibit-quit t)
 	  x xrow xcol)
-      (add-to-list 'deferred-recalc sym)
+      (add-to-list 'ses--deferred-recalc sym)
       ;;Delete old references from this cell.  Skip the ones that are also
       ;;in the new list.
       (dolist (ref oldref)
@@ -542,10 +649,10 @@
 	  ;;Don't lose the *skip* - previous field spans this one
 	  (setq newval '*skip*))
       (when (or force (not (eq newval oldval)))
-	(add-to-list 'deferred-write (cons row col)) ;In case force=t
+	(add-to-list 'ses--deferred-write (cons row col)) ;In case force=t
 	(ses-set-cell row col 'value newval)
 	(dolist (ref (ses-cell-references cell))
-	  (add-to-list 'deferred-recalc ref))))
+	  (add-to-list 'ses--deferred-recalc ref))))
     (setq printer-error (ses-print-cell row col))
     (or formula-error printer-error)))
 
@@ -558,31 +665,31 @@
   "Recalculate cells in LIST, checking for dependency loops.  Prints
 progress messages every second.  Dependent cells are not recalculated
 if the cell's value is unchanged if FORCE is nil."
-  (let ((deferred-recalc list)
-	(nextlist        list)
-	(pos		 (point))
+  (let ((ses--deferred-recalc list)
+	(nextlist             list)
+	(pos		      (point))
 	curlist prevlist rowcol formula)
     (with-temp-message " "
-      (while (and deferred-recalc (not (equal nextlist prevlist)))
+      (while (and ses--deferred-recalc (not (equal nextlist prevlist)))
 	;;In each loop, recalculate cells that refer only to other cells that
 	;;have already been recalculated or aren't in the recalculation
 	;;region.  Repeat until all cells have been processed or until the
 	;;set of cells being worked on stops changing.
 	(if prevlist
 	    (message "Recalculating... (%d cells left)"
-		     (length deferred-recalc)))
-	(setq curlist         deferred-recalc
-	      deferred-recalc nil
-	      prevlist        nextlist)
+		     (length ses--deferred-recalc)))
+	(setq curlist              ses--deferred-recalc
+	      ses--deferred-recalc nil
+	      prevlist             nextlist)
 	(while curlist
 	  (setq rowcol  (ses-sym-rowcol (car curlist))
 		formula (ses-cell-formula (car rowcol) (cdr rowcol)))
 	  (or (catch 'ref
 		(dolist (ref (ses-formula-references formula))
 		  (when (or (memq ref curlist)
-			    (memq ref deferred-recalc))
+			    (memq ref ses--deferred-recalc))
 		    ;;This cell refers to another that isn't done yet
-		    (add-to-list 'deferred-recalc (car curlist))
+		    (add-to-list 'ses--deferred-recalc (car curlist))
 		    (throw 'ref t))))
 	      ;;ses-update-cells is called from post-command-hook, so
 	      ;;inhibit-quit is implicitly bound to t.
@@ -591,19 +698,19 @@
 		(error "Quit"))
 	      (ses-calculate-cell (car rowcol) (cdr rowcol) force))
 	  (setq curlist (cdr curlist)))
-	(dolist (ref deferred-recalc)
+	(dolist (ref ses--deferred-recalc)
 	  (add-to-list 'nextlist ref))
 	(setq nextlist (sort (copy-sequence nextlist) 'string<))
 	(if (equal nextlist prevlist)
 	    ;;We'll go around the loop one more time.
 	    (add-to-list 'nextlist t)))
-      (when deferred-recalc
+      (when ses--deferred-recalc
 	;;Just couldn't finish these
-	(dolist (x deferred-recalc)
+	(dolist (x ses--deferred-recalc)
 	  (let ((rowcol (ses-sym-rowcol x)))
 	    (ses-set-cell (car rowcol) (cdr rowcol) 'value '*error*)
 	    (1value (ses-print-cell (car rowcol) (cdr rowcol)))))
-	(error "Circular references: %s" deferred-recalc))
+	(error "Circular references: %s" ses--deferred-recalc))
       (message " "))
     ;;Can't use save-excursion here: if the cell under point is
     ;;updated, save-excusion's marker will move past the cell.
@@ -614,46 +721,50 @@
 ;;;; The print area
 ;;;----------------------------------------------------------------------------
 
+(defun ses-in-print-area ()
+  "Returns t if point is in print area of spreadsheet."
+  (eq (get-text-property (point) 'keymap) 'ses-mode-print-map))
+
 ;;;We turn off point-motion-hooks and explicitly position the cursor, in case
 ;;;the intangible properties have gotten screwed up (e.g., when
 ;;;ses-goto-print is called during a recursive ses-print-cell).
 (defun ses-goto-print (row col)
   "Move point to print area for cell (ROW,COL)."
   (let ((inhibit-point-motion-hooks t))
-    (goto-char 1)
+    (goto-char (point-min))
     (forward-line row)
     (dotimes (c col)
       (forward-char (1+ (ses-col-width c))))))
 
 (defun ses-set-curcell ()
-  "Sets `curcell' to the current cell symbol, or a cons (BEG,END) for a
+  "Sets `ses--curcell' to the current cell symbol, or a cons (BEG,END) for a
 region, or nil if cursor is not at a cell."
   (if (or (not mark-active)
 	  deactivate-mark
 	  (= (region-beginning) (region-end)))
       ;;Single cell
-      (setq curcell (get-text-property (point) 'intangible))
+      (setq ses--curcell (get-text-property (point) 'intangible))
     ;;Range
     (let ((bcell (get-text-property (region-beginning) 'intangible))
 	  (ecell (get-text-property (1- (region-end))  'intangible)))
-      (setq curcell (if (and bcell ecell)
-			(cons bcell ecell)
-		      nil))))
+      (setq ses--curcell (if (and bcell ecell)
+			     (cons bcell ecell)
+			   nil))))
   nil)
 
 (defun ses-check-curcell (&rest args)
-  "Signal an error if curcell is inappropriate.  The end marker is
+  "Signal an error if ses--curcell is inappropriate.  The end marker is
 appropriate if some argument is 'end.  A range is appropriate if some
 argument is 'range.  A single cell is appropriate unless some argument is
 'needrange."
-  (if (eq curcell t)
+  (if (eq ses--curcell t)
       ;;curcell recalculation was postponed, but user typed ahead
       (ses-set-curcell))
   (cond
-   ((not curcell)
+   ((not ses--curcell)
     (or (memq 'end args)
 	(error "Not at cell")))
-   ((consp curcell)
+   ((consp ses--curcell)
     (or (memq 'range args)
 	(memq 'needrange args)
 	(error "Can't use a range")))
@@ -689,7 +800,7 @@
 	;;Print the value
 	(setq text (ses-call-printer (or printer
 					 (ses-col-printer col)
-					 default-printer)
+					 ses--default-printer)
 				     value))
 	(if (consp ses-call-printer-return)
 	    ;;Printer returned an error
@@ -708,7 +819,7 @@
 	  ;;Spill over into following cells, if possible
 	  (let ((maxwidth width))
 	    (while (and (> len maxwidth)
-			(< maxcol numcols)
+			(< maxcol ses--numcols)
 			(or (not (setq x (ses-cell-value row maxcol)))
 			    (eq x '*skip*)))
 	      (unless x
@@ -748,7 +859,7 @@
 	(delete-char (1+ (length text)))
 	;;We use concat instead of inserting separate strings in order to
 	;;reduce the number of cells in the undo list.
-	(setq x (concat text (if (< maxcol numcols) " " "\n")))
+	(setq x (concat text (if (< maxcol ses--numcols) " " "\n")))
 	;;We use set-text-properties to prevent a wacky print function
 	;;from inserting rogue properties, and to ensure that the keymap
 	;;property is inherited (is it a bug that only unpropertied strings
@@ -759,15 +870,16 @@
 			   (ses-cell-symbol cell))
 	(when (and (zerop row) (zerop col))
 	  ;;Reconstruct special beginning-of-buffer attributes
-	  (put-text-property 1 (point) 'keymap 'ses-mode-print-map)
-	  (put-text-property 1 (point) 'read-only 'ses)
-	  (put-text-property 1 2 'front-sticky t)))
-      (if (= row (1- header-row))
+	  (put-text-property (point-min) (point) 'keymap 'ses-mode-print-map)
+	  (put-text-property (point-min) (point) 'read-only 'ses)
+	  (put-text-property (point-min) (1+ (point-min)) 'front-sticky t)))
+      (if (= row (1- ses--header-row))
 	  ;;This line is part of the header - force recalc
 	  (ses-reset-header-string))
       ;;If this cell (or a preceding one on the line) previously spilled over
       ;;and has gotten shorter, redraw following cells on line recursively.
-      (when (and (< maxcol numcols) (eq (ses-cell-value row maxcol) '*skip*))
+      (when (and (< maxcol ses--numcols)
+		 (eq (ses-cell-value row maxcol) '*skip*))
 	(ses-set-cell row maxcol 'value nil)
 	(ses-print-cell row maxcol))
       ;;Return to start of cell
@@ -808,12 +920,12 @@
 inhibit-quit to t."
   (let ((inhibit-read-only t)
 	(blank  (if (> change 0) (make-string change ? )))
-	(at-end (= col numcols)))
-    (ses-set-with-undo 'linewidth (+ linewidth change))
+	(at-end (= col ses--numcols)))
+    (ses-set-with-undo 'ses--linewidth (+ ses--linewidth change))
     ;;ses-set-with-undo always returns t for strings.
-    (1value (ses-set-with-undo 'blank-line
-			       (concat (make-string linewidth ? ) "\n")))
-    (dotimes (row numrows)
+    (1value (ses-set-with-undo 'ses--blank-line
+			       (concat (make-string ses--linewidth ? ) "\n")))
+    (dotimes (row ses--numrows)
       (ses-goto-print row col)
       (when at-end
 	;;Insert new columns before newline
@@ -841,21 +953,22 @@
 ;;;----------------------------------------------------------------------------
 
 (defun ses-goto-data (def &optional col)
-  "Move point to data area for (DEF,COL).  If DEF is a row number, COL is the
-column number for a data cell -- otherwise DEF is one of the symbols
-column-widths, col-printers, default-printer, numrows, or numcols."
+  "Move point to data area for (DEF,COL).  If DEF is a row
+number, COL is the column number for a data cell -- otherwise DEF
+is one of the symbols ses--col-widths, ses--col-printers,
+ses--default-printer, ses--numrows, or ses--numcols."
   (if (< (point-max) (buffer-size))
-      (setq deferred-narrow t))
+      (setq ses--deferred-narrow t))
   (widen)
   (let ((inhibit-point-motion-hooks t)) ;In case intangible attrs are wrong
-    (goto-char 1)
+    (goto-char (point-min))
     (if col
       ;;It's a cell
-      (forward-line (+ numrows 2 (* def (1+ numcols)) col))
+      (forward-line (+ ses--numrows 2 (* def (1+ ses--numcols)) col))
     ;;Convert def-symbol to offset
     (setq def (plist-get ses-paramlines-plist def))
     (or def (signal 'args-out-of-range nil))
-    (forward-line (+ (* numrows (+ numcols 2)) def)))))
+    (forward-line (+ (* ses--numrows (+ ses--numcols 2)) def)))))
 
 (defun ses-set-parameter (def value &optional elem)
   "Sets parameter DEF to VALUE (with undo) and writes the value to the data
@@ -870,19 +983,19 @@
 	(ses-aset-with-undo (symbol-value def) elem value)
       (ses-set-with-undo def value))
     (let ((inhibit-read-only t)
-	  (fmt (plist-get '(column-widths   "(ses-column-widths %S)"
-			    col-printers    "(ses-column-printers %S)"
-			    default-printer "(ses-default-printer %S)"
-			    header-row      "(ses-header-row %S)"
-			    file-format     " %S ;SES file-format"
-			    numrows         " %S ;numrows"
-			    numcols         " %S ;numcols")
+	  (fmt (plist-get '(ses--column-widths   "(ses-column-widths %S)"
+			    ses--col-printers    "(ses-column-printers %S)"
+			    ses--default-printer "(ses-default-printer %S)"
+			    ses--header-row      "(ses-header-row %S)"
+			    ses--file-format     " %S ;SES file-format"
+			    ses--numrows         " %S ;numrows"
+			    ses--numcols         " %S ;numcols")
 			  def)))
       (delete-region (point) (line-end-position))
       (insert (format fmt (symbol-value def))))))
 
 (defun ses-write-cells ()
-  "`deferred-write' is a list of (ROW,COL) for cells to be written from
+  "`ses--deferred-write' is a list of (ROW,COL) for cells to be written from
 buffer-local variables to data area.  Newlines in the data are escaped."
   (let* ((inhibit-read-only t)
 	 (print-escape-newlines t)
@@ -890,10 +1003,10 @@
     (setq ses-start-time (float-time))
     (with-temp-message " "
       (save-excursion
-	(while deferred-write
+	(while ses--deferred-write
 	  (ses-time-check "Writing... (%d cells left)"
-			  '(length deferred-write))
-	  (setq rowcol  (pop deferred-write)
+			  '(length ses--deferred-write))
+	  (setq rowcol  (pop ses--deferred-write)
 		row     (car rowcol)
 		col     (cdr rowcol)
 		cell    (ses-get-cell row col)
@@ -1013,7 +1126,7 @@
       (setq row (+ row rowincr)
 	    col (+ col colincr))
       (if (and (>= row startrow) (>= col startcol)
-	       (< row numrows) (< col numcols))
+	       (< row ses--numrows) (< col ses--numcols))
 	  ;;Relocate this variable
 	  (ses-create-cell-symbol row col)
 	;;Delete reference to a deleted cell
@@ -1050,7 +1163,8 @@
       (if (not max)
 	  (if (> rowincr 0)
 	      ;;Trying to insert a nonexistent row
-	      (setq max (ses-create-cell-symbol (1- numrows) (cdr minrowcol)))
+	      (setq max (ses-create-cell-symbol (1- ses--numrows)
+						(cdr minrowcol)))
 	    ;;End of range is being deleted
 	    (setq max (ses-create-cell-symbol (1- startrow) (cdr minrowcol))
 		  ses-relocate-return 'range))
@@ -1070,7 +1184,8 @@
       (if (not max)
 	  (if (> colincr 0)
 	      ;;Trying to insert a nonexistent column
-	      (setq max (ses-create-cell-symbol (car maxrowcol) (1- numcols)))
+	      (setq max (ses-create-cell-symbol (car maxrowcol)
+						(1- ses--numcols)))
 	    ;;End of range is being deleted
 	    (setq max (ses-create-cell-symbol (car maxrowcol) (1- startcol))
 		  ses-relocate-return 'range))
@@ -1095,8 +1210,8 @@
 to each symbol."
   (let (reform)
     (let (mycell newval)
-      (ses-dotimes-msg (row numrows) "Relocating formulas..."
-	(dotimes (col numcols)
+      (ses-dotimes-msg (row ses--numrows) "Relocating formulas..."
+	(dotimes (col ses--numcols)
 	  (setq ses-relocate-return nil
 		mycell (ses-get-cell row col)
 		newval (ses-relocate-formula (ses-cell-formula mycell)
@@ -1110,7 +1225,7 @@
 	      ;;This cell referred to a cell that's been deleted or is no
 	      ;;longer part of the range.  We can't fix that now because
 	      ;;reference lists cells have been partially updated.
-	      (add-to-list 'deferred-recalc
+	      (add-to-list 'ses--deferred-recalc
 			   (ses-create-cell-symbol row col)))
 	  (setq newval (ses-relocate-formula (ses-cell-references mycell)
 					     minrow mincol rowincr colincr))
@@ -1123,25 +1238,25 @@
       (cond
        ((and (<= rowincr 0) (<= colincr 0))
 	;;Deletion of rows and/or columns
-	(ses-dotimes-msg (row (- numrows minrow)) "Relocating variables..."
+	(ses-dotimes-msg (row (- ses--numrows minrow)) "Relocating variables..."
 	  (setq myrow  (+ row minrow))
-	  (dotimes (col (- numcols mincol))
+	  (dotimes (col (- ses--numcols mincol))
 	    (setq mycol  (+ col mincol)
 		  xrow   (- myrow rowincr)
 		  xcol   (- mycol colincr))
-	    (if (and (< xrow numrows) (< xcol numcols))
+	    (if (and (< xrow ses--numrows) (< xcol ses--numcols))
 		(setq oldval (ses-cell-value xrow xcol))
 	      ;;Cell is off the end of the array
 	      (setq oldval (symbol-value (ses-create-cell-symbol xrow xcol))))
 	    (ses-set-cell myrow mycol 'value oldval))))
        ((and (wholenump rowincr) (wholenump colincr))
 	;;Insertion of rows and/or columns.  Run the loop backwards.
-	(let ((disty (1- numrows))
-	      (distx (1- numcols))
+	(let ((disty (1- ses--numrows))
+	      (distx (1- ses--numcols))
 	      myrow mycol)
-	  (ses-dotimes-msg (row (- numrows minrow)) "Relocating variables..."
+	  (ses-dotimes-msg (row (- ses--numrows minrow)) "Relocating variables..."
 	    (setq myrow (- disty row))
-	    (dotimes (col (- numcols mincol))
+	    (dotimes (col (- ses--numcols mincol))
 	      (setq mycol (- distx col)
 		    xrow  (- myrow rowincr)
 		    xcol  (- mycol colincr))
@@ -1192,7 +1307,8 @@
     (if (not (eq major-mode 'ses-mode))
 	ad-do-it
       ;;Here is some extra code for SES mode.
-      (setq deferred-narrow (or deferred-narrow (< (point-max) (buffer-size))))
+      (setq ses--deferred-narrow
+	    (or ses--deferred-narrow (< (point-max) (buffer-size))))
       (widen)
       (condition-case x
 	  ad-do-it
@@ -1241,101 +1357,6 @@
 ;;;; Startup for major mode
 ;;;----------------------------------------------------------------------------
 
-(defun ses-build-mode-map ()
-  "Set up `ses-mode-map', `ses-mode-print-map', and `ses-mode-edit-map' with
-standard keymap bindings for SES."
-  (message "Building mode map...")
-  ;;;Define ses-mode-map
-  (let ((keys '("\C-c\M-\C-l" ses-reconstruct-all
-		"\C-c\C-l"    ses-recalculate-all
-		"\C-c\C-n"    ses-renarrow-buffer
-		"\C-c\C-c"    ses-recalculate-cell
-		"\C-c\M-\C-s" ses-sort-column
-		"\C-c\M-\C-h" ses-read-header-row
-		"\C-c\C-t"    ses-truncate-cell
-		"\C-c\C-j"    ses-jump
-		"\C-c\C-p"    ses-read-default-printer
-		"\M-\C-l"     ses-reprint-all
-		[?\S-\C-l]    ses-reprint-all
-		[header-line mouse-2] ses-sort-column-click))
-	(newmap (make-sparse-keymap)))
-    (while keys
-      (define-key (1value newmap) (car keys) (cadr keys))
-      (setq keys (cddr keys)))
-    (setq ses-mode-map (1value newmap)))
-  ;;;Define ses-mode-print-map
-  (let ((keys '(;;At least three ways to define shift-tab--and some PC systems
-		;;won't generate it at all!
-		[S-tab]   backward-char
-		[backtab] backward-char
-		[S-iso-backtab] backward-char
-		[S-iso-lefttab] backward-char
-		[tab]     ses-forward-or-insert
-		"\C-i"	  ses-forward-or-insert  ;Needed for ses-coverage.el?
-		"\M-o"    ses-insert-column
-		"\C-o"	  ses-insert-row
-		"\C-m"    ses-edit-cell
-		"\M-k"    ses-delete-column
-		"\M-y"	  ses-yank-pop
-		"\C-k"    ses-delete-row
-		"\C-j"    ses-append-row-jump-first-column
-		"\M-h"    ses-mark-row
-		"\M-H"	  ses-mark-column
-		"\C-d"	  ses-clear-cell-forward
-		"\C-?"	  ses-clear-cell-backward
-		"("       ses-read-cell
-		"\""      ses-read-cell
-		"'"       ses-read-symbol
-		"="	  ses-edit-cell
-		"j"	  ses-jump
-		"p"	  ses-read-cell-printer
-		"w"	  ses-set-column-width
-		"x"	  ses-export-keymap
-		"\M-p"	  ses-read-column-printer))
-	(repl '(;;We'll replace these wherever they appear in the keymap
-		clipboard-kill-region ses-kill-override
-		end-of-line	      ses-end-of-line
-		kill-line	      ses-delete-row
-		kill-region           ses-kill-override
-		open-line	      ses-insert-row))
-	(numeric "0123456789.-")
-	(newmap (make-keymap)))
-    ;;Get rid of printables
-    (suppress-keymap (1value newmap) t)
-    ;;These keys insert themselves as the beginning of a numeric value
-    (dotimes (x (length (1value numeric)))
-      (define-key (1value newmap)
-	(substring (1value numeric) x (1+ x))
-	'ses-read-cell))
-    ;;Override these global functions wherever they're bound
-    (while repl
-      (substitute-key-definition (car repl) (cadr repl)
-				 (1value newmap)
-				 (current-global-map))
-      (setq repl (cddr repl)))
-    ;;Apparently substitute-key-definition doesn't catch this?
-    (define-key (1value newmap) [(menu-bar) edit cut] 'ses-kill-override)
-    ;;Define our other local keys
-    (while keys
-      (define-key (1value newmap) (car keys) (cadr keys))
-      (setq keys (cddr keys)))
-    ;;Keymap property wants the map as a function, not a variable
-    (fset 'ses-mode-print-map (1value newmap))
-    (setq ses-mode-print-map (1value newmap)))
-  ;;;Define ses-mode-edit-map
-  (let ((keys '("\C-c\C-r"    ses-insert-range
-		"\C-c\C-s"    ses-insert-ses-range
-		[S-mouse-3]   ses-insert-range-click
-		[C-S-mouse-3] ses-insert-ses-range-click
-		"\M-\C-i"     lisp-complete-symbol))
-	(newmap (make-sparse-keymap)))
-    (1value (set-keymap-parent (1value newmap) (1value minibuffer-local-map)))
-    (while keys
-      (define-key (1value newmap) (car keys) (cadr keys))
-      (setq keys (cddr keys)))
-    (setq ses-mode-edit-map (1value newmap)))
-  (message nil))
-
 (defun ses-load ()
   "Parse the current buffer and sets up buffer-local variables.  Does not
 execute cell formulas or print functions."
@@ -1353,34 +1374,34 @@
 	     (numberp (nth 2 params))
 	     (> (nth 2 params) 0))
 	(error "Invalid SES file"))
-    (setq file-format (car params)
-	  numrows     (cadr params)
-	  numcols     (nth 2 params))
-    (when (= file-format 1)
+    (setq ses--file-format (car params)
+	  ses--numrows     (cadr params)
+	  ses--numcols     (nth 2 params))
+    (when (= ses--file-format 1)
       (let (buffer-undo-list) ;This is not undoable
-	(ses-goto-data 'header-row)
+	(ses-goto-data 'ses--header-row)
 	(insert "(ses-header-row 0)\n")
-	(ses-set-parameter 'file-format 2)
+	(ses-set-parameter 'ses--file-format 2)
 	(message "Upgrading from SES-1 file format")))
-    (or (= file-format 2)
+    (or (= ses--file-format 2)
 	(error "This file needs a newer version of the SES library code."))
-    (ses-create-cell-variable-range 0 (1- numrows) 0 (1- numcols))
+    (ses-create-cell-variable-range 0 (1- ses--numrows) 0 (1- ses--numcols))
     ;;Initialize cell array
-    (setq cells (make-vector numrows nil))
-    (dotimes (row numrows)
-      (aset cells row (make-vector numcols nil))))
+    (setq ses--cells (make-vector ses--numrows nil))
+    (dotimes (row ses--numrows)
+      (aset ses--cells row (make-vector ses--numcols nil))))
   ;;Skip over print area, which we assume is correct
-  (goto-char 1)
-  (forward-line numrows)
+  (goto-char (point-min))
+  (forward-line ses--numrows)
   (or (looking-at ses-print-data-boundary)
       (error "Missing marker between print and data areas"))
   (forward-char (length ses-print-data-boundary))
   ;;Initialize printer and symbol lists
   (mapc 'ses-printer-record ses-standard-printer-functions)
-  (setq symbolic-formulas nil)
+  (setq ses--symbolic-formulas nil)
   ;;Load cell definitions
-  (dotimes (row numrows)
-    (dotimes (col numcols)
+  (dotimes (row ses--numrows)
+    (dotimes (col ses--numcols)
       (let* ((x      (read (current-buffer)))
 	     (rowcol (ses-sym-rowcol (car-safe (cdr-safe x)))))
 	(or (and (looking-at "\n")
@@ -1421,7 +1442,7 @@
   ;;Check for overall newline count in definitions area
   (forward-line 3)
   (let ((start (point)))
-    (ses-goto-data 'numrows)
+    (ses-goto-data 'ses--numrows)
     (or (= (point) start)
 	(error "Extraneous newlines someplace?"))))
 
@@ -1431,28 +1452,28 @@
 Narrows the buffer to show only the print area.  Gives it `read-only' and
 `intangible' properties.  Sets up highlighting for current cell."
   (interactive)
-  (let ((end 1)
+  (let ((end (point-min))
 	(inhibit-read-only t)
 	(was-modified (buffer-modified-p))
 	pos sym)
     (ses-goto-data 0 0) ;;Include marker between print-area and data-area
-    (set-text-properties (point) (buffer-size) nil) ;Delete garbage props
-    (mapc 'delete-overlay (overlays-in 1 (buffer-size)))
+    (set-text-properties (point) (point-max) nil) ;Delete garbage props
+    (mapc 'delete-overlay (overlays-in (point-min) (point-max)))
     ;;The print area is read-only (except for our special commands) and uses a
     ;;special keymap.
-    (put-text-property 1 (1- (point)) 'read-only 'ses)
-    (put-text-property 1 (1- (point)) 'keymap 'ses-mode-print-map)
+    (put-text-property (point-min) (1- (point)) 'read-only 'ses)
+    (put-text-property (point-min) (1- (point)) 'keymap 'ses-mode-print-map)
     ;;For the beginning of the buffer, we want the read-only and keymap
     ;;attributes to be  inherited from the first character
-    (put-text-property 1 2 'front-sticky t)
+    (put-text-property (point-min) (1+ (point-min)) 'front-sticky t)
     ;;Create intangible properties, which also indicate which cell the text
     ;;came from.
-    (ses-dotimes-msg (row numrows) "Finding cells..."
-      (dotimes (col numcols)
+    (ses-dotimes-msg (row ses--numrows) "Finding cells..."
+      (dotimes (col ses--numcols)
 	(setq pos  end
 	      sym  (ses-cell-symbol row col))
 	;;Include skipped cells following this one
-	(while (and (< col (1- numcols))
+	(while (and (< col (1- ses--numcols))
 		    (eq (ses-cell-value row (1+ col)) '*skip*))
 	  (setq end (+ end (ses-col-width col) 1)
 		col (1+ col)))
@@ -1465,8 +1486,8 @@
       (buffer-enable-undo)))
   ;;Create the underlining overlay.  It's impossible for (point) to be 2,
   ;;because column A must be at least 1 column wide.
-  (setq curcell-overlay (make-overlay 2 2))
-  (overlay-put curcell-overlay 'face 'underline))
+  (setq ses--curcell-overlay (make-overlay (1+ (point-min)) (1+ (point-min))))
+  (overlay-put ses--curcell-overlay 'face 'underline))
 
 (defun ses-cleanup ()
   "Cleanup when changing a buffer from SES mode to something else.  Delete
@@ -1476,15 +1497,16 @@
 	(was-modified      (buffer-modified-p))
 	end)
     ;;Delete read-only, keymap, and intangible properties
-    (set-text-properties 1 (point-max) nil)
+    (set-text-properties (point-min) (point-max) nil)
     ;;Delete overlay
-    (mapc 'delete-overlay (overlays-in 1 (point-max)))
+    (mapc 'delete-overlay (overlays-in (point-min) (point-max)))
     (unless was-modified
       (set-buffer-modified-p nil))))
 
 ;;;###autoload
 (defun ses-mode ()
-  "Major mode for Simple Emacs Spreadsheet.  See \"ses-readme.txt\" for more info.
+  "Major mode for Simple Emacs Spreadsheet.
+See \"ses-example.ses\" (in the etc data directory) for more info.
 
 Key definitions:
 \\{ses-mode-map}
@@ -1493,8 +1515,8 @@
 These are active only in the minibuffer, when entering or editing a formula:
 \\{ses-mode-edit-map}"
   (interactive)
-  (unless (and (boundp 'deferred-narrow)
-	       (eq deferred-narrow 'ses-mode))
+  (unless (and (boundp 'ses--deferred-narrow)
+	       (eq ses--deferred-narrow 'ses-mode))
     (kill-all-local-variables)
     (mapc 'make-local-variable ses-localvars)
     (setq major-mode             'ses-mode
@@ -1505,23 +1527,22 @@
 	  show-trailing-whitespace nil
 	  ;;Cell ranges do not work reasonably without this
 	  transient-mark-mode    t)
-    (unless (and ses-mode-map ses-mode-print-map ses-mode-edit-map)
-      (ses-build-mode-map))
     (1value (add-hook 'change-major-mode-hook 'ses-cleanup nil t))
     (1value (add-hook 'before-revert-hook 'ses-cleanup nil t))
-    (setq curcell         nil
-	  deferred-recalc nil
-	  deferred-write  nil
-	  header-hscroll  -1  ;Flag for "initial recalc needed"
-	  header-line-format '(:eval (progn
-				       (when (/= (window-hscroll)
-						 header-hscroll)
-					 ;;Reset header-hscroll first, to
-					 ;;avoid recursion problems when
-					 ;;debugging ses-create-header-string
-					 (setq header-hscroll (window-hscroll))
-					 (ses-create-header-string))
-				       header-string)))
+    (setq ses--curcell         nil
+	  ses--deferred-recalc nil
+	  ses--deferred-write  nil
+	  ses--header-hscroll  -1  ;Flag for "initial recalc needed"
+	  header-line-format   '(:eval (progn
+					 (when (/= (window-hscroll)
+						   ses--header-hscroll)
+					   ;;Reset ses--header-hscroll first, to
+					   ;;avoid recursion problems when
+					   ;;debugging ses-create-header-string
+					   (setq ses--header-hscroll
+						 (window-hscroll))
+					   (ses-create-header-string))
+					 ses--header-string)))
     (let ((was-empty    (zerop (buffer-size)))
 	  (was-modified (buffer-modified-p)))
       (save-excursion
@@ -1531,20 +1552,20 @@
 	(ses-load)
 	(ses-setup))
       (when was-empty
-	(unless (equal ses-initial-default-printer (1value default-printer))
+	(unless (equal ses-initial-default-printer (1value ses--default-printer))
 	  (1value (ses-read-default-printer ses-initial-default-printer)))
 	(unless (= ses-initial-column-width (1value (ses-col-width 0)))
 	  (1value (ses-set-column-width 0 ses-initial-column-width)))
 	(ses-set-curcell)
-	(if (> (car ses-initial-size) (1value numrows))
+	(if (> (car ses-initial-size) (1value ses--numrows))
 	    (1value (ses-insert-row (1- (car ses-initial-size)))))
-	(if (> (cdr ses-initial-size) (1value numcols))
+	(if (> (cdr ses-initial-size) (1value ses--numcols))
 	    (1value (ses-insert-column (1- (cdr ses-initial-size)))))
 	(ses-write-cells)
-	(set-buffer-modified-p was-modified)
+	(restore-buffer-modified-p was-modified)
 	(buffer-disable-undo)
 	(buffer-enable-undo)
-	(goto-char 1)))
+	(goto-char (point-min))))
     (use-local-map ses-mode-map)
     ;;Set the deferred narrowing flag (we can't narrow until after
     ;;after-find-file completes).  If .ses is on the auto-load alist and the
@@ -1552,7 +1573,7 @@
     ;;a special flag to detect this (will be reset by ses-command-hook).
     ;;For find-alternate-file, post-command-hook doesn't get run for some
     ;;reason, so use an idle timer to make sure.
-    (setq deferred-narrow 'ses-mode)
+    (setq ses--deferred-narrow 'ses-mode)
     (1value (add-hook 'post-command-hook 'ses-command-hook nil t))
     (run-with-idle-timer 0.01 nil 'ses-command-hook)
     (run-hooks 'ses-mode-hook)))
@@ -1566,50 +1587,51 @@
 narrows the buffer now."
   (condition-case err
       (when (eq major-mode 'ses-mode)  ;Otherwise, not our buffer anymore
-	(when deferred-recalc
+	(when ses--deferred-recalc
 	  ;;We reset the deferred list before starting on the recalc -- in case
 	  ;;of error, we don't want to retry the recalc after every keystroke!
-	  (let ((old deferred-recalc))
-	    (setq deferred-recalc nil)
+	  (let ((old ses--deferred-recalc))
+	    (setq ses--deferred-recalc nil)
 	    (ses-update-cells old)))
-	(if deferred-write
+	(if ses--deferred-write
 	    ;;We don't reset the deferred list before starting -- the most
 	    ;;likely error is keyboard-quit, and we do want to keep trying
 	    ;;these writes after a quit.
 	    (ses-write-cells))
-	(when deferred-narrow
+	(when ses--deferred-narrow
 	  ;;We're not allowed to narrow the buffer until after-find-file has
 	  ;;read the local variables at the end of the file.  Now it's safe to
 	  ;;do the narrowing.
 	  (save-excursion
-	    (goto-char 1)
-	    (forward-line numrows)
-	    (narrow-to-region 1 (point)))
-	  (setq deferred-narrow nil))
+	    (goto-char (point-min))
+	    (forward-line ses--numrows)
+	    (narrow-to-region (point-min) (point)))
+	  (setq ses--deferred-narrow nil))
 	;;Update the modeline
-	(let ((oldcell curcell))
+	(let ((oldcell ses--curcell))
 	  (ses-set-curcell)
-	  (unless (eq curcell oldcell)
+	  (unless (eq ses--curcell oldcell)
 	    (cond
-	     ((not curcell)
+	     ((not ses--curcell)
 	      (setq mode-line-process nil))
-	     ((atom curcell)
-	      (setq mode-line-process (list " cell " (symbol-name curcell))))
+	     ((atom ses--curcell)
+	      (setq mode-line-process (list " cell "
+					    (symbol-name ses--curcell))))
 	     (t
 	      (setq mode-line-process (list " range "
-					    (symbol-name (car curcell))
+					    (symbol-name (car ses--curcell))
 					    "-"
-					    (symbol-name (cdr curcell))))))
+					    (symbol-name (cdr ses--curcell))))))
 	    (force-mode-line-update)))
 	;;Use underline overlay for single-cells only, turn off otherwise
-	(if (listp curcell)
-	    (move-overlay curcell-overlay 2 2)
+	(if (listp ses--curcell)
+	    (move-overlay ses--curcell-overlay 2 2)
 	  (let ((next (next-single-property-change (point) 'intangible)))
-	    (move-overlay curcell-overlay (point) (1- next))))
+	    (move-overlay ses--curcell-overlay (point) (1- next))))
 	(when (not (pos-visible-in-window-p))
 	  ;;Scrolling will happen later
 	  (run-with-idle-timer 0.01 nil 'ses-command-hook)
-	  (setq curcell t)))
+	  (setq ses--curcell t)))
     ;;Prevent errors in this post-command-hook from silently erasing the hook!
     (error
      (unless executing-kbd-macro
@@ -1633,23 +1655,23 @@
     (+ left-fringe left-scrollbar)))
 
 (defun ses-create-header-string ()
-  "Sets up `header-string' as the buffer's header line, based on the
+  "Sets up `ses--header-string' as the buffer's header line, based on the
 current set of columns and window-scroll position."
   (let* ((left-offset (ses-header-string-left-offset))
 	 (totwidth (- left-offset (window-hscroll)))
 	 result width result x)
     ;;Leave room for the left-side fringe and scrollbar
     (push (make-string left-offset ? ) result)
-    (dotimes (col numcols)
+    (dotimes (col ses--numcols)
       (setq width    (ses-col-width col)
 	    totwidth (+ totwidth width 1))
       (if (= totwidth (+ left-offset 1))
 	  ;;Scrolled so intercolumn space is leftmost
 	  (push " " result))
       (when (> totwidth (+ left-offset 1))
-	(if (> header-row 0)
+	(if (> ses--header-row 0)
 	    (save-excursion
-	      (ses-goto-print (1- header-row) col)
+	      (ses-goto-print (1- ses--header-row) col)
 	      (setq x (buffer-substring-no-properties (point)
 						      (+ (point) width)))
 	      (if (>= width (- totwidth left-offset))
@@ -1665,11 +1687,11 @@
 	;;Coverage test ignores properties, thinks this is always a space!
 	(push (1value (propertize " " 'display `((space :align-to ,totwidth))))
 	      result)))
-    (if (> header-row 0)
-	(push (propertize (format "  [row %d]" header-row)
+    (if (> ses--header-row 0)
+	(push (propertize (format "  [row %d]" ses--header-row)
 			  'display '((height (- 1))))
 	      result))
-    (setq header-string (apply 'concat (nreverse result)))))
+    (setq ses--header-string (apply 'concat (nreverse result)))))
 
 
 ;;;----------------------------------------------------------------------------
@@ -1697,23 +1719,23 @@
   (interactive "*P")
   (widen)
   (unless nonarrow
-    (setq deferred-narrow t))
+    (setq ses--deferred-narrow t))
   (let ((startcell (get-text-property (point) 'intangible))
 	(inhibit-read-only t))
     (ses-begin-change)
-    (goto-char 1)
+    (goto-char (point-min))
     (search-forward ses-print-data-boundary)
     (backward-char (length ses-print-data-boundary))
-    (delete-region 1 (point))
+    (delete-region (point-min) (point))
     ;;Insert all blank lines before printing anything, so ses-print-cell can
     ;;find the data area when inserting or deleting *skip* values for cells
-    (dotimes (row numrows)
-      (insert-and-inherit blank-line))
-    (ses-dotimes-msg (row numrows) "Reprinting..."
+    (dotimes (row ses--numrows)
+      (insert-and-inherit ses--blank-line))
+    (ses-dotimes-msg (row ses--numrows) "Reprinting..."
       (if (eq (ses-cell-value row 0) '*skip*)
 	  ;;Column deletion left a dangling skip
 	  (ses-set-cell row 0 'value nil))
-      (dotimes (col numcols)
+      (dotimes (col ses--numcols)
 	(ses-print-cell row col))
       (beginning-of-line 2))
     (ses-jump-safe startcell)))
@@ -1730,12 +1752,12 @@
   (ses-begin-change)
   (let (sig)
     (setq ses-start-time (float-time))
-    (if (atom curcell)
-	(setq sig (ses-sym-rowcol curcell)
+    (if (atom ses--curcell)
+	(setq sig (ses-sym-rowcol ses--curcell)
 	      sig (ses-calculate-cell (car sig) (cdr sig) t))
       ;;First, recalculate all cells that don't refer to other cells and
       ;;produce a list of cells with references.
-      (ses-dorange curcell
+      (ses-dorange ses--curcell
 	(ses-time-check "Recalculating... %s" '(ses-cell-symbol row col))
 	(condition-case nil
 	    (progn
@@ -1745,26 +1767,27 @@
 	      (setq sig (ses-calculate-cell row col t)))
 	  (wrong-type-argument
 	   ;;The formula contains a reference
-	   (add-to-list 'deferred-recalc (ses-cell-symbol row col))))))
+	   (add-to-list 'ses--deferred-recalc (ses-cell-symbol row col))))))
     ;;Do the update now, so we can force recalculation
-    (let ((x deferred-recalc))
-      (setq deferred-recalc nil)
+    (let ((x ses--deferred-recalc))
+      (setq ses--deferred-recalc nil)
       (condition-case hold
 	  (ses-update-cells x t)
 	(error (setq sig hold))))
     (cond
      (sig
       (message (error-message-string sig)))
-     ((consp curcell)
+     ((consp ses--curcell)
       (message " "))
      (t
-      (princ (symbol-value curcell))))))
+      (princ (symbol-value ses--curcell))))))
 
 (defun ses-recalculate-all ()
   "Recalculate and reprint all cells."
   (interactive "*")
-  (let ((startcell (get-text-property (point) 'intangible))
-	(curcell   (cons 'A1 (ses-cell-symbol (1- numrows) (1- numcols)))))
+  (let ((startcell    (get-text-property (point) 'intangible))
+	(ses--curcell (cons 'A1 (ses-cell-symbol (1- ses--numrows)
+						 (1- ses--numcols)))))
     (ses-recalculate-cell)
     (ses-jump-safe startcell)))
 
@@ -1773,10 +1796,10 @@
 cells."
   (interactive "*")
   (ses-check-curcell)
-  (let* ((rowcol (ses-sym-rowcol curcell))
+  (let* ((rowcol (ses-sym-rowcol ses--curcell))
 	 (row    (car rowcol))
 	 (col    (cdr rowcol)))
-    (when (and (< col (1- numcols)) ;;Last column can't spill over, anyway
+    (when (and (< col (1- ses--numcols)) ;;Last column can't spill over, anyway
 	       (eq (ses-cell-value row (1+ col)) '*skip*))
       ;;This cell has spill-over.  We'll momentarily pretend the following
       ;;cell has a `t' in it.
@@ -1793,12 +1816,12 @@
   ;;Reconstruct reference lists.
   (let (refs x yrow ycol)
     ;;Delete old reference lists
-    (ses-dotimes-msg (row numrows) "Deleting references..."
-      (dotimes (col numcols)
+    (ses-dotimes-msg (row ses--numrows) "Deleting references..."
+      (dotimes (col ses--numcols)
 	(ses-set-cell row col 'references nil)))
     ;;Create new reference lists
-    (ses-dotimes-msg (row numrows) "Computing references..."
-      (dotimes (col numcols)
+    (ses-dotimes-msg (row ses--numrows) "Computing references..."
+      (dotimes (col ses--numcols)
 	(dolist (ref (ses-formula-references (ses-cell-formula row col)))
 	  (setq x    (ses-sym-rowcol ref)
 		yrow (car x)
@@ -1808,35 +1831,35 @@
 			      (ses-cell-references yrow ycol)))))))
   ;;Delete everything and reconstruct basic data area
   (if (< (point-max) (buffer-size))
-      (setq deferred-narrow t))
+      (setq ses--deferred-narrow t))
   (widen)
   (let ((inhibit-read-only t))
     (goto-char (point-max))
     (if (search-backward ";;; Local Variables:\n" nil t)
-	(delete-region 1 (point))
+	(delete-region (point-min) (point))
       ;;Buffer is quite screwed up - can't even save the user-specified locals
-      (delete-region 1 (point-max))
+      (delete-region (point-min) (point-max))
       (insert ses-initial-file-trailer)
-      (goto-char 1))
+      (goto-char (point-min)))
     ;;Create a blank display area
-    (dotimes (row numrows)
-      (insert blank-line))
+    (dotimes (row ses--numrows)
+      (insert ses--blank-line))
     (insert ses-print-data-boundary)
     ;;Placeholders for cell data
-    (insert (make-string (* numrows (1+ numcols)) ?\n))
+    (insert (make-string (* ses--numrows (1+ ses--numcols)) ?\n))
     ;;Placeholders for col-widths, col-printers, default-printer, header-row
     (insert "\n\n\n\n")
     (insert ses-initial-global-parameters))
-  (ses-set-parameter 'column-widths column-widths)
-  (ses-set-parameter 'col-printers col-printers)
-  (ses-set-parameter 'default-printer default-printer)
-  (ses-set-parameter 'header-row header-row)
-  (ses-set-parameter 'numrows numrows)
-  (ses-set-parameter 'numcols numcols)
+  (ses-set-parameter 'ses--col-widths ses--col-widths)
+  (ses-set-parameter 'ses--col-printers ses--col-printers)
+  (ses-set-parameter 'ses--default-printer ses--default-printer)
+  (ses-set-parameter 'ses--header-row ses--header-row)
+  (ses-set-parameter 'ses--numrows ses--numrows)
+  (ses-set-parameter 'ses--numcols ses--numcols)
   ;;Keep our old narrowing
   (ses-setup)
   (ses-recalculate-all)
-  (goto-char 1))
+  (goto-char (point-min)))
 
 
 ;;;----------------------------------------------------------------------------
@@ -1850,7 +1873,7 @@
    (progn
      (barf-if-buffer-read-only)
      (ses-check-curcell)
-     (let* ((rowcol  (ses-sym-rowcol curcell))
+     (let* ((rowcol  (ses-sym-rowcol ses--curcell))
 	    (row     (car rowcol))
 	    (col     (cdr rowcol))
 	    (formula (ses-cell-formula row col))
@@ -1864,7 +1887,7 @@
 	   ;;Position cursor inside close-quote
 	   (setq initial (cons initial (length initial))))
        (list row col
-	     (read-from-minibuffer (format "Cell %s: " curcell)
+	     (read-from-minibuffer (format "Cell %s: " ses--curcell)
 				   initial
 				   ses-mode-edit-map
 				   t ;Convert to Lisp object
@@ -1878,7 +1901,7 @@
   "Self-insert for initial character of cell function."
   (interactive
    (let ((initial (this-command-keys))
-	 (rowcol  (progn (ses-check-curcell) (ses-sym-rowcol curcell))))
+	 (rowcol  (progn (ses-check-curcell) (ses-sym-rowcol ses--curcell))))
      (barf-if-buffer-read-only)
      (if (string= initial "\"")
 	 (setq initial "\"\"") ;Enter a string
@@ -1886,7 +1909,7 @@
 	   (setq initial "()"))) ;Enter a formula list
      (list (car rowcol)
 	   (cdr rowcol)
-	   (read-from-minibuffer (format "Cell %s: " curcell)
+	   (read-from-minibuffer (format "Cell %s: " ses--curcell)
 				 (cons initial 2)
 				 ses-mode-edit-map
 				 t ;Convert to Lisp object
@@ -1900,11 +1923,11 @@
   "Self-insert for a symbol as a cell formula.  The set of all symbols that
 have been used as formulas in this spreadsheet is available for completions."
   (interactive
-   (let ((rowcol (progn (ses-check-curcell) (ses-sym-rowcol curcell)))
+   (let ((rowcol (progn (ses-check-curcell) (ses-sym-rowcol ses--curcell)))
 	 newval)
      (barf-if-buffer-read-only)
-     (setq newval (completing-read (format "Cell %s ': " curcell)
-				   symbolic-formulas))
+     (setq newval (completing-read (format "Cell %s ': " ses--curcell)
+				   ses--symbolic-formulas))
      (list (car rowcol)
 	   (cdr rowcol)
 	   (if (string= newval "")
@@ -1925,7 +1948,7 @@
     (ses-begin-change)
     (dotimes (x count)
       (ses-set-curcell)
-      (let ((rowcol (ses-sym-rowcol curcell)))
+      (let ((rowcol (ses-sym-rowcol ses--curcell)))
 	(or rowcol (signal 'end-of-buffer nil))
 	(ses-clear-cell (car rowcol) (cdr rowcol)))
       (forward-char 1))))
@@ -1941,7 +1964,7 @@
     (dotimes (x count)
       (backward-char 1) ;Will signal 'beginning-of-buffer if appropriate
       (ses-set-curcell)
-      (let ((rowcol (ses-sym-rowcol curcell)))
+      (let ((rowcol (ses-sym-rowcol ses--curcell)))
 	(ses-clear-cell (car rowcol) (cdr rowcol))))))
 
 
@@ -1986,11 +2009,11 @@
 right-justified) or a list of one string (will be left-justified)."
   (interactive
    (let ((default t)
-	 prompt)
+	 prompt x)
      (ses-check-curcell 'range)
      ;;Default is none if not all cells in range have same printer
      (catch 'ses-read-cell-printer
-       (ses-dorange curcell
+       (ses-dorange ses--curcell
 	 (setq x (ses-cell-printer row col))
 	 (if (eq (car-safe x) 'ses-safe-printer)
 	     (setq x (cadr x)))
@@ -2000,10 +2023,11 @@
 	     ;;Range contains differing printer functions
 	     (setq default t)
 	     (throw 'ses-read-cell-printer t)))))
-     (list (ses-read-printer (format "Cell %S printer: " curcell) default))))
+     (list (ses-read-printer (format "Cell %S printer: " ses--curcell)
+			     default))))
   (unless (eq newval t)
     (ses-begin-change)
-    (ses-dorange curcell
+    (ses-dorange ses--curcell
       (ses-set-cell row col 'printer newval)
       (ses-print-cell row col))))
 
@@ -2011,7 +2035,7 @@
   "Set the printer function for the current column.  See
 `ses-read-cell-printer' for input forms."
   (interactive
-   (let ((col (cdr (ses-sym-rowcol curcell))))
+   (let ((col (cdr (ses-sym-rowcol ses--curcell))))
      (ses-check-curcell)
      (list col (ses-read-printer (format "Column %s printer: "
 					 (ses-column-letter col))
@@ -2019,19 +2043,19 @@
 
   (unless (eq newval t)
     (ses-begin-change)
-    (ses-set-parameter 'col-printers newval col)
+    (ses-set-parameter 'ses--col-printers newval col)
     (save-excursion
-      (dotimes (row numrows)
+      (dotimes (row ses--numrows)
 	(ses-print-cell row col)))))
 
 (defun ses-read-default-printer (newval)
   "Set the default printer function for cells that have no other.  See
 `ses-read-cell-printer' for input forms."
   (interactive
-   (list (ses-read-printer "Default printer: " default-printer)))
+   (list (ses-read-printer "Default printer: " ses--default-printer)))
   (unless (eq newval t)
     (ses-begin-change)
-    (ses-set-parameter 'default-printer newval)
+    (ses-set-parameter 'ses--default-printer newval)
     (ses-reprint-all t)))
 
 
@@ -2048,47 +2072,47 @@
   (ses-begin-change)
   (let ((inhibit-quit t)
 	(inhibit-read-only t)
-	(row (or (car (ses-sym-rowcol curcell)) numrows))
+	(row (or (car (ses-sym-rowcol ses--curcell)) ses--numrows))
 	newrow)
     ;;Create a new set of cell-variables
-    (ses-create-cell-variable-range numrows (+ numrows count -1)
-				    0       (1- numcols))
-    (ses-set-parameter 'numrows (+ numrows count))
+    (ses-create-cell-variable-range ses--numrows (+ ses--numrows count -1)
+				    0            (1- ses--numcols))
+    (ses-set-parameter 'ses--numrows (+ ses--numrows count))
     ;;Insert each row
     (ses-goto-print row 0)
     (ses-dotimes-msg (x count) "Inserting row..."
       ;;Create a row of empty cells.  The `symbol' fields will be set by
       ;;the call to ses-relocate-all.
-      (setq newrow (make-vector numcols nil))
-      (dotimes (col numcols)
+      (setq newrow (make-vector ses--numcols nil))
+      (dotimes (col ses--numcols)
 	(aset newrow col (make-vector ses-cell-size nil)))
-      (setq cells (ses-vector-insert cells row newrow))
-      (push `(ses-vector-delete cells ,row 1) buffer-undo-list)
-      (insert blank-line))
+      (setq ses--cells (ses-vector-insert ses--cells row newrow))
+      (push `(ses-vector-delete ses--cells ,row 1) buffer-undo-list)
+      (insert ses--blank-line))
     ;;Insert empty lines in cell data area (will be replaced by
     ;;ses-relocate-all)
     (ses-goto-data row 0)
-    (insert (make-string (* (1+ numcols) count) ?\n))
+    (insert (make-string (* (1+ ses--numcols) count) ?\n))
     (ses-relocate-all row 0 count 0)
     ;;If any cell printers insert constant text, insert that text
     ;;into the line.
-    (let ((cols   (mapconcat #'ses-call-printer col-printers nil))
-	  (global (ses-call-printer default-printer)))
+    (let ((cols   (mapconcat #'ses-call-printer ses--col-printers nil))
+	  (global (ses-call-printer ses--default-printer)))
       (if (or (> (length cols) 0) (> (length global) 0))
 	  (dotimes (x count)
-	    (dotimes (col numcols)
+	    (dotimes (col ses--numcols)
 	      ;;These cells are always nil, only constant formatting printed
 	      (1value (ses-print-cell (+ x row) col))))))
-    (when (> header-row row)
+    (when (> ses--header-row row)
       ;;Inserting before header
-      (ses-set-parameter 'header-row (+ header-row count))
+      (ses-set-parameter 'ses--header-row (+ ses--header-row count))
       (ses-reset-header-string)))
   ;;Reconstruct text attributes
   (ses-setup)
   ;;Return to current cell
-  (if curcell
-      (ses-jump-safe curcell)
-    (ses-goto-print (1- numrows) 0)))
+  (if ses--curcell
+      (ses-jump-safe ses--curcell)
+    (ses-goto-print (1- ses--numrows) 0)))
 
 (defun ses-delete-row (count)
   "Delete the current row.  With prefix, Deletes COUNT rows starting from the
@@ -2098,31 +2122,31 @@
   (or (> count 0) (signal 'args-out-of-range nil))
   (let ((inhibit-quit t)
 	(inhibit-read-only t)
-	(row (car (ses-sym-rowcol curcell)))
+	(row (car (ses-sym-rowcol ses--curcell)))
 	pos)
-    (setq count (min count (- numrows row)))
+    (setq count (min count (- ses--numrows row)))
     (ses-begin-change)
-    (ses-set-parameter 'numrows (- numrows count))
+    (ses-set-parameter 'ses--numrows (- ses--numrows count))
     ;;Delete lines from print area
     (ses-goto-print row 0)
     (ses-delete-line count)
     ;;Delete lines from cell data area
     (ses-goto-data row 0)
-    (ses-delete-line (* count (1+ numcols)))
+    (ses-delete-line (* count (1+ ses--numcols)))
     ;;Relocate variables and formulas
-    (ses-set-with-undo 'cells (ses-vector-delete cells row count))
+    (ses-set-with-undo 'ses--cells (ses-vector-delete ses--cells row count))
     (ses-relocate-all row 0 (- count) 0)
-    (ses-destroy-cell-variable-range numrows (+ numrows count -1)
-				     0       (1- numcols))
-    (when (> header-row row)
-      (if (<= header-row (+ row count))
+    (ses-destroy-cell-variable-range ses--numrows (+ ses--numrows count -1)
+				     0            (1- ses--numcols))
+    (when (> ses--header-row row)
+      (if (<= ses--header-row (+ row count))
 	  ;;Deleting the header row
-	  (ses-set-parameter 'header-row 0)
-	(ses-set-parameter 'header-row (- header-row count)))
+	  (ses-set-parameter 'ses--header-row 0)
+	(ses-set-parameter 'ses--header-row (- ses--header-row count)))
       (ses-reset-header-string)))
   ;;Reconstruct attributes
   (ses-setup)
-  (ses-jump-safe curcell))
+  (ses-jump-safe ses--curcell))
 
 (defun ses-insert-column (count &optional col width printer)
   "Insert a new column before COL (default is the current one).  With prefix,
@@ -2133,30 +2157,30 @@
   (ses-check-curcell)
   (or (> count 0) (signal 'args-out-of-range nil))
   (or col
-      (setq col     (cdr (ses-sym-rowcol curcell))
+      (setq col     (cdr (ses-sym-rowcol ses--curcell))
 	    width   (ses-col-width col)
 	    printer (ses-col-printer col)))
   (ses-begin-change)
   (let ((inhibit-quit t)
 	(inhibit-read-only t)
-	(widths   column-widths)
-	(printers col-printers)
+	(widths   ses--col-widths)
+	(printers ses--col-printers)
 	has-skip)
     ;;Create a new set of cell-variables
-    (ses-create-cell-variable-range 0       (1- numrows)
-				    numcols (+ numcols count -1))
+    (ses-create-cell-variable-range 0            (1- ses--numrows)
+				    ses--numcols (+ ses--numcols count -1))
     ;;Insert each column.
     (ses-dotimes-msg (x count) "Inserting column..."
       ;;Create a column of empty cells.  The `symbol' fields will be set by
       ;;the call to ses-relocate-all.
       (ses-adjust-print-width col (1+ width))
-      (ses-set-parameter 'numcols (1+ numcols))
-      (dotimes (row numrows)
-	(and (< (1+ col) numcols) (eq (ses-cell-value row col) '*skip*)
+      (ses-set-parameter 'ses--numcols (1+ ses--numcols))
+      (dotimes (row ses--numrows)
+	(and (< (1+ col) ses--numcols) (eq (ses-cell-value row col) '*skip*)
 	     ;;Inserting in the middle of a spill-over
 	     (setq has-skip t))
-	(ses-aset-with-undo cells row
-			    (ses-vector-insert (aref cells row)
+	(ses-aset-with-undo ses--cells row
+			    (ses-vector-insert (aref ses--cells row)
 					       col
 					      (make-vector ses-cell-size nil)))
 	;;Insert empty lines in cell data area (will be replaced by
@@ -2166,22 +2190,22 @@
       ;;Insert column width and printer
       (setq widths      (ses-vector-insert widths col width)
 	    printers    (ses-vector-insert printers col printer)))
-    (ses-set-parameter 'column-widths widths)
-    (ses-set-parameter 'col-printers printers)
+    (ses-set-parameter 'ses--col-widths widths)
+    (ses-set-parameter 'ses--col-printers printers)
     (ses-reset-header-string)
     (ses-relocate-all 0 col 0 count)
     (if has-skip
 	(ses-reprint-all t)
       (when (or (> (length (ses-call-printer printer)) 0)
-		(> (length (ses-call-printer default-printer)) 0))
+		(> (length (ses-call-printer ses--default-printer)) 0))
 	;;Either column printer or global printer inserts some constant text
 	;;Reprint the new columns to insert that text.
-	(dotimes (x numrows)
+	(dotimes (x ses--numrows)
 	  (dotimes (y count)
 	    ;Always nil here - this is a blank column
 	    (1value (ses-print-cell-new-width x (+ y col))))))
       (ses-setup)))
-  (ses-jump-safe curcell))
+  (ses-jump-safe ses--curcell))
 
 (defun ses-delete-column (count)
   "Delete the current column.  With prefix, Deletes COUNT columns starting
@@ -2191,45 +2215,45 @@
   (or (> count 0) (signal 'args-out-of-range nil))
   (let ((inhibit-quit t)
 	(inhibit-read-only t)
-	(rowcol  (ses-sym-rowcol curcell))
+	(rowcol  (ses-sym-rowcol ses--curcell))
 	(width 0)
 	new col origrow has-skip)
     (setq origrow (car rowcol)
 	  col     (cdr rowcol)
-	  count   (min count (- numcols col)))
-    (if (= count numcols)
+	  count   (min count (- ses--numcols col)))
+    (if (= count ses--numcols)
 	(error "Can't delete all columns!"))
     ;;Determine width of column(s) being deleted
     (dotimes (x count)
       (setq width (+ width (ses-col-width (+ col x)) 1)))
     (ses-begin-change)
-    (ses-set-parameter 'numcols (- numcols count))
+    (ses-set-parameter 'ses--numcols (- ses--numcols count))
     (ses-adjust-print-width col (- width))
-    (ses-dotimes-msg (row numrows) "Deleting column..."
+    (ses-dotimes-msg (row ses--numrows) "Deleting column..."
       ;;Delete lines from cell data area
       (ses-goto-data row col)
       (ses-delete-line count)
       ;;Delete cells.  Check if deletion area begins or ends with a skip.
       (if (or (eq (ses-cell-value row col) '*skip*)
-	      (and (< col numcols)
+	      (and (< col ses--numcols)
 		   (eq (ses-cell-value row (+ col count)) '*skip*)))
 	  (setq has-skip t))
-      (ses-aset-with-undo cells row
-			  (ses-vector-delete (aref cells row) col count)))
+      (ses-aset-with-undo ses--cells row
+			  (ses-vector-delete (aref ses--cells row) col count)))
     ;;Update globals
-    (ses-set-parameter 'column-widths
-		       (ses-vector-delete column-widths col count))
-    (ses-set-parameter 'col-printers
-		       (ses-vector-delete col-printers col count))
+    (ses-set-parameter 'ses--col-widths
+		       (ses-vector-delete ses--col-widths col count))
+    (ses-set-parameter 'ses--col-printers
+		       (ses-vector-delete ses--col-printers col count))
     (ses-reset-header-string)
     ;;Relocate variables and formulas
     (ses-relocate-all 0 col 0 (- count))
-    (ses-destroy-cell-variable-range 0       (1- numrows)
-				     numcols (+ numcols count -1))
+    (ses-destroy-cell-variable-range 0            (1- ses--numrows)
+				     ses--numcols (+ ses--numcols count -1))
     (if has-skip
 	(ses-reprint-all t)
       (ses-setup))
-    (if (>= col numcols)
+    (if (>= col ses--numcols)
 	(setq col (1- col)))
     (ses-goto-print origrow col)))
 
@@ -2241,11 +2265,11 @@
   (setq deactivate-mark t) ;Doesn't combine well with ranges
   (dotimes (x count)
     (ses-set-curcell)
-    (if (not curcell)
+    (if (not ses--curcell)
 	(progn ;At bottom of print area
 	  (barf-if-buffer-read-only)
 	  (ses-insert-row 1))
-      (let ((col (cdr (ses-sym-rowcol curcell))))
+      (let ((col (cdr (ses-sym-rowcol ses--curcell))))
 	(when (/= 32
 		  (char-before (next-single-property-change (point)
 							    'intangible)))
@@ -2253,7 +2277,7 @@
 	  ;;new column.
 	  (barf-if-buffer-read-only)
 	  (ses-insert-column (- count x)
-			     numcols
+			     ses--numcols
 			     (ses-col-width col)
 			     (ses-col-printer col)))))
     (forward-char)))
@@ -2270,7 +2294,7 @@
 (defun ses-set-column-width (col newwidth)
   "Set the width of the current column."
   (interactive
-   (let ((col (cdr (progn (ses-check-curcell) (ses-sym-rowcol curcell)))))
+   (let ((col (cdr (progn (ses-check-curcell) (ses-sym-rowcol ses--curcell)))))
      (barf-if-buffer-read-only)
      (list col
 	   (if current-prefix-arg
@@ -2291,8 +2315,8 @@
   (save-excursion
     (let ((inhibit-quit t))
       (ses-adjust-print-width col (- newwidth (ses-col-width col)))
-      (ses-set-parameter 'column-widths newwidth col))
-    (dotimes (row numrows)
+      (ses-set-parameter 'ses--col-widths newwidth col))
+    (dotimes (row ses--numrows)
       (ses-print-cell-new-width row col))))
 
 
@@ -2373,9 +2397,9 @@
   ;;check whether the buffer really is read-only.
   (barf-if-buffer-read-only)
   (ses-begin-change)
-  (ses-dorange curcell
+  (ses-dorange ses--curcell
     (ses-clear-cell row col))
-  (ses-jump (car curcell)))
+  (ses-jump (car ses--curcell)))
 
 (defadvice yank (around ses-yank activate preactivate)
   "In SES mode, the yanked text is inserted as cells.
@@ -2560,10 +2584,12 @@
 confirmation and then inserts them.  Result is (row,col) for top left of yank
 spot, or error signal if user requests cancel."
   (ses-begin-change)
-  (let ((rowcol (if curcell (ses-sym-rowcol curcell) (cons numrows 0)))
+  (let ((rowcol (if ses--curcell
+		    (ses-sym-rowcol ses--curcell)
+		  (cons ses--numrows 0)))
 	rowbool colbool)
-    (setq needrows (- (+ (car rowcol) needrows) numrows)
-	  needcols (- (+ (cdr rowcol) needcols) numcols)
+    (setq needrows (- (+ (car rowcol) needrows) ses--numrows)
+	  needcols (- (+ (cdr rowcol) needcols) ses--numcols)
 	  rowbool  (> needrows 0)
 	  colbool  (> needcols 0))
     (when (or rowbool colbool)
@@ -2574,15 +2600,15 @@
 			    (if colbool (format "%d columns" needcols) "")))
 	  (error "Cancelled"))
       (when rowbool
-	(let (curcell)
+	(let (ses--curcell)
 	  (save-excursion
-	    (ses-goto-print numrows 0)
+	    (ses-goto-print ses--numrows 0)
 	    (ses-insert-row needrows))))
       (when colbool
 	  (ses-insert-column needcols
-			     numcols
-			     (ses-col-width (1- numcols))
-			     (ses-col-printer (1- numcols)))))
+			     ses--numcols
+			     (ses-col-width (1- ses--numcols))
+			     (ses-col-printer (1- ses--numcols)))))
     rowcol))
 
 (defun ses-export-tsv (beg end)
@@ -2604,7 +2630,7 @@
   (ses-check-curcell 'needrange)
   (let ((print-escape-newlines t)
 	result item)
-    (ses-dorange curcell
+    (ses-dorange ses--curcell
       (setq item (if want-formulas
 		     (ses-cell-formula row col)
 		   (ses-cell-value row col)))
@@ -2632,19 +2658,55 @@
 ;;;; Other user commands
 ;;;----------------------------------------------------------------------------
 
-(defun ses-read-header-row (row)
-  (interactive "NHeader row: ")
-  (if (or (< row 0) (> row numrows))
+;; This should be used by `call-interactively'.
+(defun ses-read-number (prompt &optional default)
+  (let ((n nil))
+    (when default
+      (setq prompt
+	    (if (string-match "\\(\\):[^:]*" prompt)
+		(replace-match (format " [%s]" default) t t prompt 1)
+	      (concat prompt (format " [%s] " default)))))
+    (while
+	(progn
+	  (let ((str (read-from-minibuffer prompt nil nil nil nil
+					   (number-to-string default))))
+	    (setq n (cond
+		     ((zerop (length str)) default)
+		     ((stringp str) (read str)))))
+	  (unless (numberp n)
+	    (message "Please enter a number.")
+	    (sit-for 1)
+	    t)))
+    n))
+
+(defun ses-unset-header-row ()
+  "Select the default header row."
+  (interactive)
+  (ses-set-header-row 0))
+
+(defun ses-set-header-row (row)
+  "Set the ROW to display in the header-line.
+With a numerical prefix arg, use that row.
+With no prefix arg, use the current row.
+With a \\[universal-argument] prefix arg, prompt the user.
+The top row is row 1.  Selecting row 0 displays the default header row."
+  (interactive
+   (list (if (numberp current-prefix-arg) current-prefix-arg
+	   (let ((currow (1+ (car (ses-sym-rowcol ses--curcell)))))
+	     (if current-prefix-arg
+		 (ses-read-number "Header row: " currow)
+	       currow)))))
+  (if (or (< row 0) (> row ses--numrows))
       (error "Invalid header-row"))
   (ses-begin-change)
-  (ses-set-parameter 'header-row row)
+  (ses-set-parameter 'ses--header-row row)
   (ses-reset-header-string))
 
 (defun ses-mark-row ()
   "Marks the entirety of current row as a range."
   (interactive)
   (ses-check-curcell 'range)
-  (let ((row (car (ses-sym-rowcol (or (car-safe curcell) curcell)))))
+  (let ((row (car (ses-sym-rowcol (or (car-safe ses--curcell) ses--curcell)))))
     (push-mark (point))
     (ses-goto-print (1+ row) 0)
     (push-mark (point) nil t)
@@ -2654,10 +2716,10 @@
   "Marks the entirety of current column as a range."
   (interactive)
   (ses-check-curcell 'range)
-  (let ((col (cdr (ses-sym-rowcol (or (car-safe curcell) curcell))))
+  (let ((col (cdr (ses-sym-rowcol (or (car-safe ses--curcell) ses--curcell))))
 	(row 0))
     (push-mark (point))
-    (ses-goto-print (1- numrows) col)
+    (ses-goto-print (1- ses--numrows) col)
     (forward-char 1)
     (push-mark (point) nil t)
     (while (eq '*skip* (ses-cell-value row col))
@@ -2669,25 +2731,25 @@
   "Move point to last cell on line."
   (interactive)
   (ses-check-curcell 'end 'range)
-  (when curcell  ;Otherwise we're at the bottom row, which is empty anyway
-    (let ((col (1- numcols))
+  (when ses--curcell  ;Otherwise we're at the bottom row, which is empty anyway
+    (let ((col (1- ses--numcols))
 	  row rowcol)
-      (if (symbolp curcell)
+      (if (symbolp ses--curcell)
 	  ;;Single cell
-	  (setq row (car (ses-sym-rowcol curcell)))
+	  (setq row (car (ses-sym-rowcol ses--curcell)))
 	;;Range - use whichever end of the range the point is at
 	(setq rowcol (ses-sym-rowcol (if (< (point) (mark))
-				     (car curcell)
-				   (cdr curcell))))
+				     (car ses--curcell)
+				   (cdr ses--curcell))))
 	;;If range already includes the last cell in a row, point is actually
 	;;in the following row
 	(if (<= (cdr rowcol) (1- col))
 	    (setq row (car rowcol))
 	  (setq row (1+ (car rowcol)))
-	  (if (= row numrows)
+	  (if (= row ses--numrows)
 	      ;;Already at end - can't go anywhere
 	      (setq col 0))))
-      (when (< row numrows) ;Otherwise it's a range that includes last cell
+      (when (< row ses--numrows) ;Otherwise it's a range that includes last cell
 	(while (eq (ses-cell-value row col) '*skip*)
 	  ;;Back to beginning of multi-column cell
 	  (setq col (1- col)))
@@ -2696,15 +2758,15 @@
 (defun ses-renarrow-buffer ()
   "Narrow the buffer so only the print area is visible.  Use after \\[widen]."
   (interactive)
-  (setq deferred-narrow t))
+  (setq ses--deferred-narrow t))
 
 (defun ses-sort-column (sorter &optional reverse)
   "Sorts the range by a specified column.  With prefix, sorts in
 REVERSE order."
   (interactive "*sSort column: \nP")
   (ses-check-curcell 'needrange)
-  (let ((min (ses-sym-rowcol (car curcell)))
-	(max (ses-sym-rowcol (cdr curcell))))
+  (let ((min (ses-sym-rowcol (car ses--curcell)))
+	(max (ses-sym-rowcol (cdr ses--curcell))))
     (let ((minrow (car min))
 	  (mincol (cdr min))
 	  (maxrow (car max))
@@ -2737,15 +2799,16 @@
 	(ses-yank-cells (pop extracts) nil)))))
 
 (defun ses-sort-column-click (event reverse)
+  "Mouse version of `ses-sort-column'."
   (interactive "*e\nP")
   (setq event (event-end event))
   (select-window (posn-window event))
   (setq event (car (posn-col-row event))) ;Click column
   (let ((col 0))
-    (while (and (< col numcols) (> event (ses-col-width col)))
+    (while (and (< col ses--numcols) (> event (ses-col-width col)))
       (setq event (- event (ses-col-width col) 1)
 	    col   (1+ col)))
-    (if (>= col numcols)
+    (if (>= col ses--numcols)
 	(ding)
       (ses-sort-column (ses-column-letter col) reverse))))
 
@@ -2757,7 +2820,8 @@
     (with-current-buffer (window-buffer minibuffer-scroll-window)
       (ses-command-hook)  ;For ses-coverage
       (ses-check-curcell 'needrange)
-      (setq x (cdr (macroexpand `(ses-range ,(car curcell) ,(cdr curcell))))))
+      (setq x (cdr (macroexpand `(ses-range ,(car ses--curcell)
+					    ,(cdr ses--curcell))))))
     (insert (substring (prin1-to-string (nreverse x)) 1 -1))))
 
 (defun ses-insert-ses-range ()
@@ -2768,7 +2832,9 @@
     (with-current-buffer (window-buffer minibuffer-scroll-window)
       (ses-command-hook)  ;For ses-coverage
       (ses-check-curcell 'needrange)
-      (setq x (format "(ses-range %S %S)" (car curcell) (cdr curcell))))
+      (setq x (format "(ses-range %S %S)"
+		      (car ses--curcell)
+		      (cdr ses--curcell))))
     (insert x)))
 
 (defun ses-insert-range-click (event)
@@ -2879,17 +2945,15 @@
 ;;dynamically bound by ses-print-cell.  We define these varables at
 ;;compile-time to make the compiler happy.
 (eval-when-compile
-  (make-local-variable 'row)
-  (make-local-variable 'col)
-  ;;Don't use setq -- that gives a "free variable" compiler warning
-  (set 'row nil)
-  (set 'col nil))
+  (dolist (x '(row col))
+    (make-local-variable x)
+    (set x nil)))
 
 (defun ses-center (value &optional span fill)
   "Print VALUE, centered within column.  FILL is the fill character for
 centering (default = space).  SPAN indicates how many additional rightward
 columns to include in width (default = 0)."
-  (let ((printer (or (ses-col-printer col) default-printer))
+  (let ((printer (or (ses-col-printer col) ses--default-printer))
 	(width   (ses-col-width col))
 	half)
     (or fill (setq fill ? ))
@@ -2909,7 +2973,7 @@
 and continues until the next nonblank column.  FILL specifies the fill
 character (default = space)."
   (let ((end (1+ col)))
-    (while (and (< end numcols)
+    (while (and (< end ses--numcols)
 		(memq (ses-cell-value row end) '(nil *skip*)))
       (setq end (1+ end)))
     (ses-center value (- end col 1) fill)))
--- a/lisp/simple.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/simple.el	Tue Feb 17 01:52:25 2004 +0000
@@ -499,14 +499,14 @@
   "Print the current buffer line number and narrowed line number of point."
   (interactive)
   (let ((opoint (point)) (start (point-min))
-	(n (line-at-pos)))
+	(n (line-number-at-pos)))
     (if (= start 1)
 	(message "Line %d" n)
       (save-excursion
 	(save-restriction
 	  (widen)
 	  (message "line %d (narrowed line %d)" 
-		   (+ n (line-at-pos start) -1) n))))))
+		   (+ n (line-number-at-pos start) -1) n))))))
 
 (defun count-lines (start end)
   "Return number of lines between START and END.
@@ -531,7 +531,7 @@
 		done)))
 	(- (buffer-size) (forward-line (buffer-size)))))))
 
-(defun line-at-pos (&optional pos)
+(defun line-number-at-pos (&optional pos)
   "Return (narrowed) buffer line number at position POS.
 If POS is nil, use current buffer location."
   (let ((opoint (or pos (point))) start)
@@ -1834,7 +1834,7 @@
 Optional third arguments YANK-HANDLER controls how the STRING is later
 inserted into a buffer; see `insert-for-yank' for details.
 When a yank handler is specified, STRING must be non-empty (the yank
-handler is stored as a `yank-handler'text property on STRING).
+handler is stored as a `yank-handler' text property on STRING).
 
 When the yank handler has a non-nil PARAM element, the original STRING
 argument is not used by `insert-for-yank'.  However, since Lisp code
@@ -1842,7 +1842,8 @@
 argument should still be a \"useful\" string for such uses."
   (if (> (length string) 0)
       (if yank-handler
-	  (put-text-property 0 1 'yank-handler yank-handler string))
+	  (put-text-property 0 (length string)
+			     'yank-handler yank-handler string))
     (if yank-handler
 	(signal 'args-out-of-range
 		(list string "yank-handler specified for empty string"))))
@@ -1863,8 +1864,8 @@
 Optional third argument YANK-HANDLER specifies the yank-handler text
 property to be set on the combined kill ring string.  If the specified
 yank-handler arg differs from the yank-handler property of the latest
-kill string, STRING is added as a new kill ring element instead of
-being appending to the last kill.
+kill string, this function adds the combined string to the kill
+ring as a new element, instead of replacing the last kill with it.
 If `interprogram-cut-function' is set, pass the resulting kill to it."
   (let* ((cur (car kill-ring)))
     (kill-new (if before-p (concat string cur) (concat cur string))
--- a/lisp/tar-mode.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/tar-mode.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; tar-mode.el --- simple editing of tar files from GNU emacs
 
-;; Copyright (C) 1990,91,93,94,95,96,97,98,99,2000,2001
+;; Copyright (C) 1990,91,93,94,95,96,97,98,99,2000,01,2004
 ;; Free Software Foundation, Inc.
 
 ;; Author: Jamie Zawinski <jwz@lucid.com>
@@ -289,7 +289,7 @@
     (dotimes (i L)
        (if (or (< (aref string i) ?0)
 	       (> (aref string i) ?7))
-	   (error "`%c' is not an octal digit"))))
+	   (error "`%c' is not an octal digit" (aref string i)))))
   (tar-parse-octal-integer string))
 
 
@@ -743,6 +743,7 @@
 				 (min (+ (point-min) 16384) (point-max)) t)))
 		  (if coding
 		      (or (numberp (coding-system-eol-type coding))
+			  (vectorp (coding-system-eol-type detected))
 			  (setq coding (coding-system-change-eol-conversion
 					coding
 					(coding-system-eol-type detected))))
--- a/lisp/term/x-win.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/term/x-win.el	Tue Feb 17 01:52:25 2004 +0000
@@ -82,6 +82,7 @@
 (require 'select)
 (require 'menu-bar)
 (require 'fontset)
+(require 'x-dnd)
 
 (defvar x-invocation-args)
 
@@ -2180,13 +2181,11 @@
 	char)
     (if (/= len-utf8 len-ctext)
 	(if (> len-utf8 len-ctext) utf8 ctext)
-      (while (< i len-utf8)
-	(setq char (aref ctext i))
-	(if (and (< char 128) (/= char (aref utf8 i)))
-	    (setq selected utf8
-		  i len-utf8)
-	  (setq i (1+ i))))
-      selected)))
+      (let ((result (compare-strings utf8 0 len-utf8 ctext 0 len-ctext)))
+	(if (or (eq result t)
+		(>= (aref ctext (1- (abs result))) 128))
+	    ctext
+	  utf8)))))
 
 (defun x-selection-value (type)
   (let (text)
@@ -2484,5 +2483,9 @@
 
 (provide 'x-win)
 
+;; Initiate drag and drop
+(add-hook 'after-make-frame-functions 'x-dnd-init-frame)
+(global-set-key [drag-n-drop] 'x-dnd-handle-drag-n-drop-event)
+
 ;;; arch-tag: f1501302-db8b-4d95-88e3-116697d89f78
 ;;; x-win.el ends here
--- a/lisp/textmodes/refer.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/textmodes/refer.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; refer.el --- look up references in bibliography files
 
-;; Copyright (C) 1992, 1996, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1996, 2001, 2004 Free Software Foundation, Inc.
 
 ;; Author: Ashwin Ram <ashwin@cc.gatech.edu>
 ;; Maintainer: Gernot Heiser <gernot@acm.org>
@@ -226,10 +226,12 @@
                      (throw 'found (find-file file)))
                  (setq refer-saved-pos nil
                        files (cdr files)))
-             (progn (message "Scanning %s... No such file" (car files) (ding))
+             (progn (ding)
+		    (message "Scanning %s... No such file" (car files))
                     (sit-for 1)
                     (setq files (cdr files))))))
-       (message "Keywords \"%s\" not found in any \.bib file" keywords (ding)))
+       (ding)
+       (message "Keywords \"%s\" not found in any \.bib file" keywords))
      (select-window old-window)))
 
 (defun refer-find-entry-in-file (keywords-list file &optional old-pos)
--- a/lisp/textmodes/reftex-toc.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/textmodes/reftex-toc.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,5 +1,5 @@
 ;;; reftex-toc.el --- RefTeX's table of contents mode
-;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
+;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
 ;; Version: 4.21
@@ -754,13 +754,13 @@
   "Make sure all files of the document are being visited by buffers,
 and that the scanning info is absolutely up to date.
 We do this by rescanning with reftex-keep-temporary-buffers bound to t.
-The variable PRO-OR-DE is assumed to be dynamically scoped into thes function.
+The variable PRO-OR-DE is assumed to be dynamically scoped into this function.
 When finished, we exit with an error message."
   (let ((reftex-keep-temporary-buffers t))
     (reftex-toc-Rescan)
     (reftex-toc-restore-region start-line mark-line)
     (throw 'exit
-           (format "TOC had to be updated first.  Please check selection and repeat the command." pro-or-de))))
+           "TOC had to be updated first.  Please check selection and repeat the command.")))
 
 (defun reftex-toc-rename-label ()
   "Rename the currently selected label in the *TOC* buffer.
--- a/lisp/vc.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/vc.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,13 +1,13 @@
 ;;; vc.el --- drive a version-control system from within Emacs
 
-;; Copyright (C) 1992,93,94,95,96,97,98,2000,01,2003
+;; Copyright (C) 1992,93,94,95,96,97,98,2000,01,2003,2004
 ;;           Free Software Foundation, Inc.
 
 ;; Author:     FSF (see below for full credits)
 ;; Maintainer: Andre Spiegel <spiegel@gnu.org>
 ;; Keywords: tools
 
-;; $Id: vc.el,v 1.365 2004/01/23 11:20:55 uid65624 Exp $
+;; $Id: vc.el,v 1.367 2004/02/08 22:42:42 uid65629 Exp $
 
 ;; This file is part of GNU Emacs.
 
@@ -804,11 +804,11 @@
   (let ((filevar (make-symbol "file")))
     `(let ((,filevar (expand-file-name ,file)))
        (or (vc-backend ,filevar)
-           (error (format "File not under version control: `%s'" file)))
+           (error "File not under version control: `%s'" file))
        (unless (vc-editable-p ,filevar)
          (let ((state (vc-state ,filevar)))
            (if (stringp state)
-               (error (format "`%s' is locking `%s'" state ,filevar))
+               (error "`%s' is locking `%s'" state ,filevar)
              (vc-checkout ,filevar t))))
        (save-excursion
          ,@body)
@@ -2487,7 +2487,7 @@
      ((not (vc-call latest-on-branch-p file))
       (error "This is not the latest version; VC cannot cancel it"))
      ((not (vc-up-to-date-p file))
-      (error (substitute-command-keys "File is not up to date; use \\[vc-revert-buffer] to discard changes"))))
+      (error "%s" (substitute-command-keys "File is not up to date; use \\[vc-revert-buffer] to discard changes"))))
     (if (null (yes-or-no-p (format "Remove version %s from master? " target)))
 	(error "Aborted")
       (setq norevert (or norevert (not
@@ -3144,7 +3144,7 @@
 revision."
   (if (not (equal major-mode 'vc-annotate-mode))
       (message "Cannot be invoked outside of a vc annotate buffer")
-    (let* ((oldline (line-at-pos))
+    (let* ((oldline (line-number-at-pos))
 	   (revspeccopy revspec)
 	   (newrev nil))
       (cond
@@ -3176,7 +3176,7 @@
 	(switch-to-buffer (car (car (last vc-annotate-buffers))))
 	(goto-line (min oldline (progn (goto-char (point-max))
 				       (previous-line)
-				       (line-at-pos))))))))
+				       (line-number-at-pos))))))))
 
 (defun vc-annotate-car-last-cons (a-list)
   "Return car of last cons in association list A-LIST."
--- a/lisp/window.el	Tue Feb 10 13:52:03 2004 +0000
+++ b/lisp/window.el	Tue Feb 17 01:52:25 2004 +0000
@@ -1,6 +1,6 @@
 ;;; window.el --- GNU Emacs window commands aside from those written in C
 
-;; Copyright (C) 1985, 1989, 1992, 1993, 1994, 2000, 2001, 2002
+;; Copyright (C) 1985, 1989, 1992, 1993, 1994, 2000, 2001, 2002, 2004
 ;;  Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
@@ -188,13 +188,11 @@
 (defun window-safely-shrinkable-p (&optional window)
   "Non-nil if the WINDOW can be shrunk without shrinking other windows.
 If WINDOW is nil or omitted, it defaults to the currently selected window."
-  (save-selected-window
-    (when window (select-window window))
-    (or (and (not (eq window (frame-first-window)))
-	     (= (car (window-edges))
-		(car (window-edges (previous-window)))))
-	(= (car (window-edges))
-	   (car (window-edges (next-window)))))))
+  (with-selected-window (or window (selected-window))
+    (let ((edges (window-edges)))
+      (or (= (nth 2 edges) (nth 2 (window-edges (previous-window))))
+	  (= (nth 0 edges) (nth 0 (window-edges (next-window))))))))
+
 
 (defun balance-windows ()
   "Make all visible windows the same height (approximately)."
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/x-dnd.el	Tue Feb 17 01:52:25 2004 +0000
@@ -0,0 +1,870 @@
+;;; x-dnd.el --- drag and drop support for X.
+
+;; Copyright (C) 2004
+;;  Free Software Foundation, Inc.
+
+;; Author: Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
+;; Maintainer: FSF
+;; Keywords: window, drag, drop
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; This file provides the drop part only.  Currently supported protocols
+;; are XDND, Motif and the old KDE 1.x protocol.
+
+;;; Code:
+
+;;; Customizable variables
+
+
+(defcustom x-dnd-test-function 'x-dnd-default-test-function
+  "The function drag and drop uses to determine if to accept or reject a drop.
+The function takes three arguments, WINDOW ACTION and TYPES.
+WINDOW is where the mouse is when the function is called.  WINDOW may be a
+frame if the mouse isn't over a real window (i.e. menu bar, tool bar or
+scroll bar).  ACTION is the suggested action from the drag and drop source,
+one of the symbols move, copy link or ask.  TYPES is a list of available types
+for the drop.
+
+The function shall return nil to reject the drop or a cons with two values,
+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'."
+  :type 'symbol
+  :group 'x)
+
+(defcustom x-dnd-protocol-alist
+  '(
+    ("^file:///" . x-dnd-open-local-file)	; XDND format.
+    ("^file://"  . x-dnd-open-file)		; URL with host
+    ("^file:"    . x-dnd-open-local-file)	; Old KDE, Motif, Sun
+    )
+
+  "The functions to call for different protocols when a drop is made.
+This variable is used by `x-dnd-handle-uri-list' and `x-dnd-handle-moz-url'.
+The list contains of (REGEXP . FUNCTION) pairs.
+The functions shall take two arguments, URL, which is the URL dropped and
+ACTION which is the action to be performed for the drop (move, copy, link,
+private or ask).
+If no match is found here, and the value of `browse-url-browser-function'
+is a pair of (REGEXP . FUNCTION), those regexps are tried for a match.
+Insertion of text is not handeled by these functions, see `x-dnd-types-alist'
+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."
+  :type 'alist
+  :group 'x)
+
+
+(defcustom x-dnd-types-alist
+  '(
+    ("text/uri-list" . x-dnd-handle-uri-list)
+    ("text/x-moz-url" . x-dnd-handle-moz-url)
+    ("_NETSCAPE_URL" . x-dnd-handle-uri-list)
+    ("FILE_NAME" . x-dnd-handle-file-name)
+    ("UTF8_STRING" . x-dnd-insert-utf8-text)
+    ("text/plain;charset=UTF-8" . x-dnd-insert-utf8-text)
+    ("text/plain;charset=utf-8" . x-dnd-insert-utf8-text)
+    ("text/unicode" . x-dnd-insert-utf16-text)
+    ("text/plain" . x-dnd-insert-text)
+    ("COMPOUND_TEXT" . x-dnd-insert-ctext)
+    ("STRING" . x-dnd-insert-text)
+    ("TEXT"   . x-dnd-insert-text)
+    )
+  "Which function to call to handle a drop of that type.
+If the type for the drop is not present, or the function is nil,
+the drop is rejected.  The function takes three arguments, WINDOW, ACTION
+and DATA.  WINDOW is where the drop occured, ACTION is the action for
+this drop (copy, move, link, private or ask) as determined by a previous
+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."
+  :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."
+  :type 'boolean
+  :group 'x)
+
+;; Internal variables
+
+(defvar x-dnd-known-types
+  '("text/uri-list"
+    "text/x-moz-url"
+    "_NETSCAPE_URL"
+    "FILE_NAME"
+    "UTF8_STRING"
+    "text/plain;charset=UTF-8"
+    "text/plain;charset=utf-8"
+    "text/unicode"
+    "text/plain"
+    "COMPOUND_TEXT"
+    "STRING"
+    "TEXT"
+    )
+  "The types accepted by default for dropped data.
+The types are chosen in the order they appear in the list.")
+
+(defvar x-dnd-current-state nil
+  "The current state for a drop.
+This is an alist with one entry for each display.  The value for each display
+is a vector that contains the state for drag and drop for that display.
+Elements in the vector are: 
+Last buffer drag was in,
+last window drag was in,
+types available for drop, 
+the action suggested by the source,
+the type we want for the drop,
+the action we want for the drop,
+any protocol specific data.")
+
+(defvar x-dnd-empty-state [nil nil nil nil nil nil nil])
+
+
+
+(defun x-dnd-init-frame (&optional frame)
+  "Setup drag and drop for FRAME (i.e. create appropriate properties)."
+  (x-dnd-init-xdnd-for-frame frame)
+  (x-dnd-init-motif-for-frame frame))
+
+(defun x-dnd-get-state-cons-for-frame (frame-or-window)
+  "Return the entry in x-dnd-current-state for a frame or window."
+  (let* ((frame (if (framep frame-or-window) frame-or-window
+		  (window-frame frame-or-window)))
+	 (display (frame-parameter frame 'display)))
+    (if (not (assoc display x-dnd-current-state))
+	(push (cons display (copy-sequence x-dnd-empty-state))
+	      x-dnd-current-state))
+    (assoc display x-dnd-current-state)))
+
+(defun x-dnd-get-state-for-frame (frame-or-window)
+  "Return the state in x-dnd-current-state for a frame or window."
+  (cdr (x-dnd-get-state-cons-for-frame frame-or-window)))
+
+(defun x-dnd-default-test-function (window action types)
+  "The default test function for drag and drop.
+WINDOW is where the mouse is when this function is called.  It may be a frame
+if the mouse is over the menu bar, scroll bar or tool bar.
+ACTION is the suggested action from the source, and TYPES are the
+types the drop data can have.  This function only accepts drops with
+types in `x-dnd-known-types'.  It always returns the action private."
+  (let ((type (x-dnd-choose-type types)))
+    (when type (cons 'private type))))
+
+
+(defun x-dnd-current-type (frame-or-window)
+  "Return the type we want the DND data to be in for the current drop.
+FRAME-OR-WINDOW is the frame or window that the mouse is over."
+  (aref (x-dnd-get-state-for-frame frame-or-window) 4))
+
+(defun x-dnd-forget-drop (frame-or-window)
+  "Remove all state for the last drop.
+FRAME-OR-WINDOW is the frame or window that the mouse is over."
+  (setcdr (x-dnd-get-state-cons-for-frame frame-or-window)
+	  (copy-sequence x-dnd-empty-state)))
+
+(defun x-dnd-maybe-call-test-function (window action)
+  "Call `x-dnd-test-function' if something has changed.
+WINDOW is the window the mouse is over.  ACTION is the suggested
+action from the source.  If nothing has changed, return the last
+action and type we got from `x-dnd-test-function'."
+  (let ((buffer (when (and (windowp window) (window-live-p window))
+		  (window-buffer window)))
+	(current-state (x-dnd-get-state-for-frame window)))
+    (when (or (not (equal buffer (aref current-state 0)))
+	      (not (equal window (aref current-state 1)))
+	      (not (equal action (aref current-state 3))))
+      (save-excursion
+	(when buffer (set-buffer buffer))
+	(let* ((action-type (funcall x-dnd-test-function
+				     window
+				     action
+				     (aref current-state 2)))
+	       (handler (cdr (assoc (cdr action-type) x-dnd-types-alist))))
+	  ;; Ignore action-type if we have no handler.
+	  (setq current-state
+		(x-dnd-save-state window 
+				  action
+				  (when handler action-type)))))))
+  (let ((current-state (x-dnd-get-state-for-frame window)))
+    (cons (aref current-state 5)
+	  (aref current-state 4))))
+
+(defun x-dnd-save-state (window action action-type &optional types extra-data)
+  "Save the state of the current drag and drop.
+WINDOW is the window the mouse is over.  ACTION is the action suggested
+by the source.  ACTION-TYPE is the result of calling `x-dnd-test-function'.
+If given, TYPES are the types for the drop data that the source supports.
+EXTRA-DATA is data needed for a specific protocol."
+  (let ((current-state (x-dnd-get-state-for-frame window)))
+    (aset current-state 5 (car action-type))
+    (aset current-state 4 (cdr action-type))
+    (aset current-state 3 action)
+    (when types (aset current-state 2 types))
+    (when extra-data (aset current-state 6 extra-data))
+    (aset current-state 1 window)
+    (aset current-state 0 (if (and (windowp window)
+				   (window-live-p window))
+			      (window-buffer window) nil))
+    (setcdr (x-dnd-get-state-cons-for-frame window) current-state)))
+
+
+(defun x-dnd-handle-one-url (window action arg)
+  "Handle one dropped url by calling the appropriate handler.
+The handler is first localted by looking at `x-dnd-protocol-alist'.
+If no match is found here, and the value of `browse-url-browser-function'
+is a pair of (REGEXP . FUNCTION), those regexps are tried for a match.
+If no match is found, just call `x-dnd-insert-text'.
+WINDOW is where the drop happend, ACTION is the action for the drop,
+ARG is the URL that has been dropped.
+Returns ACTION."
+  (require 'browse-url)
+  (let* ((uri (replace-regexp-in-string
+	       "%[A-Z0-9][A-Z0-9]"
+	       (lambda (arg)
+		 (format "%c" (string-to-number (substring arg 1) 16)))
+	       arg))
+	 ret)
+    (or
+     (catch 'done
+       (dolist (bf x-dnd-protocol-alist)
+	 (when (string-match (car bf) uri)
+	   (setq ret (funcall (cdr bf) uri action))
+	   (throw 'done t)))
+       nil)
+     (when (not (functionp browse-url-browser-function))
+       (catch 'done
+	 (dolist (bf browse-url-browser-function)
+	   (when (string-match (car bf) uri)
+	     (setq ret 'private)
+	     (funcall (cdr bf) uri action)
+	     (throw 'done t)))
+	 nil))
+     (progn
+       (x-dnd-insert-text window action uri)
+       (setq ret 'private)))
+    ret))
+
+
+(defun x-dnd-get-local-file-uri (uri)
+  "Return an uri converted to file:/// syntax if uri is a local file.
+Return nil if URI is not a local file."
+
+  ;; The hostname may be our hostname, in that case, convert to a local
+  ;; file.  Otherwise return nil.  TODO:  How about an IP-address as hostname?
+  (let ((hostname (when (string-match "^file://\\([^/]*\\)" uri)
+		      (downcase (match-string 1 uri))))
+	(system-name-no-dot
+	 (downcase (if (string-match "^[^\\.]+" system-name)
+		       (match-string 0 system-name)
+		     system-name))))
+    (when (and hostname
+	     (or (string-equal "localhost" hostname)
+		 (string-equal (downcase system-name) hostname)
+		 (string-equal system-name-no-dot hostname)))
+	(concat "file://" (substring uri (+ 7 (length hostname)))))))
+
+(defun x-dnd-get-local-file-name (uri &optional must-exist)
+  "Return file name converted from file:/// or file: syntax.
+URI is the uri for the file.  If MUST-EXIST is given and non-nil,
+only return non-nil if the file exists.
+Return nil if URI is not a local file."
+  (let ((f (cond ((string-match "^file:///" uri)	; XDND format.
+		  (substring uri (1- (match-end 0))))
+		 ((string-match "^file:" uri)		; Old KDE, Motif, Sun
+		  (substring uri (match-end 0))))))
+    (when (and f must-exist)
+      (let* ((decoded-f (decode-coding-string 
+			 f
+			 (or file-name-coding-system
+			     default-file-name-coding-system)))
+	     (try-f (if (file-readable-p decoded-f) decoded-f f)))
+	(when (file-readable-p try-f) try-f)))))
+	
+
+(defun x-dnd-open-local-file (uri action)
+  "Open a local file.
+The file is opened in the current window, or a new window if
+`x-dnd-open-file-other-window' is set.  URI is the url for the file,
+and must have the format file:file-name or file:///file-name.
+The last / in file:/// is part of the file name.  ACTION is ignored."
+
+  (let* ((f (x-dnd-get-local-file-name uri t)))
+    (when f
+      (if (file-readable-p f)
+	  (progn
+	    (if x-dnd-open-file-other-window
+		(find-file-other-window f)
+	      (find-file f))
+	    'private)
+	(error "Can not read %s (%s)" f uri)))))
+
+(defun x-dnd-open-file (uri action)
+  "Open a local or remote file.
+The file is opened in the current window, or a new window if
+`x-dnd-open-file-other-window' is set.  URI is the url for the file,
+and must have the format file://hostname/file-name.  ACTION is ignored.
+The last / in file://hostname/ is part of the file name."
+
+  ;; The hostname may be our hostname, in that case, convert to a local
+  ;; file.  Otherwise return nil.
+  (let ((local-file (x-dnd-get-local-file-uri uri)))
+    (when local-file (x-dnd-open-local-file local-file action))))
+
+
+(defun x-dnd-handle-moz-url (window action data)
+  "Handle one item of type text/x-moz-url.
+WINDOW is the window where the drop happened.  ACTION is ignored.
+DATA is the moz-url, which is formatted as two strings separated by \r\n.
+The first string is the URL, the second string is the title of that URL.
+DATA is encoded in utf-16.  Decode the URL and call `x-dnd-handle-uri-list'."
+  (let* ((string (decode-coding-string data 'utf-16le))  ;; ALWAYS LE???
+	 (strings (split-string string "[\r\n]" t))
+	 ;; Can one drop more than one moz-url ??  Assume not.
+	 (url (car strings))
+	 (title (car (cdr strings))))
+    (x-dnd-handle-uri-list window action url)))
+
+(defun x-dnd-insert-utf8-text (window action text)
+  "Decode the UTF-8 text and insert it at point.
+TEXT is the text as a string, WINDOW is the window where the drop happened."
+  (x-dnd-insert-text window action (decode-coding-string text 'utf-8)))
+
+(defun x-dnd-insert-utf16-text (window action text)
+  "Decode the UTF-16 text and insert it at point.
+TEXT is the text as a string, WINDOW is the window where the drop happened."
+  (x-dnd-insert-text window action (decode-coding-string text 'utf-16le)))
+
+(defun x-dnd-insert-ctext (window action text)
+  "Decode the compound text and insert it at point.
+TEXT is the text as a string, WINDOW is the window where the drop happened."
+  (x-dnd-insert-text window action
+		     (decode-coding-string text
+					   'compound-text-with-extensions)))
+
+(defun x-dnd-insert-text (window action text)
+  "Insert text at point or push to the kill ring if buffer is read only.
+TEXT is the text as a string, WINDOW is the window where the drop happened."
+  (if (or buffer-read-only
+	  (not (windowp window)))
+      (progn
+	(kill-new text)
+	(message
+	 (substitute-command-keys
+	  "The dropped text can be accessed with \\[yank]")))
+    (insert text))
+  action)
+
+(defun x-dnd-handle-uri-list (window action string)
+  "Split an uri-list into separate URIs and call `x-dnd-handle-one-url'.
+WINDOW is the window where the drop happened.
+STRING is the uri-list as a string.  The URIs are separated by \r\n."
+  (let ((uri-list (split-string string "[\0\r\n]" t))
+	retval)
+    (dolist (bf uri-list)
+      ;; If one URL is handeled, treat as if the whole drop succeeded.
+      (let ((did-action (x-dnd-handle-one-url window action bf)))
+	(when did-action (setq retval did-action))))
+    retval))
+
+(defun x-dnd-handle-file-name (window action string)
+  "Prepend file:// to file names and call `x-dnd-handle-one-url'.
+WINDOW is the window where the drop happened.
+STRING is the file names as a string, separated by nulls."
+  (let ((uri-list (split-string string "[\0\r\n]" t))
+	retval)
+    (dolist (bf uri-list)
+      ;; If one URL is handeled, treat as if the whole drop succeeded.
+      (let* ((file-uri (concat "file://" bf))
+	     (did-action (x-dnd-handle-one-url window action file-uri)))
+	(when did-action (setq retval did-action))))
+    retval))
+
+
+(defun x-dnd-choose-type (types &optional known-types)
+  "Choose which type we want to receive for the drop.
+TYPES are the types the source of the drop offers, a vector of type names
+as strings or symbols.  Select among the types in `x-dnd-known-types' or
+KNOWN-TYPES if given,  and return that type name.
+If no suitable type is found, return nil."
+  (let* ((known-list (or known-types x-dnd-known-types))
+	 (first-known-type (car known-list))
+	 (types-array types)
+	 (found (when first-known-type
+		  (catch 'done
+		    (dotimes (i (length types-array))
+		      (let* ((type (aref types-array i))
+			     (typename (if (symbolp type)
+					   (symbol-name type) type)))
+			(when (equal first-known-type typename)
+			  (throw 'done first-known-type))))
+		    nil))))
+
+    (if (and (not found) (cdr known-list))
+	(x-dnd-choose-type types (cdr known-list))
+      found)))
+
+(defun x-dnd-drop-data (event frame window data type)
+  "Drop one data item onto a frame.
+EVENT is the client message for the drop, FRAME is the frame the drop occurred
+on.  WINDOW is the window of FRAME where the drop happened.  DATA is the data
+received from the source, and type is the type for DATA, see
+`x-dnd-types-alist').
+
+Returns the action used (move, copy, link, private) if drop was successful,
+nil if not."
+  (let* ((type-info (assoc type x-dnd-types-alist))
+	 (handler (cdr type-info))
+	 (state (x-dnd-get-state-for-frame frame))
+	 (action (aref state 5))
+	 (w (posn-window (event-start event))))
+    (when handler
+      (if (and (windowp w) (window-live-p w))
+	  ;; If dropping in a window, open files in that window rather
+	  ;; than in a new widow.
+	  (let ((x-dnd-open-file-other-window nil))
+	    (goto-char (posn-point (event-start event)))
+	    (funcall handler window action data))
+	(let ((x-dnd-open-file-other-window t))  ;; Dropping on non-window.
+	  (select-frame frame)
+	  (funcall handler window action data))))))
+
+(defun x-dnd-handle-drag-n-drop-event (event)
+  "Receive drag and drop events (X client messages).
+Currently XDND, Motif and old KDE 1.x protocols are recognized."
+  (interactive "e")
+  (let* ((client-message (car (cdr (cdr event))))
+	 (window (posn-window (event-start event)))
+	 (message-atom (aref client-message 0))
+	 (frame (aref client-message 1))
+	 (format (aref client-message 2))
+	 (data (aref client-message 3)))
+
+    (cond ((equal "DndProtocol" message-atom)	; Old KDE 1.x.
+	   (x-dnd-handle-old-kde event frame window message-atom format data))
+
+	  ((equal "_MOTIF_DRAG_AND_DROP_MESSAGE" message-atom)	; Motif
+	   (x-dnd-handle-motif event frame window message-atom format data))
+
+	  ((and (> (length message-atom) 4)	; XDND protocol.
+		(equal "Xdnd" (substring message-atom 0 4)))
+	   (x-dnd-handle-xdnd event frame window message-atom format data)))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;  Old KDE protocol.  Only dropping of files.
+
+(defun x-dnd-handle-old-kde (event frame window message format data)
+  "Open the files in a KDE 1.x drop."
+  (let ((values (x-window-property "DndSelection" frame nil 0 t)))
+    (x-dnd-handle-uri-list window 'private
+			   (replace-regexp-in-string "\0$" "" values))))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;  XDND protocol.
+
+(defvar x-dnd-xdnd-to-action
+  '(("XdndActionPrivate" . private)
+    ("XdndActionCopy" . copy)
+    ("XdndActionMove" . move)
+    ("XdndActionLink" . link)
+    ("XdndActionAsk" . ask))
+  "Mapping from XDND action types to lisp symbols.")
+
+(defun x-dnd-init-xdnd-for-frame (frame)
+  "Set the XdndAware property for FRAME to indicate that we do XDND."
+  (x-change-window-property "XdndAware"
+			    '(5)	;; The version of XDND we support.
+			    frame "ATOM" 32 t))
+
+(defun x-dnd-get-drop-width-height (frame w accept)
+  "Return the widht/height to be sent in a XDndStatus message.
+FRAME is the frame and W is the window where the drop happened.
+If ACCEPT is nil return 0 (empty rectangle),
+otherwise if W is a window, return its widht/height,
+otherwise return the frame width/height."
+  (if accept
+      (if (windowp w)   ;; w is not a window if dropping on the menu bar,
+			;; scroll bar or tool bar.
+	  (let ((edges (window-inside-pixel-edges w)))
+	    (cons
+	     (- (nth 2 edges) (nth 0 edges))	;; right - left
+	     (- (nth 3 edges) (nth 1 edges))))	;; bottom - top
+	(cons (frame-pixel-width frame)
+	      (frame-pixel-height frame)))
+    0))
+
+(defun x-dnd-get-drop-x-y (frame w)
+  "Return the x/y coordinates to be sent in a XDndStatus message.
+Coordinates are required to be absolute.
+FRAME is the frame and W is the window where the drop happened.
+If W is a window, return its absolute corrdinates,
+otherwise return the frame coordinates."
+  (let* ((frame-left (frame-parameter frame 'left))
+	 ;; If the frame is outside the display, frame-left looks like
+	 ;; '(0 -16).  Extract the -16.
+	 (frame-real-left (if (consp frame-left) (car (cdr frame-left))
+			    frame-left))
+	 (frame-top (frame-parameter frame 'top))
+	 (frame-real-top (if (consp frame-top) (car (cdr frame-top))
+			   frame-top)))
+    (if (windowp w)
+	(let ((edges (window-inside-pixel-edges w)))
+	  (cons
+	   (+ frame-real-left (nth 0 edges))
+	   (+ frame-real-top (nth 1 edges))))
+      (cons frame-real-left frame-real-top))))
+
+(defun x-dnd-handle-xdnd (event frame window message format data)
+  "Receive one XDND event (client message) and send the appropriate reply.
+EVENT is the client message.  FRAME is where the mouse is now.
+WINDOW is the window within FRAME where the mouse is now.
+FORMAT is 32 (not used).  MESSAGE is the data part of an XClientMessageEvent."
+  (cond ((equal "XdndEnter" message)
+	 (let ((version (ash (car (aref data 1)) -8))
+	       (more-than-3 (cdr (aref data 1)))
+	       (dnd-source (aref data 0)))
+	   (x-dnd-save-state 
+	    window nil nil
+	    (if (> more-than-3 0)
+		(x-window-property "XdndTypeList"
+				   frame "AnyPropertyType"
+				   dnd-source nil t)
+	      (vector (x-get-atom-name (aref data 2))
+		      (x-get-atom-name (aref data 3))
+		      (x-get-atom-name (aref data 4)))))))
+
+	((equal "XdndPosition" message)
+	 (let* ((x (car (aref data 2)))
+		(y (cdr (aref data 2)))
+		(action (x-get-atom-name (aref data 4)))
+		(dnd-source (aref data 0))
+		(dnd-time (aref data 3))
+		(action-type (x-dnd-maybe-call-test-function
+			      window
+			      (cdr (assoc action x-dnd-xdnd-to-action))))
+		(reply-action (car (rassoc (car action-type)
+					   x-dnd-xdnd-to-action)))
+		(accept ;; 1 = accept, 0 = reject
+		 (if (and reply-action action-type) 1 0))
+		(list-to-send
+		 (list (string-to-number
+			(frame-parameter frame 'outer-window-id))
+		       accept ;; 1 = Accept, 0 = reject.
+		       (x-dnd-get-drop-x-y frame window)
+		       (x-dnd-get-drop-width-height 
+			frame window (eq accept 1))
+		       (or reply-action 0)
+		       )))
+	   (x-send-client-message
+	    frame dnd-source frame "XdndStatus" 32 list-to-send)
+	   ))
+
+	((equal "XdndLeave" message)
+	 (x-dnd-forget-drop window))
+
+	((equal "XdndDrop" message)
+	 (if (windowp window) (select-window window))
+	 (let* ((dnd-source (aref data 0))
+		(value (and (x-dnd-current-type window)
+			    (x-get-selection-internal
+			     'XdndSelection
+			     (intern (x-dnd-current-type window)))))
+		success action ret-action)
+
+	   (setq action (if value
+			    (condition-case info
+				(x-dnd-drop-data event frame window value 
+						 (x-dnd-current-type window))
+			      (error 
+			       (message "Error: %s" info)
+			       nil))))
+
+	   (setq success (if action 1 0))
+	   (setq ret-action
+		 (if (eq success 1)
+		     (or (car (rassoc action x-dnd-xdnd-to-action))
+			 "XdndActionPrivate")
+		   0))
+
+	   (x-send-client-message
+	    frame dnd-source frame "XdndFinished" 32
+	    (list (string-to-number (frame-parameter frame 'outer-window-id))
+		  success	;; 1 = Success, 0 = Error
+		  (if success "XdndActionPrivate" 0)
+		  ))
+	   (x-dnd-forget-drop window)))
+
+	(t (error "Unknown XDND message %s %s" message data))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;  Motif protocol.
+
+(defun x-dnd-init-motif-for-frame (frame)
+  "Set _MOTIF_DRAG_RECEIVER_INFO  for FRAME to indicate that we do Motif DND."
+  (x-change-window-property "_MOTIF_DRAG_RECEIVER_INFO"
+			    (list
+			     (byteorder)
+			     0			; The Motif DND version.
+			     5			; We want drag dynamic.
+			     0 0 0 0 0 0 0
+			     0 0 0 0 0 0)	; Property must be 16 bytes.
+			    frame "_MOTIF_DRAG_RECEIVER_INFO" 8 t))
+
+(defun x-dnd-get-motif-value (data offset size byteorder)
+  (cond ((eq size 2)
+	 (if (eq byteorder ?l)
+	     (+ (ash (aref data (1+ offset)) 8)
+		(aref data offset))
+	   (+ (ash (aref data offset) 8)
+	      (aref data (1+ offset)))))
+
+	((eq size 4)
+	 (if (eq byteorder ?l)
+	     (cons (+ (ash (aref data (+ 3 offset)) 8)
+		      (aref data (+ 2 offset)))
+		   (+ (ash (aref data (1+ offset)) 8)
+		      (aref data offset)))
+	   (cons (+ (ash (aref data offset) 8)
+		    (aref data (1+ offset)))
+		 (+ (ash (aref data (+ 2 offset)) 8)
+		    (aref data (+ 3 offset))))))))
+
+(defun x-dnd-motif-value-to-list (value size byteorder)
+  (let ((bytes (cond ((eq size 2)
+		      (list (logand (lsh value -8) ?\xff)
+			    (logand value ?\xff)))
+
+		     ((eq size 4)
+		      (if (consp value)
+			  (list (logand (lsh (car value) -8) ?\xff)
+				(logand (car value) ?\xff)
+				(logand (lsh (cdr value) -8) ?\xff)
+				(logand (cdr value) ?\xff))
+			(list (logand (lsh value -24) ?\xff)
+			      (logand (lsh value -16) ?\xff)
+			      (logand (lsh value -8) ?\xff)
+			      (logand value ?\xff)))))))
+    (if (eq byteorder ?l)
+	(reverse bytes)
+      bytes)))
+
+
+(defvar x-dnd-motif-message-types
+  '((0 . XmTOP_LEVEL_ENTER)
+    (1 . XmTOP_LEVEL_LEAVE)
+    (2 . XmDRAG_MOTION)
+    (3 . XmDROP_SITE_ENTER)
+    (4 . XmDROP_SITE_LEAVE)
+    (5 . XmDROP_START)
+    (6 . XmDROP_FINISH)
+    (7 . XmDRAG_DROP_FINISH)
+    (8 . XmOPERATION_CHANGED))
+  "Mapping from numbers to Motif DND message types.")
+
+(defvar x-dnd-motif-to-action
+  '((1 . move)
+    (2 . copy)
+    (3 . link)	; Both 3 and 4 has been seen as link.
+    (4 . link)
+    (2 . private)) ; Motif does not have private, so use copy for private.
+  "Mapping from number to operation for Motif DND.")
+
+(defun x-dnd-handle-motif (event frame window message-atom format data)
+  (let* ((message-type (cdr (assoc (aref data 0) x-dnd-motif-message-types)))
+	 (source-byteorder (aref data 1))
+	 (my-byteorder (byteorder))
+	 (source-flags (x-dnd-get-motif-value data 2 2 source-byteorder))
+	 (source-action (cdr (assoc (logand ?\xF source-flags)
+				    x-dnd-motif-to-action))))
+
+    (cond ((eq message-type 'XmTOP_LEVEL_ENTER)
+	   (let* ((dnd-source (x-dnd-get-motif-value
+			       data 8 4 source-byteorder))
+		  (selection-atom (x-dnd-get-motif-value
+				   data 12 4 source-byteorder))
+		  (atom-name (x-get-atom-name selection-atom))
+		  (types (when atom-name
+			   (x-get-selection-internal (intern atom-name)
+						     'TARGETS))))
+	     (x-dnd-forget-drop frame)
+	     (when types (x-dnd-save-state window nil nil
+					   types
+					   dnd-source))))
+
+	  ;; Can not forget drop here, LEAVE comes before DROP_START and
+	  ;; we need the state in DROP_START.
+	  ((eq message-type 'XmTOP_LEVEL_LEAVE)
+	   nil)
+
+	  ((eq message-type 'XmDRAG_MOTION)
+	   (let* ((state (x-dnd-get-state-for-frame frame))
+		  (timestamp (x-dnd-motif-value-to-list
+			      (x-dnd-get-motif-value data 4 4 
+						     source-byteorder)
+			      4 my-byteorder))
+		  (x (x-dnd-motif-value-to-list
+		      (x-dnd-get-motif-value data 8 2 source-byteorder)
+		      2 my-byteorder))
+		  (y (x-dnd-motif-value-to-list
+		      (x-dnd-get-motif-value data 10 2 source-byteorder)
+		      2 my-byteorder))
+		  (dnd-source (aref state 6))
+		  (first-move (not (aref state 3)))
+		  (action-type (x-dnd-maybe-call-test-function
+				window
+				source-action))
+		  (reply-action (car (rassoc (car action-type)
+					     x-dnd-motif-to-action)))
+		  (reply-flags
+		   (x-dnd-motif-value-to-list
+		    (if reply-action
+			(+ reply-action 
+			   ?\x30	; 30:  valid drop site
+			   ?\x700)	; 700: can do copy, move or link
+		      ?\x30)		; 30:  drop site, but noop.
+		    2 my-byteorder))
+		  (reply (append
+			  (list
+			   (+ ?\x80	; 0x80 indicates a reply.
+			      (if first-move
+				  3	; First time, reply is SITE_ENTER.
+				2))	; Not first time, reply is DRAG_MOTION.
+			   my-byteorder)
+			  reply-flags
+			  timestamp
+			  x
+			  y)))
+	     (x-send-client-message frame
+				    dnd-source
+				    frame
+				    "_MOTIF_DRAG_AND_DROP_MESSAGE"
+				    8
+				    reply)))
+
+	  ((eq message-type 'XmOPERATION_CHANGED)
+	   (let* ((state (x-dnd-get-state-for-frame frame))
+		  (timestamp (x-dnd-motif-value-to-list
+			      (x-dnd-get-motif-value data 4 4 source-byteorder)
+			      4 my-byteorder))
+		  (dnd-source (aref state 6))
+		  (action-type (x-dnd-maybe-call-test-function
+				window
+				source-action))
+		  (reply-action (car (rassoc (car action-type)
+					     x-dnd-motif-to-action)))
+		  (reply-flags
+		   (x-dnd-motif-value-to-list
+		    (if reply-action
+			(+ reply-action 
+			   ?\x30	; 30:  valid drop site
+			   ?\x700)	; 700: can do copy, move or link
+		      ?\x30)		; 30:  drop site, but noop
+		    2 my-byteorder))
+		  (reply (append
+			  (list
+			   (+ ?\x80	; 0x80 indicates a reply.
+			      8)	; 8 is OPERATION_CHANGED
+			   my-byteorder)
+			  reply-flags
+			  timestamp)))
+	     (x-send-client-message frame
+				    dnd-source
+				    frame
+				    "_MOTIF_DRAG_AND_DROP_MESSAGE"
+				    8
+				    reply)))
+
+	  ((eq message-type 'XmDROP_START)
+	   (let* ((x (x-dnd-motif-value-to-list
+		      (x-dnd-get-motif-value data 8 2 source-byteorder)
+		      2 my-byteorder))
+		  (y (x-dnd-motif-value-to-list
+		      (x-dnd-get-motif-value data 10 2 source-byteorder)
+		      2 my-byteorder))
+		  (selection-atom (x-dnd-get-motif-value
+				   data 12 4 source-byteorder))
+		  (atom-name (x-get-atom-name selection-atom))
+		  (dnd-source (x-dnd-get-motif-value
+			       data 16 4 source-byteorder))
+		  (action-type (x-dnd-maybe-call-test-function
+				window
+				source-action))
+		  (reply-action (car (rassoc (car action-type)
+					     x-dnd-motif-to-action)))
+		  (reply-flags
+		   (x-dnd-motif-value-to-list
+		    (if reply-action
+			(+ reply-action 
+			   ?\x30	; 30:  valid drop site
+			   ?\x700)	; 700: can do copy, move or link
+		      (+ ?\x30		; 30:  drop site, but noop.
+			 ?\x200))	; 200: drop cancel.
+		    2 my-byteorder))
+		  (reply (append
+			  (list
+			   (+ ?\x80	; 0x80 indicates a reply.
+			      5)	; DROP_START.
+			   my-byteorder)
+			  reply-flags
+			  x
+			  y))
+		  (timestamp (x-dnd-get-motif-value 
+			      data 4 4 source-byteorder))
+		  action)
+
+	     (x-send-client-message frame
+				    dnd-source
+				    frame
+				    "_MOTIF_DRAG_AND_DROP_MESSAGE"
+				    8
+				    reply)
+	     (setq action 
+		   (when (and reply-action atom-name)
+		     (let* ((value (x-get-selection-internal
+				    (intern atom-name)
+				    (intern (x-dnd-current-type window)))))
+		       (when value
+			 (condition-case info
+			     (x-dnd-drop-data event frame window value 
+					      (x-dnd-current-type window))
+			   (error
+			    (message "Error: %s" info)
+			    nil))))))
+	     (x-get-selection-internal
+	      (intern atom-name)	  
+	      (if action 'XmTRANSFER_SUCCESS 'XmTRANSFER_FAILURE)
+	      timestamp)
+	     (x-dnd-forget-drop frame)))
+
+	  (t (error "Unknown Motif DND message %s %s" message data)))))
+					   
+
+;;;
+
+
+(provide 'x-dnd)
+
+;;; arch-tag: b621fb7e-50da-4323-850b-5fc71ae64621
+;;; x-dnd.el ends here
--- a/lispref/ChangeLog	Tue Feb 10 13:52:03 2004 +0000
+++ b/lispref/ChangeLog	Tue Feb 17 01:52:25 2004 +0000
@@ -1,3 +1,49 @@
+2004-02-12  Kim F. Storm  <storm@cua.dk>
+
+	* display.texi (Fringes): Use consistent wording.
+	Note that window-fringe's window arg is optional.
+	(Scroll Bars): Use consistent wording.
+
+2004-02-11  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* tips.texi (Comment Tips): Document the new conventions for
+	commenting out code.
+
+2004-02-07  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* positions.texi (Text Lines): Added missing end defun.
+
+2004-02-07  Kim F. Storm  <storm@cua.dk>
+
+	* positions.texi (Text Lines): Add line-number-at-pos.
+
+2004-02-06  John Paul Wallington  <jpw@gnu.org>
+
+	* display.texi (Button Properties, Button Buffer Commands):
+	mouse-2 invokes button, not down-mouse-1.
+
+2004-02-04  Jason Rumney  <jasonr@gnu.org>
+
+	* makefile.w32-in: Sync with Makefile.in changes.
+
+2004-02-03  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* minibuf.texi (Text from Minibuffer): Various corrections and
+	clarifications.
+	(Object from Minibuffer): Correct Lisp description of
+	read-minibuffer.
+	(Minibuffer History): Clarify description of cons values for
+	HISTORY arguments.
+	(Basic Completion): Various corrections and clarifications.  Add
+	completion-regexp-list.
+	(Minibuffer Completion): Correct and clarify description of
+	completing-read.
+	(Completion Commands): Mention Partial Completion mode.  Various
+	other minor changes.
+	(High-Level Completion): Various corrections and clarifications.
+	(Reading File Names): Ditto.
+	(Minibuffer Misc): Ditto.
+
 2004-01-26  Luc Teirlinck  <teirllm@auburn.edu>
 
 	* strings.texi (Text Comparison): assoc-string also matches
--- a/lispref/display.texi	Tue Feb 10 13:52:03 2004 +0000
+++ b/lispref/display.texi	Tue Feb 17 01:52:25 2004 +0000
@@ -2563,7 +2563,7 @@
 
 @defun set-window-fringes window left &optional right outside-margins
 This function sets the fringe widthes of window @var{window}.
-If window is @code{nil}, that stands for the selected window.
+If @var{window} is @code{nil}, the selected window is used.
 
 The argument @var{left} specifies the width in pixels of the left
 fringe, and likewise @var{right} for the right fringe.  A value of
@@ -2572,9 +2572,10 @@
 should appear outside of the display margins.
 @end defun
 
-@defun window-fringes window
+@defun window-fringes &optional window
 This function returns information about the fringes of a window
-@var{window}.  The value has the form @code{(@var{left-width}
+@var{window}.  If @var{window} is omitted or @code{nil}, the selected
+window is used.  The value has the form @code{(@var{left-width}
 @var{right-width} @var{frames-outside-margins})}.
 @end defun
 
@@ -2591,8 +2592,8 @@
 @code{set-window-scroll-bars} to specify what to do for a specific window:
 
 @defun set-window-scroll-bars window width &optional vertical-type horizontal-type
-Set width and type of scroll bars of window @var{window}.  (If
-@var{window} is @code{nil}, this applies to the selected window.)
+Set width and type of scroll bars of window @var{window}.  
+If @var{window} is @code{nil}, the selected window is used.
 @var{width} specifies the scroll bar width in pixels (@code{nil} means
 use whatever is specified for width for the frame).
 @var{vertical-type} specifies whether to have a vertical scroll bar
@@ -2607,8 +2608,8 @@
 
 @defun window-scroll-bars &optional window
 Report the width and type of scroll bars specified for @var{window}.
-If @var{window} is omitted or @code{nil}, it defaults to the currently
-selected window.  The value is a list of the form @code{(@var{width}
+If @var{window} is omitted or @code{nil}, the selected window is used.
+The value is a list of the form @code{(@var{width}
 @var{cols} @var{vertical-type} @var{horizontal-type})}.  The value
 @var{width} is the value that was specified for the width (which may
 be @code{nil}); @var{cols} is the number of columns that the scroll
@@ -3483,7 +3484,7 @@
 The button's keymap, defining bindings active within the button
 region.  By default this is the usual button region keymap, stored
 in the variable @code{button-map}, which defines @key{RET} and
-@key{down-mouse-1} to invoke the button.
+@key{mouse-2} to invoke the button.
 
 @item type
 @kindex type @r{(button property)}
@@ -3668,7 +3669,7 @@
 
 @code{push-button} is the command that a user uses to actually `push'
 a button, and is bound by default in the button itself to @key{RET}
-and to @key{mouse-down-1} using a region-specific keymap.  Commands
+and to @key{mouse-2} using a region-specific keymap.  Commands
 that are useful outside the buttons itself, such as
 @code{forward-button} and @code{backward-button} are additionally
 available in the keymap stored in @code{button-buffer-map}; a mode
--- a/lispref/makefile.w32-in	Tue Feb 10 13:52:03 2004 +0000
+++ b/lispref/makefile.w32-in	Tue Feb 17 01:52:25 2004 +0000
@@ -39,9 +39,6 @@
 VERSION=2.9
 manual = elisp-manual-21-$(VERSION)
 
-# Uncomment this line for permuted index.
-# permuted_index = 1 
-
 # List of all the texinfo files in the manual:
 
 srcs = \
@@ -95,8 +92,7 @@
   $(srcdir)/tips.texi \
   $(srcdir)/variables.texi \
   $(srcdir)/windows.texi \
-  $(srcdir)/index.unperm \
-  $(srcdir)/index.perm \
+  $(srcdir)/index.texi \
   $(srcdir)/gpl.texi \
   $(srcdir)/doclicense.texi
 
@@ -107,29 +103,16 @@
 info: $(infodir)/elisp
 	$(INSTALL_INFO) --info-dir=$(infodir) $(infodir)/elisp
 
-$(infodir)/elisp: $(srcs) index.texi
+$(infodir)/elisp: $(srcs)
 	$(MAKEINFO) -I. -I$(srcdir) $(srcdir)/elisp.texi -o $(infodir)/elisp
 
-elisp.dvi: $(srcs) index.texi
-#	Avoid losing old contents of aux file entirely.
-	-ren elisp.aux elisp.oaux
-#	First shot to define xrefs.
+elisp.dvi: $(srcs)
 	$(texinputdir) $(TEX) $(srcdir)/elisp.texi
-	if not a$(permuted_index) == a  sh $(srcdir)/permute-index
-	if not a$(permuted_index) == a  ren permuted.fns elisp.fns
-	if not a$(permuted_index) == a  texindex elisp.tp
-	if a$(permuted_index) == a  texindex elisp.??
-	$(texinputdir) $(TEX) $(srcdir)/elisp.texi
-
-index.texi:
-	if a$(permuted_index) == a  cp $(srcdir)/index.unperm index.texi
-	if not a$(permuted_index) == a  cp $(srcdir)/index.perm index.texi
 
 clean:
 	rm -f *.toc *.aux *.log *.cp *.cps *.fn *.fns *.tp *.tps \
               *.vr *.vrs *.pg *.pgs *.ky *.kys
 	rm -f make.out core 
-	rm -f index.texi
 	rm -f $(infodir)/elisp*
 
 distclean: clean
--- a/lispref/minibuf.texi	Tue Feb 10 13:52:03 2004 +0000
+++ b/lispref/minibuf.texi	Tue Feb 17 01:52:25 2004 +0000
@@ -135,13 +135,17 @@
 (@xref{Input Functions}, for information about reading.)
 
 The argument @var{default} specifies a default value to make available
-through the history commands.  It should be a string, or @code{nil}.  If
-@var{read} is non-@code{nil}, then @var{default} is also used as the
-input to @code{read}, if the user enters empty input.  However, in the
-usual case (where @var{read} is @code{nil}), @code{read-from-minibuffer}
-does not return @var{default} when the user enters empty input; it
-returns an empty string, @code{""}.  In this respect, it is different
-from all the other minibuffer input functions in this chapter.
+through the history commands.  It should be a string, or @code{nil}.
+If non-@code{nil}, the user can access it using
+@code{next-history-element}, usually bound in the minibuffer to
+@kbd{M-n}.  If @var{read} is non-@code{nil}, then @var{default} is
+also used as the input to @code{read}, if the user enters empty input.
+(If @var{read} is non-@code{nil} and @var{default} is @code{nil}, empty
+input results in an @code{end-of-file} error.)  However, in the usual
+case (where @var{read} is @code{nil}), @code{read-from-minibuffer}
+ignores @var{default} when the user enters empty input and returns an
+empty string, @code{""}.  In this respect, it is different from all
+the other minibuffer input functions in this chapter.
 
 If @var{keymap} is non-@code{nil}, that keymap is the local keymap to
 use in the minibuffer.  If @var{keymap} is omitted or @code{nil}, the
@@ -171,8 +175,9 @@
 
 Alternatively, @var{initial-contents} can be a cons cell of the form
 @code{(@var{string} . @var{position})}.  This means to insert
-@var{string} in the minibuffer but put point @var{position} characters
-from the beginning, rather than at the end.
+@var{string} in the minibuffer but put point at @emph{one-indexed}
+@var{position} in the minibuffer, rather than at the end.  Any integer
+value less or equal to one puts point at the beginning of the string.
 
 @strong{Usage note:} The @var{initial-contents} argument and the
 @var{default} argument are two alternative features for more or less the
@@ -180,21 +185,21 @@
 to @code{read-from-minibuffer}.  In general, we recommend using
 @var{default}, since this permits the user to insert the default value
 when it is wanted, but does not burden the user with deleting it from
-the minibuffer on other occasions.
+the minibuffer on other occasions.  For an exception to this rule,
+see @ref{Minibuffer History}.
 @end defun
 
 @defun read-string prompt &optional initial history default inherit-input-method
 This function reads a string from the minibuffer and returns it.  The
-arguments @var{prompt} and @var{initial} are used as in
-@code{read-from-minibuffer}.  The keymap used is
-@code{minibuffer-local-map}.
+arguments @var{prompt}, @var{initial}, @var{history} and
+@var{inherit-input-method} are used as in @code{read-from-minibuffer}.
+The keymap used is @code{minibuffer-local-map}.
 
-The optional argument @var{history}, if non-@code{nil}, specifies a
-history list and optionally the initial position in the list.  The
-optional argument @var{default} specifies a default value to return if
-the user enters null input; it should be a string.  The optional
-argument @var{inherit-input-method} specifies whether to inherit the
-current buffer's input method.
+The optional argument @var{default} is used as in
+@code{read-from-minibuffer}, except that, if non-@code{nil}, it also
+specifies a default value to return if the user enters null input.  As
+in @code{read-from-minibuffer} it should be a string, or @code{nil},
+which is equivalent to an empty string.
 
 This function is a simplified interface to the
 @code{read-from-minibuffer} function:
@@ -206,7 +211,7 @@
 (let ((value
        (read-from-minibuffer @var{prompt} @var{initial} nil nil
                              @var{history} @var{default} @var{inherit})))
-  (if (equal value "")
+  (if (and (equal value "") @var{default})
       @var{default}
     value))
 @end group
@@ -216,13 +221,15 @@
 @defvar minibuffer-allow-text-properties
 If this variable is @code{nil}, then @code{read-from-minibuffer} strips
 all text properties from the minibuffer input before returning it.
-Since all minibuffer input uses @code{read-from-minibuffer}, this
-variable applies to all minibuffer input.
-
-Note that the completion functions discard text properties unconditionally,
-regardless of the value of this variable.
+This variable also affects @code{read-string}.  However,
+@code{read-no-blanks-input} (see below), as well as
+@code{read-minibuffer} and related functions (@pxref{Object from
+Minibuffer,, Reading Lisp Objects With the Minibuffer}), and all
+functions that do minibuffer input with completion, discard text
+properties unconditionally, regardless of the value of this variable.
 @end defvar
 
+@anchor{Definition of minibuffer-local-map}
 @defvar minibuffer-local-map
 This is the default local keymap for reading from the minibuffer.  By
 default, it makes the following bindings:
@@ -243,10 +250,10 @@
 @item @kbd{M-p}
 @code{previous-history-element}
 
-@item @kbd{M-r}
+@item @kbd{M-s}
 @code{next-matching-history-element}
 
-@item @kbd{M-s}
+@item @kbd{M-r}
 @code{previous-matching-history-element}
 @end table
 @end defvar
@@ -265,11 +272,15 @@
 @code{minibuffer-local-ns-map} does not rebind @kbd{C-q}, it @emph{is}
 possible to put a space into the string, by quoting it.
 
+This function discards text properties, regardless of the value of
+@code{minibuffer-allow-text-properties}.
+
 @smallexample
 @group
 (read-no-blanks-input @var{prompt} @var{initial})
 @equiv{}
-(read-from-minibuffer @var{prompt} @var{initial} minibuffer-local-ns-map)
+(let (minibuffer-allow-text-properties)
+  (read-from-minibuffer @var{prompt} @var{initial} minibuffer-local-ns-map))
 @end group
 @end smallexample
 @end defun
@@ -312,7 +323,8 @@
 @group
 (read-minibuffer @var{prompt} @var{initial})
 @equiv{}
-(read-from-minibuffer @var{prompt} @var{initial} nil t)
+(let (minibuffer-allow-text-properties)
+  (read-from-minibuffer @var{prompt} @var{initial} nil t))
 @end group
 @end smallexample
 
@@ -421,11 +433,16 @@
 
 @item (@var{variable} . @var{startpos})
 Use @var{variable} (a symbol) as the history list, and assume that the
-initial history position is @var{startpos} (an integer, counting from
-zero which specifies the most recent element of the history).
+initial history position is @var{startpos} (a nonnegative integer).
 
-If you specify @var{startpos}, then you should also specify that element
-of the history as the initial minibuffer contents, for consistency.
+Specifying 0 for @var{startpos} is equivalent to just specifying the
+symbol @var{variable}.  @code{previous-history-element} will display
+the most recent element of the history list in the minibuffer.  If you
+specify a positive @var{startpos}, the minibuffer history functions
+behave as if @code{(elt @var{variable} (1- @var{STARTPOS}))} were the
+history element currently shown in the minibuffer.  For consistency,
+you should also specify that element of the history as the initial
+minibuffer contents.
 @end table
 
   If you don't specify @var{hist}, then the default history list
@@ -539,8 +556,9 @@
 @defun try-completion string collection &optional predicate
 This function returns the longest common substring of all possible
 completions of @var{string} in @var{collection}.  The value of
-@var{collection} must be a list of strings, an alist, an obarray, or a
-function that implements a virtual set of strings (see below).
+@var{collection} must be a list of strings, an alist, an obarray, a
+hash table, or a function that implements a virtual set of strings
+(see below).
 
 Completion compares @var{string} against each of the permissible
 completions specified by @var{collection}; if the beginning of the
@@ -552,7 +570,12 @@
 match.
 
 If @var{collection} is an alist (@pxref{Association Lists}), the
-@sc{car}s of the alist elements form the set of permissible completions.
+permissible completions are the elements of the alist that are either
+strings or conses whose @sc{car} is a string.  Other elements of the
+alist are ignored. (Remember that in Emacs Lisp, the elements of
+alists do not @emph{have} to be conses.)  As all elements of the alist
+can be strings, this case actually includes lists of strings, even
+though we usually do not think of such lists as alists.
 
 @cindex obarray in completion
 If @var{collection} is an obarray (@pxref{Creating Symbols}), the names
@@ -564,6 +587,9 @@
 empty and then add symbols to it one by one using @code{intern}.
 Also, you cannot intern a given symbol in more than one obarray.
 
+If @var{collection} is a hash table, then the keys that are strings
+are the possible completions.  Other keys are ignored.
+
 You can also use a symbol that is a function as @var{collection}.  Then
 the function is solely responsible for performing completion;
 @code{try-completion} returns whatever this function returns.  The
@@ -573,11 +599,20 @@
 thing in either case.)  @xref{Programmed Completion}.
 
 If the argument @var{predicate} is non-@code{nil}, then it must be a
-function of one argument.  It is used to test each possible match, and
-the match is accepted only if @var{predicate} returns non-@code{nil}.
-The argument given to @var{predicate} is either a string from the
-list, a cons cell from the alist (the @sc{car} of which is a string)
-or a symbol (@emph{not} a symbol name) from the obarray.
+function of one argument, unless @var{collection} is a hash table, in
+which case it should be a function of two arguments.  It is used to
+test each possible match, and the match is accepted only if
+@var{predicate} returns non-@code{nil}.  The argument given to
+@var{predicate} is either a string or a cons cell (the @sc{car} of
+which is a string) from the alist, or a symbol (@emph{not} a symbol
+name) from the obarray.  If @var{collection} is a hash table,
+@var{predicate} is called with two arguments, the string key and the
+associated value.
+
+In addition, to be acceptable, a completion must also match all the
+regular expressions in @code{completion-regexp-list}.  (Unless
+@var{collection} is a function, in which case that function has to
+handle @code{completion-regexp-list} itself.)
 
 In the first of the following examples, the string @samp{foo} is
 matched by three of the alist @sc{car}s.  All of the matches begin with
@@ -633,10 +668,13 @@
 
 @defun all-completions string collection &optional predicate nospace
 This function returns a list of all possible completions of
-@var{string}.  The arguments to this function (aside from @var{nospace})
-are the same as those of @code{try-completion}.  If @var{nospace} is
-non-@code{nil}, completions that start with a space are ignored unless
-@var{string} also starts with a space.
+@var{string}.  The arguments to this function (aside from
+@var{nospace}) are the same as those of @code{try-completion}.  Also,
+this function uses @code{completion-regexp-list} in the same way that
+@code{try-completion} does.  The optional argument @var{nospace} only
+matters if @var{string} is the empty string.  In that case, if
+@var{nospace} is non-@code{nil}, completions that start with a space
+are ignored.
 
 If @var{collection} is a function, it is called with three arguments:
 @var{string}, @var{predicate} and @code{t}; then @code{all-completions}
@@ -662,13 +700,24 @@
 @end smallexample
 @end defun
 
+@anchor{Definition of test-completion}
 @defun test-completion string collection &optional predicate
 This function returns non-@code{nil} if @var{string} is a valid
 completion possibility specified by @var{collection} and
-@var{predicate}.  The other arguments are the same as in
-@code{try-completion}.  For instance, if @var{collection} is a list,
-this is true if @var{string} appears in the list and @var{predicate}
-is satisfied.
+@var{predicate}.  The arguments are the same as in
+@code{try-completion}.  For instance, if @var{collection} is a list of
+strings, this is true if @var{string} appears in the list and
+@var{predicate} is satisfied.
+
+@code{test-completion} uses @code{completion-regexp-list} in the same
+way that @code{try-completion} does.
+
+If @var{predicate} is non-@code{nil} and if @var{collection} contains
+several strings that are equal to each other, as determined by
+@code{compare-strings} according to @code{completion-ignore-case},
+then @var{predicate} should accept either all or none of them.
+Otherwise, the return value of @code{test-completion} is essentially
+unpredictable.
 
 If @var{collection} is a function, it is called with three arguments,
 the values @var{string}, @var{predicate} and @code{lambda}; whatever
@@ -680,6 +729,13 @@
 consider case significant in completion.
 @end defvar
 
+@defvar completion-regexp-list
+This is a list of regular expressions.  The completion functions only
+consider a completion acceptable if it matches all regular expressions
+in this list, with @code{case-fold-search} (@pxref{Searching and Case})
+bound to the value of @code{completion-ignore-case}.
+@end defvar
+
 @defmac lazy-completion-table var fun &rest args
 This macro provides a way to initialize the variable @var{var} as a
 collection for completion in a lazy way, not computing its actual
@@ -711,8 +767,12 @@
 @var{prompt}, which must be a string.
 
 The actual completion is done by passing @var{collection} and
-@var{predicate} to the function @code{try-completion}.  This happens in
-certain commands bound in the local keymaps used for completion.
+@var{predicate} to the function @code{try-completion}.  This happens
+in certain commands bound in the local keymaps used for completion.
+Some of these commands also call @code{test-completion}.  Thus, if
+@var{predicate} is non-@code{nil}, it should be compatible with
+@var{collection} and @code{completion-ignore-case}.  @xref{Definition
+of test-completion}.
 
 If @var{require-match} is @code{nil}, the exit commands work regardless
 of the input in the minibuffer.  If @var{require-match} is @code{t}, the
@@ -723,19 +783,13 @@
 
 However, empty input is always permitted, regardless of the value of
 @var{require-match}; in that case, @code{completing-read} returns
-@var{default}.  The value of @var{default} (if non-@code{nil}) is also
-available to the user through the history commands.
+@var{default}, or @code{""}, if @var{default} is @code{nil}.  The
+value of @var{default} (if non-@code{nil}) is also available to the
+user through the history commands.
 
-The user can exit with null input by typing @key{RET} with an empty
-minibuffer.  Then @code{completing-read} returns @code{""}.  This is how
-the user requests whatever default the command uses for the value being
-read.  The user can return using @key{RET} in this way regardless of the
-value of @var{require-match}, and regardless of whether the empty string
-is included in @var{collection}.
-
-The function @code{completing-read} works by calling
-@code{read-minibuffer}.  It uses @code{minibuffer-local-completion-map}
-as the keymap if @var{require-match} is @code{nil}, and uses
+The function @code{completing-read} uses
+@code{minibuffer-local-completion-map} as the keymap if
+@var{require-match} is @code{nil}, and uses
 @code{minibuffer-local-must-match-map} if @var{require-match} is
 non-@code{nil}.  @xref{Completion Commands}.
 
@@ -744,15 +798,21 @@
 @code{minibuffer-history}.  @xref{Minibuffer History}.
 
 If @var{initial} is non-@code{nil}, @code{completing-read} inserts it
-into the minibuffer as part of the input.  Then it allows the user to
-edit the input, providing several commands to attempt completion.
-In most cases, we recommend using @var{default}, and not @var{initial}.
+into the minibuffer as part of the input, with point at the end.  Then
+it allows the user to edit the input, providing several commands to
+attempt completion.  @var{initial} can also be a cons cell of the form
+@code{(@var{string} .  @var{position})}.  In that case, point is put at
+@emph{zero-indexed} position @var{position} in @var{string}.  Note
+that this is different from @code{read-from-minibuffer} and related
+functions, which use a one-indexed position.  In most cases, we
+recommend using @var{default}, and not @var{initial}.
 
 @strong{We discourage use of a non-@code{nil} value for
 @var{initial}}, because it is an intrusive interface.  The history
 list feature (which did not exist when we introduced @var{initial})
 offers a far more convenient and general way for the user to get the
-default and edit it, and it is always available.
+default and edit it, and it is always available.  For an exception to
+this rule, see @ref{Minibuffer History}.
 
 If the argument @var{inherit-input-method} is non-@code{nil}, then the
 minibuffer inherits the current input method (@pxref{Input
@@ -799,8 +859,11 @@
 @node Completion Commands
 @subsection Minibuffer Commands that Do Completion
 
-  This section describes the keymaps, commands and user options used in
-the minibuffer to do completion.
+  This section describes the keymaps, commands and user options used
+in the minibuffer to do completion.  The description refers to the
+situation when Partial Completion mode is disabled (as it is by
+default).  When enabled, this minor mode uses its own alternatives to
+some of the commands described below.
 
 @defvar minibuffer-local-completion-map
 @code{completing-read} uses this value as the local keymap when an
@@ -820,7 +883,7 @@
 
 @noindent
 with other characters bound as in @code{minibuffer-local-map}
-(@pxref{Text from Minibuffer}).
+(@pxref{Definition of minibuffer-local-map}).
 @end defvar
 
 @defvar minibuffer-local-must-match-map
@@ -852,8 +915,8 @@
 @end defvar
 
 @defvar minibuffer-completion-table
-The value of this variable is the alist or obarray used for completion
-in the minibuffer.  This is the global variable that contains what
+The value of this variable is the collection used for completion in
+the minibuffer.  This is the global variable that contains what
 @code{completing-read} passes to @code{try-completion}.  It is used by
 minibuffer completion commands such as @code{minibuffer-complete-word}.
 @end defvar
@@ -907,8 +970,10 @@
 information about streams.)  The argument @var{completions} is normally
 a list of completions just returned by @code{all-completions}, but it
 does not have to be.  Each element may be a symbol or a string, either
-of which is simply printed, or a list of two strings, which is printed
-as if the strings were concatenated.
+of which is simply printed.  It can also be a list of two strings,
+which is printed as if the strings were concatenated.  The first of
+the two strings is the actual completion, the second string serves as
+annotation.
 
 This function is called by @code{minibuffer-completion-help}.  The
 most common way to use it is together with
@@ -948,9 +1013,10 @@
 If @var{existing} is non-@code{nil}, then the name specified must be
 that of an existing buffer.  The usual commands to exit the minibuffer
 do not exit if the text is not valid, and @key{RET} does completion to
-attempt to find a valid name.  (However, @var{default} is not checked
-for validity; it is returned, whatever it is, if the user exits with the
-minibuffer empty.)
+attempt to find a valid name.  If @var{existing} is neither @code{nil}
+nor @code{t}, confirmation is required after completion.  (However,
+@var{default} is not checked for validity; it is returned, whatever it
+is, if the user exits with the minibuffer empty.)
 
 In the following example, the user enters @samp{minibuffer.t}, and
 then types @key{RET}.  The argument @var{existing} is @code{t}, and the
@@ -996,7 +1062,8 @@
 null input.  It can be a symbol or a string; if it is a string,
 @code{read-command} interns it before returning it.  If @var{default} is
 @code{nil}, that means no default has been specified; then if the user
-enters null input, the return value is @code{nil}.
+enters null input, the return value is @code{(intern "")}, that is, a
+symbol whose name is an empty string.
 
 @example
 (read-command "Command name? ")
@@ -1041,7 +1108,7 @@
 null input.  It can be a symbol or a string; if it is a string,
 @code{read-variable} interns it before returning it.  If @var{default}
 is @code{nil}, that means no default has been specified; then if the
-user enters null input, the return value is @code{nil}.
+user enters null input, the return value is @code{(intern "")}.
 
 @example
 @group
@@ -1090,10 +1157,7 @@
 
 @defun read-file-name prompt &optional directory default existing initial predicate
 This function reads a file name in the minibuffer, prompting with
-@var{prompt} and providing completion.  If @var{default} is
-non-@code{nil}, then the function returns @var{default} if the user just
-types @key{RET}.  @var{default} is not checked for validity; it is
-returned, whatever it is, if the user exits with the minibuffer empty.
+@var{prompt} and providing completion.
 
 If @var{existing} is non-@code{nil}, then the user must specify the name
 of an existing file; @key{RET} performs completion to make the name
@@ -1104,10 +1168,10 @@
 acceptable.
 
 The argument @var{directory} specifies the directory to use for
-completion of relative file names.  If @code{insert-default-directory}
-is non-@code{nil}, @var{directory} is also inserted in the minibuffer as
-initial input.  It defaults to the current buffer's value of
-@code{default-directory}.
+completion of relative file names.  It should be an absolute directory
+name.  If @code{insert-default-directory} is non-@code{nil},
+@var{directory} is also inserted in the minibuffer as initial input.
+It defaults to the current buffer's value of @code{default-directory}.
 
 @c Emacs 19 feature
 If you specify @var{initial}, that is an initial file name to insert
@@ -1118,11 +1182,45 @@
 note:} we recommend using @var{default} rather than @var{initial} in
 most cases.
 
+If @var{default} is non-@code{nil}, then the function returns
+@var{default} if the user exits the minibuffer with the same non-empty
+contents that @code{read-file-name} inserted initially.  The initial
+minibuffer contents are always non-empty if
+@code{insert-default-directory} is non-@code{nil}, as it is by
+default.  @var{default} is not checked for validity, regardless of the
+value of @var{existing}.  However, if @var{existing} is
+non-@code{nil}, the initial minibuffer contents should be a valid file
+(or directory) name.  Otherwise @code{read-file-name} attempts
+completion if the user exits without any editing, and does not return
+@var{default}.  @var{default} is also available through the history
+commands.
+
+If @var{default} is @code{nil}, @code{read-file-name} tries to find a
+substitute default to use in its place, which it treats in exactly the
+same way as if it had been specified explicitly.  If @var{default} is
+@code{nil}, but @var{initial} is non-@code{nil}, then the default is
+the absolute file name obtained from @var{directory} and
+@var{initial}.  If both @var{default} and @var{initial} are @code{nil}
+and the buffer is visiting a file, @code{read-file-name} uses the
+absolute file name of that file as default.  If the buffer is not
+visiting a file, then there is no default.  In that case, if the user
+types @key{RET} without any editing, @code{read-file-name} simply
+returns the pre-inserted contents of the minibuffer.
+
+If the user types @key{RET} in an empty minibuffer, this function
+returns an empty string, regardless of the value of @var{existing}.
+This is, for instance, how the user can make the current buffer visit
+no file using @code{M-x set-visited-file-name}.
+
 If @var{predicate} is non-@code{nil}, it specifies a function of one
 argument that decides which file names are acceptable completion
 possibilities.  A file name is an acceptable value if @var{predicate}
 returns non-@code{nil} for it.
 
+@code{read-file-name} does not automatically expand file names.  You
+must call @code{expand-file-name} yourself if an absolute file name is
+required.
+
 Here is an example:
 
 @example
@@ -1160,17 +1258,35 @@
 @defun read-directory-name prompt &optional directory default existing initial
 This function is like @code{read-file-name} but allows only directory
 names as completion possibilities.
+
+If @var{default} is @code{nil} and @var{initial} is non-@code{nil},
+@code{read-directory-name} constructs a substitute default by
+combining @var{directory} (or the current buffer's default directory
+if @var{directory} is @code{nil}) and @var{initial}.  If both
+@var{default} and @var{initial} are @code{nil}, this function uses the
+current buffer's default directory as substitute default, ignoring
+@var{directory}.
 @end defun
 
 @defopt insert-default-directory
-This variable is used by @code{read-file-name}.  Its value controls
-whether @code{read-file-name} starts by placing the name of the default
-directory in the minibuffer, plus the initial file name if any.  If the
-value of this variable is @code{nil}, then @code{read-file-name} does
-not place any initial input in the minibuffer (unless you specify
-initial input with the @var{initial} argument).  In that case, the
-default directory is still used for completion of relative file names,
-but is not displayed.
+This variable is used by @code{read-file-name}, and thus, indirectly,
+by most commands reading file names.  (This includes all commands that
+use the code letters @samp{f} or @samp{F} in their interactive form.
+@xref{Interactive Codes,, Code Characters for interactive}.)  Its
+value controls whether @code{read-file-name} starts by placing the
+name of the default directory in the minibuffer, plus the initial file
+name if any.  If the value of this variable is @code{nil}, then
+@code{read-file-name} does not place any initial input in the
+minibuffer (unless you specify initial input with the @var{initial}
+argument).  In that case, the default directory is still used for
+completion of relative file names, but is not displayed.
+
+If this variable is @code{nil} and the initial minibuffer contents are
+empty, the user may have to explicitly fetch the next history element
+to access a default value.  If the variable is non-@code{nil}, the
+initial minibuffer contents are always non-empty and the user can
+always request a default value by immediately typing @key{RET} in an
+unedited minibuffer.  (See above.)
 
 For example:
 
@@ -1627,9 +1743,10 @@
 locally inside the minibuffer (@pxref{Help Functions}).
 @end defvar
 
-@defun minibufferp &optional buffer
-This function returns non-@code{nil} if @var{buffer} is a minibuffer.
-If @var{buffer} is omitted, it tests the current buffer.
+@defun minibufferp &optional buffer-or-name
+This function returns non-@code{nil} if @var{buffer-or-name} is a
+minibuffer.  If @var{buffer-or-name} is omitted, it tests the current
+buffer.
 @end defun
 
 @defun active-minibuffer-window
@@ -1654,8 +1771,10 @@
 @end defun
 
 @c Emacs 19 feature
-@defun window-minibuffer-p window
-This function returns non-@code{nil} if @var{window} is a minibuffer window.
+@defun window-minibuffer-p &optional window
+This function returns non-@code{nil} if @var{window} is a minibuffer
+window.
+@var{window} defaults to the selected window.
 @end defun
 
 It is not correct to determine whether a given window is a minibuffer by
@@ -1704,14 +1823,16 @@
 @c Emacs 19 feature
 If a command name has a property @code{enable-recursive-minibuffers}
 that is non-@code{nil}, then the command can use the minibuffer to read
-arguments even if it is invoked from the minibuffer.  The minibuffer
-command @code{next-matching-history-element} (normally @kbd{M-s} in the
-minibuffer) uses this feature.
+arguments even if it is invoked from the minibuffer.  A command can
+also achieve this by binding @code{enable-recursive-minibuffers}
+to @code{t} in the interactive declaration (@pxref{Using Interactive}).
+The minibuffer command @code{next-matching-history-element} (normally
+@kbd{M-s} in the minibuffer) does the latter.
 
-@defun minibuffer-message string &optional timeout
+@defun minibuffer-message string
 This function displays @var{string} temporarily at the end of the
-minibuffer text, for @var{timeout} seconds.  (The default is 2
-seconds.)
+minibuffer text, for two seconds, or until the next input event
+arrives, whichever comes first.
 @end defun
 
 @ignore
--- a/lispref/positions.texi	Tue Feb 10 13:52:03 2004 +0000
+++ b/lispref/positions.texi	Tue Feb 17 01:52:25 2004 +0000
@@ -409,6 +409,13 @@
 @end example
 @end defun
 
+@defun line-number-at-pos &optional pos
+@cindex line number
+This function returns the line number in the current buffer
+corresponding the buffer position @var{pos}.  If @var{pos} is nil or
+omitted, the current buffer position is used.
+@end defun
+
 @ignore
 @c ================
 The @code{previous-line} and @code{next-line} commands are functions
--- a/lispref/tips.texi	Tue Feb 10 13:52:03 2004 +0000
+++ b/lispref/tips.texi	Tue Feb 17 01:52:25 2004 +0000
@@ -802,19 +802,30 @@
 the left margin.  These are used, occasionally, for comments within
 functions that should start at the margin.  We also use them sometimes
 for comments that are between functions---whether to use two or three
-semicolons there is a matter of style.
+semicolons depends on whether the comment should be considered a
+``heading'' by Outline minor mode.  By default, comments starting with
+at least three semicolons (followed by a single space and a
+non-whitespace character) are considered headings, comments starting
+with two or less are not.
 
 Another use for triple-semicolon comments is for commenting out lines
 within a function.  We use three semicolons for this precisely so that
-they remain at the left margin.
+they remain at the left margin.  By default, Outline minor mode does
+not consider a comment to be a heading (even if it starts with at
+least three semicolons) if the semicolons are followed by at least two
+spaces.  Thus, if you add an introductory comment to the commented out
+code, make sure to indent it by at least two spaces after the three
+semicolons.
 
 @smallexample
 (defun foo (a)
-;;; This is no longer necessary.
+;;;  This is no longer necessary.
 ;;;  (force-mode-line-update)
   (message "Finished with %s" a))
 @end smallexample
 
+When commenting out entire functions, use two semicolons.
+
 @item ;;;;
 Comments that start with four semicolons, @samp{;;;;}, should be aligned
 to the left margin and are used for headings of major sections of a
--- a/man/ChangeLog	Tue Feb 10 13:52:03 2004 +0000
+++ b/man/ChangeLog	Tue Feb 17 01:52:25 2004 +0000
@@ -1,3 +1,18 @@
+2004-02-15  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* frames.texi (Drag and drop): Add Motif to list of supported
+	protocols.
+
+2004-02-14  Jonathan Yavner  <jyavner@member.fsf.org>
+
+	* ses.texi (Advanced Features): New functionality for
+	ses-set-header-row (defaults to current row unless C-u used).
+	(Acknowledgements): Added Stefan Monnier.
+
+2004-02-03  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* frames.texi (Drag and drop): New section.
+
 2004-01-24  Richard M. Stallman  <rms@gnu.org>
 
 	* emacs.texi (Acknowledgments): Renamed from Acknowledgements.
--- a/man/frames.texi	Tue Feb 10 13:52:03 2004 +0000
+++ b/man/frames.texi	Tue Feb 17 01:52:25 2004 +0000
@@ -48,6 +48,7 @@
 * Frame Parameters::    Changing the colors and other modes of frames.
 * Scroll Bars::	        How to enable and disable scroll bars; how to use them.
 * Wheeled Mice::        Using mouse wheels for scrolling.
+* Drag and drop::       Using drag and drop to open files and insert text.
 * Menu Bars::	        Enabling and disabling the menu bar.
 * Tool Bars::           Enabling and disabling the tool bar.
 * Dialog Boxes::        Controlling use of dialog boxes.
@@ -795,6 +796,40 @@
 @code{mouse-wheel-scroll-amount} determine where and by how much
 buffers are scrolled.
 
+@node Drag and drop
+@section Drag and drop in Emacs.
+
+@cindex drag and drop
+  Emacs supports drag and drop so that dropping of files and text is handeled.
+Currently supported drag and drop protocols are XDND, Motif and the old
+KDE 1.x protocol.  There is no drag support yet. 
+When text is dropped on Emacs, Emacs inserts the text where it is dropped.
+When a file is dragged from a file manager to Emacs, Emacs opens that file.
+As a special case, if a file is dropped on a dired buffer the file is
+copied or moved (depends on exactly how it is dragged and the application
+it was dragged from) to the directory the dired buffer is displaying.
+
+@vindex x-dnd-open-file-other-window
+  A file is normally opened in the window it is dropped on, but if you
+prefer the file to be opened in a new window you can customize the variable
+@code{x-dnd-open-file-other-window}.
+
+@vindex x-dnd-types-alist
+  If you want to change the way Emacs handles drop of different types
+or add a new type, you shall customize @code{x-dnd-types-alist}.  This
+requires detailed knowledge of what types other applications use
+for drag and drop.
+
+@vindex x-dnd-protocol-alist
+  When an URL is dropped on Emacs it may be a file, but it may also be
+another URL type (ftp, http, etc.).  Emacs first checks
+@code{x-dnd-protocol-alist} to determine what to do with the URL.  If there
+is no match there and if @code{browse-url-browser-function} is an alist,
+Emacs looks for a match there.  If no match is found the text for the URL
+is inserted.  If you want to alter Emacs behaviour you can customize these
+variables.
+
+
 @node Menu Bars
 @section Menu Bars
 @cindex Menu Bar mode
--- a/man/ses.texi	Tue Feb 10 13:52:03 2004 +0000
+++ b/man/ses.texi	Tue Feb 17 01:52:25 2004 +0000
@@ -406,11 +406,15 @@
 
 @table @kbd
 @item C-c M-C-h
-(@code{ses-read-header-row}).  The header line at the top of the SES
+(@code{ses-set-header-row}).  The header line at the top of the SES
 window normally shows the column letter for each column.  You can set
 it to show a copy of some row, such as a row of column titles, so that
-row will always be visible.  Set the header line to row 0 to show
-column letters again.
+row will always be visible.  Default is to set the current row as the
+header; use C-u to prompt for header row.  Set the header to row 0 to
+show column letters again.
+@item [header-line mouse-3]
+Pops up a menu to set the current row as the header, or revert to
+column letters.
 @end table
 
 @menu
@@ -816,6 +820,13 @@
 @node Acknowledgements,  , For Gurus, Top
 @chapter Acknowledgements
 
+Coding by:
+@quotation
+Jonathan Yavner @email{jyavner@@member.fsf.org}@*
+Stefan Monnier @email{monnier@@gnu.org}
+@end quotation
+
+Ideas from:
 @quotation
 Christoph Conrad @email{christoph.conrad@@gmx.de}@*
 CyberBob @email{cyberbob@@redneck.gacracker.org}@*
@@ -832,6 +843,7 @@
 Stefan Reichör @email{xsteve@@riic.at}@*
 Oliver Scholz @email{epameinondas@@gmx.de}@*
 Richard M. Stallman @email{rms@@gnu.org}@*
+Luc Teirlinck @email{teirllm@@dms.auburn.edu}@*
 J. Otto Tennant @email{jotto@@pobox.com}@*
 Jean-Philippe Theberge @email{jphil@@acs.pagesjaunes.fr}
 @end quotation
--- a/src/ChangeLog	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/ChangeLog	Tue Feb 17 01:52:25 2004 +0000
@@ -1,3 +1,285 @@
+2004-02-16  Stephen Eglen  <stephen@gnu.org>
+
+	* fringe.c (init_fringe_bitmap): Define j in MAC_OS code.
+
+2004-02-15  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* data.c (Fbyteorder): 
+	* fringe.c (Fdefine_fringe_bitmap): 
+	* xdisp.c (handle_single_display_prop): 
+	* xselect.c (x_handle_dnd_message): Lisp_Object/int mixup.
+
+2004-02-16  Jason Rumney  <jasonr@gnu.org>
+
+	* w32term.c (w32_draw_fringe_bitmap): Handle overlay fringe bitmaps.
+
+2004-02-15  Steven Tamm  <steventamm@mac.com>
+
+	* macterm.c (Vmac_emulate_three_button_mouse): New variable for
+	controlling emulation of a three button mouse with option and
+	command keys.
+	(Qreverse, mac_get_enumlated_btn): Handle the emulation
+	(mac_event_to_emacs_modifiers, XTread_socket): Ditto
+
+2004-02-15  Kim F. Storm  <storm@cua.dk>
+
+	* buffer.c (syms_of_buffer): Doc fix for indicate-buffer-boundaries.
+
+	* fringe.c (init_fringe_bitmap) [MAC_OS, WORDS_BIG_ENDIAN]:
+	Perform byte-swapping.
+
+2004-02-14  Kim F. Storm  <storm@cua.dk>
+
+	* dispextern.h (struct draw_fringe_bitmap_params): Change member
+	bits from char to short to facilitate wider bitmaps.
+	(struct redisplay_interface): Fix prototype of define_fringe_bitmap
+	member.
+
+	* fringe.c (struct fringe_bitmap): Change member bits from char to
+	short to facilitate 16 bits wide bitmaps.  Modify all standard
+	bitmaps accordingly.
+	(BYTES_PER_BITMAP_ROW, STANDARD_BITMAP_HEIGHT): New macros.
+	(FRBITS): Use STANDARD_BITMAP_HEIGHT instead of just sizeof.
+	(draw_fringe_bitmap): Ditto.
+	(init_fringe_bitmap) [MAC_OS]: Don't bitswap.
+	(init_fringe_bitmap) [HAVE_X_WINDOWS]: Enhance bitswapping to
+	handle up to 16 bits wide bitmaps.
+	(Fdefine_fringe_bitmap): Doc fix.  Handle wider bitmaps.
+	(Ffringe_bitmaps_at_pos): Add missing arg declarations.
+
+	* macterm.c (mac_draw_bitmap): Handle 16 bits wide bitmaps directly.
+	(x_draw_fringe_bitmap): Use enhanced mac_draw_bitmap, so we no longer
+	need to call mac_create_bitmap_from_bitmap_data and mac_free_bitmap.
+
+	* w32term.c (w32_define_fringe_bitmap): Bitmaps are now 16 bits wide,
+	so it is no longer necessary to expand them here.
+
+	* xterm.c (x_draw_fringe_bitmap): Handle wider bitmaps (max 16 bits).
+
+2004-02-12  Kim F. Storm  <storm@cua.dk>
+
+	* window.c (Fwindow_fringes): Doc fix.
+
+2004-02-10  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* xselect.c (x_get_foreign_selection): Add new optional parameter
+	time_stamp.
+	(Fx_get_selection_internal): Ditto, pass time_stamp to
+	x_get_foreign_selection.
+
+	* data.c (Fbyteorder): New function.
+
+2004-02-09  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* atimer.c: Move include stdio.h to same place as in other files.
+
+	* region-cache.c: Ditto.
+
+	* sysdep.c: Ditto.
+
+	* xfaces.c: Ditto.
+
+2004-02-09  Sam Steingold  <sds@gnu.org>
+
+	* w32term.c (w32_draw_fringe_bitmap): Fixed a typo in the last patch.
+
+2004-02-09  Kim F. Storm  <storm@cua.dk>
+
+	* fringe.c: New file.  Move original fringe related declarations
+	and code from dispextern.h and xdisp.c here.
+	Rework code to support user defined fringe bitmaps, redefining
+	standard bitmaps, ability to overlay user defined bitmap with
+	overlay arrow bitmap, and add faces to bitmaps.
+	(Voverflow_newline_into_fringe): Declare here.
+	(enum fringe_bitmap_align): New enum.
+	(..._bits): All bitmaps are now defined without bitswapping; that
+	is now done in init_fringe_once (if necessary).
+	(standard_bitmaps): New array with specifications for the
+	standard fringe bitmaps.
+	(fringe_faces): New array.
+	(valid_fringe_bitmap_id_p): New function.
+	(draw_fringe_bitmap_1): Rename from draw_fringe_bitmap.
+	(draw_fringe_bitmap): New function which draws fringe bitmap,
+	possibly overlaying bitmap with cursor in right fringe or the
+	overlay arrow in the left fringe.
+	(update_window_fringes): Do not handle overlay arrow here.
+	Compare and copy fringe bitmap faces.
+	(init_fringe_bitmap): New function.
+	(Fdefine_fringe_bitmap, Fdestroy_fringe_bitmap): New DEFUNs to
+	define and destroy user defined fringe bitmaps.
+	(Fset_fringe_bitmap_face): New DEFUN to set face for a fringe bitmap.
+	(Ffringe_bitmaps_at_pos): New DEFUN to read current fringe bitmaps.
+	(syms_of_fringe): New function.  Defsubr new DEFUNs.
+	DEFVAR_LISP Voverflow_newline_into_fringe.
+	(init_fringe_once, init_fringe): New functions.
+	(w32_init_fringe, w32_reset_fringes) [WINDOWS_NT]: New functions.
+
+	* Makefile.in (obj): Add fringe.o.
+	(fringe.o): New dependencies.
+
+	* dispextern.h (FRINGE_ID_BITS): New definition for number of
+	bits allocated to hold a fringe number.  Increase number of bits
+	from 4 to 8 to allow user defined fringe bitmaps.
+	(struct glyph_row, struct it): New members left_user_fringe_bitmap,
+	left_user_fringe_face_id, right_user_fringe_bitmap,
+	right_user_fringe_face_id.
+	(enum fringe_bitmap_type, struct fringe_bitmap, fringe_bitmaps):
+	Move to new file fringe.c.
+	(MAX_FRINGE_BITMAPS): Define here.
+	(struct draw_fringe_bitmap_params): New members bits, cursor_p,
+	and overlay_p.  Change member which to int.
+	(struct redisplay_interface): New members define_fringe_bitmap
+	and destroy_fringe_bitmap.
+	(valid_fringe_bitmap_id_p): Add prototype.
+	(w32_init_fringe, w32_reset_fringes) [WINDOWS_NT]: Add prototypes.
+
+	* dispnew.c (row_equal_p): Compare fringe bitmap faces and overlay
+	arrows.
+	(update_frame): Do flush_display if force_flush_display_p to
+	ensure display (specifically fringes) are updated in a timely
+	manner when resizing the frame by dragging the mouse.
+	(update_window_line): Update row if overlay arrow changed.
+	(scrolling_window): Redraw fringe bitmaps if fringe bitmap faces
+	or overlay arrow changed.
+
+	* emacs.c (main) [HAVE_WINDOW_SYSTEM]: Call init_fringe_once,
+	syms_of_fringe, and init_fringe.
+
+	* frame.h (struct frame): New member force_flush_display_p.
+
+	* lisp.h (syms_of_fringe, init_fringe, init_fringe_once):
+	Add prototypes.
+
+	* macterm.c (mac_draw_bitmap): Add overlay_p arg.
+	(x_draw_fringe_bitmap):  Handle overlayed fringe bitmaps;
+	thanks to YAMAMOTO Mitsuharu for advice on how to do this.
+	Use cursor color for displaying cursor in fringe.
+	(x_redisplay_interface): Add null handlers for
+	define_fringe_bitmap and destroy_fringe_bitmap functions.
+
+	* w32term.c (w32_draw_fringe_bitmap): Copy unadapted code from
+	xterm.c to handle overlayed fringe bitmaps and to use cursor color
+	for displaying cursor in fringe.
+	(w32_define_fringe_bitmap, w32_destroy_fringe_bitmap): New W32
+	specific functions to define and destroy fringe bitmaps in fringe_bmp.
+	(w32_redisplay_interface): Add them to redisplay_interface.
+	(w32_term_init): Call w32_init_fringe instead of explicitly
+	defining fringe bitmaps in fringe_bmp array.
+	(x_delete_display): Call w32_reset_fringes instead of explicitly
+	destroying fringe bitmaps in fringe_bmp array.
+
+	* xdisp.c (Voverflow_newline_into_fringe, syms_of_xdisp)
+	(left_bits, right_bits, up_arrow_bits, down_arrow_bits)
+	(continued_bits, continuation_bits, ov_bits, first_line_bits)
+	(last_line_bits, filled_box_cursor_bits, hollow_box_cursor_bits)
+	(bar_cursor_bits, hbar_cursor_bits, zv_bits, hollow_square_bits)
+	(fringe_bitmaps, draw_fringe_bitmap, draw_row_fringe_bitmaps)
+	(draw_window_fringes, compute_fringe_widths, update_window_fringes):
+	Move fringe handling vars and code to new file fringe.c.
+	(handle_display_prop): Handle left-fringe and right-fringe
+	display properties; store user fringe bitmaps in iterator.
+	(move_it_in_display_line_to): Handle cursor in fringe at eob.
+	(clear_garbaged_frames): Set force_flush_display_p if resized.
+	(redisplay_window): Redraw fringe bitmaps if not just_this_one_p.
+	(display_line): Handle cursor in fringe at eob.
+	(display_line): Set row user fringe bitmaps from iterator.
+
+	* xterm.c (x_draw_fringe_bitmap): Handle overlayed fringe bitmaps.
+	Use cursor color for displaying cursor in fringe.
+	(x_redisplay_interface): Add null handlers for
+	define_fringe_bitmap and destroy_fringe_bitmap functions.
+
+2004-02-07  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* macfns.c (Fx_change_window_property): Make doc string and
+	parameters same as for X version.
+
+	* w32fns.c (Fx_change_window_property): Ditto.
+
+2004-02-07  Kim F. Storm  <storm@cua.dk>
+
+	* xdisp.c (hscroll_window_tree): Position cursor near to right
+	margin in hscrolled window when jumping to end of line (rather
+	than centering cursor).
+
+	* process.c (wait_reading_process_input): Don't do adaptive read
+	buffering if waiting for a specific process.
+
+2004-02-05  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* minibuf.c (Fminibufferp, Fread_from_minibuffer)
+	(Fread_minibuffer, Feval_minibuffer)
+	(Fread_string, Fread_no_blanks_input)
+	(Fcompleting_read): Doc fixes.
+	(syms_of_minibuf): Doc fixes for minibuffer-completion-table and
+	completion-regexp-list.  Define Qcase_fold_search and staticpro it.
+	(read_minibuf): Fix initial comment.
+	(Ftry_completion, Fall_completions, Ftest_completion): Bind
+	case-fold-serach to the value of completion-ignore-case when
+	checking completion-regexp-list.
+	(Fdisplay_completion_list): Make it handle arguments that are
+	symbols.  Doc fix.
+
+2004-02-05  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* xterm.h: Add declaration of free_frame_menubar.
+
+	* xfns.c (x_create_bitmap_mask): Removed unused variable depth.
+	(x_set_menu_bar_lines): Added ! defined USE_GTK for olines.
+	(Fx_change_window_property): Add declaration of parameters type and
+	format.  Remove unused variable cons.
+
+	* xselect.c: Include stdio,h.
+
+2004-02-05  Kenichi Handa  <handa@m17n.org>
+
+	* fns.c (Fset_char_table_range): Fix previous change.
+
+	* buffer.c (Fset_buffer_multibyte): Fix docstring.
+
+2004-02-04  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* editfns.c (Fchar_after, Fchar_before): Doc fixes.
+
+2004-02-04  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* keymap.c (Vmouse_events): Rename from Vmenu_events.
+	(syms_of_keymap): Add mouse-[45], header-line, and mode-line to it.
+
+2004-02-04  Kenichi Handa  <handa@m17n.org>
+
+	* fns.c (Fset_char_table_range): Handle charsets ascii,
+	eight-bit-control, and eight-bit-graphic correctly.
+
+2004-02-03  Jason Rumney  <jasonr@gnu.org>
+
+	* w32select.c (Fw32_set_clipboard_data): Make coding iso2022 safe.
+
+	* w32fns.c (x_to_w32_font): Likewise.
+
+2004-02-03  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* xterm.h: Add x_handle_dnd_message, x_check_property_data,
+	x_fill_property_data, x_property_data_to_lisp and check_x_display_info.
+
+	* xterm.c (handle_one_xevent): Call x_handle_dnd_message for
+	ClientMessages.
+
+	* xselect.c: Include termhooks.h and X11/Xproto.h
+	(x_check_property_data, x_fill_property_data)
+	(x_property_data_to_lisp, mouse_position_for_drop)
+	(Fx_get_atom_name, x_handle_dnd_message): New functions for DND support.
+	(Fx_send_client_event): Move here from xfns.c.
+	(syms_of_xselect): Add Sx_get_atom_name and Sx_send_client_message.
+
+	* xfns.c (x-send-client-message): Move to xselect.c
+	(Fx_change_window_property): Add optional arguments TYPE, FORMAT and
+	OUTER_P.
+	(Fx_window_property): Add optional arguments TYPE, SOURCE, DELETE_P,
+	VECTOR_RET_P.  Handle AnyPropertyType.  Call x_property_data_to_lisp
+	if vector_ret_p is true.
+	(syms_of_xfns): Sx_send_client_message moved to xselect.c.
+
 2004-02-02  Eli Zaretskii  <eliz@elta.co.il>
 
 	* fileio.c (Fcopy_file): If NEWNAME is a directory, expand the
@@ -43,10 +325,9 @@
 
 2004-01-27  Steven Tamm <steventamm@mac.com>
 
-	* macterm.c (make_mac_frame, make_mac_terminal_frame): Move
-	setting of scroll bars from make_mac_frame to
-	make_mac_terminal_frame to prevent clobbering of
-	scroll-bar-mode.
+	* macterm.c (make_mac_frame, make_mac_terminal_frame):
+	Move setting of scroll bars from make_mac_frame to
+	make_mac_terminal_frame to prevent clobbering of scroll-bar-mode.
 
 2004-01-26  Richard M. Stallman  <rms@gnu.org>
 
--- a/src/Makefile.in	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/Makefile.in	Tue Feb 17 01:52:25 2004 +0000
@@ -571,7 +571,7 @@
 
 /* lastfile must follow all files
    whose initialized data areas should be dumped as pure by dump-emacs.  */
-obj=    dispnew.o frame.o scroll.o xdisp.o $(XMENU_OBJ) window.o \
+obj=    dispnew.o frame.o scroll.o xdisp.o fringe.o $(XMENU_OBJ) window.o \
 	charset.o coding.o category.o ccl.o \
 	cm.o term.o xfaces.o $(XOBJ) \
 	emacs.o keyboard.o macros.o keymap.o sysdep.o \
@@ -1075,6 +1075,7 @@
 frame.o: frame.c xterm.h window.h frame.h termhooks.h commands.h keyboard.h \
    blockinput.h atimer.h systime.h buffer.h charset.h fontset.h \
    msdos.h dosfns.h dispextern.h $(config_h)
+fringe.o: fringe.c dispextern.h frame.h window.h buffer.h $(config_h)
 fontset.o: dispextern.h fontset.h fontset.c ccl.h buffer.h charset.h frame.h \
    keyboard.h termhooks.h $(config_h)
 getloadavg.o: getloadavg.c $(config_h)
--- a/src/atimer.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/atimer.c	Tue Feb 17 01:52:25 2004 +0000
@@ -19,13 +19,13 @@
 Boston, MA 02111-1307, USA.  */
 
 #include <config.h>
+#include <signal.h>
+#include <stdio.h>
 #include <lisp.h>
-#include <signal.h>
 #include <syssignal.h>
 #include <systime.h>
 #include <blockinput.h>
 #include <atimer.h>
-#include <stdio.h>
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
--- a/src/buffer.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/buffer.c	Tue Feb 17 01:52:25 2004 +0000
@@ -2081,7 +2081,9 @@
 If FLAG is t, this makes the buffer a multibyte buffer.
 If FLAG is nil, this makes the buffer a single-byte buffer.
 The buffer contents remain unchanged as a sequence of bytes
-but the contents viewed as characters do change.  */)
+but the contents viewed as characters do change.
+If the multibyte flag was really changed, undo information of the
+current buffer is cleared.  */)
      (flag)
      Lisp_Object flag;
 {
@@ -5637,10 +5639,20 @@
   DEFVAR_PER_BUFFER ("indicate-buffer-boundaries",
 		     &current_buffer->indicate_buffer_boundaries, Qnil,
 		     doc: /* *Visually indicate buffer boundaries and scrolling.
-If non-nil, the first and last line of the buffer are marked in the left and
-right fringe of a window on window-systems.
-In addition, if value is t, the top and bottom line of the window are marked
-with up and down arrow bitmaps in the right fringe if window can be scrolled.  */);
+If non-nil, the first and last line of the buffer are marked in the fringe
+of a window on window-systems with angle bitmaps, or if the window can be
+scrolled, the top and bottom line of the window are marked with up and down
+arrow bitmaps.
+If value is `left' or `right', both angle and arrow bitmaps are displayed in
+the left or right fringe, resp.  Any other non-nil value causes the
+bitmap on the top line to be displayed in the left fringe, and the
+bitmap on the bottom line in the right fringe.
+If value is a cons (ANGLES . ARROWS), the car specifies the position
+of the angle bitmaps, and the cdr specifies the position of the arrow
+bitmaps.  For example, (t . right) places the top angle bitmap in left
+fringe, the bottom angle bitmap in right fringe, and both arrow
+bitmaps in right fringe.  To show just the angle bitmaps in the left
+fringe, but no arrow bitmaps, use (left . nil).  */);
 
   DEFVAR_PER_BUFFER ("scroll-up-aggressively",
 		     &current_buffer->scroll_up_aggressively, Qnil,
--- a/src/data.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/data.c	Tue Feb 17 01:52:25 2004 +0000
@@ -2879,6 +2879,20 @@
   XSETINT (number, ~XINT (number));
   return number;
 }
+
+DEFUN ("byteorder", Fbyteorder, Sbyteorder, 0, 0, 0,
+       doc: /* Return the byteorder for the machine.
+Returns 66 (ASCII uppercase B) for big endian machines or 108 (ASCII
+lowercase l) for small endian machines.  */)
+     ()
+{
+  unsigned i = 0x04030201;
+  int order = *(char *)&i == 4 ? 66 : 108;
+
+  return make_number (order);
+}
+
+
 
 void
 syms_of_data ()
@@ -3281,6 +3295,7 @@
   defsubr (&Sadd1);
   defsubr (&Ssub1);
   defsubr (&Slognot);
+  defsubr (&Sbyteorder);
   defsubr (&Ssubr_arity);
 
   XSYMBOL (Qwholenump)->function = XSYMBOL (Qnatnump)->function;
--- a/src/dispextern.h	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/dispextern.h	Tue Feb 17 01:52:25 2004 +0000
@@ -126,6 +126,9 @@
   ON_RIGHT_MARGIN
 };
 
+/* Number of bits allocated to store fringe bitmap numbers.  */
+#define FRINGE_ID_BITS  8
+
 
 
 /***********************************************************************
@@ -710,10 +713,28 @@
   struct display_pos end;
 
   /* Left fringe bitmap number (enum fringe_bitmap_type).  */
-  unsigned left_fringe_bitmap : 4;
+  unsigned left_user_fringe_bitmap : FRINGE_ID_BITS;
+
+  /* Face of the left fringe glyph.  */
+  unsigned left_user_fringe_face_id : FACE_ID_BITS;
 
   /* Right fringe bitmap number (enum fringe_bitmap_type).  */
-  unsigned right_fringe_bitmap : 4;
+  unsigned right_user_fringe_bitmap : FRINGE_ID_BITS;
+
+  /* Face of the right fringe glyph.  */
+  unsigned right_user_fringe_face_id : FACE_ID_BITS;
+
+  /* Left fringe bitmap number (enum fringe_bitmap_type).  */
+  unsigned left_fringe_bitmap : FRINGE_ID_BITS;
+
+  /* Face of the left fringe glyph.  */
+  unsigned left_fringe_face_id : FACE_ID_BITS;
+
+  /* Right fringe bitmap number (enum fringe_bitmap_type).  */
+  unsigned right_fringe_bitmap : FRINGE_ID_BITS;
+
+  /* Face of the right fringe glyph.  */
+  unsigned right_fringe_face_id : FACE_ID_BITS;
 
   /* 1 means that we must draw the bitmaps of this row.  */
   unsigned redraw_fringe_bitmaps_p : 1;
@@ -1609,35 +1630,6 @@
 			       Fringes
  ***********************************************************************/
 
-enum fringe_bitmap_type
-{
-  NO_FRINGE_BITMAP = 0,
-  LEFT_TRUNCATION_BITMAP,
-  RIGHT_TRUNCATION_BITMAP,
-  UP_ARROW_BITMAP,
-  DOWN_ARROW_BITMAP,
-  CONTINUED_LINE_BITMAP,
-  CONTINUATION_LINE_BITMAP,
-  OVERLAY_ARROW_BITMAP,
-  FIRST_LINE_BITMAP,
-  LAST_LINE_BITMAP,
-  FILLED_BOX_CURSOR_BITMAP,
-  HOLLOW_BOX_CURSOR_BITMAP,
-  BAR_CURSOR_BITMAP,
-  HBAR_CURSOR_BITMAP,
-  ZV_LINE_BITMAP,
-  HOLLOW_SQUARE_BITMAP,
-  MAX_FRINGE_BITMAPS
-};
-
-struct fringe_bitmap
-{
-  int width;
-  int height;
-  int period;
-  unsigned char *bits;
-};
-
 /* Structure used to describe where and how to draw a fringe bitmap.
    WHICH is the fringe bitmap to draw.  WD and H is the (adjusted)
    width and height of the bitmap, DH is the height adjustment (if
@@ -1648,14 +1640,17 @@
 
 struct draw_fringe_bitmap_params
 {
-  enum fringe_bitmap_type which;
+  int which;  /* enum fringe_bitmap_type */
+  unsigned short *bits;
   int wd, h, dh;
   int x, y;
   int bx, nx, by, ny;
+  unsigned cursor_p : 1;
+  unsigned overlay_p : 1;
   struct face *face;
 };
 
-extern struct fringe_bitmap fringe_bitmaps[MAX_FRINGE_BITMAPS];
+#define MAX_FRINGE_BITMAPS (1<<FRINGE_ID_BITS)
 
 
 /***********************************************************************
@@ -2025,6 +2020,18 @@
   /* Horizontal matrix position reached in move_it_in_display_line.
      Only set there, not in display_line.  */
   int hpos;
+
+  /* Left fringe bitmap number (enum fringe_bitmap_type).  */
+  unsigned left_user_fringe_bitmap : FRINGE_ID_BITS;
+
+  /* Face of the left fringe glyph.  */
+  unsigned left_user_fringe_face_id : FACE_ID_BITS;
+
+  /* Right fringe bitmap number (enum fringe_bitmap_type).  */
+  unsigned right_user_fringe_bitmap : FRINGE_ID_BITS;
+
+  /* Face of the right fringe glyph.  */
+  unsigned right_user_fringe_face_id : FACE_ID_BITS;
 };
 
 
@@ -2181,6 +2188,11 @@
   void (*draw_fringe_bitmap) P_ ((struct window *w, struct glyph_row *row,
 				  struct draw_fringe_bitmap_params *p));
 
+  /* Define and destroy fringe bitmap no. WHICH.  */
+  void (*define_fringe_bitmap) P_ ((int which, unsigned short *bits,
+				    int h, int wd));
+  void (*destroy_fringe_bitmap) P_ ((int which));
+
 /* Get metrics of character CHAR2B in FONT of type FONT_TYPE.
    Value is null if CHAR2B is not contained in the font.  */
   XCharStruct * (*per_char_metric) P_ ((XFontStruct *font, XChar2b *char2b,
@@ -2526,11 +2538,6 @@
 int in_display_vector_p P_ ((struct it *));
 int frame_mode_line_height P_ ((struct frame *));
 void highlight_trailing_whitespace P_ ((struct frame *, struct glyph_row *));
-void draw_fringe_bitmap P_ ((struct window *, struct glyph_row *, int));
-void draw_row_fringe_bitmaps P_ ((struct window *, struct glyph_row *));
-void draw_window_fringes P_ ((struct window *));
-int update_window_fringes P_ ((struct window *, int));
-void compute_fringe_widths P_ ((struct frame *, int));
 extern Lisp_Object Qtool_bar;
 extern Lisp_Object Vshow_trailing_whitespace;
 extern int mode_line_in_non_selected_windows;
@@ -2600,6 +2607,20 @@
 				       XRectangle *));
 #endif
 
+/* Defined in fringe.c */
+
+int valid_fringe_bitmap_id_p (int);
+void draw_fringe_bitmap P_ ((struct window *, struct glyph_row *, int));
+void draw_row_fringe_bitmaps P_ ((struct window *, struct glyph_row *));
+void draw_window_fringes P_ ((struct window *));
+int update_window_fringes P_ ((struct window *, int));
+void compute_fringe_widths P_ ((struct frame *, int));
+
+#ifdef WINDOWS_NT
+void w32_init_fringe P_ ((void));
+void w32_reset_fringes P_ ((void));
+#endif
+
 /* Defined in sysdep.c */
 
 void get_tty_size P_ ((int, int *, int *));
--- a/src/dispnew.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/dispnew.c	Tue Feb 17 01:52:25 2004 +0000
@@ -1503,7 +1503,10 @@
       if (a->fill_line_p != b->fill_line_p
 	  || a->cursor_in_fringe_p != b->cursor_in_fringe_p
 	  || a->left_fringe_bitmap != b->left_fringe_bitmap
+	  || a->left_fringe_face_id != b->left_fringe_face_id
 	  || a->right_fringe_bitmap != b->right_fringe_bitmap
+	  || a->right_fringe_face_id != b->right_fringe_face_id
+	  || a->overlay_arrow_p != b->overlay_arrow_p
 	  || a->exact_window_width_line_p != b->exact_window_width_line_p
 	  || a->overlapped_p != b->overlapped_p
 	  || (MATRIX_ROW_CONTINUATION_LINE_P (a)
@@ -3820,10 +3823,15 @@
       paused_p = update_window_tree (root_window, force_p);
       update_end (f);
 
-#if 0 /* This flush is a performance bottleneck under X,
-	 and it doesn't seem to be necessary anyway.  */
-      FRAME_RIF (f)->flush_display (f);
-#endif
+      /* This flush is a performance bottleneck under X,
+ 	 and it doesn't seem to be necessary anyway (in general).
+         It is necessary when resizing the window with the mouse, or
+ 	 at least the fringes are not redrawn in a timely manner.  ++kfs */
+      if (f->force_flush_display_p)
+ 	{
+     	  FRAME_RIF (f)->flush_display (f);
+ 	  f->force_flush_display_p = 0;
+ 	}
     }
   else
     {
@@ -4524,6 +4532,7 @@
 	  || desired_row->y != current_row->y
 	  || desired_row->visible_height != current_row->visible_height
 	  || desired_row->cursor_in_fringe_p != current_row->cursor_in_fringe_p
+	  || desired_row->overlay_arrow_p != current_row->overlay_arrow_p
 	  || current_row->redraw_fringe_bitmaps_p
 	  || desired_row->mode_line_p != current_row->mode_line_p
 	  || desired_row->exact_window_width_line_p != current_row->exact_window_width_line_p
@@ -5032,7 +5041,10 @@
 	    to_overlapped_p = to->overlapped_p;
 	    if (!from->mode_line_p && !w->pseudo_window_p
 		&& (to->left_fringe_bitmap != from->left_fringe_bitmap
-		    || to->right_fringe_bitmap != from->right_fringe_bitmap))
+		    || to->right_fringe_bitmap != from->right_fringe_bitmap
+		    || to->left_fringe_face_id != from->left_fringe_face_id
+		    || to->right_fringe_face_id != from->right_fringe_face_id
+		    || to->overlay_arrow_p != from->overlay_arrow_p))
 	      from->redraw_fringe_bitmaps_p = 1;
 	    assign_row (to, from);
 	    to->enabled_p = 1, from->enabled_p = 0;
--- a/src/editfns.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/editfns.c	Tue Feb 17 01:52:25 2004 +0000
@@ -1138,7 +1138,7 @@
 
 DEFUN ("char-after", Fchar_after, Schar_after, 0, 1, 0,
        doc: /* Return character in current buffer at position POS.
-POS is an integer or a marker.
+POS is an integer or a marker and defaults to point.
 If POS is out of range, the value is nil.  */)
      (pos)
      Lisp_Object pos;
@@ -1171,7 +1171,7 @@
 
 DEFUN ("char-before", Fchar_before, Schar_before, 0, 1, 0,
        doc: /* Return character in current buffer preceding position POS.
-POS is an integer or a marker.
+POS is an integer or a marker and defaults to point.
 If POS is out of range, the value is nil.  */)
      (pos)
      Lisp_Object pos;
--- a/src/emacs.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/emacs.c	Tue Feb 17 01:52:25 2004 +0000
@@ -1236,6 +1236,9 @@
 
       init_window_once ();	/* Init the window system.  */
       init_fileio_once ();	/* Must precede any path manipulation.  */
+#ifdef HAVE_WINDOW_SYSTEM
+      init_fringe_once ();	/* Swap bitmaps if necessary. */
+#endif /* HAVE_WINDOW_SYSTEM */
     }
 
   init_alloc ();
@@ -1500,6 +1503,9 @@
 #endif /* WINDOWSNT */
       syms_of_window ();
       syms_of_xdisp ();
+#ifdef HAVE_WINDOW_SYSTEM
+      syms_of_fringe ();
+#endif /* HAVE_WINDOW_SYSTEM */
 #ifdef HAVE_X_WINDOWS
       syms_of_xterm ();
       syms_of_xfns ();
@@ -1581,6 +1587,9 @@
 #endif /* HAVE_X_WINDOWS */
   init_fns ();
   init_xdisp ();
+#ifdef HAVE_WINDOW_SYSTEM
+  init_fringe ();
+#endif /* HAVE_WINDOW_SYSTEM */
   init_macros ();
   init_editfns ();
   init_floatfns ();
--- a/src/fns.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/fns.c	Tue Feb 17 01:52:25 2004 +0000
@@ -2512,14 +2512,26 @@
   else if (SYMBOLP (range))
     {
       Lisp_Object charset_info;
+      int charset_id;
 
       charset_info = Fget (range, Qcharset);
-      CHECK_VECTOR (charset_info);
-
-      return Faset (char_table,
-		    make_number (XINT (XVECTOR (charset_info)->contents[0])
-				 + 128),
-		    value);
+      if (! VECTORP (charset_info)
+	  || ! NATNUMP (AREF (charset_info, 0))
+	  || (charset_id = XINT (AREF (charset_info, 0)),
+	      ! CHARSET_DEFINED_P (charset_id)))
+	error ("Invalid charset: %s", SDATA (SYMBOL_NAME (range)));
+
+      if (charset_id == CHARSET_ASCII)
+	for (i = 0; i < 128; i++)
+	  XCHAR_TABLE (char_table)->contents[i] = value;
+      else if (charset_id == CHARSET_8_BIT_CONTROL)
+	for (i = 128; i < 160; i++)
+	  XCHAR_TABLE (char_table)->contents[i] = value;
+      else if (charset_id == CHARSET_8_BIT_GRAPHIC)
+	for (i = 160; i < 256; i++)
+	  XCHAR_TABLE (char_table)->contents[i] = value;
+      else
+	XCHAR_TABLE (char_table)->contents[charset_id + 128] = value;
     }
   else if (INTEGERP (range))
     Faset (char_table, range, value);
--- a/src/frame.h	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/frame.h	Tue Feb 17 01:52:25 2004 +0000
@@ -438,6 +438,10 @@
      Clear the frame in clear_garbaged_frames if set.  */
   unsigned resized_p : 1;
 
+  /* Set to non-zero in when we want for force a flush_display in
+     update_frame, usually after resizing the frame.  */
+  unsigned force_flush_display_p : 1;
+  
   /* All display backends seem to need these two pixel values. */
   unsigned long background_pixel;
   unsigned long foreground_pixel;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fringe.c	Tue Feb 17 01:52:25 2004 +0000
@@ -0,0 +1,1362 @@
+/* Fringe handling (split from xdisp.c).
+   Copyright (C) 1985,86,87,88,93,94,95,97,98,99,2000,01,02,03,04
+   Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+#include <config.h>
+#include <stdio.h>
+
+#include "lisp.h"
+#include "frame.h"
+#include "window.h"
+#include "dispextern.h"
+#include "buffer.h"
+#include "blockinput.h"
+#include "termhooks.h"
+
+#ifdef HAVE_WINDOW_SYSTEM
+
+extern Lisp_Object Qtop, Qbottom, Qcenter;
+
+/* Non-nil means that newline may flow into the right fringe.  */
+
+Lisp_Object Voverflow_newline_into_fringe;
+
+
+enum fringe_bitmap_type
+{
+  NO_FRINGE_BITMAP = 0,
+  UNDEF_FRINGE_BITMAP,
+  LEFT_TRUNCATION_BITMAP,
+  RIGHT_TRUNCATION_BITMAP,
+  UP_ARROW_BITMAP,
+  DOWN_ARROW_BITMAP,
+  CONTINUED_LINE_BITMAP,
+  CONTINUATION_LINE_BITMAP,
+  OVERLAY_ARROW_BITMAP,
+  TOP_LEFT_ANGLE_BITMAP,
+  TOP_RIGHT_ANGLE_BITMAP,
+  BOTTOM_LEFT_ANGLE_BITMAP,
+  BOTTOM_RIGHT_ANGLE_BITMAP,
+  LEFT_BRACKET_BITMAP,
+  RIGHT_BRACKET_BITMAP,
+  FILLED_BOX_CURSOR_BITMAP,
+  HOLLOW_BOX_CURSOR_BITMAP,
+  HOLLOW_SQUARE_BITMAP,
+  BAR_CURSOR_BITMAP,
+  HBAR_CURSOR_BITMAP,
+  ZV_LINE_BITMAP,
+  MAX_STANDARD_FRINGE_BITMAPS
+};
+
+enum fringe_bitmap_align
+{
+  ALIGN_BITMAP_CENTER = 0,
+  ALIGN_BITMAP_TOP,
+  ALIGN_BITMAP_BOTTOM
+};
+
+struct fringe_bitmap
+{
+  unsigned short *bits;
+  unsigned height : 8;
+  unsigned width : 8;
+  unsigned period : 8;
+  unsigned align : 2;
+  unsigned dynamic : 1;
+};
+
+
+/***********************************************************************
+			       Fringe bitmaps
+ ***********************************************************************/
+
+/* Undefined bitmap.  A question mark.  */
+/*
+  ..xxxx..
+  .xxxxxx.
+  xx....xx
+  xx....xx
+  ....xx..
+  ...xx...
+  ...xx...
+  ........
+  ...xx...
+  ...xx...
+*/
+static unsigned short unknown_bits[] = {
+  0x3c, 0x7e, 0x7e, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x18};
+
+/* An arrow like this: `<-'.  */
+/*
+  ...xx...
+  ..xx....
+  .xx.....
+  xxxxxx..
+  xxxxxx..
+  .xx.....
+  ..xx....
+  ...xx...
+*/
+static unsigned short left_arrow_bits[] = {
+   0x18, 0x30, 0x60, 0xfc, 0xfc, 0x60, 0x30, 0x18};
+
+
+/* Right truncation arrow bitmap `->'.  */
+/*
+  ...xx...
+  ....xx..
+  .....xx.
+  ..xxxxxx
+  ..xxxxxx
+  .....xx.
+  ....xx..
+  ...xx...
+*/
+static unsigned short right_arrow_bits[] = {
+   0x18, 0x0c, 0x06, 0x3f, 0x3f, 0x06, 0x0c, 0x18};
+
+
+/* Up arrow bitmap.  */
+/*
+  ...xx...
+  ..xxxx..
+  .xxxxxx.
+  xxxxxxxx
+  ...xx...
+  ...xx...
+  ...xx...
+  ...xx...
+*/
+static unsigned short up_arrow_bits[] = {
+   0x18, 0x3c, 0x7e, 0xff, 0x18, 0x18, 0x18, 0x18};
+
+
+/* Down arrow bitmap.  */
+/*
+  ...xx...
+  ...xx...
+  ...xx...
+  ...xx...
+  xxxxxxxx
+  .xxxxxx.
+  ..xxxx..
+  ...xx...
+*/
+static unsigned short down_arrow_bits[] = {
+   0x18, 0x18, 0x18, 0x18, 0xff, 0x7e, 0x3c, 0x18};
+
+/* Marker for continued lines.  */
+/*
+  ..xxxx..
+  ..xxxxx.
+  ......xx
+  ..x..xxx
+  ..xxxxxx
+  ..xxxxx.
+  ..xxxx..
+  ..xxxxx.
+*/
+static unsigned short continued_bits[] = {
+   0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e};
+
+/* Marker for continuation lines.  */
+/*
+  ..xxxx..
+  .xxxxx..
+  xx......
+  xxx..x..
+  xxxxxx..
+  .xxxxx..
+  ..xxxx..
+  .xxxxx..
+*/
+static unsigned short continuation_bits[] = {
+   0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c};
+
+/* Overlay arrow bitmap.  A triangular arrow.  */
+/*
+  xx......
+  xxxx....
+  xxxxx...
+  xxxxxx..
+  xxxxxx..
+  xxxxx...
+  xxxx....
+  xx......
+*/
+static unsigned short ov_bits[] = {
+   0xc0, 0xf0, 0xf8, 0xfc, 0xfc, 0xf8, 0xf0, 0xc0};
+
+#if 0
+/* Reverse Overlay arrow bitmap.  A triangular arrow.  */
+/*
+  ......xx
+  ....xxxx
+  ...xxxxx
+  ..xxxxxx
+  ..xxxxxx
+  ...xxxxx
+  ....xxxx
+  ......xx
+*/
+static unsigned short rev_ov_bits[] = {
+   0x03, 0x0f, 0x1f, 0x3f, 0x3f, 0x1f, 0x0f, 0x03};
+#endif
+
+/* First line bitmap.  An top-left angle.  */
+/*
+  xxxxxx..
+  xxxxxx..
+  xx......
+  xx......
+  xx......
+  xx......
+  xx......
+  ........
+*/
+static unsigned short top_left_angle_bits[] = {
+   0xfc, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00};
+
+/* First line bitmap.  An right-up angle.  */
+/*
+  ..xxxxxx
+  ..xxxxxx
+  ......xx
+  ......xx
+  ......xx
+  ......xx
+  ......xx
+  ........
+*/
+static unsigned short top_right_angle_bits[] = {
+   0x3f, 0x3f, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00};
+
+/* Last line bitmap.  An left-down angle.  */
+/*
+  ........
+  xx......
+  xx......
+  xx......
+  xx......
+  xx......
+  xxxxxx..
+  xxxxxx..
+*/
+static unsigned short bottom_left_angle_bits[] = {
+   0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xfc};
+
+/* Last line bitmap.  An right-down angle.  */
+/*
+  ........
+  ......xx
+  ......xx
+  ......xx
+  ......xx
+  ......xx
+  ..xxxxxx
+  ..xxxxxx
+*/
+static unsigned short bottom_right_angle_bits[] = {
+   0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3f};
+
+/* First/last line bitmap.  An left bracket.  */
+/*
+  xxxxxx..
+  xxxxxx..
+  xx......
+  xx......
+  xx......
+  xx......
+  xx......
+  xx......
+  xxxxxx..
+  xxxxxx..
+*/
+static unsigned short left_bracket_bits[] = {
+   0xfc, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xfc};
+
+/* First/last line bitmap.  An right bracket.  */
+/*
+  ..xxxxxx
+  ..xxxxxx
+  ......xx
+  ......xx
+  ......xx
+  ......xx
+  ......xx
+  ......xx
+  ..xxxxxx
+  ..xxxxxx
+*/
+static unsigned short right_bracket_bits[] = {
+  0x3f, 0x3f, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x3f, 0x3f};
+
+/* Filled box cursor bitmap.  A filled box; max 13 pixels high.  */
+/*
+  xxxxxxx.
+  xxxxxxx.
+  xxxxxxx.
+  xxxxxxx.
+  xxxxxxx.
+  xxxxxxx.
+  xxxxxxx.
+  xxxxxxx.
+  xxxxxxx.
+  xxxxxxx.
+  xxxxxxx.
+  xxxxxxx.
+  xxxxxxx.
+*/
+static unsigned short filled_box_cursor_bits[] = {
+   0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
+
+/* Hollow box cursor bitmap.  A hollow box; max 13 pixels high.  */
+/*
+  xxxxxxx.
+  x.....x.
+  x.....x.
+  x.....x.
+  x.....x.
+  x.....x.
+  x.....x.
+  x.....x.
+  x.....x.
+  x.....x.
+  x.....x.
+  x.....x.
+  xxxxxxx.
+*/
+static unsigned short hollow_box_cursor_bits[] = {
+   0xfe, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0xfe};
+
+/* Bar cursor bitmap.  A vertical bar; max 13 pixels high.  */
+/*
+  xx......
+  xx......
+  xx......
+  xx......
+  xx......
+  xx......
+  xx......
+  xx......
+  xx......
+  xx......
+  xx......
+  xx......
+  xx......
+*/
+static unsigned short bar_cursor_bits[] = {
+   0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0};
+
+/* HBar cursor bitmap.  A horisontal bar; 2 pixels high.  */
+/*
+  xxxxxxx.
+  xxxxxxx.
+*/
+static unsigned short hbar_cursor_bits[] = {
+  0xfe, 0xfe};
+
+
+/* Bitmap drawn to indicate lines not displaying text if
+   `indicate-empty-lines' is non-nil.  */
+/*
+  ........
+  ..xxxx..
+  ........
+  ........
+  ..xxxx..
+  ........
+*/
+static unsigned short zv_bits[] = {
+  0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
+  0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
+  0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
+  0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
+  0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
+  0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
+  0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
+  0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00};
+
+/* Hollow square bitmap.  */
+/*
+  .xxxxxx.
+  .x....x.
+  .x....x.
+  .x....x.
+  .x....x.
+  .xxxxxx.
+*/
+static unsigned short hollow_square_bits[] = {
+   0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e};
+
+
+#define BYTES_PER_BITMAP_ROW  (sizeof (unsigned short))
+#define STANDARD_BITMAP_HEIGHT(bits) (sizeof (bits)/BYTES_PER_BITMAP_ROW)
+#define FRBITS(bits)  bits, STANDARD_BITMAP_HEIGHT (bits)
+
+struct fringe_bitmap standard_bitmaps[MAX_STANDARD_FRINGE_BITMAPS] =
+{
+  { NULL, 0, 0, 0, 0, 0 }, /* NO_FRINGE_BITMAP */
+  { FRBITS (unknown_bits),            8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (left_arrow_bits),         8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (right_arrow_bits),        8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (up_arrow_bits),           8, 0, ALIGN_BITMAP_TOP,    0 },
+  { FRBITS (down_arrow_bits),         8, 0, ALIGN_BITMAP_BOTTOM, 0 },
+  { FRBITS (continued_bits),          8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (continuation_bits),       8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (ov_bits),                 8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (top_left_angle_bits),     8, 0, ALIGN_BITMAP_TOP,    0 },
+  { FRBITS (top_right_angle_bits),    8, 0, ALIGN_BITMAP_TOP,    0 },
+  { FRBITS (bottom_left_angle_bits),  8, 0, ALIGN_BITMAP_BOTTOM, 0 },
+  { FRBITS (bottom_right_angle_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 },
+  { FRBITS (left_bracket_bits),       8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (right_bracket_bits),      8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (filled_box_cursor_bits),  8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (hollow_box_cursor_bits),  8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (hollow_square_bits),      8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (bar_cursor_bits),         8, 0, ALIGN_BITMAP_CENTER, 0 },
+  { FRBITS (hbar_cursor_bits),        8, 0, ALIGN_BITMAP_BOTTOM, 0 },
+  { FRBITS (zv_bits),                 8, 3, ALIGN_BITMAP_TOP,    0 },
+};
+
+static struct fringe_bitmap *fringe_bitmaps[MAX_FRINGE_BITMAPS];
+static unsigned fringe_faces[MAX_FRINGE_BITMAPS];
+
+static int max_used_fringe_bitmap = MAX_STANDARD_FRINGE_BITMAPS;
+
+/* Return 1 if FRINGE_ID is a valid fringe bitmap id.  */
+
+int
+valid_fringe_bitmap_id_p (fringe_id)
+     int fringe_id;
+{
+  return (fringe_id >= NO_FRINGE_BITMAP
+	  && fringe_id < max_used_fringe_bitmap
+	  && (fringe_id < MAX_STANDARD_FRINGE_BITMAPS
+	      || fringe_bitmaps[fringe_id] != NULL));
+}
+
+/* Draw the bitmap WHICH in one of the left or right fringes of
+   window W.  ROW is the glyph row for which to display the bitmap; it
+   determines the vertical position at which the bitmap has to be
+   drawn.
+   LEFT_P is 1 for left fringe, 0 for right fringe.
+*/
+
+void
+draw_fringe_bitmap_1 (w, row, left_p, overlay, which)
+     struct window *w;
+     struct glyph_row *row;
+     int left_p, overlay;
+     enum fringe_bitmap_type which;
+{
+  struct frame *f = XFRAME (WINDOW_FRAME (w));
+  struct draw_fringe_bitmap_params p;
+  struct fringe_bitmap *fb;
+  int period;
+  int face_id = DEFAULT_FACE_ID;
+
+  p.cursor_p = 0;
+  p.overlay_p = (overlay & 1) == 1;
+  p.cursor_p = (overlay & 2) == 2;
+
+  if (which != NO_FRINGE_BITMAP)
+    {
+    }
+  else if (left_p)
+    {
+      which = row->left_fringe_bitmap;
+      face_id = row->left_fringe_face_id;
+    }
+  else
+    {
+      which = row->right_fringe_bitmap;
+      face_id = row->right_fringe_face_id;
+    }
+
+  if (face_id == DEFAULT_FACE_ID)
+    face_id = fringe_faces[which];
+
+  fb = fringe_bitmaps[which];
+  if (fb == NULL)
+    fb = &standard_bitmaps[which < MAX_STANDARD_FRINGE_BITMAPS
+			   ? which : UNDEF_FRINGE_BITMAP];
+
+  period = fb->period;
+
+  /* Convert row to frame coordinates.  */
+  p.y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
+
+  p.which = which;
+  p.bits = fb->bits;
+  p.wd = fb->width;
+
+  p.h = fb->height;
+  p.dh = (period > 0 ? (p.y % period) : 0);
+  p.h -= p.dh;
+  /* Clip bitmap if too high.  */
+  if (p.h > row->height)
+    p.h = row->height;
+
+  p.face = FACE_FROM_ID (f, face_id);
+
+  if (p.face == NULL)
+    {
+      /* Why does this happen?  ++kfs */
+      return;
+    }
+
+  PREPARE_FACE_FOR_DISPLAY (f, p.face);
+
+  /* Clear left fringe if no bitmap to draw or if bitmap doesn't fill
+     the fringe.  */
+  p.bx = -1;
+  if (left_p)
+    {
+      int wd = WINDOW_LEFT_FRINGE_WIDTH (w);
+      int x = window_box_left (w, (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
+				   ? LEFT_MARGIN_AREA
+				   : TEXT_AREA));
+      if (p.wd > wd)
+	p.wd = wd;
+      p.x = x - p.wd - (wd - p.wd) / 2;
+
+      if (p.wd < wd || row->height > p.h)
+	{
+	  /* If W has a vertical border to its left, don't draw over it.  */
+	  wd -= ((!WINDOW_LEFTMOST_P (w)
+		  && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w))
+		 ? 1 : 0);
+	  p.bx = x - wd;
+	  p.nx = wd;
+	}
+    }
+  else
+    {
+      int x = window_box_right (w,
+				(WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
+				 ? RIGHT_MARGIN_AREA
+				 : TEXT_AREA));
+      int wd = WINDOW_RIGHT_FRINGE_WIDTH (w);
+      if (p.wd > wd)
+	p.wd = wd;
+      p.x = x + (wd - p.wd) / 2;
+      /* Clear right fringe if no bitmap to draw of if bitmap doesn't fill
+	 the fringe.  */
+      if (p.wd < wd || row->height > p.h)
+	{
+	  p.bx = x;
+	  p.nx = wd;
+	}
+    }
+
+  if (p.bx >= 0)
+    {
+      int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w);
+
+      p.by = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height, row->y));
+      p.ny = row->visible_height;
+    }
+
+  /* Adjust y to the offset in the row to start drawing the bitmap.  */
+  switch (fb->align)
+    {
+    case ALIGN_BITMAP_CENTER:
+      p.y += (row->height - p.h) / 2;
+      break;
+    case ALIGN_BITMAP_BOTTOM:
+      p.h = fb->height;
+      p.y += (row->visible_height - p.h);
+      break;
+    case ALIGN_BITMAP_TOP:
+      break;
+    }
+
+  FRAME_RIF (f)->draw_fringe_bitmap (w, row, &p);
+}
+
+void
+draw_fringe_bitmap (w, row, left_p)
+     struct window *w;
+     struct glyph_row *row;
+     int left_p;
+{
+  int overlay = 0;
+
+  if (!left_p && row->cursor_in_fringe_p)
+    {
+      int cursor = NO_FRINGE_BITMAP;
+
+      switch (w->phys_cursor_type)
+	{
+	case HOLLOW_BOX_CURSOR:
+	  if (row->visible_height >= STANDARD_BITMAP_HEIGHT (hollow_box_cursor_bits))
+	    cursor = HOLLOW_BOX_CURSOR_BITMAP;
+	  else
+	    cursor = HOLLOW_SQUARE_BITMAP;
+	  break;
+	case FILLED_BOX_CURSOR:
+	  cursor = FILLED_BOX_CURSOR_BITMAP;
+	  break;
+	case BAR_CURSOR:
+	  cursor = BAR_CURSOR_BITMAP;
+	  break;
+	case HBAR_CURSOR:
+	  cursor = HBAR_CURSOR_BITMAP;
+	  break;
+	case NO_CURSOR:
+	default:
+	  w->phys_cursor_on_p = 0;
+	  row->cursor_in_fringe_p = 0;
+	  break;
+	}
+      if (cursor != NO_FRINGE_BITMAP)
+	{
+	  draw_fringe_bitmap_1 (w, row, 0, 2, cursor);
+	  overlay = cursor == FILLED_BOX_CURSOR_BITMAP ? 3 : 1;
+	}
+    }
+
+  draw_fringe_bitmap_1 (w, row, left_p, overlay, NO_FRINGE_BITMAP);
+
+  if (left_p && row->overlay_arrow_p)
+    draw_fringe_bitmap_1 (w, row, 1, 1, OVERLAY_ARROW_BITMAP);
+}
+
+
+/* Draw fringe bitmaps for glyph row ROW on window W.  Call this
+   function with input blocked.  */
+
+void
+draw_row_fringe_bitmaps (w, row)
+     struct window *w;
+     struct glyph_row *row;
+{
+  xassert (interrupt_input_blocked);
+
+  /* If row is completely invisible, because of vscrolling, we
+     don't have to draw anything.  */
+  if (row->visible_height <= 0)
+    return;
+
+  if (WINDOW_LEFT_FRINGE_WIDTH (w) != 0)
+    draw_fringe_bitmap (w, row, 1);
+
+  if (WINDOW_RIGHT_FRINGE_WIDTH (w) != 0)
+    draw_fringe_bitmap (w, row, 0);
+}
+
+/* Draw the fringes of window W.  Only fringes for rows marked for
+   update in redraw_fringe_bitmaps_p are drawn.  */
+
+void
+draw_window_fringes (w)
+     struct window *w;
+{
+  struct glyph_row *row;
+  int yb = window_text_bottom_y (w);
+  int nrows = w->current_matrix->nrows;
+  int y = 0, rn;
+
+  if (w->pseudo_window_p)
+    return;
+
+  for (y = 0, rn = 0, row = w->current_matrix->rows;
+       y < yb && rn < nrows;
+       y += row->height, ++row, ++rn)
+    {
+      if (!row->redraw_fringe_bitmaps_p)
+	continue;
+      draw_row_fringe_bitmaps (w, row);
+      row->redraw_fringe_bitmaps_p = 0;
+    }
+}
+
+
+/* Recalculate the bitmaps to show in the fringes of window W.
+   If FORCE_P is 0, only mark rows with modified bitmaps for update in
+   redraw_fringe_bitmaps_p; else mark all rows for update.  */
+
+int
+update_window_fringes (w, force_p)
+     struct window *w;
+     int force_p;
+{
+  struct glyph_row *row, *cur = 0;
+  int yb = window_text_bottom_y (w);
+  int rn, nrows = w->current_matrix->nrows;
+  int y;
+  int redraw_p = 0;
+  Lisp_Object ind;
+  int boundary_pos = 0, arrow_pos = 0;
+  int empty_pos = 0;
+
+  if (w->pseudo_window_p)
+    return 0;
+
+  if (!MINI_WINDOW_P (w)
+      && (ind = XBUFFER (w->buffer)->indicate_buffer_boundaries, !NILP (ind)))
+    {
+      int do_eob = 1, do_bob = 1;
+      Lisp_Object arrows;
+
+      if (CONSP (ind))
+	arrows = XCDR (ind), ind = XCAR (ind);
+      else
+	arrows = ind;
+
+      if (EQ (ind, Qleft))
+	boundary_pos = -1;
+      else if (EQ (ind, Qright))
+	boundary_pos = 1;
+
+      if (EQ (arrows, Qleft))
+	arrow_pos = -1;
+      else if (EQ (arrows, Qright))
+	arrow_pos = 1;
+
+      for (y = 0, rn = 0;
+	   y < yb && rn < nrows;
+	   y += row->height, ++rn)
+	{
+	  unsigned indicate_bob_p, indicate_top_line_p;
+	  unsigned indicate_eob_p, indicate_bottom_line_p;
+	  
+	  row = w->desired_matrix->rows + rn;
+	  if (!row->enabled_p)
+	    row = w->current_matrix->rows + rn;
+
+	  indicate_bob_p = row->indicate_bob_p;
+	  indicate_top_line_p = row->indicate_top_line_p;
+	  indicate_eob_p = row->indicate_eob_p;
+	  indicate_bottom_line_p = row->indicate_bottom_line_p;
+	  
+	  row->indicate_bob_p = row->indicate_top_line_p = 0;
+	  row->indicate_eob_p = row->indicate_bottom_line_p = 0;
+
+	  if (!NILP (ind)
+	      && MATRIX_ROW_START_CHARPOS (row) <= BUF_BEGV (XBUFFER (w->buffer)))
+	    row->indicate_bob_p = do_bob, do_bob = 0;
+	  else if (!NILP (arrows)
+		   && (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0) == rn)
+	    row->indicate_top_line_p = 1;
+
+	  if (!NILP (ind)
+	      && MATRIX_ROW_END_CHARPOS (row) >= BUF_ZV (XBUFFER (w->buffer)))
+	    row->indicate_eob_p = do_eob, do_eob = 0;
+	  else if (!NILP (arrows)
+		   && y + row->height >= yb)
+	    row->indicate_bottom_line_p = 1;
+
+	  if (indicate_bob_p != row->indicate_bob_p
+	      || indicate_top_line_p != row->indicate_top_line_p
+	      || indicate_eob_p != row->indicate_eob_p
+	      || indicate_bottom_line_p != row->indicate_bottom_line_p)
+	    row->redraw_fringe_bitmaps_p = 1;
+	}
+    }
+
+  if (EQ (XBUFFER (w->buffer)->indicate_empty_lines, Qright))
+    empty_pos = 1;
+  else if (EQ (XBUFFER (w->buffer)->indicate_empty_lines, Qleft))
+    empty_pos = -1;
+
+  for (y = 0, rn = 0;
+       y < yb && rn < nrows;
+       y += row->height, rn++)
+    {
+      enum fringe_bitmap_type left, right;
+      unsigned left_face_id, right_face_id;
+
+      row = w->desired_matrix->rows + rn;
+      cur = w->current_matrix->rows + rn;
+      if (!row->enabled_p)
+	row = cur;
+
+      left_face_id = right_face_id = DEFAULT_FACE_ID;
+
+      /* Decide which bitmap to draw in the left fringe.  */
+      if (WINDOW_LEFT_FRINGE_WIDTH (w) == 0)
+	left = NO_FRINGE_BITMAP;
+      else if (row->left_user_fringe_bitmap != NO_FRINGE_BITMAP)
+	{
+	  left = row->left_user_fringe_bitmap;
+	  left_face_id = row->left_user_fringe_face_id;
+	}
+#if 0  /* this is now done via an overlay */
+      else if (row->overlay_arrow_p)
+	left = OVERLAY_ARROW_BITMAP;
+#endif
+      else if (row->indicate_bob_p && boundary_pos <= 0)
+	left = ((row->indicate_eob_p && boundary_pos < 0)
+		? LEFT_BRACKET_BITMAP : TOP_LEFT_ANGLE_BITMAP);
+      else if (row->indicate_eob_p && boundary_pos < 0)
+	left = BOTTOM_LEFT_ANGLE_BITMAP;
+      else if (row->truncated_on_left_p)
+	left = LEFT_TRUNCATION_BITMAP;
+      else if (MATRIX_ROW_CONTINUATION_LINE_P (row))
+	left = CONTINUATION_LINE_BITMAP;
+      else if (row->indicate_empty_line_p && empty_pos <= 0)
+	left = ZV_LINE_BITMAP;
+      else if (row->indicate_top_line_p && arrow_pos <= 0)
+	left = UP_ARROW_BITMAP;
+      else if (row->indicate_bottom_line_p && arrow_pos < 0)
+	left = DOWN_ARROW_BITMAP;
+      else
+	left = NO_FRINGE_BITMAP;
+
+      /* Decide which bitmap to draw in the right fringe.  */
+      if (WINDOW_RIGHT_FRINGE_WIDTH (w) == 0)
+	right = NO_FRINGE_BITMAP;
+      else if (row->right_user_fringe_bitmap != NO_FRINGE_BITMAP)
+	{
+	  right = row->right_user_fringe_bitmap;
+	  right_face_id = row->right_user_fringe_face_id;
+	}
+      else if (row->indicate_bob_p && boundary_pos > 0)
+	right = ((row->indicate_eob_p && boundary_pos >= 0)
+		 ? RIGHT_BRACKET_BITMAP : TOP_RIGHT_ANGLE_BITMAP);
+      else if (row->indicate_eob_p && boundary_pos >= 0)
+	right = BOTTOM_RIGHT_ANGLE_BITMAP;
+      else if (row->truncated_on_right_p)
+	right = RIGHT_TRUNCATION_BITMAP;
+      else if (row->continued_p)
+	right = CONTINUED_LINE_BITMAP;
+      else if (row->indicate_top_line_p && arrow_pos > 0)
+	right = UP_ARROW_BITMAP;
+      else if (row->indicate_bottom_line_p && arrow_pos >= 0)
+	right = DOWN_ARROW_BITMAP;
+      else if (row->indicate_empty_line_p
+	       && (empty_pos > 0
+		   || (WINDOW_LEFT_FRINGE_WIDTH (w) == 0 && empty_pos == 0)))
+	right = ZV_LINE_BITMAP;
+      else
+	right = NO_FRINGE_BITMAP;
+
+      if (force_p
+	  || row->y != cur->y
+	  || row->visible_height != cur->visible_height
+	  || left != cur->left_fringe_bitmap
+	  || right != cur->right_fringe_bitmap
+	  || left_face_id != cur->left_fringe_face_id
+	  || right_face_id != cur->right_fringe_face_id
+	  || cur->redraw_fringe_bitmaps_p)
+	{
+	  redraw_p = row->redraw_fringe_bitmaps_p = cur->redraw_fringe_bitmaps_p = 1;
+	  cur->left_fringe_bitmap = left;
+	  cur->right_fringe_bitmap = right;
+	  cur->left_fringe_face_id = left_face_id;
+	  cur->right_fringe_face_id = right_face_id;
+	}
+
+      if (row->overlay_arrow_p != cur->overlay_arrow_p)
+	{
+	  redraw_p = row->redraw_fringe_bitmaps_p = cur->redraw_fringe_bitmaps_p = 1;
+	  cur->overlay_arrow_p = row->overlay_arrow_p;
+	}
+
+      row->left_fringe_bitmap = left;
+      row->right_fringe_bitmap = right;
+      row->left_fringe_face_id = left_face_id;
+      row->right_fringe_face_id = right_face_id;
+    }
+
+  return redraw_p;
+}
+
+
+/* Compute actual fringe widths for frame F.  
+
+   If REDRAW is 1, redraw F if the fringe settings was actually
+   modified and F is visible.
+
+   Since the combined left and right fringe must occupy an integral
+   number of columns, we may need to add some pixels to each fringe.
+   Typically, we add an equal amount (+/- 1 pixel) to each fringe,
+   but a negative width value is taken literally (after negating it).
+
+   We never make the fringes narrower than specified.  It is planned
+   to make fringe bitmaps customizable and expandable, and at that
+   time, the user will typically specify the minimum number of pixels
+   needed for his bitmaps, so we shouldn't select anything less than
+   what is specified.
+*/
+
+void
+compute_fringe_widths (f, redraw)
+     struct frame *f;
+     int redraw;
+{
+  int o_left = FRAME_LEFT_FRINGE_WIDTH (f);
+  int o_right = FRAME_RIGHT_FRINGE_WIDTH (f);
+  int o_cols = FRAME_FRINGE_COLS (f);
+
+  Lisp_Object left_fringe = Fassq (Qleft_fringe, f->param_alist);
+  Lisp_Object right_fringe = Fassq (Qright_fringe, f->param_alist);
+  int left_fringe_width, right_fringe_width;
+
+  if (!NILP (left_fringe))
+    left_fringe = Fcdr (left_fringe);
+  if (!NILP (right_fringe))
+    right_fringe = Fcdr (right_fringe);
+
+  left_fringe_width = ((NILP (left_fringe) || !INTEGERP (left_fringe)) ? 8 :
+		       XINT (left_fringe));
+  right_fringe_width = ((NILP (right_fringe) || !INTEGERP (right_fringe)) ? 8 :
+			XINT (right_fringe));
+
+  if (left_fringe_width || right_fringe_width)
+    {
+      int left_wid = left_fringe_width >= 0 ? left_fringe_width : -left_fringe_width;
+      int right_wid = right_fringe_width >= 0 ? right_fringe_width : -right_fringe_width;
+      int conf_wid = left_wid + right_wid;
+      int font_wid = FRAME_COLUMN_WIDTH (f);
+      int cols = (left_wid + right_wid + font_wid-1) / font_wid;
+      int real_wid = cols * font_wid;
+      if (left_wid && right_wid)
+	{
+	  if (left_fringe_width < 0)
+	    {
+	      /* Left fringe width is fixed, adjust right fringe if necessary */
+	      FRAME_LEFT_FRINGE_WIDTH (f) = left_wid;
+	      FRAME_RIGHT_FRINGE_WIDTH (f) = real_wid - left_wid;
+	    }
+	  else if (right_fringe_width < 0)
+	    {
+	      /* Right fringe width is fixed, adjust left fringe if necessary */
+	      FRAME_LEFT_FRINGE_WIDTH (f) = real_wid - right_wid;
+	      FRAME_RIGHT_FRINGE_WIDTH (f) = right_wid;
+	    }
+	  else
+	    {
+	      /* Adjust both fringes with an equal amount.
+		 Note that we are doing integer arithmetic here, so don't
+		 lose a pixel if the total width is an odd number.  */
+	      int fill = real_wid - conf_wid;
+	      FRAME_LEFT_FRINGE_WIDTH (f) = left_wid + fill/2;
+	      FRAME_RIGHT_FRINGE_WIDTH (f) = right_wid + fill - fill/2;
+	    }
+	}
+      else if (left_fringe_width)
+	{
+	  FRAME_LEFT_FRINGE_WIDTH (f) = real_wid;
+	  FRAME_RIGHT_FRINGE_WIDTH (f) = 0;
+	}
+      else
+	{
+	  FRAME_LEFT_FRINGE_WIDTH (f) = 0;
+	  FRAME_RIGHT_FRINGE_WIDTH (f) = real_wid;
+	}
+      FRAME_FRINGE_COLS (f) = cols;
+    }
+  else
+    {
+      FRAME_LEFT_FRINGE_WIDTH (f) = 0;
+      FRAME_RIGHT_FRINGE_WIDTH (f) = 0;
+      FRAME_FRINGE_COLS (f) = 0;
+    }
+
+  if (redraw && FRAME_VISIBLE_P (f))
+    if (o_left != FRAME_LEFT_FRINGE_WIDTH (f) ||
+	o_right != FRAME_RIGHT_FRINGE_WIDTH (f) ||
+	o_cols != FRAME_FRINGE_COLS (f))
+      redraw_frame (f);
+}
+
+DEFUN ("destroy-fringe-bitmap", Fdestroy_fringe_bitmap, Sdestroy_fringe_bitmap,
+       1, 1, 0,
+       doc: /* Destroy fringe bitmap WHICH.
+If WHICH overrides a standard fringe bitmap, the original bitmap is restored.  */)
+  (which)
+     Lisp_Object which;
+{
+  int n;
+  struct fringe_bitmap **fbp;
+
+  CHECK_NUMBER (which);
+  if (n = XINT (which), n >= max_used_fringe_bitmap)
+    return Qnil;
+
+  fringe_faces[n] = FRINGE_FACE_ID;
+
+  fbp = &fringe_bitmaps[n];
+  if (*fbp && (*fbp)->dynamic)
+    {
+      /* XXX Is SELECTED_FRAME OK here? */
+      if (FRAME_RIF (SELECTED_FRAME ())->destroy_fringe_bitmap)
+	FRAME_RIF (SELECTED_FRAME ())->destroy_fringe_bitmap (n);
+      xfree (*fbp);
+      *fbp = NULL;
+    }
+
+  while (max_used_fringe_bitmap > MAX_STANDARD_FRINGE_BITMAPS
+	 && fringe_bitmaps[max_used_fringe_bitmap - 1] == NULL)
+    max_used_fringe_bitmap--;
+
+  return Qnil;
+}
+
+
+/* Initialize bitmap bit.
+
+   On X, we bit-swap the built-in bitmaps and reduce bitmap
+   from short to char array if width is <= 8 bits.
+
+   On MAC with big-endian CPU, we need to byte-swap each short.
+
+   On W32 and MAC (little endian), there's no need to do this.
+*/
+
+void
+init_fringe_bitmap (which, fb, once_p)
+     enum fringe_bitmap_type which;
+     struct fringe_bitmap *fb;
+     int once_p;
+{
+  if (once_p || fb->dynamic)
+    {
+#if defined (HAVE_X_WINDOWS)
+      static unsigned char swap_nibble[16]
+	= { 0x0, 0x8, 0x4, 0xc,    /* 0000 1000 0100 1100 */
+	    0x2, 0xa, 0x6, 0xe,    /* 0010 1010 0110 1110 */
+	    0x1, 0x9, 0x5, 0xd,    /* 0001 1001 0101 1101 */
+	    0x3, 0xb, 0x7, 0xf };  /* 0011 1011 0111 1111 */
+      unsigned short *bits = fb->bits;
+      int j;
+
+      if (fb->width <= 8)
+	{
+	  unsigned char *cbits = (unsigned char *)fb->bits;
+	  for (j = 0; j < fb->height; j++)
+	    {
+	      unsigned short b = *bits++;
+	      unsigned char c;
+	      c = (unsigned char)((swap_nibble[b & 0xf] << 4)
+				  | (swap_nibble[(b>>4) & 0xf]));
+	      *cbits++ = (c >> (8 - fb->width));
+	    }
+	}
+      else
+	{
+	  for (j = 0; j < fb->height; j++)
+	    {
+	      unsigned short b = *bits;
+	      b = (unsigned short)((swap_nibble[b & 0xf] << 12)
+				   | (swap_nibble[(b>>4) & 0xf] << 8)
+				   | (swap_nibble[(b>>8) & 0xf] << 4)
+				   | (swap_nibble[(b>>12) & 0xf]));
+	      *bits++ = (b >> (16 - fb->width));
+	    }
+	}
+#endif /* HAVE_X_WINDOWS */
+
+#if defined (MAC_OS) && defined (WORDS_BIG_ENDIAN)
+      unsigned short *bits = fb->bits;
+      int j;
+      for (j = 0; j < fb->height; j++)
+	{
+	  unsigned short b = *bits;
+	  *bits++ = ((b >> 8) & 0xff) | ((b & 0xff) << 8);
+	}
+#endif /* MAC_OS && WORDS_BIG_ENDIAN */
+    }
+
+  if (!once_p)
+    {
+      Fdestroy_fringe_bitmap (make_number (which));
+
+      /* XXX Is SELECTED_FRAME OK here? */
+      if (FRAME_RIF (SELECTED_FRAME ())->define_fringe_bitmap)
+	FRAME_RIF (SELECTED_FRAME ())->define_fringe_bitmap (which, fb->bits, fb->height, fb->width);
+
+      fringe_bitmaps[which] = fb;
+      if (which >= max_used_fringe_bitmap)
+	max_used_fringe_bitmap = which + 1;
+    }
+}
+
+
+DEFUN ("define-fringe-bitmap", Fdefine_fringe_bitmap, Sdefine_fringe_bitmap,
+       1, 5, 0,
+       doc: /* Define a fringe bitmap from BITS of height HEIGHT and width WIDTH.
+BITS is either a string or a vector of integers.
+HEIGHT is height of bitmap.  If HEIGHT is nil, use length of BITS.
+WIDTH must be an integer between 1 and 16, or nil which defaults to 8.
+Optional forth arg ALIGN may be one of `top', `center', or `bottom',
+indicating the positioning of the bitmap relative to the rows where it
+is used; the default is to center the bitmap.  Fourth arg may also be a
+list (ALIGN PERIODIC) where PERIODIC non-nil specifies that the bitmap
+should be repeated.
+Optional fifth argument WHICH is bitmap number to redefine.
+Return new bitmap number, or nil of no more free bitmap slots.  */)
+  (bits, height, width, align, which)
+     Lisp_Object bits, height, width, align, which;
+{
+  Lisp_Object len;
+  int n, h, i, j;
+  unsigned short *b;
+  struct fringe_bitmap fb, *xfb;
+  int fill1 = 0, fill2 = 0;
+
+  if (!STRINGP (bits) && !VECTORP (bits))
+    bits = wrong_type_argument (Qstringp, bits);
+
+  len = Flength (bits);
+
+  if (NILP (height))
+    h = fb.height = XINT (len);
+  else
+    {
+      CHECK_NUMBER (height);
+      fb.height = min (XINT (height), 255);
+      if (fb.height > XINT (len))
+	{
+	  h = XINT (len);
+	  fill1 = (fb.height - h) / 2;
+	  fill2 = fb.height - h - fill1;
+	}
+    }
+  
+  if (NILP (width))
+    fb.width = 8;
+  else
+    {
+      CHECK_NUMBER (width);
+      fb.width = min (XINT (width), 255);
+    }
+
+  fb.period = 0;
+  fb.align = ALIGN_BITMAP_CENTER;
+
+  if (CONSP (align))
+    {
+      Lisp_Object period = XCDR (align);
+      if (CONSP (period))
+	{
+	  period = XCAR (period);
+	  if (!NILP (period))
+	    {
+	      fb.period = fb.height;
+	      fb.height = 255;
+	    }
+	}
+      align = XCAR (align);
+    }
+  if (EQ (align, Qtop))
+    fb.align = ALIGN_BITMAP_TOP;
+  else if (EQ (align, Qbottom))
+    fb.align = ALIGN_BITMAP_BOTTOM;
+  else if (!NILP (align) && !EQ (align, Qcenter))
+    error ("Bad align argument");
+
+  if (NILP (which))
+    {
+      if (max_used_fringe_bitmap < MAX_FRINGE_BITMAPS)
+	n = max_used_fringe_bitmap++;
+      else
+	{
+	  for (n = MAX_STANDARD_FRINGE_BITMAPS;
+	       n < MAX_FRINGE_BITMAPS;
+	       n++)
+	    if (fringe_bitmaps[n] == NULL)
+	      break;
+	  if (n == MAX_FRINGE_BITMAPS)
+	    return Qnil;
+	}
+      which = make_number (n);
+    }
+  else
+    {
+      CHECK_NUMBER (which);
+      n = XINT (which);
+      if (n <= NO_FRINGE_BITMAP || n >= MAX_FRINGE_BITMAPS)
+	error ("Invalid fringe bitmap number");
+    }
+
+  fb.dynamic = 1;
+
+  xfb = (struct fringe_bitmap *)xmalloc (sizeof fb
+					 + fb.height * BYTES_PER_BITMAP_ROW);
+  fb.bits = b = (unsigned short *)(xfb+1);
+  bzero (b, fb.height);
+
+  j = 0;
+  while (j < fb.height)
+    {
+      for (i = 0; i < fill1 && j < fb.height; i++)
+	b[j++] = 0;
+      for (i = 0; i < h && j < fb.height; i++)
+	{
+	  Lisp_Object elt = Faref (bits, make_number (i));
+	  b[j++] = NUMBERP (elt) ? XINT (elt) : 0;
+	}
+      for (i = 0; i < fill2 && j < fb.height; i++)
+	b[j++] = 0;
+    }
+
+  *xfb = fb;
+
+  init_fringe_bitmap (n, xfb, 0);
+
+  return which;
+}
+
+DEFUN ("set-fringe-bitmap-face", Fset_fringe_bitmap_face, Sset_fringe_bitmap_face,
+       1, 2, 0,
+       doc:  /* Set face for fringe bitmap FRINGE-ID to FACE.
+If FACE is nil, reset face to default fringe face.  */)
+  (fringe_id, face)
+     Lisp_Object fringe_id, face;
+{
+  int face_id;
+
+  CHECK_NUMBER (fringe_id);
+  if (!valid_fringe_bitmap_id_p (XINT (fringe_id)))
+    error ("Invalid fringe id");
+
+  if (!NILP (face))
+    {
+      face_id = lookup_named_face (SELECTED_FRAME (), face, 'A');
+      if (face_id < 0)
+	error ("No such face");
+    }
+  else
+    face_id = FRINGE_FACE_ID;
+
+  fringe_faces [XINT (fringe_id)] = face_id;
+
+  return Qnil;
+}
+
+DEFUN ("fringe-bitmaps-at-pos", Ffringe_bitmaps_at_pos, Sfringe_bitmaps_at_pos,
+       0, 2, 0,
+       doc:  /* Return fringe bitmaps of row containing position POS in window WINDOW.
+If WINDOW is nil, use selected window.  If POS is nil, use value of point
+in that window.  Return value is a cons (LEFT . RIGHT) where LEFT and RIGHT
+are the fringe bitmap numbers for the bitmaps in the left and right fringe,
+resp.  Return nil if POS is not visible in WINDOW.  */)
+  (pos, window)
+     Lisp_Object pos, window;
+{
+  struct window *w;
+  struct buffer *old_buffer = NULL;
+  struct glyph_row *row;
+  int textpos;
+
+  if (NILP (window))
+    window = selected_window;
+  CHECK_WINDOW (window);
+  w = XWINDOW (window);
+
+  if (!NILP (pos))
+    {
+      CHECK_NUMBER_COERCE_MARKER (pos);
+      textpos = XINT (pos);
+    }
+  else if (w == XWINDOW (selected_window))
+    textpos = PT;
+  else
+    textpos = XMARKER (w->pointm)->charpos;
+
+  row = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
+  row = row_containing_pos (w, textpos, row, NULL, 0);
+  if (row)
+    return Fcons (make_number (row->left_fringe_bitmap),
+		  make_number (row->right_fringe_bitmap));
+  else
+    return Qnil;
+}
+
+
+/***********************************************************************
+			    Initialization
+ ***********************************************************************/
+
+void
+syms_of_fringe ()
+{
+
+  defsubr (&Sdestroy_fringe_bitmap);
+  defsubr (&Sdefine_fringe_bitmap);
+  defsubr (&Sfringe_bitmaps_at_pos);
+  defsubr (&Sset_fringe_bitmap_face);
+
+  DEFVAR_LISP ("overflow-newline-into-fringe", &Voverflow_newline_into_fringe,
+    doc: /* *Non-nil means that newline may flow into the right fringe.
+This means that display lines which are exactly as wide as the window
+(not counting the final newline) will only occupy one screen line, by
+showing (or hiding) the final newline in the right fringe; when point
+is at the final newline, the cursor is shown in the right fringe.
+If nil, also continue lines which are exactly as wide as the window.  */);
+  Voverflow_newline_into_fringe = Qt;
+
+}
+
+/* Initialize this module when Emacs starts.  */
+
+void
+init_fringe_once ()
+{
+  enum fringe_bitmap_type bt;
+
+  for (bt = NO_FRINGE_BITMAP + 1; bt < MAX_STANDARD_FRINGE_BITMAPS; bt++)
+    init_fringe_bitmap(bt, &standard_bitmaps[bt], 1);
+}
+
+void
+init_fringe ()
+{
+  int i;
+
+  bzero (fringe_bitmaps, sizeof fringe_bitmaps);
+  for (i = 0; i < MAX_FRINGE_BITMAPS; i++)
+    fringe_faces[i] = FRINGE_FACE_ID;
+}
+
+#ifdef HAVE_NTGUI
+
+void
+w32_init_fringe ()
+{
+  enum fringe_bitmap_type bt;
+
+  for (bt = NO_FRINGE_BITMAP + 1; bt < MAX_STANDARD_FRINGE_BITMAPS; bt++)
+    {
+      struct fringe_bitmap *fb = &standard_bitmaps[bt];
+      rif->define_fringe_bitmap (bt, fb->bits, fb->height, fb->width);
+    }
+}
+
+void
+w32_reset_fringes ()
+{
+  /* Destroy row bitmaps.  */
+  int bt;
+  
+  for (bt = NO_FRINGE_BITMAP + 1; bt < max_used_fringe_bitmap; bt++)
+    rif->destroy_fringe_bitmap (bt);
+}
+
+#endif /* HAVE_NTGUI */
+
+#endif /* HAVE_WINDOW_SYSTEM */
+
+/* arch-tag: 04596920-43eb-473d-b319-82712338162d
+   (do not change this comment) */
--- a/src/keyboard.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/keyboard.c	Tue Feb 17 01:52:25 2004 +0000
@@ -1322,6 +1322,7 @@
      Lisp_Object arg;
 {
   cancel_hourglass ();
+  return Qnil;
 }
 #endif
 
--- a/src/keymap.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/keymap.c	Tue Feb 17 01:52:25 2004 +0000
@@ -1,5 +1,5 @@
 /* Manipulation of keymaps
-   Copyright (C) 1985, 86,87,88,93,94,95,98,99, 2000, 2001
+   Copyright (C) 1985, 86,87,88,93,94,95,98,99, 2000, 01, 2004
    Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -2321,7 +2321,7 @@
   return Qnil;
 }
 
-static Lisp_Object Vmenu_events;
+static Lisp_Object Vmouse_events;
 
 /* This function can GC if Flookup_key autoloads any keymaps.  */
 
@@ -2378,7 +2378,7 @@
       /* if (nomenus && !ascii_sequence_p (this)) */
       if (nomenus && XINT (last) >= 0
 	  && SYMBOLP (tem = Faref (this, make_number (0)))
-	  && !NILP (Fmemq (XCAR (parse_modifiers (tem)), Vmenu_events)))
+	  && !NILP (Fmemq (XCAR (parse_modifiers (tem)), Vmouse_events)))
 	/* If no menu entries should be returned, skip over the
 	   keymaps bound to `menu-bar' and `tool-bar' and other
 	   non-ascii prefixes like `C-down-mouse-2'.  */
@@ -3710,13 +3710,17 @@
 and applies even for keys that have ordinary bindings.  */);
   Vkey_translation_map = Qnil;
 
-  staticpro (&Vmenu_events);
-  Vmenu_events = Fcons (intern ("menu-bar"),
-                       Fcons (intern ("tool-bar"),
-                              Fcons (intern ("mouse-1"),
-                                     Fcons (intern ("mouse-2"),
-                                            Fcons (intern ("mouse-3"),
-                                                   Qnil)))));
+  staticpro (&Vmouse_events);
+  Vmouse_events = Fcons (intern ("menu-bar"),
+		  Fcons (intern ("tool-bar"),
+		  Fcons (intern ("header-line"),
+		  Fcons (intern ("mode-line"),
+		  Fcons (intern ("mouse-1"),
+		  Fcons (intern ("mouse-2"),
+		  Fcons (intern ("mouse-3"),
+		  Fcons (intern ("mouse-4"),
+		  Fcons (intern ("mouse-5"),
+			 Qnil)))))))));
 
 
   Qsingle_key_description = intern ("single-key-description");
--- a/src/lisp.h	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/lisp.h	Tue Feb 17 01:52:25 2004 +0000
@@ -2301,6 +2301,11 @@
 extern void init_floatfns P_ ((void));
 extern void syms_of_floatfns P_ ((void));
 
+/* Defined in fringe.c */
+extern void syms_of_fringe P_ ((void));
+extern void init_fringe P_ ((void));
+extern void init_fringe_once P_ ((void));
+
 /* Defined in insdel.c */
 extern Lisp_Object Qinhibit_modification_hooks;
 extern void move_gap P_ ((int));
--- a/src/macfns.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/macfns.c	Tue Feb 17 01:52:25 2004 +0000
@@ -7792,12 +7792,25 @@
  ***********************************************************************/
 
 DEFUN ("x-change-window-property", Fx_change_window_property,
-       Sx_change_window_property, 2, 3, 0,
+       Sx_change_window_property, 2, 6, 0,
        doc: /* Change window property PROP to VALUE on the X window of FRAME.
-PROP and VALUE must be strings.  FRAME nil or omitted means use the
-selected frame.  Value is VALUE.  */)
-  (prop, value, frame)
-     Lisp_Object frame, prop, value;
+VALUE may be a string or a list of conses, numbers and/or strings.
+If an element in the list is a string, it is converted to
+an Atom and the value of the Atom is used.  If an element is a cons,
+it is converted to a 32 bit number where the car is the 16 top bits and the
+cdr is the lower 16 bits.
+FRAME nil or omitted means use the selected frame.
+If TYPE is given and non-nil, it is the name of the type of VALUE.
+If TYPE is not given or nil, the type is STRING.
+FORMAT gives the size in bits of each element if VALUE is a list.
+It must be one of 8, 16 or 32.
+If VALUE is a string or FORMAT is nil or not given, FORMAT defaults to 8.
+If OUTER_P is non-nil, the property is changed for the outer X window of
+FRAME.  Default is to change on the edit X window.
+
+Value is VALUE.  */)
+     (prop, value, frame, type, format, outer_p)
+     Lisp_Object prop, value, frame, type, format, outer_p;
 {
 #if 0 /* MAC_TODO : port window properties to Mac */
   struct frame *f = check_x_frame (frame);
--- a/src/macterm.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/macterm.c	Tue Feb 17 01:52:25 2004 +0000
@@ -467,15 +467,21 @@
 /* Mac replacement for XCopyArea.  */
 
 static void
-mac_draw_bitmap (display, w, gc, x, y, bitmap)
+mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
      Display *display;
      WindowPtr w;
      GC gc;
-     int x, y;
-     BitMap *bitmap;
-{
+     int x, y, width, height;
+     unsigned short *bits;
+     int overlay_p;
+{
+  BitMap bitmap;
   Rect r;
 
+  bitmap.rowBytes = sizeof(unsigned short);
+  bitmap.baseAddr = bits;
+  SetRect (&(bitmap.bounds), 0, 0, width, height);
+
 #if TARGET_API_MAC_CARBON
   SetPort (GetWindowPort (w));
 #else
@@ -483,7 +489,7 @@
 #endif
 
   mac_set_colors (gc);
-  SetRect (&r, x, y, x + bitmap->bounds.right, y + bitmap->bounds.bottom);
+  SetRect (&r, x, y, x + bitmap.bounds.right, y + bitmap.bounds.bottom);
 
 #if TARGET_API_MAC_CARBON
   {
@@ -491,11 +497,13 @@
 
     LockPortBits (GetWindowPort (w));
     pmh = GetPortPixMap (GetWindowPort (w));
-    CopyBits (bitmap, (BitMap *) *pmh, &(bitmap->bounds), &r, srcCopy, 0);
+    CopyBits (&bitmap, (BitMap *) *pmh, &(bitmap.bounds), &r,
+	      overlay_p ? srcOr : srcCopy, 0);
     UnlockPortBits (GetWindowPort (w));
   }
 #else /* not TARGET_API_MAC_CARBON */
-  CopyBits (bitmap, &(w->portBits), &(bitmap->bounds), &r, srcCopy, 0);
+  CopyBits (&bitmap, &(w->portBits), &(bitmap.bounds), &r,
+	    overlay_p ? srcOr : srcCopy, 0);
 #endif /* not TARGET_API_MAC_CARBON */
 }
 
@@ -1313,7 +1321,7 @@
   else
     x_clip_to_row (w, row, gc);
 
-  if (p->bx >= 0)
+  if (p->bx >= 0 && !p->overlay_p)
     {
       XGCValues gcv;
       gcv.foreground = face->background;
@@ -1339,18 +1347,18 @@
 #endif
     }
 
-  if (p->which != NO_FRINGE_BITMAP)
-    {
-      unsigned char *bits = fringe_bitmaps[p->which].bits + p->dh;
-      BitMap bitmap;
-
-      mac_create_bitmap_from_bitmap_data (&bitmap, bits, p->wd, p->h);
-      gcv.foreground = face->foreground;
+  if (p->which)
+    {
+      unsigned short *bits = p->bits + p->dh;
+
+      gcv.foreground = (p->cursor_p
+			? (p->overlay_p ? face->background
+			   : f->output_data.mac->cursor_pixel)
+			: face->foreground);
       gcv.background = face->background;
 
-      mac_draw_bitmap (display, window, &gcv, p->x, p->y, &bitmap);
-
-      mac_free_bitmap (&bitmap);
+      mac_draw_bitmap (display, window, &gcv, p->x, p->y, 
+		       p->wd, p->h, bits, p->overlay_p);
     }
 
   mac_reset_clipping (display, window);
@@ -6455,12 +6463,19 @@
 
 Boolean	terminate_flag = false;
 
+/* Contains the string "reverse", which is a constant for mouse button emu.*/
+Lisp_Object Qreverse;
+
 /* True if using command key as meta key.  */
 Lisp_Object Vmac_command_key_is_meta;
 
 /* True if the ctrl and meta keys should be reversed.  */
 Lisp_Object Vmac_reverse_ctrl_meta;
 
+/* True if the option and command modifiers should be used to emulate
+   a three button mouse */
+Lisp_Object Vmac_emulate_three_button_mouse;
+
 #if USE_CARBON_EVENTS
 /* True if the mouse wheel button (i.e. button 4) should map to
    mouse-2, instead of mouse-3.  */
@@ -6533,6 +6548,20 @@
   return result;
 }
 
+static int
+mac_get_emulated_btn ( UInt32 modifiers )
+{
+  int result = 0;
+  if (Vmac_emulate_three_button_mouse != Qnil) {
+    int cmdIs3 = (Vmac_emulate_three_button_mouse != Qreverse);
+    if (modifiers & controlKey)
+      result = cmdIs3 ? 2 : 1;
+    else if (modifiers & optionKey)
+      result = cmdIs3 ? 1 : 2;      
+  }
+  return result;
+}
+
 #if USE_CARBON_EVENTS
 /* Obtains the event modifiers from the event ref and then calls
    mac_to_emacs_modifiers.  */
@@ -6542,6 +6571,11 @@
   UInt32 mods = 0;
   GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL,
 		    sizeof (UInt32), NULL, &mods);
+  if (Vmac_emulate_three_button_mouse != Qnil &&
+      GetEventClass(eventRef) == kEventClassMouse)
+    {
+      mods &= ~(optionKey & cmdKey);
+    }
   return mac_to_emacs_modifiers (mods);
 }
 
@@ -6556,7 +6590,14 @@
   switch (result)
     {
     case kEventMouseButtonPrimary:
-      return 0;
+      if (Vmac_emulate_three_button_mouse == Qnil) 
+	return 0;
+      else {
+	UInt32 mods = 0;
+	GetEventParameter (ref, kEventParamKeyModifiers, typeUInt32, NULL,
+			   sizeof (UInt32), NULL, &mods);
+	return mac_get_emulated_btn(mods);
+      }
     case kEventMouseButtonSecondary:
       return NILP (Vmac_wheel_button_is_mouse_2) ? 1 : 2;
     case kEventMouseButtonTertiary:
@@ -7692,7 +7733,7 @@
 #if USE_CARBON_EVENTS
 	      bufp->code = mac_get_mouse_btn (eventRef);
 #else
-	      bufp->code = 0;  /* only one mouse button */
+	      bufp_.code = mac_get_emulate_btn (er.modifiers);
 #endif
               bufp->kind = SCROLL_BAR_CLICK_EVENT;
               bufp->frame_or_window = tracked_scroll_bar->window;
@@ -7760,7 +7801,7 @@
 #if USE_CARBON_EVENTS
 		  bufp->code = mac_get_mouse_btn (eventRef);
 #else
-	          bufp->code = 0;  /* only one mouse button */
+		  bufp_.code = mac_get_emulate_btn (er.modifiers);
 #endif
 		  XSETINT (bufp->x, mouse_loc.h);
 		  XSETINT (bufp->y, mouse_loc.v);
@@ -8517,6 +8558,8 @@
   x_get_glyph_overhangs,
   x_fix_overlapping_area,
   x_draw_fringe_bitmap,
+  0, /* define_fringe_bitmap */
+  0, /* destroy_fringe_bitmap */
   mac_per_char_metric,
   mac_encode_char,
   NULL, /* mac_compute_glyph_string_overhangs */
@@ -8636,6 +8679,9 @@
 
   Fprovide (intern ("mac-carbon"), Qnil);
 
+  staticpro (&Qreverse);
+  Qreverse = intern ("reverse");
+
   staticpro (&x_display_name_list);
   x_display_name_list = Qnil;
 
@@ -8680,6 +8726,17 @@
 	    useful for non-standard keyboard layouts.  */);
   Vmac_reverse_ctrl_meta = Qnil;
 
+  DEFVAR_LISP ("mac-emulate-three-button-mouse", 
+	       &Vmac_emulate_three_button_mouse,
+    doc: /* t means that when the option-key is held down while pressing the
+    mouse button, the click will register as mouse-2 and while the 
+    command-key is held down, the click will register as mouse-3.
+    'reverse means that the the option-key will register for mouse-3
+    and the command-key will register for mouse-2.  nil means that
+    not emulation should be done and the modifiers should be placed
+    on the mouse-1 event. */);
+  Vmac_emulate_three_button_mouse = Qnil;
+
 #if USE_CARBON_EVENTS
   DEFVAR_LISP ("mac-wheel-button-is-mouse-2", &Vmac_wheel_button_is_mouse_2,
    doc: /* Non-nil means that the wheel button will be treated as mouse-2 and
--- a/src/makefile.w32-in	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/makefile.w32-in	Tue Feb 17 01:52:25 2004 +0000
@@ -118,7 +118,8 @@
 	$(BLD)/coding.$(O)			\
 	$(BLD)/category.$(O)			\
 	$(BLD)/ccl.$(O)				\
-	$(BLD)/fontset.$(O)
+	$(BLD)/fontset.$(O)			\
+	$(BLD)/fringe.$(O)
 
 WIN32OBJ = $(BLD)/w32term.$(O)			\
 	   $(BLD)/w32xfns.$(O)			\
--- a/src/minibuf.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/minibuf.c	Tue Feb 17 01:52:25 2004 +0000
@@ -132,6 +132,8 @@
 
 Lisp_Object Qcurrent_input_method, Qactivate_input_method;
 
+Lisp_Object Qcase_fold_search;
+
 extern Lisp_Object Qmouse_face;
 
 extern Lisp_Object Qfield;
@@ -322,7 +324,8 @@
 DEFUN ("minibufferp", Fminibufferp,
        Sminibufferp, 0, 1, 0,
        doc: /* Return t if BUFFER is a minibuffer.
-No argument or nil as argument means use current buffer as BUFFER.*/)
+No argument or nil as argument means use current buffer as BUFFER.
+BUFFER can be a buffer or a buffer name.  */)
      (buffer)
      Lisp_Object buffer;
 {
@@ -411,9 +414,9 @@
    with initial position HISTPOS.  INITIAL should be a string or a
    cons of a string and an integer.  BACKUP_N should be <= 0, or
    Qnil, which is equivalent to 0.  If INITIAL is a cons, BACKUP_N is
-   ignored and replaced with an integer that puts point N characters
-   from the beginning of INITIAL, where N is the CDR of INITIAL, or at
-   the beginning of INITIAL if N <= 0.
+   ignored and replaced with an integer that puts point at one-indexed
+   position N in INITIAL, where N is the CDR of INITIAL, or at the
+   beginning of INITIAL if N <= 0.
 
    Normally return the result as a string (the text that was read),
    but if EXPFLAG is nonzero, read it and return the object read.
@@ -898,23 +901,22 @@
 
 DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1, 7, 0,
        doc: /* Read a string from the minibuffer, prompting with string PROMPT.
-If optional second arg INITIAL-CONTENTS is non-nil, it is a string
-  to be inserted into the minibuffer before reading input.
-  If INITIAL-CONTENTS is (STRING . POSITION), the initial input
-  is STRING, but point is placed at position POSITION in the minibuffer.
+The optional second arg INITIAL-CONTENTS is an obsolete alternative to
+  DEFAULT-VALUE.  It normally should be nil in new code, except when
+  HIST is a cons.  It is discussed in more detail below.
 Third arg KEYMAP is a keymap to use whilst reading;
   if omitted or nil, the default is `minibuffer-local-map'.
 If fourth arg READ is non-nil, then interpret the result as a Lisp object
   and return that object:
   in other words, do `(car (read-from-string INPUT-STRING))'
-Fifth arg HIST, if non-nil, specifies a history list
-  and optionally the initial position in the list.
-  It can be a symbol, which is the history list variable to use,
-  or it can be a cons cell (HISTVAR . HISTPOS).
-  In that case, HISTVAR is the history list variable to use,
-  and HISTPOS is the initial position (the position in the list
-  which INITIAL-CONTENTS corresponds to).
-  Positions are counted starting from 1 at the beginning of the list.
+Fifth arg HIST, if non-nil, specifies a history list and optionally
+  the initial position in the list.  It can be a symbol, which is the
+  history list variable to use, or it can be a cons cell
+  (HISTVAR . HISTPOS).  In that case, HISTVAR is the history list variable
+  to use, and HISTPOS is the initial position for use by the minibuffer
+  history commands.  For consistency, you should also specify that
+  element of the history as the value of INITIAL-CONTENTS.  Positions
+  are counted starting from 1 at the beginning of the list.
 Sixth arg DEFAULT-VALUE is the default value.  If non-nil, it is available
   for history commands; but, unless READ is non-nil, `read-from-minibuffer'
   does NOT return DEFAULT-VALUE if the user enters empty input!  It returns
@@ -923,7 +925,19 @@
  the current input method and the setting of `enable-multibyte-characters'.
 If the variable `minibuffer-allow-text-properties' is non-nil,
  then the string which is returned includes whatever text properties
- were present in the minibuffer.  Otherwise the value has no text properties.  */)
+ were present in the minibuffer.  Otherwise the value has no text properties.
+
+The remainder of this documentation string describes the
+INITIAL-CONTENTS argument in more detail.  It is only relevant when
+studying existing code, or when HIST is a cons.  If non-nil,
+INITIAL-CONTENTS is a string to be inserted into the minibuffer before
+reading input.  Normally, point is put at the end of that string.
+However, if INITIAL-CONTENTS is \(STRING . POSITION), the initial
+input is STRING, but point is placed at _one-indexed_ position
+POSITION in the minibuffer.  Any integer value less than or equal to
+one puts point at the beginning of the string.  *Note* that this
+behavior differs from the way such arguments are used in `completing-read'
+and some related functions, which use zero-indexing for POSITION.  */)
      (prompt, initial_contents, keymap, read, hist, default_value, inherit_input_method)
      Lisp_Object prompt, initial_contents, keymap, read, hist, default_value;
      Lisp_Object inherit_input_method;
@@ -963,9 +977,11 @@
 }
 
 DEFUN ("read-minibuffer", Fread_minibuffer, Sread_minibuffer, 1, 2, 0,
-       doc: /* Return a Lisp object read using the minibuffer.
+       doc: /* Return a Lisp object read using the minibuffer, unevaluated.
 Prompt with PROMPT.  If non-nil, optional second arg INITIAL-CONTENTS
-is a string to insert in the minibuffer before reading.  */)
+is a string to insert in the minibuffer before reading.
+\(INITIAL-CONTENTS can also be a cons of a string and an integer.  Such
+arguments are used as in `read-from-minibuffer')  */)
      (prompt, initial_contents)
      Lisp_Object prompt, initial_contents;
 {
@@ -978,7 +994,9 @@
 DEFUN ("eval-minibuffer", Feval_minibuffer, Seval_minibuffer, 1, 2, 0,
        doc: /* Return value of Lisp expression read using the minibuffer.
 Prompt with PROMPT.  If non-nil, optional second arg INITIAL-CONTENTS
-is a string to insert in the minibuffer before reading.  */)
+is a string to insert in the minibuffer before reading.
+\(INITIAL-CONTENTS can also be a cons of a string and an integer.  Such
+arguments are used as in `read-from-minibuffer')  */)
      (prompt, initial_contents)
      Lisp_Object prompt, initial_contents;
 {
@@ -990,6 +1008,9 @@
 DEFUN ("read-string", Fread_string, Sread_string, 1, 5, 0,
        doc: /* Read a string from the minibuffer, prompting with string PROMPT.
 If non-nil, second arg INITIAL-INPUT is a string to insert before reading.
+  This argument has been superseded by DEFAULT-VALUE and should normally
+  be nil in new code.  It behaves as in `read-from-minibuffer'.  See the
+  documentation string of that function for details.
 The third arg HISTORY, if non-nil, specifies a history list
   and optionally the initial position in the list.
 See `read-from-minibuffer' for details of HISTORY argument.
@@ -1013,9 +1034,14 @@
 
 DEFUN ("read-no-blanks-input", Fread_no_blanks_input, Sread_no_blanks_input, 1, 3, 0,
        doc: /* Read a string from the terminal, not allowing blanks.
-Prompt with PROMPT, and provide INITIAL as an initial value of the input string.
+Prompt with PROMPT.  Whitespace terminates the input.  If INITIAL is
+non-nil, it should be a string, which is used as initial input, with
+point positioned at the end, so that SPACE will accept the input.
+\(Actually, INITIAL can also be a cons of a string and an integer.
+Such values are treated as in `read-from-minibuffer', but are normally
+not useful in this function.)
 Third arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits
-the current input method and the setting of `enable-multibyte-characters'.  */)
+the current input method and the setting of`enable-multibyte-characters'.  */)
      (prompt, initial, inherit_input_method)
      Lisp_Object prompt, initial, inherit_input_method;
 {
@@ -1243,7 +1269,7 @@
 	  && (tem = Fcompare_strings (eltstring, make_number (0),
 				      make_number (SCHARS (string)),
 				      string, make_number (0), Qnil,
-				      completion_ignore_case ?Qt : Qnil),
+				      completion_ignore_case ? Qt : Qnil),
 	      EQ (Qt, tem)))
 	{
 	  /* Yes. */
@@ -1252,15 +1278,20 @@
 	  XSETFASTINT (zero, 0);
 
 	  /* Ignore this element if it fails to match all the regexps.  */
-	  for (regexps = Vcompletion_regexp_list; CONSP (regexps);
-	       regexps = XCDR (regexps))
-	    {
-	      tem = Fstring_match (XCAR (regexps), eltstring, zero);
-	      if (NILP (tem))
-		break;
-	    }
-	  if (CONSP (regexps))
-	    continue;
+	  {
+	    int count = SPECPDL_INDEX ();
+	    specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil);
+	    for (regexps = Vcompletion_regexp_list; CONSP (regexps);
+		 regexps = XCDR (regexps))
+	      {
+		tem = Fstring_match (XCAR (regexps), eltstring, zero);
+		if (NILP (tem))
+		  break;
+	      }
+	    unbind_to (count, Qnil);
+	    if (CONSP (regexps))
+	      continue;
+	  }
 
 	  /* Ignore this element if there is a predicate
 	     and the predicate doesn't like it. */
@@ -1498,15 +1529,20 @@
 	  XSETFASTINT (zero, 0);
 
 	  /* Ignore this element if it fails to match all the regexps.  */
-	  for (regexps = Vcompletion_regexp_list; CONSP (regexps);
-	       regexps = XCDR (regexps))
-	    {
-	      tem = Fstring_match (XCAR (regexps), eltstring, zero);
-	      if (NILP (tem))
-		break;
-	    }
-	  if (CONSP (regexps))
-	    continue;
+	  {
+	    int count = SPECPDL_INDEX ();
+	    specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil);
+	    for (regexps = Vcompletion_regexp_list; CONSP (regexps);
+		 regexps = XCDR (regexps))
+	      {
+		tem = Fstring_match (XCAR (regexps), eltstring, zero);
+		if (NILP (tem))
+		  break;
+	      }
+	    unbind_to (count, Qnil);
+	    if (CONSP (regexps))
+	      continue;
+	  }
 
 	  /* Ignore this element if there is a predicate
 	     and the predicate doesn't like it. */
@@ -1542,7 +1578,7 @@
 DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 8, 0,
        doc: /* Read a string in the minibuffer, with completion.
 PROMPT is a string to prompt with; normally it ends in a colon and a space.
-TABLE is an alist whose elements' cars are strings, or an obarray.
+TABLE can be an list of strings, an alist, an obarray or a hash table.
 TABLE can also be a function to do the completion itself.
 PREDICATE limits completion to a subset of TABLE.
 See `try-completion' and `all-completions' for more details
@@ -1551,26 +1587,30 @@
 If REQUIRE-MATCH is non-nil, the user is not allowed to exit unless
  the input is (or completes to) an element of TABLE or is null.
  If it is also not t, typing RET does not exit if it does non-null completion.
-If the input is null, `completing-read' returns an empty string,
- regardless of the value of REQUIRE-MATCH.
-
-If INITIAL-INPUT is non-nil, insert it in the minibuffer initially.
-  If it is (STRING . POSITION), the initial input
-  is STRING, but point is placed POSITION characters into the string.
-  This feature is deprecated--it is best to pass nil for INITIAL-INPUT
-  and supply the default value DEF instead.  The user can yank the
-  default value into the minibuffer easily using \\[next-history-element].
-
-HIST, if non-nil, specifies a history list
-  and optionally the initial position in the list.
-  It can be a symbol, which is the history list variable to use,
-  or it can be a cons cell (HISTVAR . HISTPOS).
-  In that case, HISTVAR is the history list variable to use,
-  and HISTPOS is the initial position (the position in the list
-  which INITIAL-INPUT corresponds to).
-  Positions are counted starting from 1 at the beginning of the list.
-  The variable `history-length' controls the maximum length of a
-  history list.
+If the input is null, `completing-read' returns DEF, or an empty string
+ if DEF is nil, regardless of the value of REQUIRE-MATCH.
+
+If INITIAL-INPUT is non-nil, insert it in the minibuffer initially,
+  with point positioned at the end.
+  If it is (STRING . POSITION), the initial input is STRING, but point
+  is placed at _zero-indexed_ position POSITION in STRING.  (*Note*
+  that this is different from `read-from-minibuffer' and related
+  functions, which use one-indexing for POSITION.)  This feature is
+  deprecated--it is best to pass nil for INITIAL-INPUT and supply the
+  default value DEF instead.  The user can yank the default value into
+  the minibuffer easily using \\[next-history-element].
+
+HIST, if non-nil, specifies a history list and optionally the initial
+  position in the list.  It can be a symbol, which is the history list
+  variable to use, or it can be a cons cell (HISTVAR . HISTPOS).  In
+  that case, HISTVAR is the history list variable to use, and HISTPOS
+  is the initial position (the position in the list used by the
+  minibuffer history commands).  For consistency, you should also
+  specify that element of the history as the value of
+  INITIAL-CONTENTS.  (This is the only case in which you should use
+  INITIAL-INPUT instead of DEF.)  Positions are counted starting from
+  1 at the beginning of the list.  The variable `history-length'
+  controls the maximum length of a history list.
 
 DEF, if non-nil, is the default value.
 
@@ -1737,20 +1777,27 @@
     return call3 (alist, string, predicate, Qlambda);
 
   /* Reject this element if it fails to match all the regexps.  */
-  for (regexps = Vcompletion_regexp_list; CONSP (regexps);
-       regexps = XCDR (regexps))
-    {
-      if (NILP (Fstring_match (XCAR (regexps),
-			       SYMBOLP (tem) ? string : tem,
-			       Qnil)))
-	return Qnil;
-    }
+  {
+    int count = SPECPDL_INDEX ();
+    specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil);
+    for (regexps = Vcompletion_regexp_list; CONSP (regexps);
+	 regexps = XCDR (regexps))
+      {
+	if (NILP (Fstring_match (XCAR (regexps),
+				 SYMBOLP (tem) ? string : tem,
+				 Qnil)))
+	  return unbind_to (count, Qnil);
+      }
+    unbind_to (count, Qnil);
+  }
 
   /* Finally, check the predicate.  */
   if (!NILP (predicate))
-    return HASH_TABLE_P (alist)
-      ? call2 (predicate, tem, HASH_VALUE (XHASH_TABLE (alist), i))
-      : call1 (predicate, tem);
+    {
+      return HASH_TABLE_P (alist)
+	? call2 (predicate, tem, HASH_VALUE (XHASH_TABLE (alist), i))
+	: call1 (predicate, tem);
+    }
   else
     return Qt;
 }
@@ -2212,6 +2259,8 @@
        doc: /* Display the list of completions, COMPLETIONS, using `standard-output'.
 Each element may be just a symbol or string
 or may be a list of two strings to be printed as if concatenated.
+If it is a list of two strings, the first is the actual completion
+alternative, the second serves as annotation.
 `standard-output' must be a buffer.
 The actual completion alternatives, as inserted, are given `mouse-face'
 properties of `highlight'.
@@ -2252,6 +2301,8 @@
 	  startpos = Qnil;
 
 	  elt = Fcar (tail);
+	  if (SYMBOLP (elt))
+	    elt = SYMBOL_NAME (elt);
 	  /* Compute the length of this element.  */
 	  if (CONSP (elt))
 	    {
@@ -2563,6 +2614,9 @@
   Qactivate_input_method = intern ("activate-input-method");
   staticpro (&Qactivate_input_method);
 
+  Qcase_fold_search = intern ("case-fold-search");
+  staticpro (&Qcase_fold_search);
+
   DEFVAR_LISP ("read-buffer-function", &Vread_buffer_function,
 	       doc: /* If this is non-nil, `read-buffer' does its work by calling this function.  */);
   Vread_buffer_function = Qnil;
@@ -2597,7 +2651,8 @@
 
   DEFVAR_LISP ("minibuffer-completion-table", &Vminibuffer_completion_table,
 	       doc: /* Alist or obarray used for completion in the minibuffer.
-This becomes the ALIST argument to `try-completion' and `all-completion'.
+This becomes the ALIST argument to `try-completion' and `all-completions'.
+The value can also be a list of strings or a hash table.
 
 The value may alternatively be a function, which is given three arguments:
   STRING, the current buffer contents;
@@ -2644,7 +2699,12 @@
   minibuffer_auto_raise = 0;
 
   DEFVAR_LISP ("completion-regexp-list", &Vcompletion_regexp_list,
-	       doc: /* List of regexps that should restrict possible completions.  */);
+	       doc: /* List of regexps that should restrict possible completions.
+The basic completion functions only consider a completion acceptable
+if it matches all regular expressions in this list, with
+`case-fold-search' bound to the value of `completion-ignore-case'.
+See Info node `(elisp)Basic Completion', for a description of these
+functions.  */);
   Vcompletion_regexp_list = Qnil;
 
   DEFVAR_BOOL ("minibuffer-allow-text-properties",
--- a/src/process.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/process.c	Tue Feb 17 01:52:25 2004 +0000
@@ -4262,7 +4262,7 @@
 	  else
 	    Available = input_wait_mask;
 	  check_connect = (num_pending_connects > 0);
-	  check_delay = process_output_delay_count;
+ 	  check_delay = wait_channel >= 0 ? 0 : process_output_delay_count;
 	}
 
       /* If frame size has changed or the window is newly mapped,
--- a/src/region-cache.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/region-cache.c	Tue Feb 17 01:52:25 2004 +0000
@@ -21,12 +21,12 @@
 
 
 #include <config.h>
+#include <stdio.h>
+
 #include "lisp.h"
 #include "buffer.h"
 #include "region-cache.h"
 
-#include <stdio.h>
-
 
 /* Data structures.  */
 
--- a/src/sysdep.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/sysdep.c	Tue Feb 17 01:52:25 2004 +0000
@@ -24,6 +24,7 @@
 #endif
 
 #include <signal.h>
+#include <stdio.h>
 #include <setjmp.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -82,7 +83,6 @@
 #undef fwrite
 #endif
 
-#include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <errno.h>
--- a/src/w32fns.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/w32fns.c	Tue Feb 17 01:52:25 2004 +0000
@@ -5558,6 +5558,11 @@
             (Fcheck_coding_system (Vlocale_coding_system), &coding);
 	  coding.src_multibyte = 1;
 	  coding.dst_multibyte = 1;
+	  /* Need to set COMPOSITION_DISABLED, otherwise Emacs crashes in
+	     encode_coding_iso2022 trying to dereference a null pointer.  */
+	  coding.composing = COMPOSITION_DISABLED;
+	  if (coding.type == coding_type_iso2022)
+	    coding.flags |= CODING_FLAG_ISO_SAFE;
 	  bufsize = encoding_buffer_size (&coding, strlen (name));
 	  buf = (unsigned char *) alloca (bufsize);
           coding.mode |= CODING_MODE_LAST_BLOCK;
@@ -12400,12 +12405,25 @@
  ***********************************************************************/
 
 DEFUN ("x-change-window-property", Fx_change_window_property,
-       Sx_change_window_property, 2, 3, 0,
+       Sx_change_window_property, 2, 6, 0,
        doc: /* Change window property PROP to VALUE on the X window of FRAME.
-PROP and VALUE must be strings.  FRAME nil or omitted means use the
-selected frame.  Value is VALUE.  */)
-  (prop, value, frame)
-     Lisp_Object frame, prop, value;
+VALUE may be a string or a list of conses, numbers and/or strings.
+If an element in the list is a string, it is converted to
+an Atom and the value of the Atom is used.  If an element is a cons,
+it is converted to a 32 bit number where the car is the 16 top bits and the
+cdr is the lower 16 bits.
+FRAME nil or omitted means use the selected frame.
+If TYPE is given and non-nil, it is the name of the type of VALUE.
+If TYPE is not given or nil, the type is STRING.
+FORMAT gives the size in bits of each element if VALUE is a list.
+It must be one of 8, 16 or 32.
+If VALUE is a string or FORMAT is nil or not given, FORMAT defaults to 8.
+If OUTER_P is non-nil, the property is changed for the outer X window of
+FRAME.  Default is to change on the edit X window.
+
+Value is VALUE.  */)
+     (prop, value, frame, type, format, outer_p)
+     Lisp_Object prop, value, frame, type, format, outer_p;
 {
 #if 0 /* TODO : port window properties to W32 */
   struct frame *f = check_x_frame (frame);
--- a/src/w32select.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/w32select.c	Tue Feb 17 01:52:25 2004 +0000
@@ -212,6 +212,11 @@
 	  }
 	coding.src_multibyte = 1;
 	coding.dst_multibyte = 0;
+	/* Need to set COMPOSITION_DISABLED, otherwise Emacs crashes in
+	   encode_coding_iso2022 trying to dereference a null pointer.  */
+	coding.composing = COMPOSITION_DISABLED;
+	if (coding.type == coding_type_iso2022)
+	  coding.flags |= CODING_FLAG_ISO_SAFE;
 	Vnext_selection_coding_system = Qnil;
 	coding.mode |= CODING_MODE_LAST_BLOCK;
 	bufsize = encoding_buffer_size (&coding, nbytes);
--- a/src/w32term.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/w32term.c	Tue Feb 17 01:52:25 2004 +0000
@@ -698,28 +698,46 @@
   else
     w32_clip_to_row (w, row, hdc);
 
-  if (p->bx >= 0)
+  if (p->bx >= 0 && !p->overlay_p)
     {
       w32_fill_area (f, hdc, face->background,
 		     p->bx, p->by, p->nx, p->ny);
     }
 
-  if (p->which != NO_FRINGE_BITMAP)
+  if (p->which)
     {
       HBITMAP pixmap = fringe_bmp[p->which];
       HDC compat_hdc;
       HANDLE horig_obj;
 
       compat_hdc = CreateCompatibleDC (hdc);
+
       SaveDC (hdc);
 
       horig_obj = SelectObject (compat_hdc, pixmap);
       SetTextColor (hdc, face->background);
-      SetBkColor (hdc, face->foreground);
-
-      BitBlt (hdc, p->x, p->y, p->wd, p->h,
-	      compat_hdc, 0, p->dh,
-	      SRCCOPY);
+      SetBkColor (hdc, p->cursor_p
+		        ? (p->overlay_p ? face->background
+			   : f->output_data.w32->cursor_pixel)
+			   : face->foreground);
+
+      /* Paint overlays transparently.  */
+      if (p->overlay_p)
+	{
+	BitBlt (hdc, p->x, p->y, p->wd, p->h,
+		compat_hdc, 0, p->dh,
+		DSTINVERT);
+	BitBlt (hdc, p->x, p->y, p->wd, p->h,
+		compat_hdc, 0, p->dh,
+		MERGEPAINT);
+	BitBlt (hdc, p->x, p->y, p->wd, p->h,
+		compat_hdc, 0, p->dh,
+		DSTINVERT);
+	}
+      else
+	BitBlt (hdc, p->x, p->y, p->wd, p->h,
+		compat_hdc, 0, p->dh,
+		SRCCOPY);
 
       SelectObject (compat_hdc, horig_obj);
       DeleteDC (compat_hdc);
@@ -731,6 +749,25 @@
   release_frame_dc (f, hdc);
 }
 
+static void
+w32_define_fringe_bitmap (which, bits, h, wd)
+     int which;
+     unsigned short *bits;
+     int h, wd;
+{
+  fringe_bmp[which] = CreateBitmap (wd, h, 1, 1, bits);
+}
+
+static void
+w32_destroy_fringe_bitmap (which)
+     int which;
+{
+  if (fringe_bmp[which])
+    DeleteObject (fringe_bmp[which]);
+  fringe_bmp[which] = 0;
+}
+
+
 
 /* This is called when starting Emacs and when restarting after
    suspend.  When starting Emacs, no window is mapped.  And nothing
@@ -6220,32 +6257,7 @@
      horizontally reflected compared to how they appear on X, so we
      need to bitswap and convert to unsigned shorts before creating
      the bitmaps.  */
-  {
-    int i, j;
-
-    for (i = NO_FRINGE_BITMAP + 1; i < MAX_FRINGE_BITMAPS; i++)
-      {
-	int h = fringe_bitmaps[i].height;
-	int wd = fringe_bitmaps[i].width;
-	unsigned short *w32bits
-	  = (unsigned short *)alloca (h * sizeof (unsigned short));
-	unsigned short *wb = w32bits;
-	unsigned char *bits = fringe_bitmaps[i].bits;
-	for (j = 0; j < h; j++)
-	  {
-	    static unsigned char swap_nibble[16]
-	      = { 0x0, 0x8, 0x4, 0xc,    /* 0000 1000 0100 1100 */
-		  0x2, 0xa, 0x6, 0xe,    /* 0010 1010 0110 1110 */
-		  0x1, 0x9, 0x5, 0xd,    /* 0001 1001 0101 1101 */
-		  0x3, 0xb, 0x7, 0xf };	 /* 0011 1011 0111 1111 */
-
-	    unsigned char b = *bits++;
-	    *wb++ = (unsigned short)((swap_nibble[b & 0xf]<<4)
-				     | (swap_nibble[(b>>4) & 0xf]));
-	  }
-	fringe_bmp[i] = CreateBitmap (wd, h, 1, 1, w32bits);
-      }
-  }
+  w32_init_fringe ();
 
 #ifndef F_SETOWN_BUG
 #ifdef F_SETOWN
@@ -6313,13 +6325,7 @@
   xfree (dpyinfo->font_table);
   xfree (dpyinfo->w32_id_name);
 
-  /* Destroy row bitmaps.  */
-  {
-    int i;
-
-    for (i = NO_FRINGE_BITMAP + 1; i < MAX_FRINGE_BITMAPS; i++)
-      DeleteObject (fringe_bmp[i]);
-  }
+  w32_reset_fringes ();
 }
 
 /* Set up use of W32.  */
@@ -6350,6 +6356,8 @@
   w32_get_glyph_overhangs,
   x_fix_overlapping_area,
   w32_draw_fringe_bitmap,
+  w32_define_fringe_bitmap,
+  w32_destroy_fringe_bitmap,
   w32_per_char_metric,
   w32_encode_char,
   NULL, /* w32_compute_glyph_string_overhangs */
--- a/src/window.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/window.c	Tue Feb 17 01:52:25 2004 +0000
@@ -6018,9 +6018,7 @@
        0, 1, 0,
        doc: /* Get width of fringes of window WINDOW.
 If WINDOW is omitted or nil, use the currently selected window.
-Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS).
-If a window specific fringe width is not set, its width will be returned
-as nil.  */)
+Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS).  */)
      (window)
      Lisp_Object window;
 {
--- a/src/xdisp.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/xdisp.c	Tue Feb 17 01:52:25 2004 +0000
@@ -311,10 +311,7 @@
 Lisp_Object Vshow_trailing_whitespace;
 
 #ifdef HAVE_WINDOW_SYSTEM
-/* Non-nil means that newline may flow into the right fringe.  */
-
-Lisp_Object Voverflow_newline_into_fringe;
-#endif /* HAVE_WINDOW_SYSTEM */
+extern Lisp_Object Voverflow_newline_into_fringe;
 
 /* Test if overflow newline into fringe.  Called with iterator IT
    at or past right window margin, and with IT->current_x set.  */ 
@@ -325,6 +322,8 @@
    && WINDOW_RIGHT_FRINGE_WIDTH (it->w) > 0	\
    && it->current_x == it->last_visible_x)
 
+#endif /* HAVE_WINDOW_SYSTEM */
+
 /* Non-nil means show the text cursor in void text areas
    i.e. in blank areas after eol and eob.  This used to be
    the default in 21.3.  */
@@ -3275,6 +3274,8 @@
       && !EQ (XCAR (prop), Qraise)
       /* Marginal area specifications.  */
       && !(CONSP (XCAR (prop)) && EQ (XCAR (XCAR (prop)), Qmargin))
+      && !EQ (XCAR (prop), Qleft_fringe)
+      && !EQ (XCAR (prop), Qright_fringe)
       && !NILP (XCAR (prop)))
     {
       for (; CONSP (prop); prop = XCDR (prop))
@@ -3481,6 +3482,43 @@
 	}
 #endif /* HAVE_WINDOW_SYSTEM */
     }
+  else if (CONSP (prop)
+	   && (EQ (XCAR (prop), Qleft_fringe)
+	       || EQ (XCAR (prop), Qright_fringe))
+	   && CONSP (XCDR (prop)))
+    {
+      unsigned face_id = DEFAULT_FACE_ID;
+
+      /* `(left-fringe BITMAP FACE)'.  */
+      if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f))
+	return 0;
+
+#ifdef HAVE_WINDOW_SYSTEM
+      value = XCAR (XCDR (prop));
+      if (!NUMBERP (value)
+	  || !valid_fringe_bitmap_id_p (XINT (value)))
+	return 0;
+
+      if (CONSP (XCDR (XCDR (prop))))
+	{
+	  Lisp_Object face_name = XCAR (XCDR (XCDR (prop)));
+	  face_id = lookup_named_face (it->f, face_name, 'A');
+	  if (face_id < 0)
+	    return 0;
+	}
+
+      if (EQ (XCAR (prop), Qleft_fringe))
+	{
+	  it->left_user_fringe_bitmap = XINT (value);
+	  it->left_user_fringe_face_id = face_id;
+	}
+      else
+	{
+	  it->right_user_fringe_bitmap = XINT (value);
+	  it->right_user_fringe_face_id = face_id;
+	}
+#endif /* HAVE_WINDOW_SYSTEM */
+    }
   else if (!it->string_from_display_prop_p)
     {
       /* `((margin left-margin) VALUE)' or `((margin right-margin)
@@ -5610,7 +5648,11 @@
 #ifdef HAVE_WINDOW_SYSTEM
 			  if (IT_OVERFLOW_NEWLINE_INTO_FRINGE (it))
 			    {
-			      get_next_display_element (it);
+			      if (!get_next_display_element (it))
+				{
+				  result = MOVE_POS_MATCH_OR_ZV;
+				  break;
+				}
 			      if (ITERATOR_AT_END_OF_LINE_P (it))
 				{
 				  result = MOVE_NEWLINE_OR_CR;
@@ -5678,7 +5720,11 @@
 #ifdef HAVE_WINDOW_SYSTEM
 	  if (IT_OVERFLOW_NEWLINE_INTO_FRINGE (it))
 	    {
-	      get_next_display_element (it);
+	      if (!get_next_display_element (it))
+		{
+		  result = MOVE_POS_MATCH_OR_ZV;
+		  break;
+		}
 	      if (ITERATOR_AT_END_OF_LINE_P (it))
 		{
 		  result = MOVE_NEWLINE_OR_CR;
@@ -7614,7 +7660,10 @@
 	  if (FRAME_VISIBLE_P (f) && FRAME_GARBAGED_P (f))
 	    {
 	      if (f->resized_p)
-		Fredraw_frame (frame);
+		{
+		  Fredraw_frame (frame);
+		  f->force_flush_display_p = 1;
+		}
 	      clear_current_matrices (f);
 	      changed_count++;
 	      f->garbaged = 0;
@@ -8928,536 +8977,6 @@
 
 
 
-/***********************************************************************
-			       Fringes
- ***********************************************************************/
-
-#ifdef HAVE_WINDOW_SYSTEM
-
-/* Notice that all bitmaps bits are "mirrored".  */
-
-/* An arrow like this: `<-'.  */
-/*
-  ...xx...
-  ....xx..
-  .....xx.
-  ..xxxxxx
-  ..xxxxxx
-  .....xx.
-  ....xx..
-  ...xx...
-*/
-static unsigned char left_bits[] = {
-   0x18, 0x0c, 0x06, 0x3f, 0x3f, 0x06, 0x0c, 0x18};
-
-
-/* Right truncation arrow bitmap `->'.  */
-/*
-  ...xx...
-  ..xx....
-  .xx.....
-  xxxxxx..
-  xxxxxx..
-  .xx.....
-  ..xx....
-  ...xx...
-*/
-static unsigned char right_bits[] = {
-   0x18, 0x30, 0x60, 0xfc, 0xfc, 0x60, 0x30, 0x18};
-
-
-/* Up arrow bitmap.  */
-/*
-  ...xx...
-  ..xxxx..
-  .xxxxxx.
-  xxxxxxxx
-  ...xx...
-  ...xx...
-  ...xx...
-  ...xx...
-*/
-static unsigned char up_arrow_bits[] = {
-   0x18, 0x3c, 0x7e, 0xff, 0x18, 0x18, 0x18, 0x18};
-
-
-/* Down arrow bitmap.  */
-/*
-  ...xx...
-  ...xx...
-  ...xx...
-  ...xx...
-  xxxxxxxx
-  .xxxxxx.
-  ..xxxx..
-  ...xx...
-*/
-static unsigned char down_arrow_bits[] = {
-   0x18, 0x18, 0x18, 0x18, 0xff, 0x7e, 0x3c, 0x18};
-
-/* Marker for continued lines.  */
-/*
-  ..xxxx..
-  .xxxxx..
-  xx......
-  xxx..x..
-  xxxxxx..
-  .xxxxx..
-  ..xxxx..
-  .xxxxx..
-*/
-static unsigned char continued_bits[] = {
-   0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c};
-
-/* Marker for continuation lines.  */
-/*
-  ..xxxx..
-  ..xxxxx.
-  ......xx
-  ..x..xxx
-  ..xxxxxx
-  ..xxxxx.
-  ..xxxx..
-  ..xxxxx.
-*/
-static unsigned char continuation_bits[] = {
-   0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e};
-
-/* Overlay arrow bitmap.  A triangular arrow.  */
-/*
-  ......xx
-  ....xxxx
-  ...xxxxx
-  ..xxxxxx
-  ..xxxxxx
-  ...xxxxx
-  ....xxxx
-  ......xx
-*/
-static unsigned char ov_bits[] = {
-   0x03, 0x0f, 0x1f, 0x3f, 0x3f, 0x1f, 0x0f, 0x03};
-
-
-/* First line bitmap.  An left-up angle.  */
-/*
-  ..xxxxxx
-  ..xxxxxx
-  ......xx
-  ......xx
-  ......xx
-  ......xx
-  ......xx
-  ........
-*/
-static unsigned char first_line_bits[] = {
-   0x3f, 0x3f, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00};
-
-
-/* Last line bitmap.  An left-down angle.  */
-/*
-  ........
-  xx......
-  xx......
-  xx......
-  xx......
-  xx......
-  xxxxxx..
-  xxxxxx..
-*/
-static unsigned char last_line_bits[] = {
-   0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xfc};
-
-/* Filled box cursor bitmap.  A filled box; max 13 pixels high.  */
-/*
-  .xxxxxxx
-  .xxxxxxx
-  .xxxxxxx
-  .xxxxxxx
-  .xxxxxxx
-  .xxxxxxx
-  .xxxxxxx
-  .xxxxxxx
-  .xxxxxxx
-  .xxxxxxx
-  .xxxxxxx
-  .xxxxxxx
-  .xxxxxxx
-*/
-static unsigned char filled_box_cursor_bits[] = {
-   0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f};
-
-/* Hollow box cursor bitmap.  A hollow box; max 13 pixels high.  */
-/*
-  .xxxxxxx
-  .x.....x
-  .x.....x
-  .x.....x
-  .x.....x
-  .x.....x
-  .x.....x
-  .x.....x
-  .x.....x
-  .x.....x
-  .x.....x
-  .x.....x
-  .xxxxxxx
-*/
-static unsigned char hollow_box_cursor_bits[] = {
-   0x7f, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x7f};
-
-/* Bar cursor bitmap.  A vertical bar; max 13 pixels high.  */
-/*
-  ......xx
-  ......xx
-  ......xx
-  ......xx
-  ......xx
-  ......xx
-  ......xx
-  ......xx
-  ......xx
-  ......xx
-  ......xx
-  ......xx
-  ......xx
-*/
-static unsigned char bar_cursor_bits[] = {
-   0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03};
-
-/* HBar cursor bitmap.  A horisontal bar; 2 pixels high.  */
-/*
-  .xxxxxxx
-  .xxxxxxx
-*/
-static unsigned char hbar_cursor_bits[] = {
-  0x7f, 0x7f};
-
-
-/* Bitmap drawn to indicate lines not displaying text if
-   `indicate-empty-lines' is non-nil.  */
-static unsigned char zv_bits[] = {
-  0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
-  0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
-  0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
-  0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
-  0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
-  0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
-  0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
-  0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00};
-
-/* Hollow square bitmap.  */
-/*
-  .xxxxxx.
-  .x....x.
-  .x....x.
-  .x....x.
-  .x....x.
-  .xxxxxx.
-*/
-static unsigned char hollow_square_bits[] = {
-   0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e};
-
-
-struct fringe_bitmap fringe_bitmaps[MAX_FRINGE_BITMAPS] =
-{
-  { 0, 0, 0, NULL /* NO_FRINGE_BITMAP */ },
-  { 8, sizeof (left_bits), 0, left_bits },
-  { 8, sizeof (right_bits), 0, right_bits },
-  { 8, sizeof (up_arrow_bits), -1, up_arrow_bits },
-  { 8, sizeof (down_arrow_bits), -2, down_arrow_bits },
-  { 8, sizeof (continued_bits), 0, continued_bits },
-  { 8, sizeof (continuation_bits), 0, continuation_bits },
-  { 8, sizeof (ov_bits), 0, ov_bits },
-  { 8, sizeof (first_line_bits), -1, first_line_bits },
-  { 8, sizeof (last_line_bits), -2, last_line_bits },
-  { 8, sizeof (filled_box_cursor_bits), 0, filled_box_cursor_bits },
-  { 8, sizeof (hollow_box_cursor_bits), 0, hollow_box_cursor_bits },
-  { 8, sizeof (bar_cursor_bits), 0, bar_cursor_bits },
-  { 8, sizeof (hbar_cursor_bits), -2, hbar_cursor_bits },
-  { 8, sizeof (zv_bits), 3, zv_bits },
-  { 8, sizeof (hollow_square_bits), 0, hollow_square_bits },
-};
-
-
-/* Draw the bitmap WHICH in one of the left or right fringes of
-   window W.  ROW is the glyph row for which to display the bitmap; it
-   determines the vertical position at which the bitmap has to be
-   drawn.
-   LEFT_P is 1 for left fringe, 0 for right fringe.
-*/
-
-void
-draw_fringe_bitmap (w, row, left_p)
-     struct window *w;
-     struct glyph_row *row;
-     int left_p;
-{
-  struct frame *f = XFRAME (WINDOW_FRAME (w));
-  struct draw_fringe_bitmap_params p;
-  enum fringe_bitmap_type which;
-  int period;
-
-  if (left_p)
-    which = row->left_fringe_bitmap;
-  else if (!row->cursor_in_fringe_p)
-    which = row->right_fringe_bitmap;
-  else
-    switch (w->phys_cursor_type)
-      {
-      case HOLLOW_BOX_CURSOR:
-	if (row->visible_height >= sizeof(hollow_box_cursor_bits))
-	  which = HOLLOW_BOX_CURSOR_BITMAP;
-	else
-	  which = HOLLOW_SQUARE_BITMAP;
-	break;
-      case FILLED_BOX_CURSOR:
-	which = FILLED_BOX_CURSOR_BITMAP;
-	break;
-      case BAR_CURSOR:
-	which = BAR_CURSOR_BITMAP;
-	break;
-      case HBAR_CURSOR:
-	which = HBAR_CURSOR_BITMAP;
-	break;
-      case NO_CURSOR:
-      default:
-	w->phys_cursor_on_p = 0;
-	row->cursor_in_fringe_p = 0;
-	which = row->right_fringe_bitmap;
-	break;
-      }
-
-  period = fringe_bitmaps[which].period;
-
-  /* Convert row to frame coordinates.  */
-  p.y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
-
-  p.which = which;
-  p.wd = fringe_bitmaps[which].width;
-
-  p.h = fringe_bitmaps[which].height;
-  p.dh = (period > 0 ? (p.y % period) : 0);
-  p.h -= p.dh;
-  /* Clip bitmap if too high.  */
-  if (p.h > row->height)
-    p.h = row->height;
-
-  p.face = FACE_FROM_ID (f, FRINGE_FACE_ID);
-  PREPARE_FACE_FOR_DISPLAY (f, p.face);
-
-  /* Clear left fringe if no bitmap to draw or if bitmap doesn't fill
-     the fringe.  */
-  p.bx = -1;
-  if (left_p)
-    {
-      int wd = WINDOW_LEFT_FRINGE_WIDTH (w);
-      int x = window_box_left (w, (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
-				   ? LEFT_MARGIN_AREA
-				   : TEXT_AREA));
-      if (p.wd > wd)
-	p.wd = wd;
-      p.x = x - p.wd - (wd - p.wd) / 2;
-
-      if (p.wd < wd || row->height > p.h)
-	{
-	  /* If W has a vertical border to its left, don't draw over it.  */
-	  wd -= ((!WINDOW_LEFTMOST_P (w)
-		  && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w))
-		 ? 1 : 0);
-	  p.bx = x - wd;
-	  p.nx = wd;
-	}
-    }
-  else
-    {
-      int x = window_box_right (w,
-				(WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
-				 ? RIGHT_MARGIN_AREA
-				 : TEXT_AREA));
-      int wd = WINDOW_RIGHT_FRINGE_WIDTH (w);
-      if (p.wd > wd)
-	p.wd = wd;
-      p.x = x + (wd - p.wd) / 2;
-      /* Clear right fringe if no bitmap to draw of if bitmap doesn't fill
-	 the fringe.  */
-      if (p.wd < wd || row->height > p.h)
-	{
-	  p.bx = x;
-	  p.nx = wd;
-	}
-    }
-
-  if (p.bx >= 0)
-    {
-      int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w);
-
-      p.by = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height, row->y));
-      p.ny = row->visible_height;
-    }
-
-  /* Adjust y to the offset in the row to start drawing the bitmap.  */
-  if (period == 0)
-    p.y += (row->height - p.h) / 2;
-  else if (period == -2)
-    {
-      p.h = fringe_bitmaps[which].height;
-      p.y += (row->visible_height - p.h);
-    }
-
-  FRAME_RIF (f)->draw_fringe_bitmap (w, row, &p);
-}
-
-/* Draw fringe bitmaps for glyph row ROW on window W.  Call this
-   function with input blocked.  */
-
-void
-draw_row_fringe_bitmaps (w, row)
-     struct window *w;
-     struct glyph_row *row;
-{
-  xassert (interrupt_input_blocked);
-
-  /* If row is completely invisible, because of vscrolling, we
-     don't have to draw anything.  */
-  if (row->visible_height <= 0)
-    return;
-
-  if (WINDOW_LEFT_FRINGE_WIDTH (w) != 0)
-    draw_fringe_bitmap (w, row, 1);
-
-  if (WINDOW_RIGHT_FRINGE_WIDTH (w) != 0)
-    draw_fringe_bitmap (w, row, 0);
-}
-
-/* Draw the fringes of window W.  Only fringes for rows marked for
-   update in redraw_fringe_bitmaps_p are drawn.  */
-
-void
-draw_window_fringes (w)
-     struct window *w;
-{
-  struct glyph_row *row;
-  int yb = window_text_bottom_y (w);
-  int nrows = w->current_matrix->nrows;
-  int y = 0, rn;
-
-  if (w->pseudo_window_p)
-    return;
-
-  for (y = 0, rn = 0, row = w->current_matrix->rows;
-       y < yb && rn < nrows;
-       y += row->height, ++row, ++rn)
-    {
-      if (!row->redraw_fringe_bitmaps_p)
-	continue;
-      draw_row_fringe_bitmaps (w, row);
-      row->redraw_fringe_bitmaps_p = 0;
-    }
-}
-
-
-/* Compute actual fringe widths for frame F.  
-
-   If REDRAW is 1, redraw F if the fringe settings was actually
-   modified and F is visible.
-
-   Since the combined left and right fringe must occupy an integral
-   number of columns, we may need to add some pixels to each fringe.
-   Typically, we add an equal amount (+/- 1 pixel) to each fringe,
-   but a negative width value is taken literally (after negating it).
-
-   We never make the fringes narrower than specified.  It is planned
-   to make fringe bitmaps customizable and expandable, and at that
-   time, the user will typically specify the minimum number of pixels
-   needed for his bitmaps, so we shouldn't select anything less than
-   what is specified.
-*/
-
-void
-compute_fringe_widths (f, redraw)
-     struct frame *f;
-     int redraw;
-{
-  int o_left = FRAME_LEFT_FRINGE_WIDTH (f);
-  int o_right = FRAME_RIGHT_FRINGE_WIDTH (f);
-  int o_cols = FRAME_FRINGE_COLS (f);
-
-  Lisp_Object left_fringe = Fassq (Qleft_fringe, f->param_alist);
-  Lisp_Object right_fringe = Fassq (Qright_fringe, f->param_alist);
-  int left_fringe_width, right_fringe_width;
-
-  if (!NILP (left_fringe))
-    left_fringe = Fcdr (left_fringe);
-  if (!NILP (right_fringe))
-    right_fringe = Fcdr (right_fringe);
-
-  left_fringe_width = ((NILP (left_fringe) || !INTEGERP (left_fringe)) ? 8 :
-		       XINT (left_fringe));
-  right_fringe_width = ((NILP (right_fringe) || !INTEGERP (right_fringe)) ? 8 :
-			XINT (right_fringe));
-
-  if (left_fringe_width || right_fringe_width)
-    {
-      int left_wid = left_fringe_width >= 0 ? left_fringe_width : -left_fringe_width;
-      int right_wid = right_fringe_width >= 0 ? right_fringe_width : -right_fringe_width;
-      int conf_wid = left_wid + right_wid;
-      int font_wid = FRAME_COLUMN_WIDTH (f);
-      int cols = (left_wid + right_wid + font_wid-1) / font_wid;
-      int real_wid = cols * font_wid;
-      if (left_wid && right_wid)
-	{
-	  if (left_fringe_width < 0)
-	    {
-	      /* Left fringe width is fixed, adjust right fringe if necessary */
-	      FRAME_LEFT_FRINGE_WIDTH (f) = left_wid;
-	      FRAME_RIGHT_FRINGE_WIDTH (f) = real_wid - left_wid;
-	    }
-	  else if (right_fringe_width < 0)
-	    {
-	      /* Right fringe width is fixed, adjust left fringe if necessary */
-	      FRAME_LEFT_FRINGE_WIDTH (f) = real_wid - right_wid;
-	      FRAME_RIGHT_FRINGE_WIDTH (f) = right_wid;
-	    }
-	  else
-	    {
-	      /* Adjust both fringes with an equal amount.
-		 Note that we are doing integer arithmetic here, so don't
-		 lose a pixel if the total width is an odd number.  */
-	      int fill = real_wid - conf_wid;
-	      FRAME_LEFT_FRINGE_WIDTH (f) = left_wid + fill/2;
-	      FRAME_RIGHT_FRINGE_WIDTH (f) = right_wid + fill - fill/2;
-	    }
-	}
-      else if (left_fringe_width)
-	{
-	  FRAME_LEFT_FRINGE_WIDTH (f) = real_wid;
-	  FRAME_RIGHT_FRINGE_WIDTH (f) = 0;
-	}
-      else
-	{
-	  FRAME_LEFT_FRINGE_WIDTH (f) = 0;
-	  FRAME_RIGHT_FRINGE_WIDTH (f) = real_wid;
-	}
-      FRAME_FRINGE_COLS (f) = cols;
-    }
-  else
-    {
-      FRAME_LEFT_FRINGE_WIDTH (f) = 0;
-      FRAME_RIGHT_FRINGE_WIDTH (f) = 0;
-      FRAME_FRINGE_COLS (f) = 0;
-    }
-
-  if (redraw && FRAME_VISIBLE_P (f))
-    if (o_left != FRAME_LEFT_FRINGE_WIDTH (f) ||
-	o_right != FRAME_RIGHT_FRINGE_WIDTH (f) ||
-	o_cols != FRAME_FRINGE_COLS (f))
-      redraw_frame (f);
-}
-
-#endif /* HAVE_WINDOW_SYSTEM */
-
-
-
 /************************************************************************
 			 Horizontal scrolling
  ************************************************************************/
@@ -9558,7 +9077,10 @@
 
 	      /* Position cursor in window.  */
 	      if (!hscroll_relative_p && hscroll_step_abs == 0)
-		hscroll = max (0, it.current_x - text_area_width / 2)
+		hscroll = max (0, (it.current_x
+				   - (ITERATOR_AT_END_OF_LINE_P (&it)
+				      ? (text_area_width - 4 * FRAME_COLUMN_WIDTH (it.f))
+				      : (text_area_width / 2))))
 		    	  / FRAME_COLUMN_WIDTH (it.f);
 	      else if (w->cursor.x >= text_area_width - h_margin)
 		{
@@ -11674,136 +11196,6 @@
       (w, end - start, whole, start);
 }
 
-#ifdef HAVE_WINDOW_SYSTEM
-
-/* Recalculate the bitmaps to show in the fringes of window W.
-   If FORCE_P is 0, only mark rows with modified bitmaps for update in
-   redraw_fringe_bitmaps_p; else mark all rows for update.  */
-
-int
-update_window_fringes (w, force_p)
-     struct window *w;
-     int force_p;
-{
-  struct glyph_row *row, *cur = 0;
-  int yb = window_text_bottom_y (w);
-  int rn, nrows = w->current_matrix->nrows;
-  int y;
-  int redraw_p = 0;
-  Lisp_Object ind;
-
-  if (w->pseudo_window_p)
-    return 0;
-
-  if (!MINI_WINDOW_P (w)
-      && (ind = XBUFFER (w->buffer)->indicate_buffer_boundaries, !NILP (ind)))
-    {
-      int do_eob = 1, do_bob = 1;
-
-      for (y = 0, rn = 0;
-	   y < yb && rn < nrows;
-	   y += row->height, ++rn)
-	{
-	  unsigned indicate_bob_p, indicate_top_line_p;
-	  unsigned indicate_eob_p, indicate_bottom_line_p;
-	  
-	  row = w->desired_matrix->rows + rn;
-	  if (!row->enabled_p)
-	    row = w->current_matrix->rows + rn;
-
-	  indicate_bob_p = row->indicate_bob_p;
-	  indicate_top_line_p = row->indicate_top_line_p;
-	  indicate_eob_p = row->indicate_eob_p;
-	  indicate_bottom_line_p = row->indicate_bottom_line_p;
-	  
-	  row->indicate_bob_p = row->indicate_top_line_p = 0;
-	  row->indicate_eob_p = row->indicate_bottom_line_p = 0;
-
-	  if (MATRIX_ROW_START_CHARPOS (row) <= BUF_BEGV (XBUFFER (w->buffer)))
-	    row->indicate_bob_p = do_bob, do_bob = 0;
-	  else if (EQ (ind, Qt)
-		   && (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0) == rn)
-	    row->indicate_top_line_p = 1;
-
-	  if (MATRIX_ROW_END_CHARPOS (row) >= BUF_ZV (XBUFFER (w->buffer)))
-	    row->indicate_eob_p = do_eob, do_eob = 0;
-	  else if (EQ (ind, Qt)
-		   && y + row->height >= yb)
-	    row->indicate_bottom_line_p = 1;
-
-	  if (indicate_bob_p != row->indicate_bob_p
-	      || indicate_top_line_p != row->indicate_top_line_p
-	      || indicate_eob_p != row->indicate_eob_p
-	      || indicate_bottom_line_p != row->indicate_bottom_line_p)
-	    row->redraw_fringe_bitmaps_p = 1;
-	}
-    }
-
-  for (y = 0, rn = 0;
-       y < yb && rn < nrows;
-       y += row->height, rn++)
-    {
-      enum fringe_bitmap_type left, right;
-
-      row = w->desired_matrix->rows + rn;
-      cur = w->current_matrix->rows + rn;
-      if (!row->enabled_p)
-	row = cur;
-
-      /* Decide which bitmap to draw in the left fringe.  */
-      if (WINDOW_LEFT_FRINGE_WIDTH (w) == 0)
-	left = NO_FRINGE_BITMAP;
-      else if (row->overlay_arrow_p)
-	left = OVERLAY_ARROW_BITMAP;
-      else if (row->truncated_on_left_p)
-	left = LEFT_TRUNCATION_BITMAP;
-      else if (MATRIX_ROW_CONTINUATION_LINE_P (row))
-	left = CONTINUATION_LINE_BITMAP;
-      else if (row->indicate_empty_line_p)
-	left = ZV_LINE_BITMAP;
-      else if (row->indicate_bob_p)
-	left = FIRST_LINE_BITMAP;
-      else
-	left = NO_FRINGE_BITMAP;
-
-      /* Decide which bitmap to draw in the right fringe.  */
-      if (WINDOW_RIGHT_FRINGE_WIDTH (w) == 0)
-	right = NO_FRINGE_BITMAP;
-      else if (row->truncated_on_right_p)
-	right = RIGHT_TRUNCATION_BITMAP;
-      else if (row->continued_p)
-	right = CONTINUED_LINE_BITMAP;
-      else if (row->indicate_eob_p)
-	right = LAST_LINE_BITMAP;
-      else if (row->indicate_top_line_p) 
-	right = UP_ARROW_BITMAP;
-      else if (row->indicate_bottom_line_p)
-	right = DOWN_ARROW_BITMAP;
-      else if (row->indicate_empty_line_p && WINDOW_LEFT_FRINGE_WIDTH (w) == 0)
-	right = ZV_LINE_BITMAP;
-      else
-	right = NO_FRINGE_BITMAP;
-
-      if (force_p
-	  || row->y != cur->y
-	  || row->visible_height != cur->visible_height
-	  || left != cur->left_fringe_bitmap
-	  || right != cur->right_fringe_bitmap
-	  || cur->redraw_fringe_bitmaps_p)
-	{
-	  redraw_p = row->redraw_fringe_bitmaps_p = cur->redraw_fringe_bitmaps_p = 1;
-	  cur->left_fringe_bitmap = left;
-	  cur->right_fringe_bitmap = right;
-	}
-
-      row->left_fringe_bitmap = left;
-      row->right_fringe_bitmap = right;
-    }
-
-  return redraw_p;
-}
-
-#endif /* HAVE_WINDOW_SYSTEM */
 
 /* Redisplay leaf window WINDOW.  JUST_THIS_ONE_P non-zero means only
    selected_window is redisplayed.
@@ -12494,6 +11886,7 @@
 
 #ifdef HAVE_WINDOW_SYSTEM
   if (update_window_fringes (w, 0)
+      && !just_this_one_p
       && (used_current_matrix_p || overlay_arrow_seen)
       && !w->pseudo_window_p)
     {
@@ -14835,6 +14228,11 @@
 	     display the cursor there under X.  Set the charpos of the
 	     first glyph of blank lines not corresponding to any text
 	     to -1.  */
+#ifdef HAVE_WINDOW_SYSTEM
+	  if (IT_OVERFLOW_NEWLINE_INTO_FRINGE (it))
+	    row->exact_window_width_line_p = 1;
+	  else
+#endif /* HAVE_WINDOW_SYSTEM */
 	  if ((append_space (it, 1) && row->used[TEXT_AREA] == 1)
 	      || row->used[TEXT_AREA] == 0)
 	    {
@@ -14947,8 +14345,14 @@
 #ifdef HAVE_WINDOW_SYSTEM
 			  if (IT_OVERFLOW_NEWLINE_INTO_FRINGE (it))
 			    {
-			      get_next_display_element (it);
-			      if (ITERATOR_AT_END_OF_LINE_P (it))
+			      if (!get_next_display_element (it))
+				{
+				  row->exact_window_width_line_p = 1;
+				  it->continuation_lines_width = 0;
+				  row->continued_p = 0;
+				  row->ends_at_zv_p = 1;
+				}
+			      else if (ITERATOR_AT_END_OF_LINE_P (it))
 				{
 				  row->continued_p = 0;
 				  row->exact_window_width_line_p = 1;
@@ -15053,7 +14457,7 @@
 				  it->max_phys_ascent + it->max_phys_descent);
 
 	  /* End of this display line if row is continued.  */
-	  if (row->continued_p)
+	  if (row->continued_p || row->ends_at_zv_p)
 	    break;
 	}
 
@@ -15119,7 +14523,15 @@
 	      /* Don't truncate if we can overflow newline into fringe.  */
 	      if (IT_OVERFLOW_NEWLINE_INTO_FRINGE (it))
 		{
-		  get_next_display_element (it);
+		  if (!get_next_display_element (it))
+		    {
+#ifdef HAVE_WINDOW_SYSTEM
+		      it->continuation_lines_width = 0;
+		      row->ends_at_zv_p = 1;
+		      row->exact_window_width_line_p = 1;
+		      break;
+#endif /* HAVE_WINDOW_SYSTEM */
+		    }
 		  if (ITERATOR_AT_END_OF_LINE_P (it))
 		    {
 		      row->exact_window_width_line_p = 1;
@@ -15196,6 +14608,17 @@
   /* Remember the position at which this line ends.  */
   row->end = it->current;
 
+  /* Save fringe bitmaps in this row.  */
+  row->left_user_fringe_bitmap = it->left_user_fringe_bitmap;
+  row->left_user_fringe_face_id = it->left_user_fringe_face_id;
+  row->right_user_fringe_bitmap = it->right_user_fringe_bitmap;
+  row->right_user_fringe_face_id = it->right_user_fringe_face_id;
+
+  it->left_user_fringe_bitmap = 0;
+  it->left_user_fringe_face_id = 0;
+  it->right_user_fringe_bitmap = 0;
+  it->right_user_fringe_face_id = 0;
+
   /* Maybe set the cursor.  */
   if (it->w->cursor.vpos < 0
       && PT >= MATRIX_ROW_START_CHARPOS (row)
@@ -20555,8 +19978,7 @@
 	  return inside;
 	}
     }
-  else
-    return 0;
+  return 0;
 }
 
 Lisp_Object
@@ -20595,10 +20017,8 @@
   if (NILP (map))
     return Qnil;
 
-  if (!INTEGERP (x))
-    wrong_type_argument (Qintegerp, x);
-  if (!INTEGERP (y))
-    wrong_type_argument (Qintegerp, y);
+  CHECK_NUMBER (x);
+  CHECK_NUMBER (y);
 
   return find_hot_spot (map, XINT (x), XINT (y));
 }
@@ -22016,17 +21436,6 @@
 The face used for trailing whitespace is `trailing-whitespace'.  */);
   Vshow_trailing_whitespace = Qnil;
 
-#ifdef HAVE_WINDOW_SYSTEM
-  DEFVAR_LISP ("overflow-newline-into-fringe", &Voverflow_newline_into_fringe,
-    doc: /* *Non-nil means that newline may flow into the right fringe.
-This means that display lines which are exactly as wide as the window
-(not counting the final newline) will only occupy one screen line, by
-showing (or hiding) the final newline in the right fringe; when point
-is at the final newline, the cursor is shown in the right fringe.
-If nil, also continue lines which are exactly as wide as the window.  */);
-  Voverflow_newline_into_fringe = Qt;
-#endif
-
   DEFVAR_LISP ("void-text-area-pointer", &Vvoid_text_area_pointer,
     doc: /* *The pointer shape to show in void text areas.
 Nil means to show the text pointer.  Other options are `arrow', `text',
--- a/src/xfaces.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/xfaces.c	Tue Feb 17 01:52:25 2004 +0000
@@ -192,6 +192,7 @@
    used to fill in unspecified attributes of the default face.  */
 
 #include <config.h>
+#include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stdio.h>              /* This needs to be before termchar.h */
--- a/src/xfns.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/xfns.c	Tue Feb 17 01:52:25 2004 +0000
@@ -775,7 +775,6 @@
   unsigned long x, y, xp, xm, yp, ym;
   GC gc;
 
-  int depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f));
   struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
 
   if (!(id > 0))
@@ -1597,7 +1596,7 @@
      Lisp_Object value, oldval;
 {
   int nlines;
-#ifndef USE_X_TOOLKIT
+#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
   int olines = FRAME_MENU_BAR_LINES (f);
 #endif
 
@@ -4292,125 +4291,6 @@
 
 
 /***********************************************************************
-                General X functions exposed to Elisp.
- ***********************************************************************/
-
-DEFUN ("x-send-client-message", Fx_send_client_event,
-       Sx_send_client_message, 6, 6, 0,
-       doc: /* Send a client message of MESSAGE-TYPE to window DEST on DISPLAY.
-
-For DISPLAY, specify either a frame or a display name (a string).
-If DISPLAY is nil, that stands for the selected frame's display.
-DEST may be an integer, in which case it is a Window id.  The value 0 may
-be used to send to the root window of the DISPLAY.
-If DEST is a frame the event is sent to the outer window of that frame.
-Nil means the currently selected frame.
-If DEST is the string "PointerWindow" the event is sent to the window that
-contains the pointer.  If DEST is the string "InputFocus" the event is
-sent to the window that has the input focus.
-FROM is the frame sending the event.  Use nil for currently selected frame.
-MESSAGE-TYPE is the name of an Atom as a string.
-FORMAT must be one of 8, 16 or 32 and determines the size of the values in
-bits.  VALUES is a list of integer and/or strings containing the values to
-send.  If a value is a string, it is converted to an Atom and the value of
-the Atom is sent.  If more values than fits into the event is given,
-the excessive values are ignored.  */)
-     (display, dest, from, message_type, format, values)
-     Lisp_Object display, dest, from, message_type, format, values;
-{
-  struct x_display_info *dpyinfo = check_x_display_info (display);
-  Window wdest;
-  XEvent event;
-  Lisp_Object cons;
-  int i;
-  int max_nr_values = (int) sizeof (event.xclient.data.b);
-  struct frame *f = check_x_frame (from);
-  
-  CHECK_STRING (message_type);
-  CHECK_NUMBER (format);
-  CHECK_CONS (values);
-
-  for (cons = values; CONSP (cons); cons = XCDR (cons))
-    {
-      Lisp_Object o = XCAR (cons);
-
-      if (! INTEGERP (o) && ! STRINGP (o))
-        error ("Bad data in VALUES, must be integer or string");
-    }
-
-  event.xclient.type = ClientMessage;
-  event.xclient.format = XFASTINT (format);
-
-  if (event.xclient.format != 8 && event.xclient.format != 16
-      && event.xclient.format != 32)
-    error ("FORMAT must be one of 8, 16 or 32");
-  if (event.xclient.format == 16) max_nr_values /= 2;
-  if (event.xclient.format == 32) max_nr_values /= 4;
-  
-  if (FRAMEP (dest) || NILP (dest))
-    {
-      struct frame *fdest = check_x_frame (dest);
-      wdest = FRAME_OUTER_WINDOW (fdest);
-    }
-  else if (STRINGP (dest))
-    {
-      if (strcmp (SDATA (dest), "PointerWindow") == 0)
-        wdest = PointerWindow;
-      else if (strcmp (SDATA (dest), "InputFocus") == 0)
-        wdest = InputFocus;
-      else
-        error ("DEST as a string must be one of PointerWindow or InputFocus");
-    }
-  else
-    {
-      CHECK_NUMBER (dest);
-      wdest = (Window) XFASTINT (dest);
-      if (wdest == 0) wdest = dpyinfo->root_window;
-    }
-
-  BLOCK_INPUT;
-  for (cons = values, i = 0;
-       CONSP (cons) && i < max_nr_values;
-       cons = XCDR (cons), ++i)
-    {
-      Lisp_Object o = XCAR (cons);
-      long val;
-
-      if (INTEGERP (o))
-        val = XINT (o);
-      else if (STRINGP (o))
-          val = XInternAtom (dpyinfo->display, SDATA (o), False);
-
-      if (event.xclient.format == 8)
-        event.xclient.data.b[i] = (char) val;
-      else if (event.xclient.format == 16)
-        event.xclient.data.s[i] = (short) val;
-      else
-        event.xclient.data.l[i] = val;
-    }
-
-  for ( ; i < max_nr_values; ++i)
-    if (event.xclient.format == 8)
-      event.xclient.data.b[i] = 0;
-    else if (event.xclient.format == 16)
-      event.xclient.data.s[i] = 0;
-    else
-      event.xclient.data.l[i] = 0;
-
-  event.xclient.message_type
-    = XInternAtom (dpyinfo->display, SDATA (message_type), False);
-  event.xclient.display = dpyinfo->display;
-  event.xclient.window = FRAME_OUTER_WINDOW (f);
-
-  XSendEvent (dpyinfo->display, wdest, False, 0xffff, &event);
-
-  XFlush (dpyinfo->display);
-  UNBLOCK_INPUT;
-
-  return Qnil;
-}
-
-/***********************************************************************
 			    Image types
  ***********************************************************************/
 
@@ -9601,24 +9481,85 @@
  ***********************************************************************/
 
 DEFUN ("x-change-window-property", Fx_change_window_property,
-       Sx_change_window_property, 2, 3, 0,
+       Sx_change_window_property, 2, 6, 0,
        doc: /* Change window property PROP to VALUE on the X window of FRAME.
-PROP and VALUE must be strings.  FRAME nil or omitted means use the
-selected frame.  Value is VALUE.  */)
-     (prop, value, frame)
-     Lisp_Object frame, prop, value;
+PROP must be a string.
+VALUE may be a string or a list of conses, numbers and/or strings.
+If an element in the list is a string, it is converted to
+an Atom and the value of the Atom is used.  If an element is a cons,
+it is converted to a 32 bit number where the car is the 16 top bits and the
+cdr is the lower 16 bits.
+FRAME nil or omitted means use the selected frame.
+If TYPE is given and non-nil, it is the name of the type of VALUE.
+If TYPE is not given or nil, the type is STRING.
+FORMAT gives the size in bits of each element if VALUE is a list.
+It must be one of 8, 16 or 32.
+If VALUE is a string or FORMAT is nil or not given, FORMAT defaults to 8.
+If OUTER_P is non-nil, the property is changed for the outer X window of
+FRAME.  Default is to change on the edit X window.
+
+Value is VALUE.  */)
+     (prop, value, frame, type, format, outer_p)
+     Lisp_Object prop, value, frame, type, format, outer_p;
 {
   struct frame *f = check_x_frame (frame);
   Atom prop_atom;
+  Atom target_type = XA_STRING;
+  int element_format = 8;
+  unsigned char *data;
+  int nelements;
+  Window w;
 
   CHECK_STRING (prop);
-  CHECK_STRING (value);
+
+  if (! NILP (format))
+    {
+      CHECK_NUMBER (format);
+      element_format = XFASTINT (format);
+
+      if (element_format != 8 && element_format != 16
+          && element_format != 32)
+        error ("FORMAT must be one of 8, 16 or 32");
+    }
+
+  if (CONSP (value))
+    {
+      nelements = x_check_property_data (value);
+      if (nelements == -1)
+        error ("Bad data in VALUE, must be number, string or cons");
+
+      if (element_format == 8)
+        data = (unsigned char *) xmalloc (nelements);
+      else if (element_format == 16)
+        data = (unsigned char *) xmalloc (nelements*2);
+      else
+        data = (unsigned char *) xmalloc (nelements*4);
+
+      x_fill_property_data (FRAME_X_DISPLAY (f), value, data, element_format);
+    }
+  else
+    {
+      CHECK_STRING (value);
+      data = SDATA (value);
+      nelements = SCHARS (value);
+    }
 
   BLOCK_INPUT;
   prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SDATA (prop), False);
-  XChangeProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-		   prop_atom, XA_STRING, 8, PropModeReplace,
-		   SDATA (value), SCHARS (value));
+  if (! NILP (type))
+    {
+      CHECK_STRING (type);
+      target_type = XInternAtom (FRAME_X_DISPLAY (f), SDATA (type), False);
+    }
+
+  if (! NILP (outer_p)) w = FRAME_OUTER_WINDOW (f);
+  else w = FRAME_X_WINDOW (f);
+ 
+  XChangeProperty (FRAME_X_DISPLAY (f), w,
+		   prop_atom, target_type, element_format, PropModeReplace,
+		   data, nelements);
+
+  if (CONSP (value)) xfree (data);
 
   /* Make sure the property is set when we return.  */
   XFlush (FRAME_X_DISPLAY (f));
@@ -9652,13 +9593,20 @@
 
 
 DEFUN ("x-window-property", Fx_window_property, Sx_window_property,
-       1, 2, 0,
+       1, 6, 0,
        doc: /* Value is the value of window property PROP on FRAME.
-If FRAME is nil or omitted, use the selected frame.  Value is nil
-if FRAME hasn't a property with name PROP or if PROP has no string
-value.  */)
-     (prop, frame)
-     Lisp_Object prop, frame;
+If FRAME is nil or omitted, use the selected frame.
+If TYPE is nil or omitted, get the property as a string.  Otherwise TYPE
+is the name of the Atom that denotes the type expected.
+If SOURCE is non-nil, get the property on that window instead of from
+FRAME.  The number 0 denotes the root window.
+If DELETE_P is non-nil, delete the property after retreiving it.
+If VECTOR_RET_P is non-nil, don't return a string but a vector of values.
+
+Value is nil if FRAME hasn't a property with name PROP or if PROP has
+no value of TYPE.  */)
+     (prop, frame, type, source, delete_p, vector_ret_p)
+     Lisp_Object prop, frame, type, source, delete_p, vector_ret_p;
 {
   struct frame *f = check_x_frame (frame);
   Atom prop_atom;
@@ -9666,14 +9614,43 @@
   Lisp_Object prop_value = Qnil;
   char *tmp_data = NULL;
   Atom actual_type;
+  Atom target_type = XA_STRING;
   int actual_format;
   unsigned long actual_size, bytes_remaining;
-
+  Window target_window = FRAME_X_WINDOW (f);
+  struct gcpro gcpro1;
+
+  GCPRO1 (prop_value);
   CHECK_STRING (prop);
+
+  if (! NILP (source))
+    {
+      if (NUMBERP (source))
+        {
+          if (FLOATP (source))
+            target_window = (Window) XFLOAT (source);
+          else
+            target_window = XFASTINT (source);
+
+          if (target_window == 0)
+            target_window = FRAME_X_DISPLAY_INFO (f)->root_window;
+        }
+      else if (CONSP (source))
+        target_window = cons_to_long (source);
+    }
+
   BLOCK_INPUT;
+  if (STRINGP (type))
+    {
+      if (strcmp ("AnyPropertyType", SDATA (type)) == 0)
+        target_type = AnyPropertyType;
+      else
+        target_type = XInternAtom (FRAME_X_DISPLAY (f), SDATA (type), False);
+    }
+
   prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SDATA (prop), False);
-  rc = XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-			   prop_atom, 0, 0, False, XA_STRING,
+  rc = XGetWindowProperty (FRAME_X_DISPLAY (f), target_window,
+			   prop_atom, 0, 0, False, target_type,
 			   &actual_type, &actual_format, &actual_size,
 			   &bytes_remaining, (unsigned char **) &tmp_data);
   if (rc == Success)
@@ -9683,19 +9660,29 @@
       XFree (tmp_data);
       tmp_data = NULL;
 
-      rc = XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+      rc = XGetWindowProperty (FRAME_X_DISPLAY (f), target_window,
 			       prop_atom, 0, bytes_remaining,
-			       False, XA_STRING,
+			       ! NILP (delete_p), target_type,
 			       &actual_type, &actual_format,
 			       &actual_size, &bytes_remaining,
 			       (unsigned char **) &tmp_data);
       if (rc == Success && tmp_data)
-	prop_value = make_string (tmp_data, size);
-
-      XFree (tmp_data);
+        {
+          if (NILP (vector_ret_p))
+            prop_value = make_string (tmp_data, size);
+          else
+            prop_value = x_property_data_to_lisp (f,
+                                                  (unsigned char *) tmp_data,
+                                                  actual_type,
+                                                  actual_format,
+                                                  actual_size);
+        }
+
+      if (tmp_data) XFree (tmp_data);
     }
 
   UNBLOCK_INPUT;
+  UNGCPRO;
   return prop_value;
 }
 
@@ -10752,7 +10739,6 @@
   int count = specpdl_ptr - specpdl;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
   char *cdef_file;
-  char *cprompt;
 
   GCPRO5 (prompt, dir, default_filename, mustmatch, file);
   CHECK_STRING (prompt);
@@ -11110,7 +11096,6 @@
   defsubr (&Sx_close_connection);
   defsubr (&Sx_display_list);
   defsubr (&Sx_synchronize);
-  defsubr (&Sx_send_client_message);
   defsubr (&Sx_focus_frame);
   defsubr (&Sx_backspace_delete_keys_p);
 
--- a/src/xselect.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/xselect.c	Tue Feb 17 01:52:25 2004 +0000
@@ -23,6 +23,7 @@
 /* Rewritten by jwz */
 
 #include <config.h>
+#include <stdio.h>      /* termhooks.h needs this */
 #include "lisp.h"
 #include "xterm.h"	/* for all of the X includes */
 #include "dispextern.h"	/* frame.h seems to want this */
@@ -30,6 +31,9 @@
 #include "blockinput.h"
 #include "buffer.h"
 #include "process.h"
+#include "termhooks.h"
+
+#include <X11/Xproto.h>
 
 struct prop_location;
 
@@ -50,7 +54,9 @@
 static void unexpect_property_change P_ ((struct prop_location *));
 static Lisp_Object wait_for_property_change_unwind P_ ((Lisp_Object));
 static void wait_for_property_change P_ ((struct prop_location *));
-static Lisp_Object x_get_foreign_selection P_ ((Lisp_Object, Lisp_Object));
+static Lisp_Object x_get_foreign_selection P_ ((Lisp_Object,
+                                                Lisp_Object,
+                                                Lisp_Object));
 static void x_get_window_property P_ ((Display *, Window, Atom,
 				       unsigned char **, int *,
 				       Atom *, int *, unsigned long *, int));
@@ -1223,8 +1229,8 @@
    Converts this to Lisp data and returns it.  */
 
 static Lisp_Object
-x_get_foreign_selection (selection_symbol, target_type)
-     Lisp_Object selection_symbol, target_type;
+x_get_foreign_selection (selection_symbol, target_type, time_stamp)
+     Lisp_Object selection_symbol, target_type, time_stamp;
 {
   struct frame *sf = SELECTED_FRAME ();
   Window requestor_window;
@@ -1252,6 +1258,18 @@
   else
     type_atom = symbol_to_x_atom (dpyinfo, display, target_type);
 
+  if (! NILP (time_stamp))
+    {
+      if (CONSP (time_stamp))
+        requestor_time = (Time) cons_to_long (time_stamp);
+      else if (INTEGERP (time_stamp))
+        requestor_time = (Time) XUINT (time_stamp);
+      else if (FLOATP (time_stamp))
+        requestor_time = (Time) XFLOAT (time_stamp);
+      else
+        error ("TIME_STAMP must be cons or number");
+    }
+
   BLOCK_INPUT;
 
   count = x_catch_errors (display);
@@ -1943,13 +1961,15 @@
    will block until all of the data has arrived.  */
 
 DEFUN ("x-get-selection-internal", Fx_get_selection_internal,
-       Sx_get_selection_internal, 2, 2, 0,
+       Sx_get_selection_internal, 2, 3, 0,
        doc: /* Return text selected from some X window.
 SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.
 \(Those are literal upper-case symbol names, since that's what X expects.)
-TYPE is the type of data desired, typically `STRING'.  */)
-     (selection_symbol, target_type)
-     Lisp_Object selection_symbol, target_type;
+TYPE is the type of data desired, typically `STRING'.
+TIME_STAMP is the time to use in the XConvertSelection call for foreign
+selections.  If omitted, defaults to the time for the last event.  */)
+  (selection_symbol, target_type, time_stamp)
+     Lisp_Object selection_symbol, target_type, time_stamp;
 {
   Lisp_Object val = Qnil;
   struct gcpro gcpro1, gcpro2;
@@ -1973,7 +1993,7 @@
 
   if (NILP (val))
     {
-      val = x_get_foreign_selection (selection_symbol, target_type);
+      val = x_get_foreign_selection (selection_symbol, target_type, time_stamp);
       goto DONE;
     }
 
@@ -2310,6 +2330,351 @@
 
 #endif
 
+/***********************************************************************
+                      Drag and drop support
+***********************************************************************/
+/* Check that lisp values are of correct type for x_fill_property_data.
+   That is, number, string or a cons with two numbers (low and high 16
+   bit parts of a 32 bit number).  */
+
+int
+x_check_property_data (data)
+     Lisp_Object data;
+{
+  Lisp_Object iter;
+  int size = 0;
+
+  for (iter = data; CONSP (iter) && size != -1; iter = XCDR (iter), ++size)
+    {
+      Lisp_Object o = XCAR (iter);
+
+      if (! NUMBERP (o) && ! STRINGP (o) && ! CONSP (o))
+        size = -1;
+      else if (CONSP (o) &&
+               (! NUMBERP (XCAR (o)) || ! NUMBERP (XCDR (o))))
+        size = -1;
+    }
+
+  return size;
+}
+
+/* Convert lisp values to a C array.  Values may be a number, a string
+   which is taken as an X atom name and converted to the atom value, or
+   a cons containing the two 16 bit parts of a 32 bit number.
+
+   DPY is the display use to look up X atoms.
+   DATA is a Lisp list of values to be converted.
+   RET is the C array that contains the converted values.  It is assumed
+   it is big enough to hol all values.
+   FORMAT is 8, 16 or 32 and gives the size in bits for each C value to
+   be stored in RET.  */
+
+void
+x_fill_property_data (dpy, data, ret, format)
+     Display *dpy;
+     Lisp_Object data;
+     void *ret;
+     int format;
+{
+  CARD32 val;
+  CARD32 *d32 = (CARD32 *) ret;
+  CARD16 *d16 = (CARD16 *) ret;
+  CARD8  *d08 = (CARD8  *) ret;
+  Lisp_Object iter;
+
+  for (iter = data; CONSP (iter); iter = XCDR (iter))
+    {
+      Lisp_Object o = XCAR (iter);
+
+      if (INTEGERP (o))
+        val = (CARD32) XFASTINT (o);
+      else if (FLOATP (o))
+        val = (CARD32) XFLOAT (o);
+      else if (CONSP (o))
+        val = (CARD32) cons_to_long (o);
+      else if (STRINGP (o))
+        {
+          BLOCK_INPUT;
+          val = XInternAtom (dpy, (char *) SDATA (o), False);
+          UNBLOCK_INPUT;
+        }
+      else
+        error ("Wrong type, must be string, number or cons");
+
+      if (format == 8)
+        *d08++ = (CARD8) val;
+      else if (format == 16)
+        *d16++ = (CARD16) val;
+      else
+        *d32++ = val;
+    }
+}
+
+/* Convert an array of C values to a Lisp list.
+   F is the frame to be used to look up X atoms if the TYPE is XA_ATOM.
+   DATA is a C array of values to be converted.
+   TYPE is the type of the data.  Only XA_ATOM is special, it converts
+   each number in DATA to its corresponfing X atom as a symbol.
+   FORMAT is 8, 16 or 32 and gives the size in bits for each C value to
+   be stored in RET.
+   SIZE is the number of elements in DATA.
+
+   Also see comment for selection_data_to_lisp_data above.  */
+
+Lisp_Object
+x_property_data_to_lisp (f, data, type, format, size)
+     struct frame *f;
+     unsigned char *data;
+     Atom type;
+     int format;
+     unsigned long size;
+{
+  return selection_data_to_lisp_data (FRAME_X_DISPLAY (f),
+                                      data, size*format/8, type, format);
+}
+
+/* Get the mouse position frame relative coordinates.  */
+
+static void
+mouse_position_for_drop (f, x, y)
+     FRAME_PTR f;
+     int *x;
+     int *y;
+{
+  Window root, dummy_window;
+  int dummy;
+
+  BLOCK_INPUT;
+
+  XQueryPointer (FRAME_X_DISPLAY (f),
+                 DefaultRootWindow (FRAME_X_DISPLAY (f)),
+
+                 /* The root window which contains the pointer.  */
+                 &root,
+
+                 /* Window pointer is on, not used  */
+                 &dummy_window,
+
+                 /* The position on that root window.  */
+                 x, y,
+
+                 /* x/y in dummy_window coordinates, not used.  */
+                 &dummy, &dummy,
+
+                 /* Modifier keys and pointer buttons, about which
+                    we don't care.  */
+                 (unsigned int *) &dummy);
+
+
+  /* Absolute to relative.  */
+  *x -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
+  *y -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
+
+  UNBLOCK_INPUT;
+}
+
+DEFUN ("x-get-atom-name", Fx_get_atom_name,
+       Sx_get_atom_name, 1, 2, 0,
+       doc: /* Return the X atom name for VALUE as a string.
+VALUE may be a number or a cons where the car is the upper 16 bits and
+the cdr is the lower 16 bits of a 32 bit value.
+Use the display for FRAME or the current frame if FRAME is not given or nil.
+
+If the value is 0 or the atom is not known, return the empty string.  */)
+  (value, frame)
+     Lisp_Object value, frame;
+{
+  struct frame *f = check_x_frame (frame);
+  char *name = 0;
+  Lisp_Object ret = Qnil;
+  int count;
+  Display *dpy = FRAME_X_DISPLAY (f);
+  Atom atom;
+
+  if (INTEGERP (value))
+    atom = (Atom) XUINT (value);
+  else if (FLOATP (value))
+    atom = (Atom) XFLOAT (value);
+  else if (CONSP (value))
+    atom = (Atom) cons_to_long (value);
+  else
+    error ("Wrong type, value must be number or cons");
+
+  BLOCK_INPUT;
+  count = x_catch_errors (dpy);
+
+  name = atom ? XGetAtomName (dpy, atom) : "";
+
+  if (! x_had_errors_p (dpy))
+    ret = make_string (name, strlen (name));
+
+  x_uncatch_errors (dpy, count);
+
+  if (atom && name) XFree (name);
+  if (NILP (ret)) ret = make_string ("", 0);
+
+  UNBLOCK_INPUT;
+
+  return ret;
+}
+
+/* Convert an XClientMessageEvent to a Lisp event of type DRAG_N_DROP_EVENT.
+   TODO: Check if this client event really is a DND event?  */
+
+int
+x_handle_dnd_message (f, event, dpyinfo, bufp)
+     struct frame *f;
+     XClientMessageEvent *event;
+     struct x_display_info *dpyinfo;
+     struct input_event *bufp;
+{
+  Lisp_Object vec;
+  Lisp_Object frame;
+  unsigned long size = (8*sizeof (event->data))/event->format;
+  int x, y;
+
+  XSETFRAME (frame, f);
+
+  vec = Fmake_vector (make_number (4), Qnil);
+  AREF (vec, 0) = SYMBOL_NAME (x_atom_to_symbol (FRAME_X_DISPLAY (f),
+                                                 event->message_type));
+  AREF (vec, 1) = frame;
+  AREF (vec, 2) = make_number (event->format);
+  AREF (vec, 3) = x_property_data_to_lisp (f,
+                                           event->data.b,
+                                           event->message_type,
+                                           event->format,
+                                           size);
+
+  mouse_position_for_drop (f, &x, &y);
+  bufp->kind = DRAG_N_DROP_EVENT;
+  bufp->frame_or_window = Fcons (frame, vec);
+  bufp->timestamp = CurrentTime;
+  bufp->x = make_number (x);
+  bufp->y = make_number (y);
+  bufp->arg = Qnil;
+  bufp->modifiers = 0;
+
+  return 1;
+}
+
+DEFUN ("x-send-client-message", Fx_send_client_event,
+       Sx_send_client_message, 6, 6, 0,
+       doc: /* Send a client message of MESSAGE-TYPE to window DEST on DISPLAY.
+
+For DISPLAY, specify either a frame or a display name (a string).
+If DISPLAY is nil, that stands for the selected frame's display.
+DEST may be a number, in which case it is a Window id.  The value 0 may
+be used to send to the root window of the DISPLAY.
+If DEST is a cons, it is converted to a 32 bit number
+with the high 16 bits from the car and the lower 16 bit from the cdr.  That
+number is then used as a window id.
+If DEST is a frame the event is sent to the outer window of that frame.
+Nil means the currently selected frame.
+If DEST is the string "PointerWindow" the event is sent to the window that
+contains the pointer.  If DEST is the string "InputFocus" the event is
+sent to the window that has the input focus.
+FROM is the frame sending the event.  Use nil for currently selected frame.
+MESSAGE-TYPE is the name of an Atom as a string.
+FORMAT must be one of 8, 16 or 32 and determines the size of the values in
+bits.  VALUES is a list of numbers, cons and/or strings containing the values
+to send.  If a value is a string, it is converted to an Atom and the value of
+the Atom is sent.  If a value is a cons, it is converted to a 32 bit number
+with the high 16 bits from the car and the lower 16 bit from the cdr.
+If more values than fits into the event is given, the excessive values
+are ignored.  */)
+     (display, dest, from, message_type, format, values)
+     Lisp_Object display, dest, from, message_type, format, values;
+{
+  struct x_display_info *dpyinfo = check_x_display_info (display);
+  Window wdest;
+  XEvent event;
+  Lisp_Object cons;
+  int size;
+  struct frame *f = check_x_frame (from);
+  int count;
+  int to_root;
+
+  CHECK_STRING (message_type);
+  CHECK_NUMBER (format);
+  CHECK_CONS (values);
+
+  if (x_check_property_data (values) == -1)
+    error ("Bad data in VALUES, must be number, cons or string");
+
+  event.xclient.type = ClientMessage;
+  event.xclient.format = XFASTINT (format);
+
+  if (event.xclient.format != 8 && event.xclient.format != 16
+      && event.xclient.format != 32)
+    error ("FORMAT must be one of 8, 16 or 32");
+  
+  if (FRAMEP (dest) || NILP (dest))
+    {
+      struct frame *fdest = check_x_frame (dest);
+      wdest = FRAME_OUTER_WINDOW (fdest);
+    }
+  else if (STRINGP (dest))
+    {
+      if (strcmp (SDATA (dest), "PointerWindow") == 0)
+        wdest = PointerWindow;
+      else if (strcmp (SDATA (dest), "InputFocus") == 0)
+        wdest = InputFocus;
+      else
+        error ("DEST as a string must be one of PointerWindow or InputFocus");
+    }
+  else if (INTEGERP (dest))
+    wdest = (Window) XFASTINT (dest);
+  else if (FLOATP (dest))
+    wdest =  (Window) XFLOAT (dest);
+  else if (CONSP (dest))
+    {
+      if (! NUMBERP (XCAR (dest)) || ! NUMBERP (XCDR (dest)))
+        error ("Both car and cdr for DEST must be numbers");
+      else
+        wdest = (Window) cons_to_long (dest);
+    }
+  else
+    error ("DEST must be a frame, nil, string, number or cons");
+
+  if (wdest == 0) wdest = dpyinfo->root_window;
+  to_root = wdest == dpyinfo->root_window;
+
+  for (cons = values, size = 0; CONSP (cons); cons = XCDR (cons), ++size)
+    ;
+
+  BLOCK_INPUT;
+
+  event.xclient.message_type
+    = XInternAtom (dpyinfo->display, SDATA (message_type), False);
+  event.xclient.display = dpyinfo->display;
+
+  /* Some clients (metacity for example) expects sending window to be here
+     when sending to the root window.  */
+  event.xclient.window = to_root ? FRAME_OUTER_WINDOW (f) : wdest;
+
+  memset (event.xclient.data.b, 0, sizeof (event.xclient.data.b));
+  x_fill_property_data (dpyinfo->display, values, event.xclient.data.b,
+                        event.xclient.format);
+
+  /* If event mask is 0 the event is sent to the client that created
+     the destination window.  But if we are sending to the root window,
+     there is no such client.  Then we set the event mask to 0xffff.  The
+     event then goes to clients selecting for events on the root window.  */
+  count = x_catch_errors (dpyinfo->display);
+  {
+    int propagate = to_root ? False : True;
+    unsigned mask = to_root ? 0xffff : 0;
+    XSendEvent (dpyinfo->display, wdest, propagate, mask, &event);
+    XFlush (dpyinfo->display);
+  }
+  x_uncatch_errors (dpyinfo->display, count);
+  UNBLOCK_INPUT;
+
+  return Qnil;
+}
+
+
 void
 syms_of_xselect ()
 {
@@ -2325,6 +2690,9 @@
   defsubr (&Sx_rotate_cut_buffers_internal);
 #endif
 
+  defsubr (&Sx_get_atom_name);
+  defsubr (&Sx_send_client_message);
+
   reading_selection_reply = Fcons (Qnil, Qnil);
   staticpro (&reading_selection_reply);
   reading_selection_window = 0;
--- a/src/xterm.c	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/xterm.c	Tue Feb 17 01:52:25 2004 +0000
@@ -716,7 +716,7 @@
   else
     x_clip_to_row (w, row, gc);
 
-  if (p->bx >= 0)
+  if (p->bx >= 0 && !p->overlay_p)
     {
       /* In case the same realized face is used for fringes and
 	 for something displayed in the text (e.g. face `region' on
@@ -734,20 +734,49 @@
 	XSetForeground (display, face->gc, face->foreground);
     }
 
-  if (p->which != NO_FRINGE_BITMAP)
-    {
-      unsigned char *bits = fringe_bitmaps[p->which].bits + p->dh;
-      Pixmap pixmap;
+  if (p->which)
+    {
+      unsigned char *bits;
+      Pixmap pixmap, clipmask = (Pixmap) 0;
       int depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f));
+      XGCValues gcv;
+
+      if (p->wd > 8)
+	bits = (unsigned char *)(p->bits + p->dh);
+      else
+	bits = (unsigned char *)p->bits + p->dh;
 
       /* Draw the bitmap.  I believe these small pixmaps can be cached
 	 by the server.  */
       pixmap = XCreatePixmapFromBitmapData (display, window, bits, p->wd, p->h,
-					    face->foreground,
+					    (p->cursor_p
+					     ? (p->overlay_p ? face->background
+						: f->output_data.x->cursor_pixel)
+					     : face->foreground),
 					    face->background, depth);
+
+      if (p->overlay_p)
+	{
+	  clipmask = XCreatePixmapFromBitmapData (display, 
+						  FRAME_X_DISPLAY_INFO (f)->root_window,
+						  bits, p->wd, p->h, 
+						  1, 0, 1);
+	  gcv.clip_mask = clipmask;
+	  gcv.clip_x_origin = p->x;
+	  gcv.clip_y_origin = p->y; 
+	  XChangeGC (display, gc, GCClipMask | GCClipXOrigin | GCClipYOrigin, &gcv);
+	}
+
       XCopyArea (display, pixmap, window, gc, 0, 0,
 		 p->wd, p->h, p->x, p->y);
       XFreePixmap (display, pixmap);
+
+      if (p->overlay_p)
+	{
+	  gcv.clip_mask = (Pixmap) 0;
+	  XChangeGC (display, gc, GCClipMask, &gcv);
+	  XFreePixmap (display, clipmask);
+	}
     }
 
   XSetClipMask (display, gc, None);
@@ -5943,7 +5972,25 @@
           }
 #endif /* USE_TOOLKIT_SCROLL_BARS */
         else
-          goto OTHER;
+          {
+            struct frame *f
+              = x_any_window_to_frame (dpyinfo, event.xclient.window);
+
+            if (f)
+              {
+                int ret = x_handle_dnd_message (f, &event.xclient,
+                                                dpyinfo, bufp);
+                if (ret > 0)
+                  {
+                    ++bufp, ++count, --numchars;
+                  }
+
+                if (ret != 0)
+                  *finish = X_EVENT_DROP;
+              }
+            else
+              goto OTHER;
+          }
       }
       break;
 
@@ -10877,6 +10924,8 @@
     x_get_glyph_overhangs,
     x_fix_overlapping_area,
     x_draw_fringe_bitmap,
+    0, /* define_fringe_bitmap */
+    0, /* destroy_fringe_bitmap */
     x_per_char_metric,
     x_encode_char,
     x_compute_glyph_string_overhangs,
--- a/src/xterm.h	Tue Feb 10 13:52:03 2004 +0000
+++ b/src/xterm.h	Tue Feb 17 01:52:25 2004 +0000
@@ -1009,8 +1009,24 @@
 extern void x_handle_selection_clear P_ ((struct input_event *));
 extern void x_clear_frame_selections P_ ((struct frame *));
 
+extern int x_handle_dnd_message P_ ((struct frame *,
+                                     XClientMessageEvent *,
+                                     struct x_display_info *,
+                                     struct input_event *bufp));
+extern int x_check_property_data P_ ((Lisp_Object));
+extern void x_fill_property_data P_ ((Display *,
+                                      Lisp_Object,
+                                      void *,
+                                      int));
+extern Lisp_Object x_property_data_to_lisp P_ ((struct frame *,
+                                                unsigned char *,
+                                                Atom,
+                                                int,
+                                                unsigned long));
+
 /* Defined in xfns.c */
 
+extern struct x_display_info * check_x_display_info P_ ((Lisp_Object frame));
 extern int have_menus_p P_ ((void));
 extern int x_bitmap_height P_ ((struct frame *, int));
 extern int x_bitmap_width P_ ((struct frame *, int));
@@ -1062,6 +1078,7 @@
 extern void x_activate_menubar P_ ((struct frame *));
 extern int popup_activated P_ ((void));
 extern void initialize_frame_menubar P_ ((struct frame *));
+extern void free_frame_menubar P_ ((struct frame *));
 
 /* Defined in widget.c */