changeset 83098:0643dc72a250

Merged in changes from CVS trunk. Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-213 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-214 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-215 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-216 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-217 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-138
author Karoly Lorentey <lorentey@elte.hu>
date Thu, 15 Apr 2004 16:49:22 +0000
parents 01716205773e (current diff) 78763a9d3ac1 (diff)
children 9cb7ecf775c9
files lisp/ChangeLog lisp/emacs-lisp/bytecomp.el lisp/progmodes/ada-mode.el lisp/smerge-mode.el lisp/startup.el src/dispnew.c src/window.c src/xdisp.c
diffstat 38 files changed, 1886 insertions(+), 905 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.in	Tue Apr 13 18:18:05 2004 +0000
+++ b/Makefile.in	Thu Apr 15 16:49:22 2004 +0000
@@ -445,9 +445,11 @@
 	if [ `(cd ./etc; /bin/pwd)` != `(cd ${docdir}; /bin/pwd)` ]; \
 	then \
 	   echo "Copying etc/DOC-* to ${docdir} ..." ; \
-	   (cd ./etc; tar -chf - DOC*) \
+	   (cd ./etc; tar -chf - DOC* compilation.txt) \
 	     |(cd ${docdir}; umask 022; tar -xvf - && cat > /dev/null) || exit 1; \
-	   (cd $(docdir); chown $${LOGNAME:-$$USERNAME} DOC*; chmod a+r DOC*; \
+	   (cd $(docdir); \
+	    chown $${LOGNAME:-$$USERNAME} DOC* compilation.txt; \
+	    chmod a+r DOC* compilation.txt; \
 	    if test "`echo DOC-*`" != "DOC-*"; then rm DOC; fi); \
 	else true; fi
 	-unset CDPATH; \
--- a/etc/ChangeLog	Tue Apr 13 18:18:05 2004 +0000
+++ b/etc/ChangeLog	Thu Apr 15 16:49:22 2004 +0000
@@ -1,3 +1,7 @@
+2004-04-14  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+	* TUTORIAL.nl: Update Delete/Delback translation.
+
 2004-04-05  Jesper Harder  <harder@ifa.au.dk>
 
 	* TODO: Remove index-apropos entry.
--- a/etc/NEWS	Tue Apr 13 18:18:05 2004 +0000
+++ b/etc/NEWS	Thu Apr 15 16:49:22 2004 +0000
@@ -88,6 +88,12 @@
 
 * Changes in Emacs 21.4
 
+** New command line option -Q.
+
+This is like using -q --no-site-file, but in addition it also disables
+the menu-bar, the tool-bar, the scroll-bars, tool tips, the blinking
+cursor, and the fancy startup screen.
+
 ** C-h v and C-h f commands now include a hyperlink to the C source for
 variables and functions defined in C (if the C source is available).
 
--- a/etc/TUTORIAL.nl	Tue Apr 13 18:18:05 2004 +0000
+++ b/etc/TUTORIAL.nl	Thu Apr 15 16:49:22 2004 +0000
@@ -302,16 +302,21 @@
 geïnterpreteerd en meteen aan de tekst.  Type <Return> (de `volgende regel'
 toets) om een Newline toe te voegen en dus een nieuwe regel te beginnen.
 
-Je kunt het laatste teken dat je intypte weghalen door <Delete> te typen.
-<Delete> is een toets op het toetsenbord, die soms ook wel "Del"
-heet.  In sommige gevallen dient de "Backspace" toets als <Delete>, maar
-niet altijd!
+Je kunt het laatste teken dat je intypte weghalen door <Delback> te typen.
+<Delback> is een toets op het toetsenbord--dezelfde toets die je normaal
+gesproken gebruikt, buiten Emacs, om het laatst ingetypte teken te wissen.
+Het is meestal een grote toets, een paar rijen boven de <Return> toets,
+waar "Delete", "Del" of "Backspace" op staat.
 
-In het algemeen haalt <Delete> het teken dat juist voor de cursorpositie
+Als er op die grote toets "Backspace" staat, dan is dat degene die je
+gebruikt voor <Delback>.  Er kan op een andere plaats ook nog een andere
+toets zijn waarop "Delete" staat, maar dat is niet <Delback>.
+
+In het algemeen haalt <Delback> het teken dat juist voor de cursorpositie
 staat weg.
 
 >> Probeer dit nu: type een paar letters en haal ze weer weg door een paar
-   keer op <Delete> te drukken.  Maak je niet druk over het feit dat dit
+   keer op <Delback> te drukken.  Maak je niet druk over het feit dat dit
    bestand verandert; je zult niets veranderen aan de originele versie van
    deze uitleg.  Je zit slechts je eigen kopie te wijzigen.
 
@@ -323,7 +328,7 @@
 >> Voeg nu tekst toe totdat je de rechter kantlijn raakt, en blijf
    toevoegen.  Je zult zien dat er een vervolgregel verschijnt.
 
->> Type weer enkele keren <Delete> om zoveel tekens weg te halen tot
+>> Type weer enkele keren <Delback> om zoveel tekens weg te halen tot
    de regel weer op een schermregel past.  De vervolgregel zal verdwijnen.
 
 Je kunt een Newline weggooien als elk ander teken.  Als je een Newline
@@ -331,7 +336,7 @@
 enkele regel.  Als de regel die het resultaat is van deze operatie niet op
 een schermregel past zal hij getoond worden met een vervolgregel.
 
->> Beweeg de cursor naar het begin van een regel en type <Delete>.  Dit
+>> Beweeg de cursor naar het begin van een regel en type <Delback>.  Dit
    voegt de huidige en vorige regel samen.
 
 >> Type <Return> om de Newline die je net weggooide weer toe te voegen.
@@ -346,18 +351,18 @@
 corrigeren.  Je kunt tekst ook per woord of regel weggooien.  Hier volgt
 een samenvatting van de commando's om tekst te verwijderen:
 
-	<Delete>     haal het teken weg dat voor de cursor staat
+	<Delback>    haal het teken weg dat voor de cursor staat
 	C-d	     haal het teken weg dat achter de cursor staat
 
-	M-<Delete>   gooi het woord weg dat voor de cursor staat
+	M-<Delback>  gooi het woord weg dat voor de cursor staat
 	M-d	     gooi het woord weg dat achter de cursor staat
 
 	C-k	     gooi alles weg van de cursor tot het eind van de regel
 	M-k	     gooi alles weg van de cursor tot het eind van de zin
 
-Merk op dat <Delete> en C-d met M-<Delete> en M-d de analogie die begon
+Merk op dat <Delback> en C-d met M-<Delback> en M-d de analogie die begon
 met C-f en M-f verder trekken (waarbij we voor het gemak even vergeten dat
-<Delete> niet echt een control teken is).  C-k en M-k lijken enigzins op
+<Delback> niet echt een control teken is).  C-k en M-k lijken enigzins op
 C-e en M-e in hun relatie tot regels en zinnen.
 
 Als je meer dan een enkel teken tegelijk weghaalt bewaart Emacs de tekst
@@ -826,7 +831,7 @@
    `cursor' gezocht.
 >> Type nogmaals C-s, om het volgende woord `cursor' te zoeken
   
-> Type nu viermaal <Delete> en let op de cursorbewegingen.
+> Type nu viermaal <Delback> en let op de cursorbewegingen.
 >> Type <RET> om het zoeken te beëindigen.
 
 Zag je wat er gebeurde?  Tijdens incrementeel zoeken probeert Emacs naar
@@ -835,12 +840,12 @@
 geen volgende plek is gevonden piept Emacs en vertelt je dat de zoekopdracht
 is beëindigd. (`failing' in het Engels); met C-g kun je het zoeken afbreken.
 
-Als je tijdens incrementeel zoeken <Delete> typt, zul je zien dat het
+Als je tijdens incrementeel zoeken <Delback> typt, zul je zien dat het
 laatste teken dat je in de zoekstring typte weggehaald wordt en dat het
 zoeken teruggaat naar de voorgaande plaats.  Als je bijvoorbeeld begint
 met zoeken en je typt een "c" dan ga je naar de plaats waar de "c" het
 eerst voorkomt.  Type je vervolgens een "u" dan gaat de cursor naar de
-plaats waar de string "cu" het eerst voorkomt".  Als je nu <Delete> typt, dan
+plaats waar de string "cu" het eerst voorkomt".  Als je nu <Delback> typt, dan
 wordt de "u" van de zoekstring afgehaald en gaat de cursor terug naar de
 plaats waar hij stond voordat je de "u" intypte, i.e. de plaats waar "c" het
 eerst voorkomt.
--- a/lisp/ChangeLog	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/ChangeLog	Thu Apr 15 16:49:22 2004 +0000
@@ -1,3 +1,144 @@
+2004-04-14  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* emacs-lisp/bytecomp.el (batch-byte-compile-file):
+	Give a backtrace if requested.
+
+	* progmodes/ada-mode.el (ada-create-menu): Remove redundant call.
+
+	* progmodes/python.el (python-mouse-2-command, python-RET-command):
+	Remove unused functions.
+	(python-orig-start-line, python-orig-file): Remove.
+	(python-orig-start): New var.
+	(python-input-filter, python-compilation-line-number)
+	(python-send-region, python-load-file): Use it.
+
+	* info.el (info): Always jump to *info*.
+
+	* subr.el (posn-set-point): New function.
+
+	* mouse.el (mouse-set-point): Use it.
+
+	* progmodes/compile.el (compile-goto-error): Use it.
+	(compilation-button-map): New keymap.
+	(compilation-error-properties): Use it.
+	(compilation-shell-minor-mode-map): Don't bind mouse-2.
+
+	* smerge-mode.el (smerge-popup-context-menu): Use it.
+
+	* emacs-lisp/checkdoc.el (checkdoc-output-mode-map)
+	(checkdoc-find-error-mouse, checkdoc-find-error): Use it to merge the
+	mouse and non-mouse case.
+
+	* diff-mode.el (diff-goto-source): Make it work for mouse bindings.
+	(diff-mouse-goto-source): Make it an alias of diff-goto-source.
+
+	* pcvs.el (cvs-mode-toggle-mark): Rename from cvs-mouse-toggle-mark.
+	Make it work for non-mouse events.
+
+	* pcvs-info.el (cvs-status-map): Update binding name.
+
+2004-04-14  Mark A. Hershberger  <mah@everybody.org>
+
+	* xml.el (xml-maybe-do-ns): New function to handle namespace
+	parsing of both attribute and element names.
+	(xml-ns-parse-ns-attrs, xml-ns-expand-el, xml-ns-expand-attr)
+	(xml-intern-attrlist): Remove in favor of xml-maybe-do-ns.
+	(xml-parse-tag): Update assumed namespaces.  Clean up namespace parsing.
+	(xml-parse-attlist): Make it do its own namespace parsing.
+
+2004-04-14  Dave Love  <fx@gnu.org>
+
+	* progmodes/python.el (run-python): Fix use of \n.
+	(python-load-file): Remove `try' from Python fragment.
+	(python-describe-symbol): Fix message.
+
+	* comint.el: Doc fixes.
+	(comint-last-input-start, comint-last-input-end)
+	(comint-last-output-start): Give them values.
+	(comint-arguments): Avoid warning.
+	(comint-skip-prompt): Use line-end-position.
+	(comint-backward-matching-input): Rename arg to agree with doc.
+	(comint-extract-string): Use syntax-ppss.
+	(comint-dynamic-simple-complete): Delete useless list construction.
+	(comint-redirect-subvert-readonly): New.
+	(comint-redirect-preoutput-filter): Use it.
+
+	* emacs-lisp/lisp.el (beginning-of-defun-raw, end-of-defun):
+	Correctly handle negative arguments when calling hook functions.
+
+2004-04-14  Jesper Harder  <harder@ifa.au.dk>
+
+	* info.el (info-apropos): Don't clobber Info-history-list.
+
+2004-04-14  Daniel Pfeiffer  <occitan@esperanto.org>
+
+	* progmodes/compile.el (compilation-setup):
+	Localize overlay-arrow-position.
+	(compilation-sentinel): Restructure code equivalently.
+	(compilation-next-error): Find message on same line after point if
+	not found before point.
+	(compile-mouse-goto-error): Restore function so that compilation
+	buffer need not be current and use compile-goto-error.
+	(compile-goto-error): Restore function.
+	(next-error): Set overlay-arrow-position.
+	(compilation-forget-errors): Don't localize already local
+	compilation-locs and remove FIXME about refontifying.
+
+2004-04-14  Kim F. Storm  <storm@cua.dk>
+
+	* startup.el (emacs-quick-startup): New defvar (set by -Q).
+	(command-line): New option -Q.  Like -q --no-site-file, but
+	in addition it also disables menu-bar, tool-bar, scroll-bars,
+	tool-tips, and the blinking cursor.
+	(command-line-1): Skip startup screen if -Q.
+	(fancy-splash-head): Use :align-to center prop to center splash image.
+
+	* emulation/cua-base.el (cua-read-only-cursor-color)
+	(cua-overwrite-cursor-color, cua-global-mark-cursor-color): Doc fix.
+
+2004-04-13  Dave Love  <fx@gnu.org>
+
+	* progmodes/python.el: Doc fixes.  Changes for compiler warnings.
+	(syntax): Don't require.
+	(python) <defgroup>: Add :version.
+	(python-quote-syntax): Re-written.
+	(inferior-python-mode): Move stuff here from run-python and add
+	some more.
+	(python-preoutput-continuation, python-preoutput-result)
+	(python-dotty-syntax-table): New.
+	(python-describe-symbol): Use them.
+	(run-python): Move stuff to inferior-python-mode.  Modify code
+	loaded into Python.
+	(python-send-region): Use python-proc, python-send-string.
+	(python-send-string): Send newlines too.  Callers changed.
+	(python-load-file): Re-written.
+	(python-eldoc-function): New.
+	(info-look): Don't require.
+	(python-after-info-look): New.  A modified version of former
+	top-level code for use with eval-after-load.
+	(python-maybe-jython, python-guess-indent): Use widened buffer.
+	(python-fill-paragraph): Re-written.
+	(python-mode): Fix outline-regexp.  Set outline-heading-end-regexp,
+	eldoc-print-current-symbol-info-function.  Add to eldoc-mode-hook.
+
+2004-04-13  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* progmodes/python.el (run-python): Use compilation-shell-minor-mode.
+	Set compilation-error-regexp-alist earlier.
+
+2004-04-12  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* progmodes/compile.el (compile-goto-error): Select the buffer/window
+	corresponding to the event.
+
+	* url/url.el (url-retrieve): Use with-current-buffer.
+
+	* url/url-http.el (url-http-parse-headers, url-http-file-exists-p):
+	Remove unused var `version'.
+
+	* url/url-handlers.el (url-handler-mode): New minor mode.
+	(url-setup-file-name-handlers): Remove.
+
 2004-04-12  Joe Buehler  <jbuehler@hekiman.com>
 
 	* loadup.el: Add cygwin to system-type list, for unexec() support.
@@ -127,6 +268,10 @@
 	* progmodes/delphi.el (delphi-version): Variable removed.
 	* progmodes/ada-mode.el (ada-mode): RCS keyword removed from docstring.
 
+2004-04-09  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* emacs-lisp/easymenu.el (easy-menu-add): Make it work in non-X Emacs.
+
 2004-04-09  Jesper Harder  <harder@ifa.au.dk>
 
 	* info.el (info-apropos): Improve menu item regexp.
--- a/lisp/comint.el	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/comint.el	Thu Apr 15 16:49:22 2004 +0000
@@ -1,6 +1,6 @@
 ;;; comint.el --- general command interpreter in a window stuff
 
-;; Copyright (C) 1988,90,92,93,94,95,96,97,98,99,2000,01,02,2003
+;; Copyright (C) 1988,90,92,93,94,95,96,97,98,99,2000,01,02,03,2004
 ;;	Free Software Foundation, Inc.
 
 ;; Author: Olin Shivers <shivers@cs.cmu.edu>
@@ -27,14 +27,9 @@
 
 ;;; Commentary:
 
-;; Please send me bug reports, bug fixes, and extensions, so that I can
-;; merge them into the master source.
-;;     - Olin Shivers (shivers@cs.cmu.edu)
-;;     - Simon Marshall (simon@gnu.org)
-
 ;; This file defines a general command-interpreter-in-a-buffer package
-;; (comint mode). The idea is that you can build specific process-in-a-buffer
-;; modes on top of comint mode -- e.g., lisp, shell, scheme, T, soar, ....
+;; (comint mode).  The idea is that you can build specific process-in-a-buffer
+;; modes on top of comint mode -- e.g., Lisp, shell, scheme, T, soar, ....
 ;; This way, all these specific packages share a common base functionality,
 ;; and a common set of bindings, which makes them easier to use (and
 ;; saves code, implementation time, etc., etc.).
@@ -45,13 +40,13 @@
 ;;
 ;; - The file cmuscheme.el defines a scheme-in-a-buffer mode.
 ;; - The file tea.el tunes scheme and inferior-scheme modes for T.
-;; - The file soar.el tunes lisp and inferior-lisp modes for Soar.
-;; - cmutex.el defines tex and latex modes that invoke tex, latex, bibtex,
-;;   previewers, and printers from within emacs.
-;; - background.el allows csh-like job control inside emacs.
+;; - The file soar.el tunes Lisp and inferior-lisp modes for Soar.
+;; - cmutex.el defines TeX and LaTeX modes that invoke TeX, LaTeX, BibTeX,
+;;   previewers, and printers from within Emacs.
+;; - background.el allows csh-like job control inside Emacs.
 ;; It is pretty easy to make new derived modes for other processes.
 
-;; For documentation on the functionality provided by comint mode, and
+;; For documentation on the functionality provided by Comint mode, and
 ;; the hooks available for customising it, see the comments below.
 ;; For further information on the standard derived modes (shell,
 ;; inferior-lisp, inferior-scheme, ...), see the relevant source files.
@@ -66,23 +61,23 @@
 ;; Comint Mode Commands: (common to all derived modes, like shell & cmulisp
 ;; mode)
 ;;
-;; m-p	   comint-previous-input	   Cycle backwards in input history
-;; m-n	   comint-next-input		   Cycle forwards
-;; m-r     comint-previous-matching-input  Previous input matching a regexp
-;; m-s     comint-next-matching-input      Next input that matches
-;; m-c-l   comint-show-output		   Show last batch of process output
-;; return  comint-send-input
-;; c-d	   comint-delchar-or-maybe-eof     Delete char unless at end of buff
-;; c-c c-a comint-bol-or-process-mark      First time, move point to bol;
+;; M-p	   comint-previous-input	   Cycle backwards in input history
+;; M-n	   comint-next-input		   Cycle forwards
+;; M-r     comint-previous-matching-input  Previous input matching a regexp
+;; M-s     comint-next-matching-input      Next input that matches
+;; M-C-l   comint-show-output		   Show last batch of process output
+;; RET	   comint-send-input
+;; C-d	   comint-delchar-or-maybe-eof     Delete char unless at end of buff
+;; C-c C-a comint-bol-or-process-mark      First time, move point to bol;
 ;;					    second time, move to process-mark.
-;; c-c c-u comint-kill-input		    ^u
-;; c-c c-w backward-kill-word	    ^w
-;; c-c c-c comint-interrupt-subjob	    ^c
-;; c-c c-z comint-stop-subjob		    ^z
-;; c-c c-\ comint-quit-subjob		    ^\
-;; c-c c-o comint-delete-output		    Delete last batch of process output
-;; c-c c-r comint-show-output		    Show last batch of process output
-;; c-c c-l comint-dynamic-list-input-ring  List input history
+;; C-c C-u comint-kill-input		    ^u
+;; C-c C-w backward-kill-word		    ^w
+;; C-c C-c comint-interrupt-subjob	    ^c
+;; C-c C-z comint-stop-subjob		    ^z
+;; C-c C-\ comint-quit-subjob		    ^\
+;; C-c C-o comint-delete-output		    Delete last batch of process output
+;; C-c C-r comint-show-output		    Show last batch of process output
+;; C-c C-l comint-dynamic-list-input-ring  List input history
 ;;
 ;; Not bound by default in comint-mode (some are in shell mode)
 ;; comint-run				Run a program under comint-mode
@@ -97,7 +92,7 @@
 ;; comint-kill-subjob			No mercy.
 ;; comint-show-maximum-output          Show as much output as possible.
 ;; comint-continue-subjob		Send CONT signal to buffer's process
-;;					group. Useful if you accidentally
+;;					group.  Useful if you accidentally
 ;;					suspend your process (with C-c C-z).
 ;; comint-get-next-from-history        Fetch successive input history lines
 ;; comint-accumulate		       Combine lines to send them together
@@ -105,7 +100,7 @@
 ;; comint-goto-process-mark	       Move point to where process-mark is.
 ;; comint-set-process-mark	       Set process-mark to point.
 
-;; comint-mode-hook is the comint mode hook. Basically for your keybindings.
+;; comint-mode-hook is the Comint mode hook.  Basically for your keybindings.
 
 ;;; Code:
 
@@ -189,7 +184,7 @@
 
 (defcustom comint-input-autoexpand nil
   "*If non-nil, expand input command history references on completion.
-This mirrors the optional behavior of tcsh (its autoexpand and histlit).
+This mirrors the optional behavior of tcsh (its autoexpand and histlist).
 
 If the value is `input', then the expansion is seen on input.
 If the value is `history', then the expansion is only when inserting
@@ -256,7 +251,7 @@
 
 See the variable `comint-scroll-show-maximum-output' and the function
 `comint-postoutput-scroll-to-bottom'.
-This variable is buffer-local in all comint buffers."
+This variable is buffer-local in all Comint buffers."
   :type '(choice (const :tag "off" nil)
 		 (const t)
 		 (const all)
@@ -275,16 +270,16 @@
 
 Non-nil means scroll so that the window is full of text
 and point is on the last line.  A value of nil
-means don't do anyting special--scroll normally.
+means don't do anything special--scroll normally.
 
 See also the variable `comint-move-point-for-output' and the function
 `comint-postoutput-scroll-to-bottom'.
-This variable is buffer-local in all comint buffers."
+This variable is buffer-local in all Comint buffers."
   :type 'boolean
   :group 'comint)
 
 (defcustom comint-buffer-maximum-size 1024
-  "*The maximum size in lines for comint buffers.
+  "*The maximum size in lines for Comint buffers.
 Comint buffers are truncated from the top to be no greater than this number, if
 the function `comint-truncate-buffer' is on `comint-output-filter-functions'."
   :type 'integer
@@ -297,7 +292,7 @@
   "Separator between commands in the history file.")
 
 (defvar comint-input-history-ignore "^#"
-  "Regexp for history entries that should be ignored when comint initializes.")
+  "Regexp for history entries that should be ignored when Comint initializes.")
 
 (defcustom comint-process-echoes nil
   "*If non-nil, assume that the subprocess echoes any input.
@@ -316,7 +311,7 @@
 (defcustom comint-password-prompt-regexp
   "\\(\\([Oo]ld \\|[Nn]ew \\|'s \\|login \\|\
 Kerberos \\|CVS \\|UNIX \\| SMB \\|^\\)\
-[Pp]assword\\( (again)\\)?\\|\
+\[Pp]assword\\( (again)\\)?\\|\
 pass phrase\\|\\(Enter\\|Repeat\\) passphrase\\)\
 \\( for [^:]+\\)?:\\s *\\'"
   "*Regexp matching prompts for passwords in the inferior process.
@@ -326,7 +321,7 @@
 
 ;; Here are the per-interpreter hooks.
 (defvar comint-get-old-input (function comint-get-old-input-default)
-  "Function that returns old text in comint mode.
+  "Function that returns old text in Comint mode.
 This function is called when return is typed while the point is in old
 text.  It returns the text to be submitted as process input.  The
 default is `comint-get-old-input-default', which either grabs the
@@ -398,15 +393,15 @@
   :group 'comint)
 
 (defcustom comint-mode-hook '(turn-on-font-lock)
-  "Called upon entry into `comint-mode'
+  "Hook run upon entry to `comint-mode'.
 This is run before the process is cranked up."
   :type 'hook
   :group 'comint)
 
 (defcustom comint-exec-hook '()
-  "Called each time a process is exec'd by `comint-exec'.
+  "Hook run each time a process is exec'd by `comint-exec'.
 This is called after the process is cranked up.  It is useful for things that
-must be done each time a process is executed in a comint mode buffer (e.g.,
+must be done each time a process is executed in a Comint mode buffer (e.g.,
 `(process-kill-without-query)').  In contrast, the `comint-mode-hook' is only
 executed once when the buffer is created."
   :type 'hook
@@ -414,14 +409,15 @@
 
 (defvar comint-mode-map nil)
 
+;; Fixme: Is this still relevant?
 (defvar comint-ptyp t
   "Non-nil if communications via pty; false if by pipe.  Buffer local.
 This is to work around a bug in Emacs process signaling.")
 
 (defvar comint-input-ring nil)
-(defvar comint-last-input-start)
-(defvar comint-last-input-end)
-(defvar comint-last-output-start)
+(defvar comint-last-input-start nil)
+(defvar comint-last-input-end nil)
+(defvar comint-last-output-start nil)
 (defvar comint-input-ring-index nil
   "Index of last matched history element.")
 (defvar comint-matching-input-from-input-string ""
@@ -644,7 +640,7 @@
 
 ;;;###autoload
 (defun make-comint-in-buffer (name buffer program &optional startfile &rest switches)
-  "Make a comint process NAME in BUFFER, running PROGRAM.
+  "Make a Comint process NAME in BUFFER, running PROGRAM.
 If BUFFER is nil, it defaults to NAME surrounded by `*'s.
 PROGRAM should be either a string denoting an executable program to create
 via `start-process', or a cons pair of the form (HOST . SERVICE) denoting a TCP
@@ -667,20 +663,20 @@
 
 ;;;###autoload
 (defun make-comint (name program &optional startfile &rest switches)
-  "Make a comint process NAME in a buffer, running PROGRAM.
+  "Make a Comint process NAME in a buffer, running PROGRAM.
 The name of the buffer is made by surrounding NAME with `*'s.
 PROGRAM should be either a string denoting an executable program to create
 via `start-process', or a cons pair of the form (HOST . SERVICE) denoting a TCP
 connection to be opened via `open-network-stream'.  If there is already a
 running process in that buffer, it is not restarted.  Optional third arg
-STARTFILE is the name of a file to send the contents of to the process.
+STARTFILE is the name of a file to send the contents of the process to.
 
 If PROGRAM is a string, any more args are arguments to PROGRAM."
   (apply #'make-comint-in-buffer name nil program startfile switches))
 
 ;;;###autoload
 (defun comint-run (program)
-  "Run PROGRAM in a comint buffer and switch to it.
+  "Run PROGRAM in a Comint buffer and switch to it.
 The buffer name is made by surrounding the file name of PROGRAM with `*'s.
 The file name is used to make a symbol name, such as `comint-sh-hook', and any
 hooks on this symbol are run in the buffer.
@@ -691,9 +687,10 @@
     (run-hooks (intern-soft (concat "comint-" name "-hook")))))
 
 (defun comint-exec (buffer name command startfile switches)
-  "Start up a process in buffer BUFFER for comint modes.
+  "Start up a process named NAME in buffer BUFFER for Comint modes.
+Runs the given COMMAND with SWITCHES with output to STARTFILE.
 Blasts any old process running in the buffer.  Doesn't set the buffer mode.
-You can use this to cheaply run a series of processes in the same comint
+You can use this to cheaply run a series of processes in the same Comint
 buffer.  The hook `comint-exec-hook' is run after each exec."
   (with-current-buffer buffer
     (let ((proc (get-buffer-process buffer)))	; Blast any old process.
@@ -778,7 +775,7 @@
 
 
 (defun comint-insert-clicked-input (event)
-  "In a comint buffer, set the current input to the clicked-on previous input."
+  "In a Comint buffer, set the current input to the clicked-on previous input."
   (interactive "e")
   (let ((pos (posn-point (event-end event))))
     (if (not (eq (get-char-property pos 'field) 'input))
@@ -825,7 +822,7 @@
 ;; comint-replace-by-expanded-history-before-point Workhorse function.
 
 (defun comint-read-input-ring (&optional silent)
-  "Sets the buffer's `comint-input-ring' from a history file.
+  "Set the buffer's `comint-input-ring' from a history file.
 The name of the file is given by the variable `comint-input-ring-file-name'.
 The history ring is of size `comint-input-ring-size', regardless of file size.
 If `comint-input-ring-file-name' is nil this function does nothing.
@@ -970,7 +967,7 @@
 
 
 (defun comint-regexp-arg (prompt)
-  ;; Return list of regexp and prefix arg using PROMPT.
+  "Return list of regexp and prefix arg using PROMPT."
   (let* (;; Don't clobber this.
 	 (last-command last-command)
 	 (regexp (read-from-minibuffer prompt nil nil nil
@@ -996,7 +993,7 @@
 	 arg)))
 
 (defun comint-search-start (arg)
-  ;; Index to start a directional search, starting at comint-input-ring-index
+  "Index to start a directional search, starting at `comint-input-ring-index'."
   (if comint-input-ring-index
       ;; If a search is running, offset by 1 in direction of arg
       (mod (+ comint-input-ring-index (if (> arg 0) 1 -1))
@@ -1120,7 +1117,7 @@
 This function depends on the buffer's idea of the input history, which may not
 match the command interpreter's idea, assuming it has one.
 
-Assumes history syntax is like typical Un*x shells'.  However, since emacs
+Assumes history syntax is like typical Un*x shells'.  However, since Emacs
 cannot know the interpreter's idea of input line numbers, assuming it has one,
 it cannot expand absolute input line number references.
 
@@ -1285,9 +1282,10 @@
 			(t nth))))
 	(comint-arguments string nth mth)))))
 
-;; Return a list of arguments from ARG.  Break it up at the
-;; delimiters in comint-delimiter-argument-list.  Returned list is backwards.
 (defun comint-delim-arg (arg)
+  "Return a list of arguments from ARG.
+Break it up at the delimiters in `comint-delimiter-argument-list'.
+Returned list is backwards."
   (if (null comint-delimiter-argument-list)
       (list arg)
     (let ((args nil)
@@ -1321,8 +1319,8 @@
   ;; The third matches '-quoted strings.
   ;; The fourth matches `-quoted strings.
   ;; This seems to fit the syntax of BASH 2.0.
-  (let* ((first (if (and (eq system-type 'windows-nt)
-			 (w32-shell-dos-semantics))
+  (let* ((first (if (if (fboundp 'w32-shell-dos-semantics)
+			(w32-shell-dos-semantics))
 		    "[^ \n\t\"'`]+\\|"
 		  "[^ \n\t\"'`\\]+\\|\\\\[\"'`\\ \t]+\\|"))
 	 (argpart (concat first
@@ -1331,7 +1329,7 @@
 `[^`]*`\\)"))
 	 (args ()) (pos 0)
 	 (count 0)
-	 beg str value quotes)
+	 beg str quotes)
     ;; Build a list of all the args until we have as many as we want.
     (while (and (or (null mth) (<= count mth))
 		(string-match argpart string pos))
@@ -1379,7 +1377,8 @@
 point as input to the process.  Before the process output mark, calls
 value of variable `comint-get-old-input' to retrieve old input, copies
 it to the process mark, and sends it.  A terminal newline is also
-inserted into the buffer and sent to the process.
+inserted into the buffer and sent to the process unless NO-NEWLINE is
+non-nil.
 
 Any history reference may be expanded depending on the value of the variable
 `comint-input-autoexpand'.  The list of function names contained in the value
@@ -1391,7 +1390,7 @@
 end of line before sending the input.
 
 After the input has been sent, if `comint-process-echoes' is non-nil,
-then comint-send-input waits to see if the process outputs a string
+then `comint-send-input' waits to see if the process outputs a string
 matching the input, and if so, deletes that part of the output.
 
 The values of `comint-get-old-input', `comint-input-filter-functions', and
@@ -1399,19 +1398,19 @@
 in the buffer.  E.g.,
 
 If the interpreter is the csh,
-    comint-get-old-input is the default:
+    `comint-get-old-input' is the default:
 	If `comint-use-prompt-regexp-instead-of-fields' is nil, then
 	either return the current input field, if point is on an input
 	field, or the current line, if point is on an output field.
 	If `comint-use-prompt-regexp-instead-of-fields' is non-nil, then
 	return the current line with any initial string matching the
 	regexp `comint-prompt-regexp' removed.
-    comint-input-filter-functions monitors input for \"cd\", \"pushd\", and
+    `comint-input-filter-functions' monitors input for \"cd\", \"pushd\", and
 	\"popd\" commands. When it sees one, it cd's the buffer.
     comint-input-filter is the default: returns t if the input isn't all white
 	space.
 
-If the comint is Lucid Common Lisp,
+If the Comint is Lucid Common Lisp,
     comint-get-old-input snarfs the sexp ending at point.
     comint-input-filter-functions does nothing.
     comint-input-filter returns nil if the input matches input-filter-regexp,
@@ -1542,17 +1541,17 @@
 either globally or locally.")
 
 (defvar comint-inhibit-carriage-motion nil
-  "If nil, comint will interpret `carriage control' characters in output.
+  "If nil, Comint will interpret `carriage control' characters in output.
 See `comint-carriage-motion' for details.")
 
 ;; When non-nil, this is an overlay over the last recognized prompt in
 ;; the buffer; it is used when highlighting the prompt.
 (defvar comint-last-prompt-overlay nil)
 
-;; `snapshot' any current comint-last-prompt-overlay, freezing its
-;; attributes in place, even when more input comes a long and moves the
-;; prompt overlay.
 (defun comint-snapshot-last-prompt ()
+  "`snapshot' any current `comint-last-prompt-overlay'.
+freeze its attributes in place, even when more input comes a long
+and moves the prompt overlay."
   (when comint-last-prompt-overlay
     (let ((inhibit-read-only t))
       (add-text-properties (overlay-start comint-last-prompt-overlay)
@@ -1835,10 +1834,9 @@
 (defun comint-skip-prompt ()
   "Skip past the text matching regexp `comint-prompt-regexp'.
 If this takes us past the end of the current line, don't skip at all."
-  (let ((eol (save-excursion (end-of-line) (point))))
-    (if (and (looking-at comint-prompt-regexp)
-	     (<= (match-end 0) eol))
-	(goto-char (match-end 0)))))
+  (if (and (looking-at comint-prompt-regexp)
+	   (<= (match-end 0) (line-end-position)))
+      (goto-char (match-end 0))))
 
 (defun comint-after-pmark-p ()
   "Return t if point is after the process output marker."
@@ -1847,7 +1845,7 @@
 
 (defun comint-simple-send (proc string)
   "Default function for sending to PROC input STRING.
-This just sends STRING plus a newline. To override this,
+This just sends STRING plus a newline.  To override this,
 set the hook `comint-input-sender'."
   (comint-send-string proc string)
   (if comint-input-sender-no-newline
@@ -1856,7 +1854,7 @@
     (comint-send-string proc "\n")))
 
 (defun comint-line-beginning-position ()
-  "Returns the buffer position of the beginning of the line, after any prompt.
+  "Return the buffer position of the beginning of the line, after any prompt.
 If `comint-use-prompt-regexp-instead-of-fields' is non-nil, then the
 prompt skip is done by skipping text matching the regular expression
 `comint-prompt-regexp', a buffer local variable."
@@ -1876,7 +1874,7 @@
     (constrain-to-field (line-beginning-position) (line-end-position))))
 
 (defun comint-bol (&optional arg)
-  "Goes to the beginning of line, then skips past the prompt, if any.
+  "Go to the beginning of line, then skip past the prompt, if any.
 If prefix argument is given (\\[universal-argument]) the prompt is not skipped.
 If `comint-use-prompt-regexp-instead-of-fields' is non-nil, then the
 prompt skip is done by skipping text matching the regular expression
@@ -1901,7 +1899,7 @@
 filter and C-g is pressed, this function returns nil rather than a string).
 
 Note that the keystrokes comprising the text can still be recovered
-\(temporarily) with \\[view-lossage].  Some people find this worrysome (see,
+\(temporarily) with \\[view-lossage].  Some people find this worrisome (see,
 however, `clear-this-command-keys').
 Once the caller uses the password, it can erase the password
 by doing (clear-string STRING)."
@@ -1981,7 +1979,7 @@
 ;; Low-level process communication
 
 (defun comint-send-string (process string)
-  "Like `process-send-string', but also does extra bookkeeping for comint mode."
+  "Like `process-send-string', but also does extra bookkeeping for Comint mode."
   (if process
       (with-current-buffer (if (processp process)
 			       (process-buffer process)
@@ -1991,7 +1989,7 @@
   (process-send-string process string))
 
 (defun comint-send-region (process start end)
-  "Like `process-send-region', but also does extra bookkeeping for comint mode."
+  "Like `process-send-region', but also does extra bookkeeping for Comint mode."
   (if process
       (with-current-buffer (if (processp process)
 			       (process-buffer process)
@@ -2077,7 +2075,7 @@
 (defun comint-interrupt-subjob ()
   "Interrupt the current subjob.
 This command also kills the pending input
-between the process-mark and point."
+between the process mark and point."
   (interactive)
   (comint-skip-input)
   (interrupt-process nil comint-ptyp)
@@ -2087,7 +2085,7 @@
 (defun comint-kill-subjob ()
   "Send kill signal to the current subjob.
 This command also kills the pending input
-between the process-mark and point."
+between the process mark and point."
   (interactive)
   (comint-skip-input)
   (kill-process nil comint-ptyp))
@@ -2095,7 +2093,7 @@
 (defun comint-quit-subjob ()
   "Send quit signal to the current subjob.
 This command also kills the pending input
-between the process-mark and point."
+between the process mark and point."
   (interactive)
   (comint-skip-input)
   (quit-process nil comint-ptyp))
@@ -2103,7 +2101,7 @@
 (defun comint-stop-subjob ()
   "Stop the current subjob.
 This command also kills the pending input
-between the process-mark and point.
+between the process mark and point.
 
 WARNING: if there is no current subjob, you can end up suspending
 the top-level process running in the buffer. If you accidentally do
@@ -2155,7 +2153,7 @@
   (process-send-eof))
 
 
-(defun comint-backward-matching-input (regexp arg)
+(defun comint-backward-matching-input (regexp n)
   "Search backward through buffer for input fields that match REGEXP.
 If `comint-use-prompt-regexp-instead-of-fields' is non-nil, then input
 fields are identified by lines that match `comint-prompt-regexp'.
@@ -2166,8 +2164,8 @@
   (if comint-use-prompt-regexp-instead-of-fields
       ;; Use comint-prompt-regexp
       (let* ((re (concat comint-prompt-regexp ".*" regexp))
-	     (pos (save-excursion (end-of-line (if (> arg 0) 0 1))
-				  (if (re-search-backward re nil t arg)
+	     (pos (save-excursion (end-of-line (if (> n 0) 0 1))
+				  (if (re-search-backward re nil t n)
 				      (point)))))
 	(if (null pos)
 	    (progn (message "Not found")
@@ -2175,14 +2173,14 @@
 	  (goto-char pos)
 	  (comint-bol nil)))
     ;; Use input fields
-    (let* ((dir (if (< arg 0) -1 1))
+    (let* ((dir (if (< n 0) -1 1))
 	   (pos
 	    (save-excursion
-	      (while (/= arg 0)
+	      (while (/= n 0)
 		(unless (re-search-backward regexp nil t dir)
 		  (error "Not found"))
 		(when (eq (get-char-property (point) 'field) 'input)
-		  (setq arg (- arg dir))))
+		  (setq n (- n dir))))
 	      (field-beginning))))
       (goto-char pos))))
 
@@ -2252,7 +2250,7 @@
 ;; Needs fixing:
 ;;  make comint-arguments understand negative indices as bash does
 (defun comint-insert-previous-argument (index)
-  "Insert the INDEXth argument from the previous comint command-line at point.
+  "Insert the INDEXth argument from the previous Comint command-line at point.
 Spaces are added at beginning and/or end of the inserted string if
 necessary to ensure that it's separated from adjacent arguments.
 Interactively, if no prefix argument is given, the last argument is inserted.
@@ -2325,39 +2323,35 @@
 ;; COMINT-GET-SOURCE -- used by the source-file processing commands to prompt
 ;; for the file to process.
 
-;; (COMINT-SOURCE-DEFAULT previous-dir/file source-modes)
-;;============================================================================
-;; This function computes the defaults for the load-file and compile-file
-;; commands for tea, soar, cmulisp, and cmuscheme modes.
-;;
-;; - PREVIOUS-DIR/FILE is a pair (directory . filename) from the last
-;; source-file processing command.  nil if there hasn't been one yet.
-;; - SOURCE-MODES is a list used to determine what buffers contain source
-;; files: if the major mode of the buffer is in SOURCE-MODES, it's source.
-;; Typically, (lisp-mode) or (scheme-mode).
-;;
-;; If the command is given while the cursor is inside a string, *and*
-;; the string is an existing filename, *and* the filename is not a directory,
-;; then the string is taken as default.  This allows you to just position
-;; your cursor over a string that's a filename and have it taken as default.
-;;
-;; If the command is given in a file buffer whose major mode is in
-;; SOURCE-MODES, then the filename is the default file, and the
-;; file's directory is the default directory.
-;;
-;; If the buffer isn't a source file buffer (e.g., it's the process buffer),
-;; then the default directory & file are what was used in the last source-file
-;; processing command (i.e., PREVIOUS-DIR/FILE).  If this is the first time
-;; the command has been run (PREVIOUS-DIR/FILE is nil), the default directory
-;; is the cwd, with no default file. (\"no default file\" = nil)
-;;
-;; SOURCE-REGEXP is typically going to be something like (tea-mode)
-;; for T programs, (lisp-mode) for Lisp programs, (soar-mode lisp-mode)
-;; for Soar programs, etc.
-;;
-;; The function returns a pair: (default-directory . default-file).
-
 (defun comint-source-default (previous-dir/file source-modes)
+  "Compute the defaults for `load-file' and `compile-file' commands.
+
+PREVIOUS-DIR/FILE is a pair (directory . filename) from the last
+source-file processing command.  nil if there hasn't been one yet.
+SOURCE-MODES is a list used to determine what buffers contain source
+files: if the major mode of the buffer is in SOURCE-MODES, it's source.
+Typically, (lisp-mode) or (scheme-mode).
+
+If the command is given while the cursor is inside a string, *and*
+the string is an existing filename, *and* the filename is not a directory,
+then the string is taken as default.  This allows you to just position
+your cursor over a string that's a filename and have it taken as default.
+
+If the command is given in a file buffer whose major mode is in
+SOURCE-MODES, then the filename is the default file, and the
+file's directory is the default directory.
+
+If the buffer isn't a source file buffer (e.g., it's the process buffer),
+then the default directory & file are what was used in the last source-file
+processing command (i.e., PREVIOUS-DIR/FILE).  If this is the first time
+the command has been run (PREVIOUS-DIR/FILE is nil), the default directory
+is the cwd, with no default file.  (\"no default file\" = nil)
+
+SOURCE-REGEXP is typically going to be something like (tea-mode)
+for T programs, (lisp-mode) for Lisp programs, (soar-mode lisp-mode)
+for Soar programs, etc.
+
+The function returns a pair: (default-directory . default-file)."
   (cond ((and buffer-file-name (memq major-mode source-modes))
 	 (cons (file-name-directory    buffer-file-name)
 	       (file-name-nondirectory buffer-file-name)))
@@ -2366,15 +2360,13 @@
 	 (cons default-directory nil))))
 
 
-;; (COMINT-CHECK-SOURCE fname)
-;;============================================================================
-;; Prior to loading or compiling (or otherwise processing) a file (in the CMU
-;; process-in-a-buffer modes), this function can be called on the filename.
-;; If the file is loaded into a buffer, and the buffer is modified, the user
-;; is queried to see if he wants to save the buffer before proceeding with
-;; the load or compile.
-
 (defun comint-check-source (fname)
+  "Check whether to save buffers visiting file FNAME.
+Prior to loading or compiling (or otherwise processing) a file (in the CMU
+process-in-a-buffer modes), this function can be called on the filename.
+If the file is loaded into a buffer, and the buffer is modified, the user
+is queried to see if he wants to save the buffer before proceeding with
+the load or compile."
   (let ((buff (get-file-buffer fname)))
     (if (and buff
 	     (buffer-modified-p buff)
@@ -2385,44 +2377,33 @@
 	  (save-buffer)
 	  (set-buffer old-buffer)))))
 
-
-;; (COMINT-GET-SOURCE prompt prev-dir/file source-modes mustmatch-p)
-;;============================================================================
-;; COMINT-GET-SOURCE is used to prompt for filenames in command-interpreter
-;; commands that process source files (like loading or compiling a file).
-;; It prompts for the filename, provides a default, if there is one,
-;; and returns the result filename.
-;;
-;; See COMINT-SOURCE-DEFAULT for more on determining defaults.
-;;
-;; PROMPT is the prompt string. PREV-DIR/FILE is the (directory . file) pair
-;; from the last source processing command.  SOURCE-MODES is a list of major
-;; modes used to determine what file buffers contain source files.  (These
-;; two arguments are used for determining defaults). If MUSTMATCH-P is true,
-;; then the filename reader will only accept a file that exists.
-;;
-;; A typical use:
-;; (interactive (comint-get-source "Compile file: " prev-lisp-dir/file
-;;                                 '(lisp-mode) t))
-
-;; This is pretty stupid about strings. It decides we're in a string
-;; if there's a quote on both sides of point on the current line.
 (defun comint-extract-string ()
-  "Return string around POINT that starts the current line, or nil."
-  (save-excursion
-    (let* ((point (point))
-	   (bol (progn (beginning-of-line) (point)))
-	   (eol (progn (end-of-line) (point)))
-	   (start (progn (goto-char point)
-			 (and (search-backward "\"" bol t)
-			      (1+ (point)))))
-	   (end (progn (goto-char point)
-		       (and (search-forward "\"" eol t)
-			    (1- (point))))))
-      (and start end
-	   (buffer-substring-no-properties start end)))))
+  "Return string around POINT, or nil."
+  (let ((syntax (syntax-ppss)))
+    (when (nth 3 syntax)
+      (condition-case ()
+	  (buffer-substring-no-properties (1+ (nth 8 syntax))
+					  (progn (goto-char (nth 8 syntax))
+						 (forward-sexp)
+						 (1- (point))))
+	(error nil)))))
 
 (defun comint-get-source (prompt prev-dir/file source-modes mustmatch-p)
+  "Prompt for filenames in commands that process source files,
+e.g. loading or compiling a file.
+Provides a default, if there is one, and returns the result filename.
+
+See `comint-source-default' for more on determining defaults.
+
+PROMPT is the prompt string. PREV-DIR/FILE is the (directory . file) pair
+from the last source processing command.  SOURCE-MODES is a list of major
+modes used to determine what file buffers contain source files.  (These
+two arguments are used for determining defaults).  If MUSTMATCH-P is true,
+then the filename reader will only accept a file that exists.
+
+A typical use:
+ (interactive (comint-get-source \"Compile file: \" prev-lisp-dir/file
+                                 '(lisp-mode) t))"
   (let* ((def (comint-source-default prev-dir/file source-modes))
 	 (stringfile (comint-extract-string))
 	 (sfile-p (and stringfile
@@ -2464,9 +2445,10 @@
 ;; process responds with and put it in a pop-up window or on the message
 ;; line. We just display the buffer. Low tech. Simple. Works good.
 
-;; Send to the inferior process PROC the string STR. Pop-up but do not select
-;; a window for the inferior process so that its response can be seen.
 (defun comint-proc-query (proc str)
+  "Send to the inferior process PROC the string STR.
+Pop-up but do not select a window for the inferior process so that
+its response can be seen."
   (let* ((proc-buf (process-buffer proc))
 	 (proc-mark (process-mark proc)))
     (display-buffer proc-buf)
@@ -2545,7 +2527,7 @@
 
 (defvar comint-file-name-prefix ""
   "Prefix prepended to absolute file names taken from process input.
-This is used by comint's and shell's completion functions, and by shell's
+This is used by Comint's and shell's completion functions, and by shell's
 directory tracking functions.")
 
 (defvar comint-file-name-chars
@@ -2565,14 +2547,14 @@
 
 
 (defun comint-directory (directory)
-  ;; Return expanded DIRECTORY, with `comint-file-name-prefix' if absolute.
+  "Return expanded DIRECTORY, with `comint-file-name-prefix' if absolute."
   (expand-file-name (if (file-name-absolute-p directory)
 			(concat comint-file-name-prefix directory)
 		      directory)))
 
 
 (defun comint-word (word-chars)
-  "Return the word of WORD-CHARS at point, or nil if non is found.
+  "Return the word of WORD-CHARS at point, or nil if none is found.
 Word constituents are considered to be those in WORD-CHARS, which is like the
 inside of a \"[...]\" (see `skip-chars-forward'),
 plus all non-ASCII characters."
@@ -2582,6 +2564,8 @@
       (while (not giveup)
 	(let ((startpoint (point)))
 	  (skip-chars-backward (concat "\\\\" word-chars))
+	  ;; Fixme: This isn't consistent with Bash, at least -- not
+	  ;; all non-ASCII chars should be word constituents.
 	  (if (and (> (- (point) 2) (point-min))
 		   (= (char-after (- (point) 2)) ?\\))
 	      (forward-char -2))
@@ -2773,7 +2757,6 @@
 	 (suffix (cond ((not comint-completion-addsuffix) "")
 		       ((not (consp comint-completion-addsuffix)) " ")
 		       (t (cdr comint-completion-addsuffix))))
-	 (candidates (mapcar (function (lambda (x) (list x))) candidates))
 	 (completions (all-completions stub candidates)))
     (cond ((null completions)
 	   (message "No completions of %s" stub)
@@ -2962,34 +2945,36 @@
 ;;
 ;; My particular use is SQL interpreters; I want to be able to execute a
 ;; query using the process associated with a comint-buffer, and save that
-;; somewhere else. Because the process might have state (for example, it
+;; somewhere else.  Because the process might have state (for example, it
 ;; could be in an uncommitted transaction), just running starting a new
 ;; process and having it execute the query and then finish, would not
-;; work. I'm sure there are other uses as well, although in many cases
+;; work.  I'm sure there are other uses as well, although in many cases
 ;; starting a new process is the simpler, and thus preferable, approach.
 ;;
 ;; The basic implementation is as follows: comint-redirect changes the
-;; preoutput filter functions (comint-preoutput-filter-functions) to use
-;; its own filter. The filter puts the output into the designated buffer,
+;; preoutput filter functions (`comint-preoutput-filter-functions') to use
+;; its own filter.  The filter puts the output into the designated buffer,
 ;; or buffers, until it sees a regexp that tells it to stop (by default,
-;; this is the prompt for the interpreter, comint-prompt-regexp). When it
+;; this is the prompt for the interpreter, `comint-prompt-regexp'). When it
 ;; sees the stop regexp, it restores the old filter functions, and runs
-;; comint-redirect-hook.
+;; `comint-redirect-hook'.
 ;;
 ;; Each comint buffer may only use one redirection at a time, but any number
 ;; of different comint buffers may be simultaneously redirected.
 ;;
 ;; NOTE: It is EXTREMELY important that `comint-prompt-regexp' be set to the
 ;; correct prompt for your interpreter, or that you supply a regexp that says
-;; when the redirection is finished. Otherwise, redirection will continue
-;; indefinitely. The code now does a sanity check to ensure that it can find
+;; when the redirection is finished.  Otherwise, redirection will continue
+;; indefinitely.  The code now does a sanity check to ensure that it can find
 ;; a prompt in the comint buffer; however, it is still important to ensure that
 ;; this prompt is set correctly.
 ;;
-;; XXX: This doesn't work so well unless comint-prompt-regexp is set;
+;; XXX: This doesn't work so well unless `comint-prompt-regexp' is set;
 ;; perhaps it should prompt for a terminating string (with an
 ;; appropriate magic default by examining what we think is the prompt)?
 ;;
+;; Fixme: look for appropriate fields, rather than regexp, if
+;; `comint-use-prompt-regexp-instead-of-fields' is true.
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Variables
@@ -3055,6 +3040,12 @@
 When redirection is completed, the process filter is restored to
 this value.")
 
+(defvar comint-redirect-subvert-readonly nil
+  "Non-nil means comint-redirect can insert into otherwise-readonly buffers.
+The readonly status is toggled around insertion.
+This is useful, for instance, for insertion into Help mode buffers.
+You probably want to set it locally to the output buffer.")
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Functions
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -3071,7 +3062,7 @@
 in the output matches FINISHED-REGEXP.
 
 If optional argument ECHO-INPUT is non-nil, output is echoed to the
-original comint buffer.
+original Comint buffer.
 
 This function is called by `comint-redirect-send-command-to-process',
 and does not normally need to be invoked by the end user or programmer."
@@ -3117,7 +3108,7 @@
 The variable `comint-redirect-output-buffer' says which buffer(s) to
 place output in.
 
-INPUT-STRING is the input from the comint process.
+INPUT-STRING is the input from the Comint process.
 
 This function runs as a process filter, and does not need to be invoked by the
 end user."
@@ -3132,11 +3123,11 @@
 
 
 (defun comint-redirect-preoutput-filter (input-string)
-  "Comint filter function which redirects comint output to a buffer or buffers.
+  "Comint filter function which redirects Comint output to a buffer or buffers.
 The variable `comint-redirect-output-buffer' says which buffer(s) to
 place output in.
 
-INPUT-STRING is the input from the comint process.
+INPUT-STRING is the input from the Comint process.
 
 This function does not need to be invoked by the end user."
   (let ((output-buffer-list
@@ -3168,15 +3159,14 @@
 
     ;; Send output to all registered buffers
     (save-excursion
-      (mapcar
-       (function (lambda(buf)
-		   ;; Set this buffer to the output buffer
-		   (set-buffer (get-buffer-create buf))
-		   ;; Go to the end of the buffer
-		   (goto-char (point-max))
-		   ;; Insert the output
-		   (insert filtered-input-string)))
-       output-buffer-list))
+      (dolist (buf output-buffer-list)
+	;; Set this buffer to the output buffer
+	(set-buffer (get-buffer-create buf))
+	;; Go to the end of the buffer
+	(goto-char (point-max))
+	;; Insert the output
+	(let ((inhibit-read-only comint-redirect-subvert-readonly))
+	  (insert filtered-input-string))))
 
     ;; Message
     (and comint-redirect-verbose
@@ -3200,7 +3190,7 @@
 ;;;###autoload
 (defun comint-redirect-send-command (command output-buffer echo &optional no-display)
   "Send COMMAND to process in current buffer, with output to OUTPUT-BUFFER.
-With prefix arg, echo output in process buffer.
+With prefix arg ECHO, echo output in process buffer.
 
 If NO-DISPLAY is non-nil, do not show the output buffer."
   (interactive "sCommand: \nBOutput Buffer: \nP")
--- a/lisp/diff-mode.el	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/diff-mode.el	Thu Apr 15 16:49:22 2004 +0000
@@ -110,7 +110,7 @@
     ("}" . diff-file-next)
     ("{" . diff-file-prev)
     ("\C-m" . diff-goto-source)
-    ([mouse-2] . diff-mouse-goto-source)
+    ([mouse-2] . diff-goto-source)
     ;; From XEmacs' diff-mode.
     ("W" . widen)
     ;;("." . diff-goto-source)		;display-buffer
@@ -547,14 +547,6 @@
 	 file)))))
 
 
-(defun diff-mouse-goto-source (event)
-  "Run `diff-goto-source' for the diff at a mouse click."
-  (interactive "e")
-  (save-excursion
-    (mouse-set-point event)
-    (diff-goto-source)))
-
-
 (defun diff-ediff-patch ()
   "Call `ediff-patch-file' on the current buffer."
   (interactive)
@@ -1223,16 +1215,19 @@
     (diff-hunk-status-msg line-offset (diff-xor reverse switched) t)))
 
 
-(defun diff-goto-source (&optional other-file)
+(defalias 'diff-mouse-goto-source 'diff-goto-source)
+
+(defun diff-goto-source (&optional other-file event)
   "Jump to the corresponding source line.
 `diff-jump-to-old-file' (or its opposite if the OTHER-FILE prefix arg
 is given) determines whether to jump to the old or the new file.
 If the prefix arg is bigger than 8 (for example with \\[universal-argument] \\[universal-argument])
   then `diff-jump-to-old-file' is also set, for the next invocations."
-  (interactive "P")
+  (interactive (list current-prefix-arg last-input-event))
   ;; When pointing at a removal line, we probably want to jump to
   ;; the old location, and else to the new (i.e. as if reverting).
   ;; This is a convenient detail when using smerge-diff.
+  (if event (posn-set-point (event-end event)))
   (let ((rev (not (save-excursion (beginning-of-line) (looking-at "[-<]")))))
     (destructuring-bind (buf line-offset pos src dst &optional switched)
 	(diff-find-source-location other-file rev)
--- a/lisp/emacs-lisp/bytecomp.el	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/emacs-lisp/bytecomp.el	Thu Apr 15 16:49:22 2004 +0000
@@ -3966,27 +3966,29 @@
     (kill-emacs (if error 1 0))))
 
 (defun batch-byte-compile-file (file)
-  (condition-case err
+  (if debug-on-error
       (byte-compile-file file)
-    (file-error
-     (message (if (cdr err)
-		  ">>Error occurred processing %s: %s (%s)"
+    (condition-case err
+	(byte-compile-file file)
+      (file-error
+       (message (if (cdr err)
+		    ">>Error occurred processing %s: %s (%s)"
 		  ">>Error occurred processing %s: %s")
-	      file
-	      (get (car err) 'error-message)
-	      (prin1-to-string (cdr err)))
-     (let ((destfile (byte-compile-dest-file file)))
-       (if (file-exists-p destfile)
-	   (delete-file destfile)))
-     nil)
-    (error
-     (message (if (cdr err)
-		  ">>Error occurred processing %s: %s (%s)"
+		file
+		(get (car err) 'error-message)
+		(prin1-to-string (cdr err)))
+       (let ((destfile (byte-compile-dest-file file)))
+	 (if (file-exists-p destfile)
+	     (delete-file destfile)))
+       nil)
+      (error
+       (message (if (cdr err)
+		    ">>Error occurred processing %s: %s (%s)"
 		  ">>Error occurred processing %s: %s")
-	      file
-	      (get (car err) 'error-message)
-	      (prin1-to-string (cdr err)))
-     nil)))
+		file
+		(get (car err) 'error-message)
+		(prin1-to-string (cdr err)))
+       nil))))
 
 ;;;###autoload
 (defun batch-byte-recompile-directory ()
--- a/lisp/emacs-lisp/checkdoc.el	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/emacs-lisp/checkdoc.el	Thu Apr 15 16:49:22 2004 +0000
@@ -653,8 +653,7 @@
 			(sit-for 2))
 		    (setq err-list (cdr err-list))))
 		(beginning-of-defun)
-		(let ((pe (car err-list))
-		      (ne (funcall findfunc nil)))
+		(let ((ne (funcall findfunc nil)))
 		  (if ne
 		      (setq err-list (cons ne err-list))
 		    (cond ((not err-list)
@@ -900,7 +899,7 @@
 save warnings in a separate buffer.  Second optional argument START-POINT
 is the starting location.  If this is nil, `point-min' is used instead."
   (interactive "P")
-  (let ((wrong nil) (msg nil) (errors nil)
+  (let ((wrong nil) (msg nil)
 	;; Assign a flag to spellcheck flag
 	(checkdoc-spellcheck-documentation-flag
 	 (car (memq checkdoc-spellcheck-documentation-flag
@@ -2598,14 +2597,13 @@
   (setq checkdoc-output-mode-map (make-sparse-keymap))
   (if (not (string-match "XEmacs" emacs-version))
       (define-key checkdoc-output-mode-map [mouse-2]
-	'checkdoc-find-error-mouse))
+	'checkdoc-find-error))
   (define-key checkdoc-output-mode-map "\C-c\C-c" 'checkdoc-find-error)
   (define-key checkdoc-output-mode-map "\C-m" 'checkdoc-find-error))
 
 (defun checkdoc-output-mode ()
   "Create and setup the buffer used to maintain checkdoc warnings.
-\\<checkdoc-output-mode-map>\\[checkdoc-find-error]  - Go to this error location
-\\[checkdoc-find-error-mouse] - Goto the error clicked on."
+\\<checkdoc-output-mode-map>\\[checkdoc-find-error]  - Go to this error location."
   (if (get-buffer checkdoc-diagnostic-buffer)
       (get-buffer checkdoc-diagnostic-buffer)
     (save-excursion
@@ -2619,16 +2617,11 @@
       (run-hooks 'checkdoc-output-mode-hook)
       (current-buffer))))
 
-(defun checkdoc-find-error-mouse (e)
-  ;; checkdoc-params: (e)
-  "Call `checkdoc-find-error' where the user clicks the mouse."
-  (interactive "e")
-  (mouse-set-point e)
-  (checkdoc-find-error))
-
-(defun checkdoc-find-error ()
+(defalias 'checkdoc-find-error-mouse 'checkdoc-find-error)
+(defun checkdoc-find-error (&optional event)
   "In a checkdoc diagnostic buffer, find the error under point."
-  (interactive)
+  (interactive (list last-input-event))
+  (if event (posn-set-point (event-end e)))
   (beginning-of-line)
   (if (looking-at "\\(\\(\\w+\\|\\s_\\)+\\.el\\):\\([0-9]+\\):")
       (let ((l (string-to-int (match-string 3)))
--- a/lisp/emacs-lisp/lisp.el	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/emacs-lisp/lisp.el	Thu Apr 15 16:49:22 2004 +0000
@@ -1,6 +1,6 @@
 ;;; lisp.el --- Lisp editing commands for Emacs
 
-;; Copyright (C) 1985, 1986, 1994, 2000 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 86, 1994, 2000, 2004  Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: lisp, languages
@@ -188,8 +188,12 @@
 is called as a function to find the defun's beginning."
   (interactive "p")
   (if beginning-of-defun-function
-      (dotimes (i (or arg 1))
-	(funcall beginning-of-defun-function))
+      (if (> (setq arg (or arg 1)) 0)
+	  (dotimes (i arg)
+	    (funcall beginning-of-defun-function))
+	;; Better not call end-of-defun-function directly, in case
+	;; it's not defined.
+	(end-of-defun (- arg)))
     (and arg (< arg 0) (not (eobp)) (forward-char 1))
     (and (re-search-backward (if defun-prompt-regexp
 				 (concat (if open-paren-in-column-0-is-defun-start
@@ -219,13 +223,17 @@
 If variable `end-of-defun-function' is non-nil, its value
 is called as a function to find the defun's end."
   (interactive "p")
+  (if (or (null arg) (= arg 0)) (setq arg 1))
   (if end-of-defun-function
-      (dotimes (i (or arg 1))
-	(funcall end-of-defun-function))
-    (if (or (null arg) (= arg 0)) (setq arg 1))
+      (if (> arg 0)
+	  (dotimes (i arg)
+	    (funcall end-of-defun-function))
+	;; Better not call beginning-of-defun-function
+	;; directly, in case it's not defined.
+	(beginning-of-defun (- arg)))
     (let ((first t))
       (while (and (> arg 0) (< (point) (point-max)))
-	(let ((pos (point)) npos)
+	(let ((pos (point)))
 	  (while (progn
 		   (if (and first
 			    (progn
--- a/lisp/emulation/cua-base.el	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/emulation/cua-base.el	Thu Apr 15 16:49:22 2004 +0000
@@ -419,19 +419,22 @@
   :group 'cua)
 
 (defcustom cua-read-only-cursor-color "darkgreen"
-  "*Cursor color used in read-only buffers, if non-nil."
+  "*Cursor color used in read-only buffers, if non-nil.
+Only used when `cua-enable-cursor-indications' is non-nil."
   :type 'color
   :group 'cua)
 
 (defcustom cua-overwrite-cursor-color "yellow"
   "*Cursor color used when overwrite mode is set, if non-nil.
-Also used to indicate that rectangle padding is in effect."
+Also used to indicate that rectangle padding is in effect.
+Only used when `cua-enable-cursor-indications' is non-nil."
   :type 'color
   :group 'cua)
 
 (defcustom cua-global-mark-cursor-color "cyan"
   "*Indication for active global mark.
-Will change cursor color to specified color if string."
+Will change cursor color to specified color if string.
+Only used when `cua-enable-cursor-indications' is non-nil."
   :type 'color
   :group 'cua)
 
@@ -850,7 +853,7 @@
 
 With no prefix argument, clear mark if already set.  Otherwise, set
 mark, and push old mark position on local mark ring; also push mark on
-global mark ring if last mark was set in another buffer.  
+global mark ring if last mark was set in another buffer.
 
 With argument, jump to mark, and pop a new position for mark off
 the local mark ring \(this does not affect the global mark ring\).
--- a/lisp/info.el	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/info.el	Thu Apr 15 16:49:22 2004 +0000
@@ -470,18 +470,16 @@
 in all the directories in that path."
   (interactive (if current-prefix-arg
 		   (list (read-file-name "Info file name: " nil nil t))))
+  (pop-to-buffer "*info*")
   (if file
-      (progn
-	(pop-to-buffer "*info*")
-	;; If argument already contains parentheses, don't add another set
-	;; since the argument will then be parsed improperly.  This also
-	;; has the added benefit of allowing node names to be included
-	;; following the parenthesized filename.
-	(if (and (stringp file) (string-match "(.*)" file))
-	    (Info-goto-node file)
-	  (Info-goto-node (concat "(" file ")"))))
-    (if (get-buffer "*info*")
-	(pop-to-buffer "*info*")
+      ;; If argument already contains parentheses, don't add another set
+      ;; since the argument will then be parsed improperly.  This also
+      ;; has the added benefit of allowing node names to be included
+      ;; following the parenthesized filename.
+      (if (and (stringp file) (string-match "(.*)" file))
+	  (Info-goto-node file)
+	(Info-goto-node (concat "(" file ")")))
+    (if (zerop (buffer-size))
       (Info-directory))))
 
 ;;;###autoload
@@ -2432,6 +2430,7 @@
     (let ((pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^.]+\\)."
 			   (regexp-quote string)))
 	  (ohist Info-history)
+	  (ohist-list Info-history-list)
 	  (current-node Info-current-node)
 	  (current-file Info-current-file)
 	  manuals matches temp-file node)
@@ -2465,7 +2464,8 @@
 		    (Info-goto-node node))))
 	    (error nil))))
       (Info-goto-node (concat "(" current-file ")" current-node))
-      (setq Info-history ohist)
+      (setq Info-history ohist
+	    Info-history-list ohist-list)
       (message "Searching indices...done")
       (if (null matches)
 	  (message "No matches found")
--- a/lisp/mouse.el	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/mouse.el	Thu Apr 15 16:49:22 2004 +0000
@@ -1,6 +1,6 @@
 ;;; mouse.el --- window system-independent mouse support
 
-;; Copyright (C) 1993, 1994, 1995, 1999, 2000, 2001
+;; Copyright (C) 1993, 94, 95, 1999, 2000, 01, 2004
 ;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
@@ -577,12 +577,7 @@
   (mouse-minibuffer-check event)
   ;; Use event-end in case called from mouse-drag-region.
   ;; If EVENT is a click, event-end and event-start give same value.
-  (let ((posn (event-end event)))
-    (if (not (windowp (posn-window posn)))
-	(error "Cursor not in text area of window"))
-    (select-window (posn-window posn))
-    (if (numberp (posn-point posn))
-	(goto-char (posn-point posn)))))
+  (posn-set-point (event-end event)))
 
 (defvar mouse-last-region-beg nil)
 (defvar mouse-last-region-end nil)
--- a/lisp/pcvs-info.el	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/pcvs-info.el	Thu Apr 15 16:49:22 2004 +0000
@@ -130,7 +130,7 @@
   "The prefix that CVS prepends to files when rcsmerge'ing.")
 
 (easy-mmode-defmap cvs-status-map
-  '(([(mouse-2)] . cvs-mouse-toggle-mark))
+  '(([(mouse-2)] . cvs-mode-toggle-mark))
   "Local keymap for text properties of status")
 
 ;; Constructor:
--- a/lisp/pcvs.el	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/pcvs.el	Thu Apr 15 16:49:22 2004 +0000
@@ -1194,11 +1194,12 @@
       (ewoc-invalidate cvs-cookies tin)
       (cvs-mode-next-line 1))))
 
-(defun cvs-mouse-toggle-mark (e)
-  "Toggle the mark of the entry under the mouse."
-  (interactive "e")
+(defalias 'cvs-mouse-toggle-mark 'cvs-mode-toggle-mark)
+(defun cvs-mode-toggle-mark (e)
+  "Toggle the mark of the entry at point."
+  (interactive (list last-input-event))
   (save-excursion
-    (mouse-set-point e)
+    (posn-set-point (event-end e))
     (cvs-mode-mark 'toggle)))
 
 (defun-cvs-mode cvs-mode-unmark ()
@@ -1930,7 +1931,7 @@
 With a prefix, opens the buffer in an OTHER window."
   (interactive (list last-input-event current-prefix-arg))
   ;; If the event moves point, check that it moves it to a valid location.
-  (when (and (/= (point) (progn (ignore-errors (mouse-set-point e)) (point)))
+  (when (and (/= (point) (progn (posn-set-point (event-end e)) (point)))
 	     (not (memq (get-text-property (1- (line-end-position))
                                            'font-lock-face)
                         '(cvs-header-face cvs-filename-face))))
--- a/lisp/progmodes/ada-mode.el	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/progmodes/ada-mode.el	Thu Apr 15 16:49:22 2004 +0000
@@ -1,6 +1,6 @@
 ;;; ada-mode.el --- major-mode for editing Ada sources
 
-;; Copyright (C) 1994, 95, 97, 98, 99, 2000, 2001, 2002, 2003
+;; Copyright (C) 1994, 95, 97, 98, 99, 2000, 2001, 2002, 03, 2004
 ;;  Free Software Foundation, Inc.
 
 ;; Author: Rolf Ebert      <ebert@inf.enst.fr>
@@ -4732,7 +4732,6 @@
 	     )))
 
     (easy-menu-define ada-mode-menu ada-mode-map "Menu keymap for Ada mode" m)
-    (easy-menu-add ada-mode-menu ada-mode-map)
     (if (featurep 'xemacs)
 	(progn
 	  (define-key ada-mode-map [menu-bar] ada-mode-menu)
--- a/lisp/progmodes/compile.el	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/progmodes/compile.el	Thu Apr 15 16:49:22 2004 +0000
@@ -646,6 +646,7 @@
 			  (if line
 			      "mouse-2: visit this file and line"
 			    "mouse-2: visit this file"))
+	     keymap compilation-button-map
 	     mouse-face highlight))))
 
 (defun compilation-mode-font-lock-keywords ()
@@ -675,10 +676,10 @@
 	      (col (nth 3 item))
 	      (type (nth 4 item))
 	      end-line end-col fmt)
-	  (if (consp file) (setq fmt (cdr file)	  file (car file)))
-	  (if (consp line) (setq end-line (cdr line) line (car line)))
+	  (if (consp file)	(setq fmt (cdr file)	  file (car file)))
+	  (if (consp line)	(setq end-line (cdr line) line (car line)))
 	  (if (consp col)	(setq end-col (cdr col)	  col (car col)))
-	  
+
 	  (if (functionp line)
 	      ;; The old compile.el had here an undocumented hook that
 	      ;; allowed `line' to be a function that computed the actual
@@ -690,7 +691,7 @@
 					   ',(nthcdr 4 item))
 			     ,(if col `(match-string ,col)))))
 		(,file compilation-error-face t))
-		    
+
 	    `(,(nth 0 item)
 
 	      ,@(when (integerp file)
@@ -998,7 +999,6 @@
 
 (defvar compilation-shell-minor-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map [mouse-2] 'compile-goto-error)
     (define-key map "\M-\C-m" 'compile-goto-error)
     (define-key map "\M-\C-n" 'compilation-next-error)
     (define-key map "\M-\C-p" 'compilation-previous-error)
@@ -1010,6 +1010,14 @@
     map)
   "Keymap for `compilation-shell-minor-mode'.")
 
+(defvar compilation-button-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [mouse-2] 'compile-goto-error)
+    (define-key map "\C-m" 'compile-goto-error)
+    map)
+  "Keymap for compilation-message buttons.")
+(fset 'compilation-button-map compilation-button-map)
+
 (defvar compilation-mode-map
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map compilation-minor-mode-map)
@@ -1131,6 +1139,7 @@
   "Prepare the buffer for the compilation parsing commands to work."
   (make-local-variable 'compilation-current-error)
   (make-local-variable 'compilation-error-screen-columns)
+  (make-local-variable 'overlay-arrow-position)
   (setq compilation-last-buffer (current-buffer))
   (set (make-local-variable 'font-lock-extra-managed-props)
        '(directory message help-echo mouse-face debug))
@@ -1192,8 +1201,7 @@
 		  (cons msg exit-status)))
 	(omax (point-max))
 	(opoint (point)))
-    ;; Record where we put the message, so we can ignore it
-    ;; later on.
+    ;; Record where we put the message, so we can ignore it later on.
     (goto-char omax)
     (insert ?\n mode-name " " (car status))
     (if (and (numberp compilation-window-height)
@@ -1221,24 +1229,22 @@
 ;; Called when compilation process changes state.
 (defun compilation-sentinel (proc msg)
   "Sentinel for compilation buffers."
-  (let ((buffer (process-buffer proc)))
-    (if (memq (process-status proc) '(signal exit))
-	(progn
-	  (if (null (buffer-name buffer))
-	      ;; buffer killed
-	      (set-process-buffer proc nil)
-	    (with-current-buffer buffer
-	      ;; Write something in the compilation buffer
-	      ;; and hack its mode line.
-	      (compilation-handle-exit (process-status proc)
-				       (process-exit-status proc)
-				       msg)
-	      ;; Since the buffer and mode line will show that the
-	      ;; process is dead, we can delete it now.  Otherwise it
-	      ;; will stay around until M-x list-processes.
-	      (delete-process proc)))
-	  (setq compilation-in-progress (delq proc compilation-in-progress))
-	  ))))
+  (if (memq (process-status proc) '(exit signal))
+      (let ((buffer (process-buffer proc)))
+	(if (null (buffer-name buffer))
+	    ;; buffer killed
+	    (set-process-buffer proc nil)
+	  (with-current-buffer buffer
+	    ;; Write something in the compilation buffer
+	    ;; and hack its mode line.
+	    (compilation-handle-exit (process-status proc)
+				     (process-exit-status proc)
+				     msg)
+	    ;; Since the buffer and mode line will show that the
+	    ;; process is dead, we can delete it now.  Otherwise it
+	    ;; will stay around until M-x list-processes.
+	    (delete-process proc)))
+	(setq compilation-in-progress (delq proc compilation-in-progress)))))
 
 (defun compilation-filter (proc string)
   "Process filter for compilation buffers.
@@ -1293,13 +1299,11 @@
 						 'message)))
 	  (setq pt (previous-single-property-change pt 'message nil
 						    (line-beginning-position)))
-	  (if pt	 ; FIXME: `pt' can never be nil here anyway.  --stef
-	      (setq msg (get-text-property (max (1- pt) (point-min)) 'message))
+	  (unless (setq msg (get-text-property (max (1- pt) (point-min)) 'message))
 	    (setq pt (next-single-property-change pt 'message nil
 						  (line-end-position)))
-	    (if pt	 ; FIXME: `pt' can never be nil here anyway.  --stef
-		(setq msg (get-text-property pt 'message))
-	      (setq pt (point)))))
+	    (or (setq msg (get-text-property pt 'message))
+		(setq pt (point)))))
       (setq last (nth 2 (car msg)))
       (if (>= n 0)
 	  (compilation-loop > next-single-property-change 1-
@@ -1368,16 +1372,14 @@
   "Visit the source for the error message at point.
 Use this command in a compilation log buffer.  Sets the mark at point there."
   (interactive (list last-input-event))
+  (if event (posn-set-point (event-end event)))
   (or (compilation-buffer-p (current-buffer))
       (error "Not in a compilation buffer"))
-  (let* ((loc (event-end event))
-	 (pos (posn-point loc)))
-    (with-selected-window (posn-window loc)
-      (if (get-text-property pos 'directory)
-	  (dired-other-window (car (get-text-property pos 'directory)))
-	(push-mark)
-	(setq compilation-current-error pos)
-	(next-error 0)))))
+  (if (get-text-property (point) 'directory)
+      (dired-other-window (car (get-text-property (point) 'directory)))
+    (push-mark)
+    (setq compilation-current-error (point))
+    (next-error 0)))
 
 ;; Return a compilation buffer.
 ;; If the current buffer is a compilation buffer, return it.
@@ -1437,6 +1439,12 @@
 	 (end-loc (nth 2 loc))
 	 (marker (point-marker)))
     (setq compilation-current-error (point-marker)
+	  overlay-arrow-position
+	    (if (bolp)
+		compilation-current-error
+	      (save-excursion
+		(beginning-of-line)
+		(point-marker)))
 	  loc (car loc))
     ;; If loc contains no marker, no error in that file has been visited.  If
     ;; the marker is invalid the buffer has been killed.  So, recalculate all
@@ -1734,11 +1742,10 @@
 (defun compilation-forget-errors ()
   ;; In case we hit the same file/line specs, we want to recompute a new
   ;; marker for them, so flush our cache.
-  (set (make-local-variable 'compilation-locs)
-       (make-hash-table :test 'equal :weakness 'value))
+  (setq compilation-locs (make-hash-table :test 'equal :weakness 'value))
   ;; FIXME: the old code reset the directory-stack, so maybe we should
   ;; put a `directory change' marker of some sort, but where?  -stef
-  ;; 
+  ;;
   ;; FIXME: The old code moved compilation-current-error (which was
   ;; virtually represented by a mix of compilation-parsing-end and
   ;; compilation-error-list) to point-min, but that was only meaningful for
@@ -1747,10 +1754,7 @@
   ;; something equivalent to point-max.  So we speculatively move
   ;; compilation-current-error to point-max (since the external package
   ;; won't know that it should do it).  --stef
-  (setq compilation-current-error (point-max))
-  ;; FIXME the old code removed the mouse-face and help-echo properties.
-  ;; Should we font-lock-fontify-buffer?  --stef
-  )
+  (setq compilation-current-error (point-max)))
 
 (provide 'compile)
 
--- a/lisp/progmodes/python.el	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/progmodes/python.el	Thu Apr 15 16:49:22 2004 +0000
@@ -38,7 +38,7 @@
 
 ;; This doesn't implement all the facilities of python-mode.el.  Some
 ;; just need doing, e.g. catching exceptions in the inferior Python
-;; buffer (but see M-x pdb for debugging).  [Atually, the use of
+;; buffer (but see M-x pdb for debugging).  [Actually, the use of
 ;; `compilation-minor-mode' now is probably enough for that.]  Others
 ;; don't seem appropriate.  For instance, `forward-into-nomenclature'
 ;; should be done separately, since it's not specific to Python, and
@@ -56,16 +56,25 @@
 ;; bindings are changed to obey Emacs conventions, and things like
 ;; marking blocks and `beginning-of-defun' behave differently.
 
+;; TODO: See various Fixmes below.  It should be possible to arrange
+;; some sort of completion using the inferior interpreter.
+
 ;;; Code:
 
-(require 'syntax)			; ensure appropriate version
 ;; It's messy to autoload the relevant comint functions so that comint
 ;; is only required when inferior Python is used.
 (require 'comint)
+(eval-when-compile
+  (require 'compile)
+  (autoload 'Info-last "info")
+  (autoload 'Info-exit "info")
+  (autoload 'info-lookup-maybe-add-help "info-look"))
+(autoload 'compilation-start "compile")	; spurious compiler warning anyway
 
 (defgroup python nil
   "Silly walks in the Python language"
   :group 'languages
+  :version "21.4"
   :link '(emacs-commentary-link "python"))
 
 ;;;###autoload
@@ -101,7 +110,8 @@
 	       (group (syntax string-quote))	; maybe gets property
 	       (backref 2)			; per first quote
 	       (group (backref 2))))		; maybe gets property
-     (1 (python-quote-syntax 1)) (2 (python-quote-syntax 2))
+     (1 (python-quote-syntax 1))
+     (2 (python-quote-syntax 2))
      (3 (python-quote-syntax 3)))
     ;; This doesn't really help.
 ;;;     (,(rx (and ?\\ (group ?\n))) (1 " "))
@@ -110,40 +120,43 @@
 (defun python-quote-syntax (n)
   "Put `syntax-table' property correctly on triple quote.
 Used for syntactic keywords.  N is the match number (1, 2 or 3)."
-  ;; Given a triple quote, we have to look backwards for a previous
-  ;; occurrence of the sequence to know whether this is an opening or
-  ;; closing triple.  We also have to sort out a possible prefix --
-  ;; well, we don't _have_ to, but I think it should be treated as
-  ;; part of the string.
-  (let ((tag (save-excursion
-	       (goto-char (match-beginning 0))
-	       (unless (eq ?\\ (char-before))
-		 (cond
-		  ;; Look for a previous string fence.
-		  ((or (zerop (skip-syntax-backward "^|"))
-		       (bobp))
-		   'start)		; no previous string fence
-		  ;; Check fence on a matching quote.
-		  ((eq (char-before) (char-after (match-beginning 2)))
-		   (if (eq (char-before) (char-after))
-		       'end		; fence ended string
-		     'start))		; began string
-		  ;; Check for matching prefixed string.
-		  ((and (memq (char-before) '(?u ?U ?r ?R))
-			(skip-chars-forward "rR"))
-		   (if (eq (char-after) (char-after (match-beginning 2)))
-		       'end))	       ; else non-matching: return nil
-		  ;; For non-matching quote,  start new string.
-		  ((/= (char-before) (char-after))
-		   'start))))))
-    (if (if (eq tag 'start)		; Maybe starts a new string.
-	    ;; Initial property if this is the prefix (empty or not) or
-	    ;; isn't the prefix and the prefix is empty.
-	    (or (= n 1) (and (= n 2) (= (match-beginning 1) (match-end 1))))
-	  (and (eq tag 'end)		; Maybe ends existing string.
-	       (= n 3)))		; Match is at end.
-	(eval-when-compile (string-to-syntax "|"))
-      ;; Otherwise the property is nil, which is OK.
+  ;; Given a triple quote, we have to check the context to know
+  ;; whether this is an opening or closing triple or whether it's
+  ;; quoted anyhow, and should be ignored.  (For that we need to do
+  ;; the same job as `syntax-ppss' to be correct and it seems to be OK
+  ;; to use it here despite initial worries.)  We also have to sort
+  ;; out a possible prefix -- well, we don't _have_ to, but I think it
+  ;; should be treated as part of the string.
+
+  ;; Test cases:
+  ;;  ur"""ar""" x='"' # """
+  ;; x = ''' """ ' a
+  ;; '''
+  ;; x '"""' x
+  (save-excursion
+    (goto-char (match-beginning 0))
+    (unless (eq ?\\ (char-before))
+      (cond
+       ;; Consider property for the last char if in a fenced string.
+       ((= n 3)
+	(let ((syntax (syntax-ppss)))
+	  (when (eq t (nth 3 syntax))	 ; after unclosed fence
+	    (goto-char (nth 8 syntax))	 ; fence position
+	    ;; Skip any prefix.
+	    (if (memq (char-after) '(?u ?U ?R ?r))
+		(skip-chars-forward "uUrR"))
+	    ;; Is it a matching sequence?
+	    (if (eq (char-after) (char-after (match-beginning 2)))
+		(eval-when-compile (string-to-syntax "|"))))))
+       ;; Consider property for initial char, accounting for prefixes.
+       ((or (and (= n 2)				; not prefix
+		 (= (match-beginning 1) (match-end 1)))	; prefix is null
+	    (and (= n 1)				; prefix
+		 (/= (match-beginning 1) (match-end 1)))) ; non-empty
+	(unless (eq 'string (syntax-ppss-context (syntax-ppss)))
+	  (eval-when-compile (string-to-syntax "|")))))
+      ;; Otherwise (we're in a non-matching string) the property is
+      ;; nil, which is OK.
       )))
 
 ;; This isn't currently in `font-lock-defaults' as probably not worth
@@ -386,27 +399,29 @@
 Set `python-indent' locally to the value guessed."
   (interactive)
   (save-excursion
-    (goto-char (point-min))
-    (let (done indent)
-      (while (and (not done) (not (eobp)))
-	(when (and (re-search-forward (rx (and ?: (0+ space)
-					       (or (syntax comment-start)
-						   line-end)))
-				      nil 'move)
-		   (python-open-block-statement-p))
-	  (save-excursion
-	    (python-beginning-of-statement)
-	    (let ((initial (current-indentation)))
-	      (if (zerop (python-next-statement))
-		  (setq indent (- (current-indentation) initial)))
-	      (if (and (>= indent 2) (<= indent 8)) ; sanity check
-		  (setq done t))))))
-      (when done
-	(when (/= indent (default-value 'python-indent))
-	  (set (make-local-variable 'python-indent) indent)
-	  (unless (= tab-width python-indent)
-	    (setq indent-tabs-mode nil)))
-	indent))))
+    (save-restriction
+      (widen)
+      (goto-char (point-min))
+      (let (done indent)
+	(while (and (not done) (not (eobp)))
+	  (when (and (re-search-forward (rx (and ?: (0+ space)
+						 (or (syntax comment-start)
+						     line-end)))
+					nil 'move)
+		     (python-open-block-statement-p))
+	    (save-excursion
+	      (python-beginning-of-statement)
+	      (let ((initial (current-indentation)))
+		(if (zerop (python-next-statement))
+		    (setq indent (- (current-indentation) initial)))
+		(if (and (>= indent 2) (<= indent 8)) ; sanity check
+		    (setq done t))))))
+	(when done
+	  (when (/= indent (default-value 'python-indent))
+	    (set (make-local-variable 'python-indent) indent)
+	    (unless (= tab-width python-indent)
+	      (setq indent-tabs-mode nil)))
+	  indent)))))
 
 (defun python-calculate-indentation ()
   "Calculate Python indentation for line at point."
@@ -590,7 +605,7 @@
 	(def-re (rx (and line-start (0+ space) (or "def" "class")
 			 (1+ space)
 			 (group (1+ (or word (syntax symbol)))))))
-	point found lep def-line)
+	found lep def-line)
     (if (python-comment-line-p)
 	(setq ci most-positive-fixnum))
     (while (and (not (bobp)) (not found))
@@ -807,6 +822,7 @@
 
 ;;;; Imenu.
 
+(defvar python-recursing)
 (defun python-imenu-create-index ()
   "`imenu-create-index-function' for Python.
 
@@ -814,10 +830,10 @@
 The nested menus are headed by an item referencing the outer
 definition; it has a space prepended to the name so that it sorts
 first with `imenu--sort-by-name'."
-  (unless (boundp 'recursing)		; dynamically bound below
+  (unless (boundp 'python-recursing)		; dynamically bound below
     (goto-char (point-min)))		; normal call from Imenu
   (let (index-alist			; accumulated value to return
-	name is-class pos)
+	name)
     (while (re-search-forward
 	    (rx (and line-start (0+ space) ; leading space
 		     (or (group "def") (group "class"))	    ; type
@@ -830,7 +846,7 @@
 	      (setq name (concat "class " name)))
 	  (save-restriction
 	    (narrow-to-defun)
-	    (let* ((recursing t)
+	    (let* ((python-recursing t)
 		   (sublist (python-imenu-create-index)))
 	      (if sublist
 		  (progn (push (cons (concat " " name) pos) sublist)
@@ -884,8 +900,6 @@
 (defvar python-saved-check-command nil
   "Internal use.")
 
-(autoload 'compilation-start "compile")
-
 ;; After `sgml-validate-command'.
 (defun python-check (command)
   "Check a Python file (default current buffer's file).
@@ -950,6 +964,13 @@
 do the right thing.  If you run multiple processes, you can change
 `python-buffer' to another process buffer with \\[set-variable].")
 
+(defconst python-compilation-regexp-alist
+  `((,(rx (and line-start (1+ (any " \t")) "File \""
+	       (group (1+ (not (any "\"<")))) ; avoid `<stdin>' &c
+	       "\", line " (group (1+ digit))))
+     1 python-compilation-line-number))
+  "`compilation-error-regexp-alist' for inferior Python.")
+
 (define-derived-mode inferior-python-mode comint-mode "Inferior Python"
   "Major mode for interacting with an inferior Python process.
 A Python process can be started with \\[run-python].
@@ -973,7 +994,14 @@
   ;; Fixme: Maybe install some python-mode bindings too.
   (define-key inferior-python-mode-map "\C-c\C-l" 'python-load-file)
   (define-key inferior-python-mode-map "\C-c\C-z" 'python-switch-to-python)
-  (setq comint-input-filter #'python-input-filter))
+  (add-hook 'comint-input-filter-functions 'python-input-filter nil t)
+  (add-hook 'comint-preoutput-filter-functions #'python-preoutput-filter
+	    nil t)
+  ;; Still required by `comint-redirect-send-command', for instance:
+  (set (make-local-variable 'comint-prompt-regexp) "^\\([>.]\\{3\\} \\)+")
+  (set (make-local-variable 'compilation-error-regexp-alist)
+       python-compilation-regexp-alist)
+  (compilation-shell-minor-mode 1))
 
 (defcustom inferior-python-filter-regexp "\\`\\s-*\\S-?\\S-?\\s-*\\'"
   "*Input matching this regexp is not saved on the history list.
@@ -981,18 +1009,15 @@
   :type 'regexp
   :group 'python)
 
-(defvar python-orig-start-line nil
-  "Line number at start of region sent to inferior Python.")
-
-(defvar python-orig-file nil
-  "File name to associate with errors found in inferior Python.")
+(defvar python-orig-start nil
+  "Marker to the start of the region passed to the inferior Python.
+It can also be a filename.")
 
 (defun python-input-filter (str)
   "`comint-input-filter' function for inferior Python.
-Don't save anything matching `inferior-python-filter-regexp'.
+Don't save anything for STR matching `inferior-python-filter-regexp'.
 Also resets variables for adjusting error messages."
-  (setq python-orig-file nil
-	python-orig-start-line 1)
+  (setq python-orig-start nil)
   (not (string-match inferior-python-filter-regexp str)))
 
 ;; Fixme: Loses with quoted whitespace.
@@ -1005,108 +1030,103 @@
 	  (t (let ((pos (string-match "[^ \t]" string)))
 	       (if pos (python-args-to-list (substring string pos))))))))
 
-(defvar compilation-minor-mode-map)
-(defvar compilation-error-list)
-(defvar compilation-parsing-end)
-
-(defconst python-compilation-regexp-alist
-  `((,(rx (and line-start (1+ (any " \t")) "File \""
-	       (group (1+ (not (any "\"<")))) ; avoid `<stdin>' &c
-	       "\", line " (group (1+ digit))))
-     1 python-compilation-line-number))
-  "`compilation-error-regexp-alist' for inferior Python.")
-
 (defun python-compilation-line-number (file col)
   "Return error descriptor of error found for FILE, column COL.
 Used as line-number hook function in `python-compilation-regexp-alist'."
-  (let ((line (save-excursion
-		(goto-char (match-beginning 2))
-		(read (current-buffer)))))
-    (list (point-marker) (if python-orig-file
-			     (list python-orig-file default-directory)
-			   file)
-	  (+ line (1- python-orig-start-line))
-	  nil)))
+  (let ((line (string-to-number (match-string 2))))
+    (cons (point-marker)
+	  (if (and (markerp python-orig-start)
+		   (marker-buffer python-orig-start))
+	      (with-current-buffer (marker-buffer python-orig-start)
+		(goto-char python-orig-start)
+		(forward-line (1- line)))
+	    (list (if (stringp python-orig-start) python-orig-start file)
+		  line nil)))))
+
+(defvar python-preoutput-result nil
+  "Data from output line last `_emacs_out' line seen by the preoutput filter.")
+
+(defvar python-preoutput-continuation nil
+  "If non-nil, funcall this when `python-preoutput-filter' sees `_emacs_ok'.")
+
+;; Using this stops us getting lines in the buffer like
+;; >>> ... ... >>>
+;; Also look for (and delete) an `_emacs_ok' string and call
+;; `python-preoutput-continuation' if we get it.
+(defun python-preoutput-filter (s)
+  "`comint-preoutput-filter-functions' function: ignore prompts not at bol."
+  (cond ((and (string-match "\\`[.>]\\{3\\} \\'" s)
+	      (/= (let ((inhibit-field-text-motion t))
+		    (line-beginning-position))
+		  (point)))
+	 "")
+	((string= s "_emacs_ok\n")
+	 (when python-preoutput-continuation
+	   (funcall python-preoutput-continuation)
+	   (setq python-preoutput-continuation nil))
+	 "")
+	((string-match "_emacs_out \\(.*\\)\n" s)
+	 (setq python-preoutput-result (match-string 1 s))
+	 "")
+	(t s)))
 
 ;;;###autoload
-(defun run-python (cmd)
+(defun run-python (&optional cmd noshow)
   "Run an inferior Python process, input and output via buffer *Python*.
-CMD is the Python command to run.
+CMD is the Python command to run.  NOSHOW non-nil means don't show the
+buffer automatically.
 If there is a process already running in `*Python*', switch to
-that buffer.  With argument, allows you to edit the initial
-command line (default is the value of `python-command'); `-i' and
-`-c' args will be added to this to support evaluations in the
-REPL.  Runs the hooks `inferior-python-mode-hook' \(after the
-`comint-mode-hook' is run).  \(Type \\[describe-mode] in the
-process buffer for a list of commands.)"
+that buffer.  Interactively a prefix arg, allows you to edit the initial
+command line (default is the value of `python-command'); `-i' etc. args
+will be added to this as appropriate.  Runs the hooks
+`inferior-python-mode-hook' (after the `comint-mode-hook' is run).
+\(Type \\[describe-mode] in the process buffer for a list of commands.)"
   (interactive (list (if current-prefix-arg
 			 (read-string "Run Python: " python-command)
 		       python-command)))
+  (unless cmd (setq cmd python-python-command))
+  (setq python-command cmd)
   ;; Fixme: Consider making `python-buffer' buffer-local as a buffer
   ;; (not a name) in Python buffers from which `run-python' &c is
   ;; invoked.  Would support multiple processes better.
-  (if (not (comint-check-proc "*Python*"))
-      (let ((cmdlist (append (python-args-to-list cmd)
-			     '("-i" "-c" "\
-from os import remove as _emacs_rem
-def _emacs_execfile (file):
-    try:
-        execfile (file)
-    finally:
-        _emacs_rem (file)
-"))))
-	(set-buffer (apply 'make-comint "Python" (car cmdlist) nil
-			   (cdr cmdlist)))
-	(inferior-python-mode)
-	(setq comint-output-filter-functions nil)))
-  (setq python-command cmd)
-  (setq python-buffer "*Python*")
-  (pop-to-buffer "*Python*")
-  (compilation-minor-mode 1)
-  (add-hook 'comint-input-filter-functions 'python-input-filter nil t)
-  ;; Avoid clobbering comint bindings.
-  (set (make-local-variable 'minor-mode-overriding-map-alist)
-       `((compilation-minor-mode
-	  . ,(let ((map (make-sparse-keymap)))
-	       ;; It would be useful to put keymap properties on the
-	       ;; error lines so that we could use RET and mouse-2 on
-	       ;; them directly.  These bindings will only DTRT with
-	       ;; the font-lock-style compilation mode.
-	       (define-key map [mouse-2] #'python-mouse-2-command)
-	       (define-key map "\C-m" #'python-RET-command)
-	       (if (boundp 'compilation-menu-map)
-		   (define-key map [menu-bar compilation]
-		     (cons "Errors" compilation-menu-map)))
-	       map))))
-  (set (make-local-variable 'compilation-error-regexp-alist)
-       python-compilation-regexp-alist))
+  (unless (comint-check-proc "*Python*")
+    (let ((cmdlist (append (python-args-to-list cmd) '("-i"))))
+      (set-buffer (apply 'make-comint "Python" (car cmdlist) nil
+			 (cdr cmdlist))))
+    (inferior-python-mode)
+    ;; Load function defintions we need.
+    ;; Before the preoutput function was used, this was done via -c in
+    ;; cmdlist, but that loses the banner and doesn't run the startup
+    ;; file.
+    (python-send-string "\
+def _emacs_execfile (file):  # execute file and remove it
+    from os import remove
+    try: execfile (file, globals (), globals ())
+    finally: remove (file)
 
-(defun python-mouse-2-command (event)
-  "Command bound to `mouse-2' in inferior Python buffer.
-Selects Comint or Compilation mode command as appropriate."
-  (interactive "e")
-  ;; This only works with the font-lock-based compilation mode.
-  (call-interactively
-   (lookup-key (if (save-window-excursion
-		     (save-excursion
-		       (mouse-set-point event)
-		       (consp (get-text-property (line-beginning-position)
-						 'message))))
-		   compilation-mode-map
-		 comint-mode-map)
-	       [mouse-2])))
+def _emacs_args (name):  # get arglist of name for eldoc &c
+    import inspect
+    parts = name.split ('.')
+    if len (parts) > 1:
+        try: exec 'import ' + parts[0]
+        except: return None
+    try: exec 'func='+name # lose if name is keyword or undefined
+    except: return None
+    if inspect.isbuiltin (func):
+        doc = func.__doc__
+        if doc.find (' ->') != -1:
+            print '_emacs_out', doc.split (' ->')[0]
+        elif doc.find ('\\n') != -1:
+            print '_emacs_out', doc.split ('\\n')[0]
+        return None
+    if inspect.ismethod (func): func = func.im_func
+    if not inspect.isfunction (func):
+        return None
+    (args, varargs, varkw, defaults) = inspect.getargspec (func)
+    print '_emacs_out', func.__name__+inspect.formatargspec (args, varargs, varkw, defaults)
 
-(defun python-RET-command ()
-  "Command bound to `RET' in inferior Python buffer.
-Selects Comint or Compilation mode command as appropriate."
-  (interactive)
-  ;; This only works with the font-lock-based compilation mode.
-  (call-interactively
-   (lookup-key (if (consp (get-text-property (line-beginning-position)
-					     'message))
-		   compilation-mode-map
-		 comint-mode-map)
-	       "\C-m")))
+print '_emacs_ok'"))
+  (unless noshow (pop-to-buffer (setq python-buffer "*Python*"))))
 
 (defun python-send-region (start end)
   "Send the region to the inferior Python process."
@@ -1128,11 +1148,8 @@
   ;; comint-filter the first two lines of the traceback?
   (interactive "r")
   (let* ((f (make-temp-file "py"))
-	 (command (format "_emacs_execfile(%S)\n" f))
-	 (orig-file (buffer-file-name))
-	 (orig-line (save-restriction
-		      (widen)
-		      (line-number-at-pos start))))
+	 (command (format "_emacs_execfile(%S)" f))
+	 (orig-start (copy-marker start)))
     (if (save-excursion
 	  (goto-char start)
 	  (/= 0 (current-indentation)))	; need dummy block
@@ -1140,22 +1157,20 @@
     (write-region start end f t 'nomsg)
     (when python-buffer
       (with-current-buffer python-buffer
-	(let ((end (marker-position (process-mark
-				     (get-buffer-process python-buffer)))))
-	  (set (make-local-variable 'python-orig-file) orig-file)
-	  (set (make-local-variable 'python-orig-start-line) orig-line)
+	(let ((end (marker-position (process-mark (python-proc)))))
+	  (set (make-local-variable 'python-orig-start) orig-start)
 	  (set (make-local-variable 'compilation-error-list) nil)
-	  ;; (set (make-local-variable 'compilation-old-error-list) nil)
 	  (let ((comint-input-filter-functions
 		 (delete 'python-input-filter comint-input-filter-functions)))
-	    (comint-send-string (python-proc) command))
+	    (python-send-string command))
 	  (set-marker compilation-parsing-end end)
 	  (setq compilation-last-buffer (current-buffer)))))))
 
 (defun python-send-string (string)
   "Evaluate STRING in inferior Python process."
   (interactive "sPython command: ")
-  (comint-send-string (python-proc) string))
+  (comint-send-string (python-proc) string)
+  (comint-send-string (python-proc) "\n\n"))
 
 (defun python-send-buffer ()
   "Send the current buffer to the inferior Python process."
@@ -1212,19 +1227,27 @@
   (comint-check-source file-name) ; Check to see if buffer needs saved.
   (setq python-prev-dir/file (cons (file-name-directory file-name)
 				   (file-name-nondirectory file-name)))
-  (comint-send-string
-   (python-proc)
-   (if (string-match "\\.py\\'" file-name)
-       ;; Fixme: make sure the directory is in the path list
-       (let ((module (file-name-sans-extension
-		      (file-name-nondirectory file-name))))
-	 (format "\
-if globals().has_key('%s'):
-    reload(%s)
-else:
-    import %s
+  (when python-buffer
+    (with-current-buffer python-buffer
+      (let ((end (marker-position (process-mark (python-proc)))))
+	(set (make-local-variable 'compilation-error-list) nil)
+	;; (set (make-local-variable 'compilation-old-error-list) nil)
+	(let ((comint-input-filter-functions
+	       (delete 'python-input-filter comint-input-filter-functions)))
+	  (python-send-string
+	   (if (string-match "\\.py\\'" file-name)
+	       ;; Fixme: make sure the directory is in the path list
+	       (let ((module (file-name-sans-extension
+			      (file-name-nondirectory file-name))))
+		 (set (make-local-variable 'python-orig-start) nil)
+		 (format "\
+if globals().has_key(%S): reload(%s)
+else: import %s
 " module module module))
-     (format "execfile('%s')\n" filename))))
+	     (set (make-local-variable 'python-orig-start) file-name)
+	     (format "execfile('%s')" file-name))))
+	(set-marker compilation-parsing-end end)
+	(setq compilation-last-buffer (current-buffer))))))
 
 ;; Fixme: Should this start a process if there isn't one?  (Unlike cmuscheme.)
 (defun python-proc ()
@@ -1236,74 +1259,115 @@
 
 ;;;; Context-sensitive help.
 
-;; Fixme: Investigate adapting this to eldoc.
+(defconst python-dotty-syntax-table
+  (let ((table (make-syntax-table)))
+    (set-char-table-parent table python-mode-syntax-table)
+    (modify-syntax-entry ?. "_" table)
+    table)
+  "Syntax table giving `.' symbol syntax.
+Otherwise inherits from `python-mode-syntax-table'.")
 
+;; Fixme: Should this actually be used instead of info-look, i.e. be
+;; bound to C-h S?
 (defun python-describe-symbol (symbol)
   "Get help on SYMBOL using `pydoc'.
 Interactively, prompt for symbol."
+  ;; Note that we do this in the inferior process, not a separate one to
+  ;; ensure the environment is appropriate.
   (interactive
-   (let ((symbol (current-word))
+   (let ((symbol (with-syntax-table python-dotty-syntax-table
+		   (current-word)))
 	 (enable-recursive-minibuffers t)
 	 val)
      (setq val (read-string (if symbol
-				(format "Describe variable (default %s): "
+				(format "Describe symbol (default %s): "
 				      symbol)
-			      "Describe variable: ")
+			      "Describe symbol: ")
 			    nil nil symbol))
      (list (or val symbol))))
   (if (equal symbol "") (error "No symbol"))
-  (let* ((mod (if (string-match "\\(\\.[^.]+\\)\\'" symbol)
-		  (substring symbol 0 (match-beginning 1))))
-	 (import (when mod (concat "import " mod "\n"))))
-    (with-output-to-temp-buffer "*Python Output*"
-      (princ (shell-command-to-string
-	      (format "%s -c 'import pydoc %s
-try: pydoc.help(%S)
-except: print \"No help available on:\", %S'"
-		      ;; Fixme: Is this necessarily right?
-		      (car (split-string python-command))
-		      (or import "") symbol symbol))))))
+  (let* ((func `(lambda ()
+		  (comint-redirect-send-command (format "help(%S)\n" ,symbol)
+						"*Help*" nil))))
+    ;; Ensure we have a suitable help buffer.
+    (let (temp-buffer-show-hook)	; avoid xref stuff
+      (with-output-to-temp-buffer "*Help*"
+	(with-current-buffer standard-output
+	  (set (make-local-variable 'comint-redirect-subvert-readonly) t))))
+    (if (and python-buffer (get-buffer python-buffer))
+	(with-current-buffer python-buffer
+	  (funcall func))
+      (setq python-preoutput-continuation func)
+      (run-python nil t))))
 
 (add-to-list 'debug-ignored-errors "^No symbol")
+
+;; Fixme: try to make it work with point in the arglist.  Also, is
+;; there anything reasonable we can do with random methods?
+;; (Currently only works with functions.)
+(defun python-eldoc-function ()
+  "`eldoc-print-current-symbol-info' for Python.
+Only works when point is in a function name, not its arglist, for instance.
+Assumes an inferior Python is running."
+  (let ((symbol (with-syntax-table python-dotty-syntax-table
+		  (current-word)))
+	(proc (and python-buffer (python-proc))))
+    (when (and proc symbol)
+      (python-send-string
+       (format "_emacs_args(%S)" symbol))
+      (setq python-preoutput-result nil)
+      (accept-process-output proc 1)
+      python-preoutput-result)))
 
 ;;;; Info-look functionality.
 
-(require 'info-look)
-;; We should be able to add info-lookup specs without loading the file first.
-;; E.g. by setting a buffer-local var or something like that.  --Stef
-(let ((version (let ((s (shell-command-to-string (concat python-command
-							 " -V"))))
-		 (string-match "^Python \\([0-9]+\\.[0-9]+\\>\\)" s)
-		 (match-string 1 s)))
-      ;; Whether info files have a Python version suffix, e.g. in Debian.
-      (versioned (save-window-excursion
-		   (condition-case ()
-		       ;; The call to `info' might create a new frame if
-		       ;; pop-up-frames or special-display-buffers are used.
-		       ;; So I disabled it until we find a better way
-		       ;; to handle this situation.  Maybe Debian should just
-		       ;; fix their install somehow.  --Stef
-		       ;; (progn (info "(python2.3-lib)Miscellaneous Index")
-		       ;; 	      (Info-last)
-		       ;; 	      (Info-exit)
-		       ;; 	      t)
-		       nil
-		     (error nil)))))
-  (info-lookup-maybe-add-help
-   :mode 'python-mode
-   :regexp "[[:alnum:]_]+"
-   :doc-spec
-   ;; Fixme: Add python-ref?  Can this reasonably be made specific
-   ;; to indices with different rules?
-   (if versioned
-       '((,(concat "(python" version "-lib)Module Index"))
-	 (,(concat "(python" version "-lib)Class-Exception-Object Index"))
-	 (,(concat "(python" version "-lib)Function-Method-Variable Index"))
-	 (,(concat "(python" version "-lib)Miscellaneous Index")))
-     '(("(python-lib)Module Index")
-       ("(python-lib)Class-Exception-Object Index")
-       ("(python-lib)Function-Method-Variable Index")
-       ("(python-lib)Miscellaneous Index")))))
+(defun python-after-info-look ()
+  "Set up info-look for Python.
+Used with `eval-after-load'."
+  (let* ((version (let ((s (shell-command-to-string (concat python-command
+							    " -V"))))
+		    (string-match "^Python \\([0-9]+\\.[0-9]+\\>\\)" s)
+		    (match-string 1 s)))
+	 ;; Whether info files have a Python version suffix, e.g. in Debian.
+	 (versioned
+	  (with-temp-buffer
+	    (Info-mode)
+	    (condition-case ()
+		;; Don't use `info' because it would pop-up a *info* buffer.
+		(Info-goto-node (format "(python%s-lib)Miscellaneous Index"
+					version))
+	      (error nil)))))
+    (info-lookup-maybe-add-help
+     :mode 'python-mode
+     :regexp "[[:alnum:]_]+"
+     :doc-spec
+     ;; Fixme: Can this reasonably be made specific to indices with
+     ;; different rules?  Is the order of indices optimal?
+     ;; (Miscellaneous in -ref first prefers lookup of keywords, for
+     ;; instance.)
+     (if versioned
+	 ;; The empty prefix just gets us highlighted terms.
+	 `((,(concat "(python" version "-ref)Miscellaneous Index") nil "")
+	   (,(concat "(python" version "-ref)Module Index" nil ""))
+	   (,(concat "(python" version "-ref)Function-Method-Variable Index"
+		     nil ""))
+	   (,(concat "(python" version "-ref)Class-Exception-Object Index"
+		     nil ""))
+	   (,(concat "(python" version "-lib)Module Index" nil ""))
+	   (,(concat "(python" version "-lib)Class-Exception-Object Index"
+		     nil ""))
+	   (,(concat "(python" version "-lib)Function-Method-Variable Index"
+		     nil ""))
+	   (,(concat "(python" version "-lib)Miscellaneous Index" nil "")))
+       '(("(python-ref)Miscellaneous Index" nil "")
+	 ("(python-ref)Module Index" nil "")
+	 ("(python-ref)Function-Method-Variable Index" nil "")
+	 ("(python-ref)Class-Exception-Object Index" nil "")
+	 ("(python-lib)Module Index" nil "")
+	 ("(python-lib)Class-Exception-Object Index" nil "")
+	 ("(python-lib)Function-Method-Variable Index" nil "")
+	 ("(python-lib)Miscellaneous Index" nil ""))))))
+(eval-after-load "info-look" '(python-after-info-look))
 
 ;;;; Miscellancy.
 
@@ -1323,34 +1387,65 @@
 `python-jython-packages'."
   ;; The logic is taken from python-mode.el.
   (save-excursion
-    (goto-char (point-min))
-    (let ((interpreter (if (looking-at auto-mode-interpreter-regexp)
-			   (match-string 2))))
-      (if (and interpreter (eq 'jython-mode
-			       (cdr (assoc (file-name-nondirectory interpreter)
-					   interpreter-mode-alist))))
-	  (jython-mode)
-	(if (catch 'done
-	      (while (re-search-forward
-		      (rx (and line-start (or "import" "from") (1+ space)
-			       (group (1+ (not (any " \t\n."))))))
-		      (+ (point) 10000)	; Probably not worth customizing.
-		      t)
-		(if (member (match-string 1) python-jython-packages)
-		    (throw 'done t))))
-	    (jython-mode))))))
+    (save-restriction
+      (widen)
+      (goto-char (point-min))
+      (let ((interpreter (if (looking-at auto-mode-interpreter-regexp)
+			     (match-string 2))))
+	(if (and interpreter (eq 'jython-mode
+				 (cdr (assoc (file-name-nondirectory
+					      interpreter)
+					     interpreter-mode-alist))))
+	    (jython-mode)
+	  (if (catch 'done
+		(while (re-search-forward
+			(rx (and line-start (or "import" "from") (1+ space)
+				 (group (1+ (not (any " \t\n."))))))
+			10000	     ; Probably not worth customizing.
+			t)
+		  (if (member (match-string 1) python-jython-packages)
+		      (throw 'done t))))
+	      (jython-mode)))))))
 
 (defun python-fill-paragraph (&optional justify)
-  "Like \\[fill-paragraph], but handle comments and multi-line strings.
+  "`fill-paragraph-function' handling comments and multi-line strings.
 If any of the current line is a comment, fill the comment or the
-paragraph of it that point is in, preserving the comment's indentation
-and initial comment characters."
+paragraph of it that point is in, preserving the comment's
+indentation and initial comment characters.  Similarly if the end
+of the current line is in or at the end of a multi-line string.
+Otherwise, do nothing."
   (interactive "P")
   (or (fill-comment-paragraph justify)
-      (let ((paragraph-start (concat paragraph-start
-				     "\\|\\s-*\\(:?#\\s\"\\|\\s|\\|#")))
-	(fill-paragraph justify))
-      t))
+      ;; The `paragraph-start' and `paragraph-separate' variables
+      ;; don't allow us to delimit the last paragraph in a multi-line
+      ;; string properly, so narrow to the string and then fill around
+      ;; (the end of) the current line.
+      (save-excursion
+	(end-of-line)
+	(let* ((syntax (syntax-ppss))
+	       (orig (point))
+	       (start (nth 8 syntax))
+	       end)
+	  (cond ((eq t (nth 3 syntax))	    ; in fenced string
+		 (goto-char (nth 8 syntax)) ; string start
+		 (condition-case ()	    ; for unbalanced quotes
+		     (progn (forward-sexp)
+			    (setq end (point)))
+		   (error (setq end (point-max)))))
+		((re-search-backward "\\s|\\s-*\\=" nil t) ; end of fenced
+							   ; string
+		 (forward-char)
+		 (setq end (point))
+		 (condition-case ()
+		     (progn (backward-sexp)
+			    (setq start (point)))
+		   (error nil))))
+	  (when end
+	    (save-restriction
+	      (narrow-to-region start end)
+	      (goto-char orig)
+	      (fill-paragraph justify))))))
+      t)
 
 (defun python-shift-left (start end &optional count)
   "Shift lines in region COUNT (the prefix arg) columns to the left.
@@ -1391,7 +1486,8 @@
 
 (defun python-outline-level ()
   "`outline-level' function for Python mode.
-The level is the number of `python-indent' steps of indentation."
+The level is the number of `python-indent' steps of indentation
+of current line."
   (/ (current-indentation) python-indent))
 
 ;; Fixme: Consider top-level assignments, imports, &c.
@@ -1425,17 +1521,23 @@
 
 ;;;; Modes.
 
+(defvar outline-heading-end-regexp)
+(defvar eldoc-print-current-symbol-info-function)
+(defvar python-mode-running)
 ;;;###autoload
 (define-derived-mode python-mode fundamental-mode "Python"
   "Major mode for editing Python files.
 Turns on Font Lock mode unconditionally since it is required for correct
 parsing of the source.
 See also `jython-mode', which is actually invoked if the buffer appears to
-contain Jython code.
+contain Jython code.  See also `run-python' and associated Python mode
+commands for running Python under Emacs.
 
 The Emacs commands which work with `defun's, e.g. \\[beginning-of-defun], deal
 with nested `def' and `class' blocks.  They take the innermost one as
-current without distinguishing method and class definitions.
+current without distinguishing method and class definitions.  Used multiple
+times, they move over others at the same indentation level until they reach
+the end of definitions at that level, when they move up a level.
 \\<python-mode-map>
 Colon is electric: it outdents the line if appropriate, e.g. for
 an else statement.  \\[python-backspace] at the beginning of an indented statement
@@ -1444,6 +1546,13 @@
 the preceding code.  Successive TABs, with no intervening command, cycle
 through the possibilities for indentation on the basis of enclosing blocks.
 
+\\[fill-paragraph] fills comments and multiline strings appropriately, but has no
+effect outside them.
+
+Supports Eldoc mode (only for functions, using a Python process),
+Info-Look and Imenu.  In Outline minor mode, `class' and `def'
+lines count as headers.
+
 \\{python-mode-map}"
   :group 'python
   (set (make-local-variable 'font-lock-defaults)
@@ -1465,7 +1574,8 @@
   (set (make-local-variable 'add-log-current-defun-function)
        #'python-current-defun)
   ;; Fixme: Generalize to do all blocks?
-  (set (make-local-variable 'outline-regexp) "\\s-+\\(def\\|class\\)\\>")
+  (set (make-local-variable 'outline-regexp) "\\s-*\\(def\\|class\\)\\>")
+  (set (make-local-variable 'outline-heading-end-regexp) ":\\s-*\n")
   (set (make-local-variable 'outline-level) #'python-outline-level)
   (set (make-local-variable 'open-paren-in-column-0-is-defun-start) nil)
   (make-local-variable 'python-saved-check-command)
@@ -1473,6 +1583,10 @@
        'python-beginning-of-defun)
   (set (make-local-variable 'end-of-defun-function) 'python-end-of-defun)
   (setq imenu-create-index-function #'python-imenu-create-index)
+  (set (make-local-variable 'eldoc-print-current-symbol-info-function)
+       #'python-eldoc-function)
+  (add-hook 'eldoc-mode-hook
+	    '(lambda () (run-python 0 t)) nil t) ; need it running
   (unless font-lock-mode (font-lock-mode 1))
   (when python-guess-indent (python-guess-indent))
   (set (make-local-variable 'python-command) python-python-command)
@@ -1485,6 +1599,7 @@
 		   '(lambda ()
 		      "Turn on Indent Tabs mode."
 		      (set (make-local-variable 'indent-tabs-mode) t)))
+(custom-add-option 'python-mode-hook 'turn-on-eldoc-mode)
 
 ;;;###autoload
 (define-derived-mode jython-mode python-mode  "Jython"
--- a/lisp/smerge-mode.el	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/smerge-mode.el	Thu Apr 15 16:49:22 2004 +0000
@@ -314,9 +314,9 @@
   "Pop up the Smerge mode context menu under mouse."
   (interactive "e")
   (if (and smerge-mode
-	   (save-excursion (mouse-set-point event) (smerge-check 1)))
+	   (save-excursion (posn-set-point (event-end event)) (smerge-check 1)))
       (progn
-	(mouse-set-point event)
+	(posn-set-point (event-end event))
 	(smerge-match-conflict)
 	(let ((i (smerge-get-current))
 	      o)
--- a/lisp/startup.el	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/startup.el	Thu Apr 15 16:49:22 2004 +0000
@@ -274,6 +274,8 @@
 		 string)
   :group 'auto-save)
 
+(defvar emacs-quick-startup nil)
+
 (defvar init-file-debug nil)
 
 (defvar init-file-had-error nil)
@@ -690,6 +692,11 @@
 		(setq argval nil
                       argi orig-argi)))))
 	(cond
+	 ((equal argi "-Q")
+	  (setq init-file-user nil
+		site-run-file nil
+		emacs-quick-startup t)
+	  (push '(vertical-scroll-bars . nil) initial-frame-alist))
 	 ((member argi '("-q" "-no-init-file"))
 	  (setq init-file-user nil))
 	 ((member argi '("-u" "-user"))
@@ -721,18 +728,21 @@
 
   ;; If frame was created with a menu bar, set menu-bar-mode on.
   (unless (or noninteractive
+	      emacs-quick-startup
               (and (memq initial-window-system '(x w32))
                    (<= (frame-parameter nil 'menu-bar-lines) 0)))
     (menu-bar-mode 1))
 
   ;; If frame was created with a tool bar, switch tool-bar-mode on.
   (unless (or noninteractive
+	      emacs-quick-startup
               (not (display-graphic-p))
               (<= (frame-parameter nil 'tool-bar-lines) 0))
     (tool-bar-mode 1))
 
   ;; Can't do this init in defcustom because initial-window-system isn't set.
   (unless (or noninteractive
+	      emacs-quick-startup
               (eq system-type 'ms-dos)
               (not (memq initial-window-system '(x w32))))
     (setq-default blink-cursor t)
@@ -754,6 +764,7 @@
       (normal-erase-is-backspace-mode 1)))
 
   (unless (or noninteractive
+	      emacs-quick-startup
               (not (display-graphic-p))
               (not (fboundp 'x-show-tip)))
     (setq-default tooltip-mode t)
@@ -1106,8 +1117,8 @@
     (when img
       (when (> window-width image-width)
 	;; Center the image in the window.
-	(let ((pos (/ (- window-width image-width) 2)))
-	  (insert (propertize " " 'display `(space :align-to ,pos))))
+	(insert (propertize " " 'display
+			    `(space :align-to (+ center (-0.5 . ,img)))))
 
 	;; Change the color of the XPM version of the splash image
 	;; so that it is visible with a dark frame background.
@@ -1656,11 +1667,13 @@
                (list-buffers)))))
 
   ;; Maybe display a startup screen.
-  (when (and (not inhibit-startup-message) (not noninteractive)
+  (unless (or inhibit-startup-message
+	      noninteractive
+	      emacs-quick-startup
 	     ;; Don't display startup screen if init file
 	     ;; has started some sort of server.
-	     (not (and (fboundp 'process-list)
-		       (process-list))))
+	     (and (fboundp 'process-list)
+		  (process-list)))
     ;; Display a startup screen, after some preparations.
 
     ;; If there are no switches to process, we might as well
--- a/lisp/subr.el	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/subr.el	Thu Apr 15 16:49:22 2004 +0000
@@ -678,7 +678,7 @@
 
 (defsubst event-start (event)
   "Return the starting position of EVENT.
-If EVENT is a mouse press or a mouse click, this returns the location
+If EVENT is a mouse or key press or a mouse click, this returns the location
 of the event.
 If EVENT is a drag, this returns the drag's starting position.
 The return value is of the form
@@ -689,7 +689,8 @@
     (list (selected-window) (point) '(0 . 0) 0)))
 
 (defsubst event-end (event)
-  "Return the ending location of EVENT.  EVENT should be a click or drag event.
+  "Return the ending location of EVENT.
+EVENT should be a click, drag, or key press event.
 If EVENT is a click event, this function is the same as `event-start'.
 The return value is of the form
    (WINDOW AREA-OR-POS (X . Y) TIMESTAMP OBJECT POS (COL . ROW)
@@ -727,6 +728,15 @@
 	  (car (nth 1 position))
 	(nth 1 position))))
 
+(defun posn-set-point (position)
+  "Move point to POSITION.
+Select the corresponding window as well."
+    (if (not (windowp (posn-window position)))
+	(error "Position not in text area of window"))
+    (select-window (posn-window position))
+    (if (numberp (posn-point position))
+	(goto-char (posn-point position))))
+
 (defsubst posn-x-y (position)
   "Return the x and y coordinates in POSITION.
 POSITION should be a list of the form returned by the `event-start'
--- a/lisp/xml.el	Tue Apr 13 18:18:05 2004 +0000
+++ b/lisp/xml.el	Thu Apr 15 16:49:22 2004 +0000
@@ -52,15 +52,15 @@
 
 ;;; LIST FORMAT
 
-;; The functions `xml-parse-file' and `xml-parse-tag' return a list with
-;; the following format:
+;; The functions `xml-parse-file', `xml-parse-region' and
+;; `xml-parse-tag' return a list with the following format:
 ;;
 ;;    xml-list   ::= (node node ...)
-;;    node       ::= (tag_name attribute-list . child_node_list)
+;;    node       ::= (qname attribute-list . child_node_list)
 ;;    child_node_list ::= child_node child_node ...
 ;;    child_node ::= node | string
-;;    tag_name   ::= string
-;;    attribute_list ::= (("attribute" . "value") ("attribute" . "value") ...)
+;;    qname      ::= (:namespace-uri . "name") | "name"
+;;    attribute_list ::= ((qname . "value") (qname . "value") ...)
 ;;                       | nil
 ;;    string     ::= "..."
 ;;
@@ -68,6 +68,11 @@
 ;; Whitespace is preserved.  Fixme: There should be a tree-walker that
 ;; can remove it.
 
+;; TODO:
+;;  * xml:base, xml:space support
+;;  * more complete DOCTYPE parsing
+;;  * pi support
+
 ;;; Code:
 
 ;; Note that {buffer-substring,match-string}-no-properties were
@@ -230,72 +235,27 @@
 	      (cons dtd (nreverse xml))
 	    (nreverse xml)))))))
 
-(defun xml-ns-parse-ns-attrs (attr-list &optional xml-ns)
-  "Parse the namespace attributes and return a list of cons in the form:
-\(namespace . prefix)"
-
-  (mapcar
-   (lambda (attr)
-     (let* ((splitup (split-string (car attr) ":"))
-	    (prefix (nth 0 splitup))
-	    (lname (nth 1 splitup)))
-       (when (string= "xmlns" prefix)
-	 (push (cons (if lname
-			 lname
-		       "")
-		     (cdr attr))
-	       xml-ns)))) attr-list)
-  xml-ns)
-
-;; expand element names
-(defun xml-ns-expand-el (el xml-ns)
-  "Expand the XML elements from \"prefix:local-name\" to a cons in the form
-\"(namespace . local-name)\"."
+(defun xml-maybe-do-ns (name default xml-ns)
+  "Perform any namespace expansion.  NAME is the name to perform the expansion on.
+DEFAULT is the default namespace.  XML-NS is a cons of namespace
+names to uris.  When namespace-aware parsing is off, then XML-NS
+is nil.
 
-  (let* ((splitup (split-string el ":"))
-	 (lname (or (nth 1 splitup)
-		    (nth 0 splitup)))
-	 (prefix (if (nth 1 splitup)
-		     (nth 0 splitup)
-		   (if (string= lname "xmlns")
-		       "xmlns"
-		     "")))
-	 (ns (cdr (assoc-string prefix xml-ns))))
-    (if (string= "" ns)
-	lname
-      (cons (intern (concat ":" ns))
-	    lname))))
-
-;; expand attribute names
-(defun xml-ns-expand-attr (attr-list xml-ns)
-  "Expand the attribute list for a particular element from the form
-\"prefix:local-name\" to the form \"{namespace}:local-name\"."
-
-  (mapcar
-   (lambda (attr)
-     (let* ((splitup (split-string (car attr) ":"))
-	    (lname (or (nth 1 splitup)
-		       (nth 0 splitup)))
-	    (prefix (if (nth 1 splitup)
-			(nth 0 splitup)
-		      (if (string= (car attr) "xmlns")
-			  "xmlns"
-			"")))
-	    (ns (cdr (assoc-string prefix xml-ns))))
-       (setcar attr
-	       (if (string= "" ns)
-		   lname
-		 (cons (intern (concat ":" ns))
-		       lname)))))
-   attr-list)
-  attr-list)
-
-(defun xml-intern-attrlist (attr-list)
-  "Convert attribute names to symbols for backward compatibility."
-  (mapcar (lambda (attr)
-	    (setcar attr (intern (car attr))))
-	  attr-list)
-  attr-list)
+During namespace-aware parsing, any name without a namespace is
+put into the namespace identified by DEFAULT.  nil is used to
+specify that the name shouldn't be given a namespace."
+  (if (consp xml-ns)
+      (let* ((nsp (string-match ":" name))
+	     (lname (if nsp (substring name (match-end 0)) name))
+	     (prefix (if nsp (substring name 0 (match-beginning 0)) default))
+	     (special (and (string-equal lname "xmlns") (not prefix)))
+             ;; Setting default to nil will insure that there is not
+             ;; matching cons in xml-ns.  In which case we
+	     (ns (or (cdr (assoc (if special "xmlns" prefix)
+                                 xml-ns))
+                     :)))
+        (cons ns (if special "" lname)))
+    (intern name)))
 
 (defun xml-parse-tag (&optional parse-dtd parse-ns)
   "Parse the tag at point.
@@ -310,10 +270,12 @@
 		    parse-ns
 		  (if parse-ns
 		      (list
-		       ;; Default no namespace
-		       (cons "" "")
+                       ;; Default for empty prefix is no namespace
+                       (cons ""      :)
+		       ;; "xml" namespace
+		       (cons "xml"   :http://www.w3.org/XML/1998/namespace)
 		       ;; We need to seed the xmlns namespace
-		       (cons "xmlns" "http://www.w3.org/2000/xmlns/"))))))
+		       (cons "xmlns" :http://www.w3.org/2000/xmlns/))))))
     (cond
      ;; Processing instructions (like the <?xml version="1.0"?> tag at the
      ;; beginning of a document).
@@ -350,19 +312,23 @@
 
       ;; Parse this node
       (let* ((node-name (match-string 1))
-	     (attr-list (xml-parse-attlist))
-	     (children (if  (consp xml-ns) ;; take care of namespace parsing
-			    (progn
-			      (setq xml-ns (xml-ns-parse-ns-attrs
-					    attr-list xml-ns))
-			      (list (xml-ns-expand-attr
-				     attr-list xml-ns)
-				    (xml-ns-expand-el
-				     node-name xml-ns)))
-			    (list (xml-intern-attrlist attr-list)
-				  (intern node-name))))
-	     pos)
+             ;; Parse the attribute list.
+             (attrs (xml-parse-attlist xml-ns))
+             children pos)
 
+        ;; add the xmlns:* attrs to our cache
+        (when (consp xml-ns)
+	  (dolist (attr attrs)
+	    (when (and (consp (car attr))
+		       (eq :http://www.w3.org/2000/xmlns/
+			   (caar attr)))
+	      (push (cons (cdar attr) (intern (concat ":" (cdr attr))))
+		    xml-ns))))
+
+        ;; expand element names
+        (setq node-name (list (xml-maybe-do-ns node-name "" xml-ns)))
+
+        (setq children (list attrs node-name))
 	;; is this an empty element ?
 	(if (looking-at "/>")
 	(progn
@@ -416,7 +382,7 @@
      (t	;; This is not a tag.
       (error "XML: Invalid character")))))
 
-(defun xml-parse-attlist ()
+(defun xml-parse-attlist (&optional xml-ns)
   "Return the attribute-list after point.  Leave point at the
 first non-blank character after the tag."
   (let ((attlist ())
@@ -424,8 +390,9 @@
     (skip-syntax-forward " ")
     (while (looking-at (eval-when-compile
 			 (concat "\\(" xml-name-regexp "\\)\\s-*=\\s-*")))
-      (setq name (match-string 1))
-      (goto-char (match-end 0))
+      (setq end-pos (match-end 0))
+      (setq name (xml-maybe-do-ns (match-string 1) nil xml-ns))
+      (goto-char end-pos)
 
       ;; See also: http://www.w3.org/TR/2000/REC-xml-20001006#AVNormalize
 
--- a/lispref/ChangeLog	Tue Apr 13 18:18:05 2004 +0000
+++ b/lispref/ChangeLog	Thu Apr 15 16:49:22 2004 +0000
@@ -1,3 +1,30 @@
+2004-04-14  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* buffers.texi (Read Only Buffers): Mention optional ARG to
+	`toggle-read-only'.
+
+2004-04-14  Nick Roberts  <nick@nick.uklinux.net>
+
+	* windows.texi (Selecting Windows): Note that get-lru-window
+	returns a full-width window if possible.
+
+2004-04-13  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* buffers.texi: Various changes in addition to:
+	(Buffer File Name): Add `find-buffer-visiting'.
+	(Buffer Modification): Mention optional ARG to `not-modified'.
+	(Indirect Buffers): Mention optional CLONE argument to
+	`make-indirect-buffer'.
+
+	* files.texi: Various changes in addition to:
+	(Visiting Functions): `find-file-hook' is now a normal hook.
+	(File Name Expansion): Explain difference between the way that
+	`expand-file-name' and `file-truename' treat `..'.
+	(Contents of Directories): Mention optional ID-FORMAT argument to
+	`directory-files-and-attributes'.
+	(Format Conversion): Mention new optional CONFIRM argument to
+	`format-write-file'.
+
 2004-04-12  Miles Bader  <miles@gnu.org>
 
 	* macros.texi (Expansion): Add description of `macroexpand-all'.
--- a/lispref/buffers.texi	Tue Apr 13 18:18:05 2004 +0000
+++ b/lispref/buffers.texi	Thu Apr 15 16:49:22 2004 +0000
@@ -215,12 +215,16 @@
 remains current.
 @end defspec
 
-@defmac with-current-buffer buffer body...
+@defmac with-current-buffer buffer-or-name body...
 The @code{with-current-buffer} macro saves the identity of the current
-buffer, makes @var{buffer} current, evaluates the @var{body} forms, and
-finally restores the buffer.  The return value is the value of the last
-form in @var{body}.  The current buffer is restored even in case of an
-abnormal exit via @code{throw} or error (@pxref{Nonlocal Exits}).
+buffer, makes @var{buffer-or-name} current, evaluates the @var{body}
+forms, and finally restores the buffer.  The return value is the value
+of the last form in @var{body}.  The current buffer is restored even
+in case of an abnormal exit via @code{throw} or error (@pxref{Nonlocal
+Exits}).
+
+An error is signaled if @var{buffer-or-name} does not identify an
+existing buffer.
 @end defmac
 
 @anchor{Definition of with-temp-buffer}
@@ -237,10 +241,11 @@
 
 The current buffer is restored even in case of an abnormal exit via
 @code{throw} or error (@pxref{Nonlocal Exits}).
+
+See also @code{with-temp-file} in @ref{Definition of with-temp-file,,
+Writing to Files}.
 @end defmac
 
-See also @code{with-temp-file} in @ref{Writing to Files}.
-
 @node Buffer Names
 @section Buffer Names
 @cindex buffer names
@@ -293,8 +298,7 @@
 
 @deffn Command rename-buffer newname &optional unique
 This function renames the current buffer to @var{newname}.  An error
-is signaled if @var{newname} is not a string, or if there is already a
-buffer with that name.  The function returns @var{newname}.
+is signaled if @var{newname} is not a string.
 
 @c Emacs 19 feature
 Ordinarily, @code{rename-buffer} signals an error if @var{newname} is
@@ -302,6 +306,8 @@
 @var{newname} to make a name that is not in use.  Interactively, you can
 make @var{unique} non-@code{nil} with a numeric prefix argument.
 (This is how the command @code{rename-uniquely} is implemented.)
+
+This function returns the name actually given to the buffer.
 @end deffn
 
 @defun get-buffer buffer-or-name
@@ -330,11 +336,12 @@
 @end defun
 
 @c Emacs 19 feature
-@defun generate-new-buffer-name starting-name &rest ignore
+@defun generate-new-buffer-name starting-name &optional ignore
 This function returns a name that would be unique for a new buffer---but
 does not create the buffer.  It starts with @var{starting-name}, and
 produces a name not currently in use for any buffer by appending a
-number inside of @samp{<@dots{}>}.
+number inside of @samp{<@dots{}>}.  It starts at 2 and keeps
+incrementing the number until it is not the name of an existing buffer.
 
 If the optional second argument @var{ignore} is non-@code{nil}, it
 should be a string; it makes a difference if it is a name in the
@@ -404,9 +411,11 @@
 @end defvar
 
 @defvar buffer-file-truename
-This buffer-local variable holds the truename of the file visited in the
-current buffer, or @code{nil} if no file is visited.  It is a permanent
-local, unaffected by @code{kill-all-local-variables}.  @xref{Truenames}.
+This buffer-local variable holds the abbreviated truename of the file
+visited in the current buffer, or @code{nil} if no file is visited.
+It is a permanent local, unaffected by
+@code{kill-all-local-variables}.  @xref{Truenames}, and
+@ref{Definition of abbreviate-file-name}.
 @end defvar
 
 @defvar buffer-file-number
@@ -420,6 +429,9 @@
 all files accessible on the system.  See the function
 @code{file-attributes}, in @ref{File Attributes}, for more information
 about them.
+
+If @code{buffer-file-name} is the name of a symbolic link, then both
+numbers refer to the recursive target.
 @end defvar
 
 @defun get-file-buffer filename
@@ -427,7 +439,9 @@
 there is no such buffer, it returns @code{nil}.  The argument
 @var{filename}, which must be a string, is expanded (@pxref{File Name
 Expansion}), then compared against the visited file names of all live
-buffers.
+buffers.  Note that the buffer's @code{buffer-file-name} must match
+the expansion of @var{filename} exactly.  This function will not
+recognize other names for the same file.
 
 @example
 @group
@@ -441,6 +455,18 @@
 such buffer in the buffer list.
 @end defun
 
+@defun find-buffer-visiting filename &optional predicate
+This is like @code{get-file-buffer}, except that it can return any
+buffer visiting the file @emph{possibly under a different name}.  That
+is, the buffer's @code{buffer-file-name} does not need to match the
+expansion of @var{filename} exactly, it only needs to refer to the
+same file.  If @var{predicate} is non-@code{nil}, it should be a
+function of one argument, a buffer visiting @var{filename}.  The
+buffer is only considered a suitable return value if @var{predicate}
+returns non-@code{nil}.  If it can not find a suitable buffer to
+return, @code{find-buffer-visiting} returns @code{nil}.
+@end defun
+
 @deffn Command set-visited-file-name filename &optional no-query along-with-file
 If @var{filename} is a non-empty string, this function changes the
 name of the file visited in the current buffer to @var{filename}.  (If the
@@ -455,14 +481,24 @@
 
 If @var{filename} is @code{nil} or the empty string, that stands for
 ``no visited file''.  In this case, @code{set-visited-file-name} marks
-the buffer as having no visited file.
+the buffer as having no visited file, without changing the buffer's
+modified flag.
 
-Normally, this function asks the user for confirmation if the specified
-file already exists.  If @var{no-query} is non-@code{nil}, that prevents
-asking this question.
+Normally, this function asks the user for confirmation if there
+already is a buffer visiting @var{filename}.  If @var{no-query} is
+non-@code{nil}, that prevents asking this question.  If there already
+is a buffer visiting @var{filename}, and the user confirms or
+@var{query} is non-@code{nil}, this function makes the new buffer name
+unique by appending a number inside of @samp{<@dots{}>} to @var{filename}.
 
-If @var{along-with-file} is non-@code{nil}, that means to assume that the
-former visited file has been renamed to @var{filename}.
+If @var{along-with-file} is non-@code{nil}, that means to assume that
+the former visited file has been renamed to @var{filename}.  In this
+case, the command does not change the buffer's modified flag, nor the
+buffer's recorded last file modification time as reported by
+@code{visited-file-modtime} (@pxref{Modification Time}).  If
+@var{along-with-file} is @code{nil}, this function clears the recorded
+last file modification time, after which @code{visited-file-modtime}
+returns zero.
 
 @c Wordy to avoid overfull hbox.  --rjc 16mar92
 When the function @code{set-visited-file-name} is called interactively, it
@@ -523,10 +559,11 @@
 of mode lines.
 @end defun
 
-@deffn Command not-modified
-This command marks the current buffer as unmodified, and not needing to
-be saved.  With prefix arg, it marks the buffer as modified, so that it
-will be saved at the next suitable occasion.
+@deffn Command not-modified &optional arg
+This command marks the current buffer as unmodified, and not needing
+to be saved.  If @var{arg} is non-@code{nil}, it marks the buffer as
+modified, so that it will be saved at the next suitable occasion.
+Interactively, @var{arg} is the prefix argument.
 
 Don't use this function in programs, since it prints a message in the
 echo area; use @code{set-buffer-modified-p} (above) instead.
@@ -537,6 +574,7 @@
 This function returns @var{buffer}'s modification-count.  This is a
 counter that increments every time the buffer is modified.  If
 @var{buffer} is @code{nil} (or omitted), the current buffer is used.
+The counter can wrap around occasionally.
 @end defun
 
 @node Modification Time
@@ -561,6 +599,16 @@
 
 The function returns @code{t} if the last actual modification time and
 Emacs's recorded modification time are the same, @code{nil} otherwise.
+It also returns @code{t} if the buffer has no recorded last
+modification time, that is if @code{visited-file-modtime} would return
+zero.
+
+It always returns @code{t} for buffers that are not visiting a file,
+even if @code{visited-file-modtime} returns a non-zero value.  For
+instance, it always returns @code{t} for dired buffers.  It returns
+@code{t} for buffers that are visiting a file that does not exist and
+never existed, but @code{nil} for file-visiting buffers whose file has
+been deleted.
 @end defun
 
 @defun clear-visited-file-modtime
@@ -576,10 +624,30 @@
 
 @c Emacs 19 feature
 @defun visited-file-modtime
-This function returns the buffer's recorded last file modification time,
-as a list of the form @code{(@var{high} . @var{low})}.  (This is the
-same format that @code{file-attributes} uses to return time values; see
-@ref{File Attributes}.)
+This function returns the current buffer's recorded last file
+modification time, as a list of the form @code{(@var{high} .
+@var{low})}.  (This is the same format that @code{file-attributes}
+uses to return time values; see @ref{File Attributes}.)
+
+The function returns zero if the buffer has no recorded last
+modification time, which can happen, for instance, if the record has
+been explicitly cleared by @code{clear-visited-file-modtime} or if the
+buffer is not visiting a file.  Note, however, that
+@code{visited-file-modtime} can return a non-zero value for some
+buffers that are not visiting files, but are nevertheless closely
+associated with a file.  This happens, for instance, with dired
+buffers listing a directory.  For such buffers,
+@code{visited-file-modtime} returns the last modification time of that
+directory, as recorded by dired.
+
+For a new buffer visiting a not yet existing file, @var{high} is
+@minus{}1 and @var{low} is 65535, that is,
+@ifnottex
+@w{2**16 - 1.}
+@end ifnottex
+@tex
+@math{2^{16}-1}.
+@end tex
 @end defun
 
 @c Emacs 19 feature
@@ -589,7 +657,7 @@
 is not @code{nil}, and otherwise to the last modification time of the
 visited file.
 
-If @var{time} is not @code{nil}, it should have the form
+If @var{time} is neither @code{nil} nor zero, it should have the form
 @code{(@var{high} . @var{low})} or @code{(@var{high} @var{low})}, in
 either case containing two integers, each of which holds 16 bits of the
 time.
@@ -655,12 +723,13 @@
 @end defvar
 
 @defvar inhibit-read-only
-If this variable is non-@code{nil}, then read-only buffers and read-only
-characters may be modified.  Read-only characters in a buffer are those
-that have non-@code{nil} @code{read-only} properties (either text
-properties or overlay properties).  @xref{Special Properties}, for more
-information about text properties.  @xref{Overlays}, for more
-information about overlays and their properties.
+If this variable is non-@code{nil}, then read-only buffers and,
+depending on the actual value, some or all read-only characters may be
+modified.  Read-only characters in a buffer are those that have
+non-@code{nil} @code{read-only} properties (either text properties or
+overlay properties).  @xref{Special Properties}, for more information
+about text properties.  @xref{Overlays}, for more information about
+overlays and their properties.
 
 If @code{inhibit-read-only} is @code{t}, all @code{read-only} character
 properties have no effect.  If @code{inhibit-read-only} is a list, then
@@ -668,12 +737,17 @@
 of the list (comparison is done with @code{eq}).
 @end defvar
 
-@deffn Command toggle-read-only
-This command changes whether the current buffer is read-only.  It is
+@deffn Command toggle-read-only &optional arg
+This command toggles whether the current buffer is read-only.  It is
 intended for interactive use; do not use it in programs.  At any given
 point in a program, you should know whether you want the read-only flag
 on or off; so you can set @code{buffer-read-only} explicitly to the
 proper value, @code{t} or @code{nil}.
+
+If @var{arg} is non-@code{nil}, it should be a raw prefix argument.
+@code{toggle-read-only} sets @code{buffer-read-only} to @code{t} if
+the numeric value of that prefix argument is positive and to
+@code{nil} otherwise.  @xref{Prefix Command Arguments}.
 @end deffn
 
 @defun barf-if-buffer-read-only
@@ -816,12 +890,14 @@
 subprocess can also create a buffer (@pxref{Processes}).
 
 @defun get-buffer-create name
-This function returns a buffer named @var{name}.  It returns an existing
+This function returns a buffer named @var{name}.  It returns a live
 buffer with that name, if one exists; otherwise, it creates a new
 buffer.  The buffer does not become the current buffer---this function
 does not change which buffer is current.
 
-An error is signaled if @var{name} is not a string.
+If @var{name} is a buffer instead of a string, it is returned, even if
+it is dead.  An error is signaled if @var{name} is neither a string
+nor a buffer.
 
 @example
 @group
@@ -830,8 +906,8 @@
 @end group
 @end example
 
-The major mode for the new buffer is set to Fundamental mode.  The
-variable @code{default-major-mode} is handled at a higher level.
+The major mode for a newly created buffer is set to Fundamental mode.
+The variable @code{default-major-mode} is handled at a higher level.
 @xref{Auto Major Mode}.
 @end defun
 
@@ -905,8 +981,8 @@
 
 @deffn Command kill-buffer buffer-or-name
 This function kills the buffer @var{buffer-or-name}, freeing all its
-memory for other uses or to be returned to the operating system.  It
-returns @code{nil}.
+memory for other uses or to be returned to the operating system.  If
+@var{buffer-or-name} is @code{nil}, it kills the current buffer.
 
 Any processes that have this buffer as the @code{process-buffer} are
 sent the @code{SIGHUP} signal, which normally causes them to terminate.
@@ -921,16 +997,20 @@
 
 Killing a buffer that is already dead has no effect.
 
+This function returns @code{t} if it actually killed the buffer.  It
+returns @code{nil} if the user refuses to confirm or if
+@var{buffer-or-name} was already dead.
+
 @smallexample
 (kill-buffer "foo.unchanged")
-     @result{} nil
+     @result{} t
 (kill-buffer "foo.changed")
 
 ---------- Buffer: Minibuffer ----------
 Buffer foo.changed modified; kill anyway? (yes or no) @kbd{yes}
 ---------- Buffer: Minibuffer ----------
 
-     @result{} nil
+     @result{} t
 @end smallexample
 @end deffn
 
@@ -953,13 +1033,15 @@
 
 @defvar buffer-offer-save
 This variable, if non-@code{nil} in a particular buffer, tells
-@code{save-buffers-kill-emacs} and @code{save-some-buffers} to offer to
-save that buffer, just as they offer to save file-visiting buffers.  The
-variable @code{buffer-offer-save} automatically becomes buffer-local
-when set for any reason.  @xref{Buffer-Local Variables}.
+@code{save-buffers-kill-emacs} and @code{save-some-buffers} (if the
+second optional argument to that function is @code{t}) to offer to
+save that buffer, just as they offer to save file-visiting buffers.
+@xref{Definition of save-some-buffers}.  The variable
+@code{buffer-offer-save} automatically becomes buffer-local when set
+for any reason.  @xref{Buffer-Local Variables}.
 @end defvar
 
-@defun buffer-live-p buffer
+@defun buffer-live-p object
 This function returns @code{t} if @var{object} is a buffer which has
 not been killed, @code{nil} otherwise.
 @end defun
@@ -994,19 +1076,29 @@
 the base buffer effectively kills the indirect buffer in that it cannot
 ever again be the current buffer.
 
-@deffn Command make-indirect-buffer base-buffer name
-This creates an indirect buffer named @var{name} whose base buffer
-is @var{base-buffer}.  The argument @var{base-buffer} may be a buffer
-or a string.
+@deffn Command make-indirect-buffer base-buffer name &optional clone
+This creates and returns an indirect buffer named @var{name} whose
+base buffer is @var{base-buffer}.  The argument @var{base-buffer} may
+be a live buffer or the name (a string) of an existing buffer.  If
+@var{name} is the name of an existing buffer, an error is signaled.
+
+If @var{clone} is non-@code{nil}, then the indirect buffer originally
+shares the ``state'' of @var{base-buffer} such as major mode, minor
+modes, buffer local variables and so on.  If @var{clone} is omitted
+or @code{nil} the indirect buffer's state is set to the default state
+for new buffers.
 
 If @var{base-buffer} is an indirect buffer, its base buffer is used as
-the base for the new buffer.
+the base for the new buffer.  If, in addition, @var{clone} is
+non-@code{nil}, the initial state is copied from the actual base
+buffer, not from @var{base-buffer}.
 @end deffn
 
-@defun buffer-base-buffer buffer
-This function returns the base buffer of @var{buffer}.  If @var{buffer}
-is not indirect, the value is @code{nil}.  Otherwise, the value is
-another buffer, which is never an indirect buffer.
+@defun buffer-base-buffer &optional buffer
+This function returns the base buffer of @var{buffer}, which defaults
+to the current buffer.  If @var{buffer} is not indirect, the value is
+@code{nil}.  Otherwise, the value is another buffer, which is never an
+indirect buffer.
 @end defun
 
 @node Buffer Gap
--- a/lispref/files.texi	Tue Apr 13 18:18:05 2004 +0000
+++ b/lispref/files.texi	Thu Apr 15 16:49:22 2004 +0000
@@ -95,11 +95,11 @@
 using an existing buffer if there is one, and otherwise creating a
 new buffer and reading the file into it.  It also returns that buffer.
 
-The body of the @code{find-file} function is very simple and looks
-like this:
+Aside from some technical details, the body of the @code{find-file}
+function is basically equivalent to:
 
 @example
-(switch-to-buffer (find-file-noselect filename))
+(switch-to-buffer (find-file-noselect filename nil nil wildcards))
 @end example
 
 @noindent
@@ -193,12 +193,14 @@
 @end deffn
 
 @tindex find-file-wildcards
-@defvar find-file-wildcards
+@defopt find-file-wildcards
 If this variable is non-@code{nil}, then the various @code{find-file}
 commands check for wildcard characters and visit all the files that
-match them.  If this is @code{nil}, then wildcard characters are
-not treated specially.
-@end defvar
+match them (when invoked interactively or when their @var{wildcards}
+argument is non-@code{nil}).  If this option is @code{nil}, then
+the @code{find-file} commands ignore their @var{wildcards} argument
+and never treat wildcard characters specially.
+@end defopt
 
 @defvar find-file-hook
 The value of this variable is a list of functions to be called after a
@@ -206,8 +208,7 @@
 have been processed before the hooks are run.  The buffer visiting the
 file is current when the hook functions are run.
 
-This variable works just like a normal hook, but we think that renaming
-it would not be advisable.  @xref{Hooks}.
+This variable is a normal hook.  @xref{Hooks}.
 @end defvar
 
 @defvar find-file-not-found-functions
@@ -322,16 +323,21 @@
 With an argument of 16 or 64, reflecting 2 or 3 @kbd{C-u}'s, the
 @code{save-buffer} function unconditionally backs up the previous
 version of the file before saving it.
+
+@item
+With an argument of 0, unconditionally do @emph{not} make any backup file.
 @end itemize
 @end deffn
 
+@anchor{Definition of save-some-buffers}
 @deffn Command save-some-buffers &optional save-silently-p pred
 This command saves some modified file-visiting buffers.  Normally it
 asks the user about each buffer.  But if @var{save-silently-p} is
 non-@code{nil}, it saves all the file-visiting buffers without querying
 the user.
 
-The optional @var{pred} argument controls which buffers to ask about.
+The optional @var{pred} argument controls which buffers to ask about
+(or to save silently if @var{save-silently-p} is non-@code{nil}).
 If it is @code{nil}, that means to ask only about file-visiting buffers.
 If it is @code{t}, that means also offer to save certain other non-file
 buffers---those that have a non-@code{nil} buffer-local value of
@@ -346,6 +352,7 @@
 value in a certain buffer, that means do offer to save that buffer.
 @end deffn
 
+@anchor{Definition of write-file}
 @deffn Command write-file filename &optional confirm
 This function writes the current buffer into file @var{filename}, makes
 the buffer visit that file, and marks it not modified.  Then it renames
@@ -355,7 +362,13 @@
 @code{save-buffer}.
 
 If @var{confirm} is non-@code{nil}, that means to ask for confirmation
-before overwriting an existing file.
+before overwriting an existing file.  Interactively, confirmation is
+required, unless the user supplies a prefix argument.
+
+If @var{filename} is an existing directory, or a symbolic link to one,
+@code{write-file} uses the name of the visited file, in directory
+@var{filename}.  If the buffer is not visiting a file, it uses the
+buffer name instead.
 @end deffn
 
   Saving a buffer runs several hooks.  It also performs format
@@ -378,8 +391,9 @@
 @end example
 
 You might wish to save the file modes value returned by
-@code{backup-buffer} and use that to set the mode bits of the file that
-you write.  This is what @code{save-buffer} normally does.
+@code{backup-buffer} and use that (if non-@code{nil}) to set the mode
+bits of the file that you write.  This is what @code{save-buffer}
+normally does. @xref{Making Backups,, Making Backup Files}.
 
 The hook functions in @code{write-file-functions} are also responsible for
 encoding the data (if desired): they must choose a suitable coding
@@ -428,7 +442,7 @@
 highlighting information in a cache file.
 @end defopt
 
-@defvar file-precious-flag
+@defopt file-precious-flag
 If this variable is non-@code{nil}, then @code{save-buffer} protects
 against I/O errors while saving by writing the new file to a temporary
 name instead of the name it is supposed to have, and then renaming it to
@@ -442,7 +456,7 @@
 
 Some modes give this variable a non-@code{nil} buffer-local value
 in particular buffers.
-@end defvar
+@end defopt
 
 @defopt require-final-newline
 This variable determines whether files may be written out that do
@@ -541,12 +555,22 @@
 
 An error is signaled if @var{filename} specifies a nonwritable file,
 or a nonexistent file in a directory where files cannot be created.
+
+When called from Lisp, this function is completely equivalent to:
+
+@example
+(write-region start end filename t)
+@end example
 @end deffn
 
 @deffn Command write-region start end filename &optional append visit lockname mustbenew
 This function writes the region delimited by @var{start} and @var{end}
 in the current buffer into the file specified by @var{filename}.
 
+If @var{start} is @code{nil}, then the command writes the entire buffer
+contents (@emph{not} just the accessible portion) to the file and
+ignores @var{end}.
+
 @c Emacs 19 feature
 If @var{start} is a string, then @code{write-region} writes or appends
 that string, rather than text from the buffer.  @var{end} is ignored in
@@ -601,6 +625,7 @@
 files that the user does not need to know about.
 @end deffn
 
+@anchor{Definition of with-temp-file}
 @defmac with-temp-file file body...
 The @code{with-temp-file} macro evaluates the @var{body} forms with a
 temporary buffer as the current buffer; then, at the end, it writes the
@@ -612,7 +637,8 @@
 The current buffer is restored even in case of an abnormal exit via
 @code{throw} or error (@pxref{Nonlocal Exits}).
 
-See also @code{with-temp-buffer} in @ref{Current Buffer}.
+See also @code{with-temp-buffer} in @ref{Definition of
+with-temp-buffer,, The Current Buffer}.
 @end defmac
 
 @node File Locks
@@ -725,7 +751,10 @@
 @cindex accessibility of a file
 @cindex file accessibility
 
-  These functions test for permission to access a file in specific ways.
+  These functions test for permission to access a file in specific
+ways.  Unless explicitly stated otherwise, they recursively follow
+symbolic links for their file name arguments, at all levels (at the
+level of the file itself and at all levels of parent directories).
 
 @defun file-exists-p filename
 This function returns @code{t} if a file named @var{filename} appears
@@ -829,7 +858,13 @@
 
 @defun file-ownership-preserved-p filename
 This function returns @code{t} if deleting the file @var{filename} and
-then creating it anew would keep the file's owner unchanged.
+then creating it anew would keep the file's owner unchanged.  It also
+returns @code{t} for nonexistent files.
+
+If @var{filename} is a symbolic link, then, unlike the other functions
+discussed here, @code{file-ownership-preserved-p} does @emph{not}
+replace @var{filename} with its target.  However, it does recursively
+follow symbolic links at all levels of parent directories.
 @end defun
 
 @defun file-newer-than-file-p filename1 filename2
@@ -837,8 +872,8 @@
 @cindex file modification time
 This function returns @code{t} if the file @var{filename1} is
 newer than file @var{filename2}.  If @var{filename1} does not
-exist, it returns @code{nil}.  If @var{filename2} does not exist,
-it returns @code{t}.
+exist, it returns @code{nil}.  If @var{filename1} does exist, but
+@var{filename2} does not, it returns @code{t}.
 
 In the following example, assume that the file @file{aug-19} was written
 on the 19th, @file{aug-20} was written on the 20th, and the file
@@ -877,9 +912,10 @@
 @defun file-symlink-p filename
 @cindex file symbolic links
 If the file @var{filename} is a symbolic link, the
-@code{file-symlink-p} function returns the link target as a string.
-(Determining the file name that the link points to from the target is
-nontrivial.)
+@code{file-symlink-p} function returns the (non-recursive) link target
+as a string.  (Determining the file name that the link points to from
+the target is nontrivial.)  First, this function recursively follows
+symbolic links at all levels of parent directories.
 
 If the file @var{filename} is not a symbolic link (or there is no such file),
 @code{file-symlink-p} returns @code{nil}.
@@ -906,6 +942,9 @@
 @c !!! file-symlink-p: should show output of ls -l for comparison
 @end defun
 
+The next two functions recursively follow symbolic links at
+all levels for @var{filename}.
+
 @defun file-directory-p filename
 This function returns @code{t} if @var{filename} is the name of an
 existing directory, @code{nil} otherwise.
@@ -957,14 +996,31 @@
 @defun file-truename filename
 The function @code{file-truename} returns the truename of the file
 @var{filename}.  The argument must be an absolute file name.
+
+This function does not expand environment variables.  Only
+@code{substitute-in-file-name} does that.  @xref{Definition of
+substitute-in-file-name}.
+
+If you may need to follow symbolic links preceding @samp{..}@:
+appearing as a name component, you should make sure to call
+@code{file-truename} without prior direct or indirect calls to
+@code{expand-file-name}, as otherwise the file name component
+immediately preceding @samp{..} will be ``simplified away'' before
+@code{file-truename} is called.  To eliminate the need for a call to
+@code{expand-file-name}, @code{file-truename} handles @samp{~} in the
+same way that @code{expand-file-name} does.  @xref{File Name
+Expansion,, Functions that Expand Filenames}.
 @end defun
 
 @defun file-chase-links filename &optional limit
 This function follows symbolic links, starting with @var{filename},
 until it finds a file name which is not the name of a symbolic link.
-Then it returns that file name.  If you specify a number for
-@var{limit}, then after chasing through that many links, the function
-just returns what it as even if that is still a symbolic link.
+Then it returns that file name.  This function does @emph{not} follow
+symbolic links at the level of parent directories.
+
+If you specify a number for @var{limit}, then after chasing through
+that many links, the function just returns what it has even if that is
+still a symbolic link.
 @end defun
 
   To illustrate the difference between @code{file-chase-links} and
@@ -1007,6 +1063,10 @@
 everyone has read, write, and execute permission, that the @acronym{SUID} bit
 is set for both others and group, and that the sticky bit is set.
 
+If @var{filename} does not exist, @code{file-modes} returns @code{nil}.
+
+This function recursively follows symbolic links at all levels.
+
 @example
 @group
 (file-modes "~/junk/diffs")
@@ -1034,6 +1094,11 @@
 @end example
 @end defun
 
+If the @var{filename} argument to the next two functions is a symbolic
+link, then these function do @emph{not} replace it with its target.
+However, they both recursively follow symbolic links at all levels of
+parent directories.
+
 @defun file-nlinks filename
 This functions returns the number of names (i.e., hard links) that
 file @var{filename} has.  If the file does not exist, then this function
@@ -1059,6 +1124,7 @@
 @end example
 @end defun
 
+@anchor{Definition of file-attributes}
 @defun file-attributes filename &optional id-format
 This function returns a list of attributes of file @var{filename}.  If
 the specified file cannot be opened, it returns @code{nil}.
@@ -1213,7 +1279,12 @@
 is any other value.
 @end itemize
 
-@defun add-name-to-file oldname newname &optional ok-if-already-exists
+The next four commands all recursively follow symbolic links at all
+levels of parent directories for their first argument, but, if that
+argument is itself a symbolic link, then only @code{copy-file}
+replaces it with its (recursive) target.
+
+@deffn Command add-name-to-file oldname newname &optional ok-if-already-exists
 @cindex file with multiple names
 @cindex file hard link
 This function gives the file named @var{oldname} the additional name
@@ -1279,7 +1350,7 @@
 by copying the file instead.
 
 See also @code{file-nlinks} in @ref{File Attributes}.
-@end defun
+@end deffn
 
 @deffn Command rename-file filename newname &optional ok-if-already-exists
 This command renames the file @var{filename} as @var{newname}.
@@ -1288,10 +1359,6 @@
 continues to have those names.  In fact, adding the name @var{newname}
 with @code{add-name-to-file} and then deleting @var{filename} has the
 same effect as renaming, aside from momentary intermediate states.
-
-In an interactive call, this function prompts for @var{filename} and
-@var{newname} in the minibuffer; also, it requests confirmation if
-@var{newname} already exists.
 @end deffn
 
 @deffn Command copy-file oldname newname &optional ok-if-exists time
@@ -1307,9 +1374,19 @@
 
 This function copies the file modes, too.
 
-In an interactive call, this function prompts for @var{filename} and
-@var{newname} in the minibuffer; also, it requests confirmation if
-@var{newname} already exists.
+In an interactive call, a prefix argument specifies a non-@code{nil}
+value for @var{time}.
+@end deffn
+
+@deffn Command make-symbolic-link filename newname  &optional ok-if-exists
+@pindex ln
+@kindex file-already-exists
+This command makes a symbolic link to @var{filename}, named
+@var{newname}.  This is like the shell command @samp{ln -s
+@var{filename} @var{newname}}.
+
+This function is not available on systems that don't support symbolic
+links.
 @end deffn
 
 @deffn Command delete-file filename
@@ -1322,32 +1399,23 @@
 not exist, or is not deletable.  (On Unix and GNU/Linux, a file is
 deletable if its directory is writable.)
 
+If @var{filename} is a symbolic link, @code{delete-file} does not
+replace it with its target, but it does follow symbolic links at all
+levels of parent directories.
+
 See also @code{delete-directory} in @ref{Create/Delete Dirs}.
 @end deffn
 
-@deffn Command make-symbolic-link filename newname  &optional ok-if-exists
-@pindex ln
-@kindex file-already-exists
-This command makes a symbolic link to @var{filename}, named
-@var{newname}.  This is like the shell command @samp{ln -s
-@var{filename} @var{newname}}.
-
-In an interactive call, this function prompts for @var{filename} and
-@var{newname} in the minibuffer; also, it requests confirmation if
-@var{newname} already exists.
-
-This function is not available on systems that don't support symbolic
-links.
-@end deffn
-
 @defun define-logical-name varname string
 This function defines the logical name @var{varname} to have the value
 @var{string}.  It is available only on VMS.
 @end defun
 
 @defun set-file-modes filename mode
-This function sets mode bits of @var{filename} to @var{mode} (which must
-be an integer).  Only the low 12 bits of @var{mode} are used.
+This function sets mode bits of @var{filename} to @var{mode} (which
+must be an integer).  Only the low 12 bits of @var{mode} are used.
+This function recursively follows symbolic links at all levels for
+@var{filename}.
 @end defun
 
 @c Emacs 19 feature
@@ -1500,18 +1568,6 @@
 @end example
 @end defun
 
-@defun file-name-extension filename &optional period
-This function returns @var{filename}'s final ``extension,'' if any,
-after applying @code{file-name-sans-versions} to remove any
-version/backup part.  It returns @code{nil} for extensionless file
-names such as @file{foo}.  If @var{period} is non-@code{nil}, then the
-returned value includes the period that delimits the extension, and if
-@var{filename} has no extension, the value is @code{""}.  If the last
-component of a file name begins with a @samp{.}, that @samp{.} doesn't
-count as the beginning of an extension, so, for example,
-@file{.emacs}'s ``extension'' is @code{nil}, not @samp{.emacs}.
-@end defun
-
 @defun file-name-sans-versions filename &optional keep-backup-version
 This function returns @var{filename} with any file version numbers,
 backup version numbers, or trailing tildes discarded.
@@ -1541,11 +1597,29 @@
 @end example
 @end defun
 
+@defun file-name-extension filename &optional period
+This function returns @var{filename}'s final ``extension'', if any,
+after applying @code{file-name-sans-versions} to remove any
+version/backup part.  The extension, in a file name, is the part that
+starts with the last @samp{.} in the last name component (minus
+any version/backup part).
+
+This function returns @code{nil} for extensionless file names such as
+@file{foo}.  It returns @code{""} for null extensions, as in
+@file{foo.}.  If the last component of a file name begins with a
+@samp{.}, that @samp{.}  doesn't count as the beginning of an
+extension.  Thus, @file{.emacs}'s ``extension'' is @code{nil}, not
+@samp{.emacs}.
+
+If @var{period} is non-@code{nil}, then the returned value includes
+the period that delimits the extension, and if @var{filename} has no
+extension, the value is @code{""}.
+@end defun
+
 @defun file-name-sans-extension filename
-This function returns @var{filename} minus its ``extension,'' if any.
-The extension, in a file name, is the part that starts with the last
-@samp{.} in the last name component, except if that @samp{.} is the
-first character of the file name's last component.  For example,
+This function returns @var{filename} minus its extension, if any.  The
+version/backup part, if present, is only removed if the file has an
+extension.  For example,
 
 @example
 (file-name-sans-extension "foo.lose.c")
@@ -1556,7 +1630,14 @@
      @result{} "/my/home/.emacs"
 (file-name-sans-extension "/my/home/.emacs.el")
      @result{} "/my/home/.emacs"
+(file-name-sans-extension "~/foo.el.~3~")
+     @result{} "~/foo"
+(file-name-sans-extension "~/foo.~3~")
+     @result{} "~/foo.~3~"
 @end example
+
+Note that the @samp{.~3~} in the two last examples is the backup part,
+not an extension.
 @end defun
 
 @ignore
@@ -1623,9 +1704,9 @@
 the directory name but not identical to it.  (This is not quite the
 same as the usual Unix terminology.)  These two different names for
 the same entity are related by a syntactic transformation.  On GNU and
-Unix systems, this is simple: a directory name ends in a slash (or
-backslash), whereas the directory's name as a file lacks that slash.
-On MSDOS and VMS, the relationship is more complicated.
+Unix systems, this is simple: a directory name ends in a slash,
+whereas the directory's name as a file lacks that slash.  On MSDOS and
+VMS, the relationship is more complicated.
 
   The difference between a directory name and its name as a file is
 subtle but crucial.  When an Emacs variable or function argument is
@@ -1635,7 +1716,7 @@
 
   The following two functions convert between directory names and file
 names.  They do nothing special with environment variable substitutions
-such as @samp{$HOME}, and the constructs @samp{~}, and @samp{..}.
+such as @samp{$HOME}, and the constructs @samp{~}, @samp{.} and @samp{..}.
 
 @defun file-name-as-directory filename
 This function returns a string representing @var{filename} in a form
@@ -1713,7 +1794,9 @@
 @code{(@var{from} . @var{to})}, and says to replace @var{from} with
 @var{to} when it appears in a directory name.  The @var{from} string is
 actually a regular expression; it should always start with @samp{^}.
-The function @code{abbreviate-file-name} performs these substitutions.
+The @var{to} string should be an ordinary absolute directory name.  Do
+not use @samp{~} to stand for a home directory in that string.  The
+function @code{abbreviate-file-name} performs these substitutions.
 
 You can set this variable in @file{site-init.el} to describe the
 abbreviations appropriate for your site.
@@ -1732,6 +1815,7 @@
   To convert a directory name to its abbreviation, use this
 function:
 
+@anchor{Definition of abbreviate-file-name}
 @defun abbreviate-file-name filename
 This function applies abbreviations from @code{directory-abbrev-alist}
 to its argument, and substitutes @samp{~} for the user's home
@@ -1749,6 +1833,9 @@
 be expanded.  Expansion also simplifies file names by eliminating
 redundancies such as @file{./} and @file{@var{name}/../}.
 
+In the next two functions, the @var{directory} argument can be either
+a directory name or a directory file name.  @xref{Directory Names}.
+
 @defun expand-file-name filename &optional directory
 This function converts @var{filename} to an absolute file name.  If
 @var{directory} is supplied, it is the default directory to start with
@@ -1776,6 +1863,12 @@
 @end group
 @end example
 
+If the part of the combined file name before the first slash is
+@samp{~}, it expands to the value of the @env{HOME} environment
+variable (usually your home directory).  If the part before the first
+slash is @samp{~@var{user}} and if @var{user} is a valid login name,
+it expands to @var{user}'s home directory.
+
 Filenames containing @samp{.} or @samp{..} are simplified to their
 canonical form:
 
@@ -1788,6 +1881,27 @@
 
 Note that @code{expand-file-name} does @emph{not} expand environment
 variables; only @code{substitute-in-file-name} does that.
+
+Note also that @code{expand-file-name} does not follow symbolic links
+at any level.  This results in a difference between the way
+@code{file-truename} and @code{expand-file-name} treat @samp{..}.
+Assuming that @samp{/tmp/bar} is a symbolic link to the directory
+@samp{/tmp/foo/bar} we get:
+
+@example
+@group
+(file-truename "/tmp/bar/../myfile")
+     @result{} "/tmp/foo/myfile"
+@end group
+@group
+(expand-file-name "/tmp/bar/../myfile")
+     @result{} "/tmp/myfile"
+@end group
+@end example
+
+If you may need to follow symbolic links preceding @samp{..}, you
+should make sure to call @code{file-truename} without prior direct or
+indirect calls to @code{expand-file-name}.  @xref{Truenames}.
 @end defun
 
 @c Emacs 19 feature
@@ -1829,8 +1943,9 @@
 @end example
 @end defvar
 
+@anchor{Definition of substitute-in-file-name}
 @defun substitute-in-file-name filename
-This function replaces environment variables references in
+This function replaces environment variable references in
 @var{filename} with the environment variable values.  Following
 standard Unix shell syntax, @samp{$} is the prefix to substitute an
 environment variable value.  If the input contains @samp{$$}, that is
@@ -1862,8 +1977,9 @@
 @end group
 @end example
 
-After substitution, if a @samp{~} or a @samp{/} appears following a
-@samp{/}, everything before the following @samp{/} is discarded:
+After substitution, if a @samp{~} or a @samp{/} appears immediately
+after another @samp{/}, the function discards everything before it (up
+through the immediately preceding @samp{/}).
 
 @example
 @group
@@ -1895,7 +2011,7 @@
 The job of @code{make-temp-file} is to prevent two different users or
 two different jobs from trying to use the exact same file name.
 
-@defun make-temp-file prefix &optional dir-flag
+@defun make-temp-file prefix &optional dir-flag suffix
 @tindex make-temp-file
 This function creates a temporary file and returns its name.
 The name starts with @var{prefix}; it also contains a number that is
@@ -1913,8 +2029,12 @@
 empty.  At that point, you should write the intended contents into the
 file.
 
-If @var{dir-flag} is non-@code{nil}, @code{make-temp-file} creates
-an empty directory instead of an empty file.
+If @var{dir-flag} is non-@code{nil}, @code{make-temp-file} creates an
+empty directory instead of an empty file.  It returns the file name,
+not the directory name, of that directory.  @xref{Directory Names}.
+
+If @var{suffix} is non-@code{nil}, @code{make-temp-file} adds it at
+the end of the file name.
 
 To prevent conflicts among different libraries running in the same
 Emacs, each Lisp program that uses @code{make-temp-file} should have its
@@ -1944,9 +2064,10 @@
 This function generates a string that can be used as a unique file name.
 The name starts with @var{string}, and contains a number that is
 different in each Emacs job.  It is like @code{make-temp-file} except
-that it just constructs a name, and does not create a file.  On MS-DOS,
-the @var{string} prefix can be truncated to fit into the 8+3 file-name
-limits.
+that it just constructs a name, and does not create a file.  Another
+difference is that @var{string} should be an absolute file name.  On
+MS-DOS, this function can truncate the @var{string} prefix to fit into
+the 8+3 file-name limits.
 @end defun
 
 @defvar temporary-file-directory
@@ -1964,11 +2085,11 @@
 environment variables, with a fall-back to a system-dependent name if
 none of these variables is defined.
 
-Even if you do not use @code{make-temp-name} to choose the temporary
-file's name, you should still use this variable to decide which
-directory to put the file in.  However, if you expect the file to be
-small, you should use @code{small-temporary-file-directory} first if
-that is non-@code{nil}.
+Even if you do not use @code{make-temp-file} to create the temporary
+file, you should still use this variable to decide which directory to
+put the file in.  However, if you expect the file to be small, you
+should use @code{small-temporary-file-directory} first if that is
+non-@code{nil}.
 @end defvar
 
 @tindex small-temporary-file-directory
@@ -2066,8 +2187,8 @@
 @defopt completion-ignored-extensions
 @code{file-name-completion} usually ignores file names that end in any
 string in this list.  It does not ignore them when all the possible
-completions end in one of these suffixes or when a buffer showing all
-possible completions is displayed.@refill
+completions end in one of these suffixes.  This variable has no effect
+on @code{file-name-all-completions}.@refill
 
 A typical value might look like this:
 
@@ -2176,17 +2297,20 @@
 that can be read.
 @end defun
 
-@defun directory-files-and-attributes directory &optional full-name match-regexp nosort
+@defun directory-files-and-attributes directory &optional full-name match-regexp nosort id-format
 This is similar to @code{directory-files} in deciding which files
 to report on and how to report their names.  However, instead
 of returning a list of file names, it returns for each file a
 list @code{(@var{filename} . @var{attributes})}, where @var{attributes}
 is what @code{file-attributes} would return for that file.
+The optional argument @var{id-format} has the same meaning as the
+corresponding argument to @code{file-attributes} (@pxref{Definition
+of file-attributes}).
 @end defun
 
 @defun file-name-all-versions file dirname
 This function returns a list of all versions of the file named
-@var{file} in directory @var{dirname}.
+@var{file} in directory @var{dirname}.  It is only available on VMS.
 @end defun
 
 @tindex file-expand-wildcards
@@ -2207,6 +2331,8 @@
 This function inserts (in the current buffer) a directory listing for
 directory @var{file}, formatted with @code{ls} according to
 @var{switches}.  It leaves point after the inserted text.
+@var{switches} may be a string of options, or a list of strings
+representing individual options.
 
 The argument @var{file} may be either a directory name or a file
 specification including wildcard characters.  If @var{wildcard} is
@@ -2228,6 +2354,12 @@
 MS-DOS and MS-Windows systems usually lack the standard Unix program
 @code{ls}, so this function emulates the standard Unix program @code{ls}
 with Lisp code.
+
+As a technical detail, when @var{switches} contains the long
+@samp{--dired} option, @code{insert-directory} treats it specially,
+for the sake of dired.  However, the normally equivalent short
+@samp{-D} option is just passed on to @code{insert-directory-program},
+as any other option.
 @end defun
 
 @defvar insert-directory-program
@@ -2247,8 +2379,9 @@
 
 @defun make-directory dirname &optional parents
 This function creates a directory named @var{dirname}.
-If @var{parents} is non-@code{nil}, that means to create
-the parent directories first, if they don't already exist.
+If @var{parents} is non-@code{nil}, as is always the case in an
+interactive call, that means to create the parent directories first,
+if they don't already exist.
 @end defun
 
 @defun delete-directory dirname
@@ -2256,6 +2389,9 @@
 @code{delete-file} does not work for files that are directories; you
 must use @code{delete-directory} for them.  If the directory contains
 any files, @code{delete-directory} signals an error.
+
+This function only follows symbolic links at the level of parent
+directories.
 @end defun
 
 @node Magic File Names
@@ -2287,10 +2423,10 @@
 the file name matches @var{regexp}, the primitives handle that file by
 calling @var{handler}.
 
-The first argument given to @var{handler} is the name of the primitive;
-the remaining arguments are the arguments that were passed to that
-primitive.  (The first of these arguments is most often the file name
-itself.)  For example, if you do this:
+The first argument given to @var{handler} is the name of the
+primitive, as a symbol; the remaining arguments are the arguments that
+were passed to that primitive.  (The first of these arguments is most
+often the file name itself.)  For example, if you do this:
 
 @example
 (file-exists-p @var{filename})
@@ -2501,7 +2637,7 @@
 @end defun
 
 @defun file-remote-p filename
-This functions return @code{t} if @var{filename} is a remote file---that is,
+This function returns @code{t} if @var{filename} is a remote file---that is,
 a magic file name that handles @code{file-local-copy}.
 @end defun
 
@@ -2631,11 +2767,14 @@
 encoding functions for the formats listed in @code{buffer-file-format},
 in the order of appearance in the list.
 
-@deffn Command format-write-file file format
-This command writes the current buffer contents into the file @var{file}
-in format @var{format}, and makes that format the default for future
-saves of the buffer.  The argument @var{format} is a list of format
-names.
+@deffn Command format-write-file file format &optional confirm
+This command writes the current buffer contents into the file
+@var{file} in format @var{format}, and makes that format the default
+for future saves of the buffer.  The argument @var{format} is a list
+of format names.  Except for the @var{format} argument, this command
+is similar to @code{write-file}.  In particular, @var{confirm} has the
+same meaning and interactive treatment as the corresponding argument
+to @code{write-file}.  @xref{Definition of write-file}.
 @end deffn
 
 @deffn Command format-find-file file format
@@ -2667,8 +2806,10 @@
 This variable specifies the format to use for auto-saving.  Its value is
 a list of format names, just like the value of
 @code{buffer-file-format}; however, it is used instead of
-@code{buffer-file-format} for writing auto-save files.  This variable is
-always buffer-local in all buffers.
+@code{buffer-file-format} for writing auto-save files.  If the value
+is @code{t}, the default, auto-saving uses the same format as a
+regular save in the same buffer.  This variable is always buffer-local
+in all buffers.
 @end defvar
 
 @ignore
--- a/lispref/keymaps.texi	Tue Apr 13 18:18:05 2004 +0000
+++ b/lispref/keymaps.texi	Thu Apr 15 16:49:22 2004 +0000
@@ -2333,7 +2333,7 @@
 prefix keymap.  The remaining arguments @var{props} are additional
 property list elements to add to the menu item specification.
 
-To define items in some local map, bind @code{`tool-bar-map} with
+To define items in some local map, bind @code{tool-bar-map} with
 @code{let} around calls of this function:
 @example
 (defvar foo-tool-bar-map
--- a/lispref/processes.texi	Tue Apr 13 18:18:05 2004 +0000
+++ b/lispref/processes.texi	Thu Apr 15 16:49:22 2004 +0000
@@ -1896,7 +1896,7 @@
 @end table
 
 The original argument list, modified with the actual connection
-information, is available via the `process-contact' function.
+information, is available via the @code{process-contact} function.
 @end defun
 
 @defun set-network-process-option process option value
@@ -1905,7 +1905,7 @@
 @var{option} and their corresponding values @var{value}.
 
 The current setting of an option is available via the
-`process-contact' function.
+@code{process-contact} function.
 @end defun
 
 @defun network-interface-list
--- a/lispref/windows.texi	Tue Apr 13 18:18:05 2004 +0000
+++ b/lispref/windows.texi	Thu Apr 15 16:49:22 2004 +0000
@@ -455,7 +455,8 @@
 
 @defun get-lru-window &optional frame
 This function returns the window least recently ``used'' (that is,
-selected).  The selected window is always the most recently used window.
+selected).  If any full-width windows are present, it only considers
+these.  The selected window is always the most recently used window.
 
 The selected window can be the least recently used window if it is the
 only window.  A newly created window becomes the least recently used
--- a/src/ChangeLog	Tue Apr 13 18:18:05 2004 +0000
+++ b/src/ChangeLog	Thu Apr 15 16:49:22 2004 +0000
@@ -1,3 +1,39 @@
+2004-04-14  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* fileio.c (Fverify_visited_file_modtime, Fvisited_file_modtime):
+	Add hyperlink to Elisp manual to the docstring.
+
+2004-04-14  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* callint.c (fix_command): Use XDCR.
+
+2004-04-14  Nick Roberts  <nick@nick.uklinux.net>
+
+	* window.c (Fget_lru_window): Doc fix.
+
+2004-04-14  Kim F. Storm  <storm@cua.dk>
+
+	* editfns.c (Fformat): Fix allocation size of precision array.
+
+	* dispnew.c (update_window): Only set changed_p if
+	scrolling_window actually did scroll.
+	(scrolling_window): Only return 1 if we actually did scroll.
+
+	* xdisp.c (get_glyph_string_clip_rect): Fix reduction of cursor
+	height to glyph height when cursor row is not fully visible.
+	(make_cursor_line_fully_visible): Add FORCE_P arg to return
+	failure in case row is higher than window.  Callers changed.
+	(try_scrolling): Fix loop in scrolling if last_line_misfit (from Gerd).
+	Try to scroll partially visible, higher-than-window cursor row.
+	(redisplay_window): Always try to scroll partially visible,
+	higher-than-window cursor row - both initially and again with
+	centering_position = 0.
+	Clear desired matrix before retrying with centering_position = 0.
+
+2004-04-13  Joe Buehler  <jbuehler@hekimian.com>
+
+	* sheap.c, unexcw.c: New files.
+
 2004-04-12  Luc Teirlinck  <teirllm@auburn.edu>
 
 	* buffer.c (Fmake_indirect_buffer): Throw an error if the intended
@@ -32,6 +68,10 @@
 	* buffer.c (fix_start_end_in_overlays): Make overlays
 	empty if they are backwards.
 
+2004-04-09  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* xfaces.c (face_color_supported_p): Fix compilation without X11.
+
 2004-04-07  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* doc.c (Fsnarf_documentation): Ignore new file name entries.
--- a/src/callint.c	Tue Apr 13 18:18:05 2004 +0000
+++ b/src/callint.c	Thu Apr 15 16:49:22 2004 +0000
@@ -209,7 +209,7 @@
 	  Lisp_Object intail, valtail;
 	  for (intail = Fcdr (input), valtail = values;
 	       CONSP (valtail);
-	       intail = Fcdr (intail), valtail = Fcdr (valtail))
+	       intail = Fcdr (intail), valtail = XCDR (valtail))
 	    {
 	      Lisp_Object elt;
 	      elt = Fcar (intail);
--- a/src/dispnew.c	Tue Apr 13 18:18:05 2004 +0000
+++ b/src/dispnew.c	Thu Apr 15 16:49:22 2004 +0000
@@ -4132,9 +4132,11 @@
 	      goto set_cursor;
 	    }
 	  else if (rc > 0)
-	    /* We've scrolled the display.  */
-	    force_p = 1;
-	  changed_p = 1;
+	    {
+	      /* We've scrolled the display.  */
+	      force_p = 1;
+	      changed_p = 1;
+	    }
 	}
 
       /* Update the rest of the lines.  */
@@ -5056,8 +5058,8 @@
   for (i = 0; i < row_entry_idx; ++i)
     row_table[row_entry_pool[i].bucket] = NULL;
 
-  /* Value is non-zero to indicate that we scrolled the display.  */
-  return 1;
+  /* Value is > 0 to indicate that we scrolled the display.  */
+  return nruns;
 }
 
 
@@ -5919,13 +5921,13 @@
 	 it's the one we were looking for.  */
       if (area == RIGHT_MARGIN_AREA)
 	x0 = ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
-	       ? WINDOW_LEFT_FRINGE_WIDTH (w) 
+	       ? WINDOW_LEFT_FRINGE_WIDTH (w)
 	       : WINDOW_TOTAL_FRINGE_WIDTH (w))
 	      + window_box_width (w, LEFT_MARGIN_AREA)
 	      + window_box_width (w, TEXT_AREA));
       else
 	x0 = (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
-	      ? WINDOW_LEFT_FRINGE_WIDTH (w) 
+	      ? WINDOW_LEFT_FRINGE_WIDTH (w)
 	      : 0);
 
       glyph = row->glyphs[area];
--- a/src/editfns.c	Tue Apr 13 18:18:05 2004 +0000
+++ b/src/editfns.c	Thu Apr 15 16:49:22 2004 +0000
@@ -3220,7 +3220,7 @@
      string itself, will not be used.  Element NARGS, corresponding to
      no argument, *will* be assigned to in the case that a `%' and `.'
      occur after the final format specifier.  */
-  int *precision = (int *) (alloca(nargs * sizeof (int)));
+  int *precision = (int *) (alloca((nargs + 1) * sizeof (int)));
   int longest_format;
   Lisp_Object val;
   int arg_intervals = 0;
@@ -3274,7 +3274,7 @@
   /* Make room in result for all the non-%-codes in the control string.  */
   total = 5 + CONVERTED_BYTE_SIZE (multibyte, args[0]);
 
-  /* Allocate the info and discarded tables.  */ 
+  /* Allocate the info and discarded tables.  */
   {
     int nbytes = nargs * sizeof *info;
     int i;
--- a/src/fileio.c	Tue Apr 13 18:18:05 2004 +0000
+++ b/src/fileio.c	Thu Apr 15 16:49:22 2004 +0000
@@ -5509,7 +5509,8 @@
 DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime,
        Sverify_visited_file_modtime, 1, 1, 0,
        doc: /* Return t if last mod time of BUF's visited file matches what BUF records.
-This means that the file has not been changed since it was visited or saved.  */)
+This means that the file has not been changed since it was visited or saved.
+See Info node `(elisp)Modification Time' for more details.  */)
      (buf)
      Lisp_Object buf;
 {
@@ -5565,7 +5566,9 @@
        Svisited_file_modtime, 0, 0, 0,
        doc: /* Return the current buffer's recorded visited file modification time.
 The value is a list of the form (HIGH . LOW), like the time values
-that `file-attributes' returns.  */)
+that `file-attributes' returns.  If the current buffer has no recorded
+file modification time, this function returns 0.
+See Info node `(elisp)Modification Time' for more details.  */)
      ()
 {
   return long_to_cons ((unsigned long) current_buffer->modtime);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/sheap.c	Thu Apr 15 16:49:22 2004 +0000
@@ -0,0 +1,104 @@
+/* simulate sbrk() with an array in .bss, for unexec() support for Cygwin;
+   complete rewrite of xemacs Cygwin unexec() code
+
+   Copyright (C) 2004
+   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 <unistd.h>
+
+#ifdef HAVE_X_WINDOWS
+#define STATIC_HEAP_SIZE	(7 * 1024 * 1024)
+#else
+#define STATIC_HEAP_SIZE	(7 * 1024 * 1024)
+#endif
+
+int debug_sheap = 0;
+
+#define BLOCKSIZE 4096
+
+char bss_sbrk_buffer[STATIC_HEAP_SIZE];
+char *bss_sbrk_ptr;
+int bss_sbrk_did_unexec;
+
+void *
+bss_sbrk (ptrdiff_t request_size)
+{
+  if (!bss_sbrk_ptr)
+    {
+      bss_sbrk_ptr = bss_sbrk_buffer;
+#ifdef CYGWIN
+      sbrk (BLOCKSIZE);		/* force space for fork to work */
+#endif
+    }
+
+  if (!(int) request_size)
+    {
+      return (bss_sbrk_ptr);
+    }
+  else if (bss_sbrk_ptr + (int) request_size < bss_sbrk_buffer)
+    {
+      printf
+	("attempt to free too much: avail %d used %d failed request %d\n",
+	 STATIC_HEAP_SIZE, bss_sbrk_ptr - bss_sbrk_buffer,
+	 (int) request_size);
+      exit (-1);
+      return 0;
+    }
+  else if (bss_sbrk_ptr + (int) request_size >
+	   bss_sbrk_buffer + STATIC_HEAP_SIZE)
+    {
+      printf ("static heap exhausted: avail %d used %d failed request %d\n",
+	      STATIC_HEAP_SIZE,
+	      bss_sbrk_ptr - bss_sbrk_buffer, (int) request_size);
+      exit (-1);
+      return 0;
+    }
+  else if ((int) request_size < 0)
+    {
+      bss_sbrk_ptr += (int) request_size;
+      if (debug_sheap)
+	printf ("freed size %d\n", request_size);
+      return bss_sbrk_ptr;
+    }
+  else
+    {
+      char *ret = bss_sbrk_ptr;
+      if (debug_sheap)
+	printf ("allocated 0x%08x size %d\n", ret, request_size);
+      bss_sbrk_ptr += (int) request_size;
+      return ret;
+    }
+}
+
+void
+report_sheap_usage (int die_if_pure_storage_exceeded)
+{
+  char buf[200];
+  sprintf (buf, "Static heap usage: %d of %d bytes",
+	   bss_sbrk_ptr - bss_sbrk_buffer, STATIC_HEAP_SIZE);
+  message ("%s", buf);
+}
+
+/* arch-tag: 1bc386e8-71c2-4da4-b8b5-c1674a9cf926
+   (do not change this comment) */
--- a/src/syntax.c	Tue Apr 13 18:18:05 2004 +0000
+++ b/src/syntax.c	Thu Apr 15 16:49:22 2004 +0000
@@ -2398,8 +2398,8 @@
 	    case Sstring_fence:
 	      while (1)
 		{
+		  if (from == stop) goto lose;
 		  DEC_BOTH (from, from_byte);
-		  if (from == stop) goto lose;
 		  UPDATE_SYNTAX_TABLE_BACKWARD (from);
 		  if (!char_quoted (from, from_byte)
 		      && (c = FETCH_CHAR (from_byte),
@@ -2414,19 +2414,13 @@
 	      while (1)
 		{
 		  if (from == stop) goto lose;
-		  temp_pos = from_byte;
-		  if (! NILP (current_buffer->enable_multibyte_characters))
-		    DEC_POS (temp_pos);
-		  else
-		    temp_pos--;
-		  UPDATE_SYNTAX_TABLE_BACKWARD (from - 1);
-		  if (!char_quoted (from - 1, temp_pos)
-		      && stringterm == (c = FETCH_CHAR (temp_pos))
+		  DEC_BOTH (from, from_byte);
+		  UPDATE_SYNTAX_TABLE_BACKWARD (from);
+		  if (!char_quoted (from, from_byte)
+		      && stringterm == (c = FETCH_CHAR (from_byte))
 		      && SYNTAX_WITH_MULTIBYTE_CHECK (c) == Sstring)
 		    break;
-		  DEC_BOTH (from, from_byte);
 		}
-	      DEC_BOTH (from, from_byte);
 	      if (!depth && sexpflag) goto done2;
 	      break;
 	    default:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/unexcw.c	Thu Apr 15 16:49:22 2004 +0000
@@ -0,0 +1,307 @@
+/* unexec() support for Cygwin;
+   complete rewrite of xemacs Cygwin unexec() code
+
+   Copyright (C) 2004
+   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 <lisp.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <a.out.h>
+#include <unistd.h>
+#include <assert.h>
+
+#define DOTEXE ".exe"
+
+extern int bss_sbrk_did_unexec;
+
+/* emacs symbols that indicate where bss and data end for emacs internals */
+extern char my_endbss[];
+extern char my_edata[];
+
+/*
+** header for Windows executable files
+*/
+typedef struct
+{
+  FILHDR file_header;
+  PEAOUTHDR file_optional_header;
+  SCNHDR section_header[32];
+} exe_header_t;
+
+int debug_unexcw = 0;
+
+/*
+** Read the header from the executable into memory so we can more easily access it.
+*/
+static exe_header_t *
+read_exe_header (int fd, exe_header_t * exe_header_buffer)
+{
+  int i;
+  int ret;
+
+  assert (fd >= 0);
+  assert (exe_header_buffer != 0);
+
+  ret = lseek (fd, 0L, SEEK_SET);
+  assert (ret != -1);
+
+  ret =
+    read (fd, &exe_header_buffer->file_header,
+	  sizeof (exe_header_buffer->file_header));
+  assert (ret == sizeof (exe_header_buffer->file_header));
+
+  assert (exe_header_buffer->file_header.e_magic == 0x5a4d);
+  assert (exe_header_buffer->file_header.nt_signature == 0x4550);
+  assert (exe_header_buffer->file_header.f_magic == 0x014c);
+  assert (exe_header_buffer->file_header.f_nscns > 0);
+  assert (exe_header_buffer->file_header.f_nscns <=
+	  sizeof (exe_header_buffer->section_header) /
+	  sizeof (exe_header_buffer->section_header[0]));
+  assert (exe_header_buffer->file_header.f_opthdr > 0);
+
+  ret =
+    read (fd, &exe_header_buffer->file_optional_header,
+	  sizeof (exe_header_buffer->file_optional_header));
+  assert (ret == sizeof (exe_header_buffer->file_optional_header));
+
+  assert (exe_header_buffer->file_optional_header.magic == 0x010b);
+
+  for (i = 0; i < exe_header_buffer->file_header.f_nscns; ++i)
+    {
+      ret =
+	read (fd, &exe_header_buffer->section_header[i],
+	      sizeof (exe_header_buffer->section_header[i]));
+      assert (ret == sizeof (exe_header_buffer->section_header[i]));
+    }
+
+  return (exe_header_buffer);
+}
+
+/*
+** Fix the dumped emacs executable:
+**
+** - copy .data section data of interest from running executable into
+**   output .exe file
+**
+** - convert .bss section into an initialized data section (like
+**   .data) and copy .bss section data of interest from running
+**   executable into output .exe file
+*/
+static void
+fixup_executable (int fd)
+{
+  exe_header_t exe_header_buffer;
+  exe_header_t *exe_header;
+  int i;
+  int ret;
+  int found_data = 0;
+  int found_bss = 0;
+
+  exe_header = read_exe_header (fd, &exe_header_buffer);
+  assert (exe_header != 0);
+
+  assert (exe_header->file_header.f_nscns > 0);
+  for (i = 0; i < exe_header->file_header.f_nscns; ++i)
+    {
+      unsigned long start_address =
+	exe_header->section_header[i].s_vaddr +
+	exe_header->file_optional_header.ImageBase;
+      unsigned long end_address =
+	exe_header->section_header[i].s_vaddr +
+	exe_header->file_optional_header.ImageBase +
+	exe_header->section_header[i].s_paddr;
+      if (debug_unexcw)
+	printf ("%8s start 0x%08x end 0x%08x\n",
+		exe_header->section_header[i].s_name,
+		start_address, end_address);
+      if (my_edata >= (char *) start_address
+	  && my_edata < (char *) end_address)
+	{
+	  /* data section */
+	  ret =
+	    lseek (fd, (long) (exe_header->section_header[i].s_scnptr),
+		   SEEK_SET);
+	  assert (ret != -1);
+	  ret =
+	    write (fd, (char *) start_address,
+		   my_edata - (char *) start_address);
+	  assert (ret == my_edata - (char *) start_address);
+	  ++found_data;
+	  if (debug_unexcw)
+	    printf ("         .data, mem start 0x%08x mem length %d\n",
+		    start_address, my_edata - (char *) start_address);
+	  if (debug_unexcw)
+	    printf ("         .data, file start %d file length %d\n",
+		    (int) exe_header->section_header[i].s_scnptr,
+		    (int) exe_header->section_header[i].s_paddr);
+	}
+      else if (my_endbss >= (char *) start_address
+	       && my_endbss < (char *) end_address)
+	{
+	  /* bss section */
+	  ++found_bss;
+	  if (exe_header->section_header[i].s_flags & 0x00000080)
+	    {
+	      /* convert uninitialized data section to initialized data section */
+	      struct stat statbuf;
+	      ret = fstat (fd, &statbuf);
+	      assert (ret != -1);
+
+	      exe_header->section_header[i].s_flags &= ~0x00000080;
+	      exe_header->section_header[i].s_flags |= 0x00000040;
+
+	      exe_header->section_header[i].s_scnptr =
+		(statbuf.st_size +
+		 exe_header->file_optional_header.FileAlignment) /
+		exe_header->file_optional_header.FileAlignment *
+		exe_header->file_optional_header.FileAlignment;
+
+	      exe_header->section_header[i].s_size =
+		(exe_header->section_header[i].s_paddr +
+		 exe_header->file_optional_header.FileAlignment) /
+		exe_header->file_optional_header.FileAlignment *
+		exe_header->file_optional_header.FileAlignment;
+
+	      ret =
+		lseek (fd,
+		       (long) (exe_header->section_header[i].s_scnptr +
+			       exe_header->section_header[i].s_size - 1),
+		       SEEK_SET);
+	      assert (ret != -1);
+	      ret = write (fd, "", 1);
+	      assert (ret == 1);
+
+	      ret =
+		lseek (fd,
+		       (long) ((char *) &exe_header->section_header[i] -
+			       (char *) exe_header), SEEK_SET);
+	      assert (ret != -1);
+	      ret =
+		write (fd, &exe_header->section_header[i],
+		       sizeof (exe_header->section_header[i]));
+	      assert (ret == sizeof (exe_header->section_header[i]));
+	      if (debug_unexcw)
+		printf ("         seek to %ld, write %d\n",
+			(long) ((char *) &exe_header->section_header[i] -
+				(char *) exe_header),
+			sizeof (exe_header->section_header[i]));
+	    }
+	  /* write initialized data section */
+	  ret =
+	    lseek (fd, (long) (exe_header->section_header[i].s_scnptr),
+		   SEEK_SET);
+	  assert (ret != -1);
+	  ret =
+	    write (fd, (char *) start_address,
+		   my_endbss - (char *) start_address);
+	  assert (ret == (my_endbss - (char *) start_address));
+	  if (debug_unexcw)
+	    printf ("         .bss, mem start 0x%08x mem length %d\n",
+		    start_address, my_endbss - (char *) start_address);
+	  if (debug_unexcw)
+	    printf ("         .bss, file start %d file length %d\n",
+		    (int) exe_header->section_header[i].s_scnptr,
+		    (int) exe_header->section_header[i].s_paddr);
+	}
+    }
+  assert (found_bss == 1);
+  assert (found_data == 1);
+}
+
+/*
+** Windows likes .exe suffixes on executables.
+*/
+static char *
+add_exe_suffix_if_necessary (const char *name, char *modified)
+{
+  int i = strlen (name);
+  if (i <= (sizeof (DOTEXE) - 1))
+    {
+      sprintf (modified, "%s%s", name, DOTEXE);
+    }
+  else if (!strcasecmp (name + i - (sizeof (DOTEXE) - 1), DOTEXE))
+    {
+      strcpy (modified, name);
+    }
+  else
+    {
+      sprintf (modified, "%s%s", name, DOTEXE);
+    }
+  return (modified);
+}
+
+int
+unexec (char *outfile, char *infile, unsigned start_data, unsigned d1,
+	unsigned d2)
+{
+  char infile_buffer[FILENAME_MAX];
+  char outfile_buffer[FILENAME_MAX];
+  int fd_in;
+  int fd_out;
+  int ret;
+  int ret2;
+
+  if (bss_sbrk_did_unexec)
+    {
+      /* can only dump once */
+      printf ("You can only dump emacs once on this platform.\n");
+      return (1);
+    }
+
+  report_sheap_usage (1);
+
+  infile = add_exe_suffix_if_necessary (infile, infile_buffer);
+  outfile = add_exe_suffix_if_necessary (outfile, outfile_buffer);
+
+  fd_in = open (infile, O_RDONLY | O_BINARY);
+  assert (fd_in >= 0);
+  fd_out = open (outfile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, 0755);
+  assert (fd_out >= 0);
+  for (;;)
+    {
+      char buffer[4096];
+      ret = read (fd_in, buffer, sizeof (buffer));
+      if (ret == 0)
+	{
+	  /* eof */
+	  break;
+	}
+      assert (ret > 0);
+      /* data */
+      ret2 = write (fd_out, buffer, ret);
+      assert (ret2 == ret);
+    }
+  ret = close (fd_in);
+  assert (ret == 0);
+
+  bss_sbrk_did_unexec = 1;
+  fixup_executable (fd_out);
+  bss_sbrk_did_unexec = 0;
+
+  ret = close (fd_out);
+  assert (ret == 0);
+
+  return (0);
+}
+
+/* arch-tag: fc44f6c3-ca0a-45e0-a5a2-58b6101b1e65
+   (do not change this comment) */
--- a/src/window.c	Tue Apr 13 18:18:05 2004 +0000
+++ b/src/window.c	Thu Apr 15 16:49:22 2004 +0000
@@ -2080,6 +2080,7 @@
 
 DEFUN ("get-lru-window", Fget_lru_window, Sget_lru_window, 0, 1, 0,
        doc: /* Return the window least recently selected or used for display.
+Return a full-width window if possible.
 If optional argument FRAME is `visible', search all visible frames.
 If FRAME is 0, search all visible and iconified frames.
 If FRAME is t, search all frames.
--- a/src/xdisp.c	Tue Apr 13 18:18:05 2004 +0000
+++ b/src/xdisp.c	Thu Apr 15 16:49:22 2004 +0000
@@ -846,7 +846,7 @@
 							  Lisp_Object));
 static void extend_face_to_end_of_line P_ ((struct it *));
 static int append_space P_ ((struct it *, int));
-static int make_cursor_line_fully_visible P_ ((struct window *));
+static int make_cursor_line_fully_visible P_ ((struct window *, int));
 static int try_scrolling P_ ((Lisp_Object, int, EMACS_INT, EMACS_INT, int, int));
 static int try_cursor_movement P_ ((Lisp_Object, struct text_pos, int *));
 static int trailing_whitespace_p P_ ((int));
@@ -1789,8 +1789,9 @@
       height = max (FRAME_LINE_HEIGHT (s->f), glyph->ascent + glyph->descent);
       if (height < r.height)
 	{
-	  r.y = s->ybase + glyph->descent - height;
-	  r.height = height;
+	  int max_y = r.y + r.height;
+	  r.y = min (max_y, s->ybase + glyph->descent - height);
+	  r.height = min (max_y - r.y, height);
 	}
     }
 
@@ -10729,12 +10730,17 @@
    A value of 1 means there is nothing to be done.
    (Either the line is fully visible, or it cannot be made so,
    or we cannot tell.)
+
+   If FORCE_P is non-zero, return 0 even if partial visible cursor row
+   is higher than window.
+
    A value of 0 means the caller should do scrolling
    as if point had gone off the screen.  */
 
 static int
-make_cursor_line_fully_visible (w)
-     struct window *w;
+make_cursor_line_fully_visible (w, force_p)
+     struct window *w;
+     int force_p;
 {
   struct glyph_matrix *matrix;
   struct glyph_row *row;
@@ -10752,6 +10758,9 @@
   if (!MATRIX_ROW_PARTIALLY_VISIBLE_P (row))
     return 1;
 
+  if (force_p)
+    return 0;
+
   /* If the row the cursor is in is taller than the window's height,
      it's not clear what to do, so do nothing.  */
   window_height = window_box_height (w);
@@ -10848,7 +10857,7 @@
   int amount_to_scroll = 0;
   Lisp_Object aggressive;
   int height;
-  int end_scroll_margin;
+  int extra_scroll_margin_lines = last_line_misfit ? 1 : 0;
 
 #if GLYPH_DEBUG
   debug_method_add (w, "try_scrolling");
@@ -10891,11 +10900,13 @@
   CHARPOS (scroll_margin_pos) = XINT (window_end);
   BYTEPOS (scroll_margin_pos) = CHAR_TO_BYTE (CHARPOS (scroll_margin_pos));
 
-  end_scroll_margin = this_scroll_margin + !!last_line_misfit;
-  if (end_scroll_margin)
+  if (this_scroll_margin || extra_scroll_margin_lines)
     {
       start_display (&it, w, scroll_margin_pos);
-      move_it_vertically (&it, - end_scroll_margin);
+      if (this_scroll_margin)
+	move_it_vertically (&it, - this_scroll_margin);
+      if (extra_scroll_margin_lines)
+	move_it_by_lines (&it, - extra_scroll_margin_lines, 0);
       scroll_margin_pos = it.current.pos;
     }
 
@@ -11030,10 +11041,10 @@
 
       /* If cursor ends up on a partially visible line,
 	 treat that as being off the bottom of the screen.  */
-      if (! make_cursor_line_fully_visible (w))
+      if (! make_cursor_line_fully_visible (w, extra_scroll_margin_lines <= 1))
 	{
 	  clear_glyph_matrix (w->desired_matrix);
-	  last_line_misfit = 1;
+	  ++extra_scroll_margin_lines;
 	  goto too_near_end;
 	}
       rc = SCROLLING_SUCCESS;
@@ -11322,7 +11333,7 @@
 	      else
 		{
 		  set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0);
-		  if (!make_cursor_line_fully_visible (w))
+		  if (!make_cursor_line_fully_visible (w, 0))
 		    rc = CURSOR_MOVEMENT_MUST_SCROLL;
 		  else
 		    rc = CURSOR_MOVEMENT_SUCCESS;
@@ -11655,7 +11666,7 @@
 	  new_vpos = window_box_height (w) / 2;
 	}
 
-      if (!make_cursor_line_fully_visible (w))
+      if (!make_cursor_line_fully_visible (w, 0))
 	{
 	  /* Point does appear, but on a line partly visible at end of window.
 	     Move it back to a fully-visible line.  */
@@ -11792,7 +11803,7 @@
 	    /* Forget any recorded base line for line number display.  */
 	    w->base_line_number = Qnil;
 
-	  if (!make_cursor_line_fully_visible (w))
+	  if (!make_cursor_line_fully_visible (w, 1))
 	    {
 	      clear_glyph_matrix (w->desired_matrix);
 	      last_line_misfit = 1;
@@ -11952,7 +11963,7 @@
       set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0);
     }
 
-  if (!make_cursor_line_fully_visible (w))
+  if (!make_cursor_line_fully_visible (w, centering_position > 0))
     {
       /* If vscroll is enabled, disable it and try again.  */
       if (w->vscroll)
@@ -11965,6 +11976,7 @@
       /* If centering point failed to make the whole line visible,
 	 put point at the top instead.  That has to make the whole line
 	 visible, if it can be done.  */
+      clear_glyph_matrix (w->desired_matrix);
       centering_position = 0;
       goto point_at_top;
     }