changeset 83143:9fb10038ca55

Merged in changes from CVS trunk. Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-353 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-354 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-355 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-356 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-183
author Karoly Lorentey <lorentey@elte.hu>
date Mon, 31 May 2004 13:48:26 +0000
parents 62cf3d6337a0 (current diff) 96b6267053d1 (diff)
children 2e868590c17b
files lisp/ChangeLog lisp/font-lock.el lisp/subr.el man/ChangeLog src/alloc.c src/lisp.h src/macterm.c src/xdisp.c
diffstat 48 files changed, 2681 insertions(+), 1259 deletions(-) [+]
line wrap: on
line diff
--- a/etc/ChangeLog	Sun May 30 21:11:48 2004 +0000
+++ b/etc/ChangeLog	Mon May 31 13:48:26 2004 +0000
@@ -1,3 +1,8 @@
+2004-05-29  Steven Tamm  <steventamm@mac.com>
+
+	* PROBLEMS: Document the workaround for the Mac OS X port not
+	picking up the environment variables from dotfiles.
+
 2004-05-16  Juri Linkov  <juri@jurta.org>
 
 	* TUTORIAL.pt_BR: Add coding: latin-1, sentence-end-double-space: nil.
--- a/etc/NEWS	Sun May 30 21:11:48 2004 +0000
+++ b/etc/NEWS	Mon May 31 13:48:26 2004 +0000
@@ -2042,6 +2042,10 @@
 
 * Lisp Changes in Emacs 21.4
 
+** If the buffer's undo list for the current command gets longer than
+undo-outer-limit, garbage collection empties it.  This is to prevent
+it from using up the available memory and choking Emacs.
+
 ** New function quail-find-key returns a list of keys to type in the
 current input method to input a character.
 
--- a/etc/PROBLEMS	Sun May 30 21:11:48 2004 +0000
+++ b/etc/PROBLEMS	Mon May 31 13:48:26 2004 +0000
@@ -1,6 +1,18 @@
 This file describes various problems that have been encountered
 in compiling, installing and running GNU Emacs.
 
+* Environment Variables from dotfiles are ignored with Mac OS X (Carbon).
+
+When starting Emacs from the Dock or the Finder on Mac OS X, the
+environment variables that are set up in dotfiles, such as .cshrc or
+.profile, are ignored.  This is because the Finder and Dock are not
+started from a shell, but instead from the Window Manager itself.
+
+The workaround for this is to create a .MacOSX/environment.plist file to
+setup these environment variables.  These environment variables will
+apply to all processes regardless of where they are started.
+For me information, see http://developer.apple.com/qa/qa2001/qa1067.html.
+
 * Segfault on GNU/Linux using certain recent versions of the Linux kernel.
 
 With certain recent Linux kernels (like the one of Redhat Fedora Core
--- a/lisp/ChangeLog	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/ChangeLog	Mon May 31 13:48:26 2004 +0000
@@ -1,3 +1,158 @@
+2004-05-30  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* replace.el (query-replace-interactive): Convert defvar into
+	defcustom.
+
+	* autorevert.el: Update `Commentary' section.
+
+2004-05-30  Juanma Barranquero  <lektu@terra.es>
+
+	* dos-fns.el (convert-standard-filename):
+	* files.el (convert-standard-filename):
+	* w32-fns.el (convert-standard-filename):
+	Rework docstring (wording by Eli Zaretskii and Kai Grossjohann).
+
+2004-05-30  Kai Grossjohann  <kai.grossjohann@gmx.net>
+
+	Sync with Tramp.
+
+	* net/tramp.el (tramp-let-maybe): Reverse args of `get'.
+	(tramp-let-maybe): Move to an earlier spot in the file.  Patch by
+	Andreas Schwab.
+
+2004-05-30  Andreas Schwab  <schwab@suse.de>
+
+	* dired.el (dired-get-filename): Don't use dired-re-dot.
+
+2004-05-30  Richard M. Stallman  <rms@gnu.org>
+
+	* files.el (find-file): Doc fix.
+
+	* font-lock.el (lisp-font-lock-keywords-2): Add multiple-value-bind.
+
+2004-05-30  Nick Roberts  <nickrob@gnu.org>
+
+	* progmodes/gdb-ui.el (gdb-current-frame, gud-watch)
+	(gdb-locals-mode, gdb-frame-handler): Display current frame in the
+	modeline of the locals buffer.
+	(gdb-goto-breakpoint): Handle gdbmi.
+	(gdb-get-frame-number): Change for gdbmi.
+
+2004-05-30  Michael Albinus  <michael.albinus@gmx.de>
+
+	* files.el (file-remote-p): Apply file name handler for operation
+	`file-remote-p'.  It isn' a property any longer.
+	(file-relative-name): `fh' and `fd' get the required value via
+	`find-file-name-handler' already.
+
+	* ange-ftp.el (ange-ftp-file-remote-p): New defun.
+	(top): Remove setting of `file-remote-p' property for
+	`ange-ftp-hook-function'.  Add `ange-ftp' property to
+	`file-remote-p'.
+
+2004-05-29  Michael Albinus  <michael.albinus@gmx.de>
+
+	Version 2.0.41 of Tramp released.
+
+	* tramp.el (tramp-wait-for-regexp, tramp-wait-for-output): Throw
+	away if process has died.  Reported by Luc Teirlinck
+	<teirllm@dms.auburn.edu>.
+	(tramp-out-of-band-prompt-regexp): Renamed to
+	`tramp-process-alive-regexp', because its usage is widen.
+	(tramp-actions-copy-out-of-band): Apply it.
+	(tramp-actions-before-shell, tramp-multi-actions): Add
+	`tramp-action-process-alive' action.
+	(tramp-action-process-alive): New defun.
+	(tramp-file-name-handler-alist, tramp-file-name-for-operation):
+	Add entry for `file-remote-p'.
+	(tramp-handle-file-remote-p): New defun.
+	(top): Remove setting of `file-remote-p'.  Don't set
+	`inhibit-file-name-handlers' and `inhibit-file-name-operation'.
+
+	* tramp-smb.el (tramp-smb-file-name-handler-alist): Add entry for
+	`file-remote-p'.
+
+	* tramp-uu.el (tramp-uuencode-region): Padding characters aren't
+	counted for (last) line.  Reported by Aaron Ucko
+	<ucko@ncbi.nlm.nih.gov>.
+
+2004-05-29  Kai Grossjohann  <kai.grossjohann@gmx.net>
+
+	* tramp.el (tramp-initial-commands): Add "unset HISTFILE"; this is
+	not really necessary but seems to keep the shell history smaller
+	in some cases.  It is no substitute for setting HISTFILE and
+	HISTSIZE from tramp-open-connection-setup-interactive-shell,
+	though.  Suggested by Luc Teirlinck.
+	(tramp-open-connection-setup-interactive-shell): Export variables
+	HISTFILE and HISTSIZE, do not just set them.  From Luc Teirlinck.
+	(tramp-set-process-query-on-exit-flag): New compat function.
+	(tramp-open-connection-multi, tramp-open-connection-su)
+	(tramp-open-connection-rsh, tramp-open-connection-telnet)
+	(tramp-do-copy-or-rename-file-out-of-band): Use it.
+	(tramp-let-maybe): New macro, let-binds a variable only if it
+	isn't obsolete.
+	(tramp-check-ls-commands, tramp-handle-expand-file-name)
+	(tramp-handle-file-truename): Use it.
+	(tramp-completion-file-name-regexp-unified): Avoid matching
+	filenames starting with "/:" -- those are reserved for
+	file-name-non-special.
+
+	* tramp-smb.el (tramp-smb-open-connection): Use
+	tramp-set-process-query-on-exit-flag compat function.
+
+2004-05-29  Richard M. Stallman  <rms@gnu.org>
+
+	* net/browse-url.el (browse-url-interactive-arg): Doc fix.
+
+	* emacs-lisp/lisp-mode.el (prin1-char): Catch errors from `string'.
+	(eval-last-sexp-print-value): Print char equivalent regardless
+	of standard-output value.
+
+	* thumbs.el (thumbs-subst-char-in-string): Deleted.
+	(thumbs-thumbname): Use subst-char-in-string.
+	(thumbs-resize-image): Use condition-case, not ignore-errors.
+	(thumbs-kill-buffer): Likewise.
+
+	* thumbs.el: Don't include cl.  Don't bother with old Emacs versions.
+	(thumbs-mode): Make buffer read-only.
+	(thumbs-make-thumb): Unconditionally accept an existing file.
+	(thumbs-insert-thumb): Add thumb-image-file property to the image.
+	(thumbs-do-thumbs-insertion): Be smarter about where to put newlines.
+	(thumbs-show-thumbs-list): Error if images not supported.
+	(thumbs-save-current-image): Improve prompt string.
+	(thumbs-mode-map): Define u, R, x.
+	(thumbs-unmark): New command.
+	(thumbs-emboss-image): Minor cleanup.
+	(thumbs-forward-char, thumbs-backward-char): Skip chars with no image.
+	(thumbs-rename-images): New command.
+	(thumbs-show-image-num): Rewrite.  Don't rename the buffer.
+
+	* thumbs.el (thumbs-current-image): New function.
+	(thumbs-file-list, thumbs-file-alist): New functions.
+	(thumbs-find-image): Delete arg L.
+	Don't set up thumbs-fileL as buffer-local global var.
+	(thumbs-find-image-at-point): Use thumbs-current-image.
+	(thumbs-set-image-at-point-to-root-window): Likewise.
+	(thumbs-delete-images): Use thumbs-current-image, thumbs-file-alist.
+	Record and warn about errors.  Update thumbs-markedL for deletions.
+	(thumbs-next-image, thumbs-previous-image): Use thumbs-file-alist.
+	(thumbs-redraw-buffer): Use thumbs-file-list.
+	(thumbs-mark): Use thumbs-current-image.
+	(thumbs-show-name): Use thumbs-current-image.
+
+	* imenu.el (imenu--menubar-select): Set imenu-menubar-modified-tick
+	and imenu--last-menubar-index-alist.
+
+	* subr.el (with-selected-window): Undo previous change.
+
+2004-05-29  John Paul Wallington  <jpw@gnu.org>
+
+	* thumbs.el (thumbs-show-name): Do nothing if no image at point.
+	(thumbs-mouse-find-image): New command.
+	(thumbs-mode-map): Bind it to mouse-2.
+	(thumbs-mode):  Make mode-class special.
+	(thumbs-view-image-mode): Likewise.
+
 2004-05-29  Pavel Kobiakov  <pk_at_work@yahoo.com>
 
 	* flymake.el: New file.
--- a/lisp/autorevert.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/autorevert.el	Mon May 31 13:48:26 2004 +0000
@@ -36,8 +36,12 @@
 ;; Auto-Revert Mode.  Both modes automatically revert buffers
 ;; whenever the corresponding files have been changed on disk.
 ;;
-;; Auto-Revert Mode can be activated for individual buffers.
-;; Global Auto-Revert Mode applies to all file buffers.
+;; Auto-Revert Mode can be activated for individual buffers.  Global
+;; Auto-Revert Mode applies to all file buffers. (If the user option
+;; `global-auto-revert-non-file-buffers' is non-nil, it also applies
+;; to some non-file buffers.  This option is disabled by default.)
+;; Since checking a remote file is too slow, these modes do not check
+;; or revert remote files.
 ;;
 ;; Both modes operate by checking the time stamp of all files at
 ;; intervals of `auto-revert-interval'.  The default is every five
--- a/lisp/dired.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/dired.el	Mon May 31 13:48:26 2004 +0000
@@ -1634,9 +1634,7 @@
      ((eq localp 'verbatim)
       file)
      ((and (not no-error-if-not-filep)
-	   (save-excursion
-	     (beginning-of-line)
-	     (looking-at dired-re-dot)))
+	   (member file '("." "..")))
       (error "Cannot operate on `.' or `..'"))
      ((and (eq localp 'no-dir) already-absolute)
       (file-name-nondirectory file))
--- a/lisp/dos-fns.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/dos-fns.el	Mon May 31 13:48:26 2004 +0000
@@ -31,9 +31,13 @@
 ;; This overrides a trivial definition in files.el.
 (defun convert-standard-filename (filename)
   "Convert a standard file's name to something suitable for the current OS.
-This function's standard definition is trivial; it just returns the argument.
-However, on some systems, the function is redefined
-with a definition that really does change some file names."
+This means to guarantee valid names and perhaps to canonicalize
+certain patterns.
+
+On Windows and DOS, replace invalid characters.  On DOS, make
+sure to obey the 8.3 limitations.  On Windows, turn Cygwin names
+into native names, and also turn slashes into backslashes if the
+shell requires it (see `w32-shell-dos-semantics')."
   (if (or (not (stringp filename))
 	  ;; This catches the case where FILENAME is "x:" or "x:/" or
 	  ;; "/", thus preventing infinite recursion.
--- a/lisp/emacs-lisp/lisp-mode.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/emacs-lisp/lisp-mode.el	Mon May 31 13:48:26 2004 +0000
@@ -470,7 +470,10 @@
 	  (cond
 	   ((memq c '(?\; ?\( ?\) ?\{ ?\} ?\[ ?\] ?\" ?\' ?\\)) (string ?\\ c))
 	   ((eq c 127) "\\C-?")
-	   (t (string c)))))))
+	   (t
+	    (condition-case nil
+		(string c)
+	      (error nil))))))))
 
 (defun eval-last-sexp-1 (eval-last-sexp-arg-internal)
   "Evaluate sexp before point; print value in minibuffer.
@@ -538,9 +541,8 @@
 	end)
     (prog1
 	(prin1 value)
-      (if (eq standard-output t)
-          (let ((str (eval-expression-print-format value)))
-            (if str (princ str))))
+      (let ((str (eval-expression-print-format value)))
+	(if str (princ str)))
       (setq end (point))
       (when (and (bufferp standard-output)
 		 (or (not (null print-length))
--- a/lisp/files.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/files.el	Mon May 31 13:48:26 2004 +0000
@@ -481,10 +481,15 @@
 
 (defun convert-standard-filename (filename)
   "Convert a standard file's name to something suitable for the current OS.
-This function's standard definition is trivial; it just returns the argument.
-However, on some systems, the function is redefined with a definition
-that really does change some file names to canonicalize certain
-patterns and to guarantee valid names."
+This means to guarantee valid names and perhaps to canonicalize
+certain patterns.
+
+This function's standard definition is trivial; it just returns
+the argument.  However, on Windows and DOS, replace invalid
+characters.  On DOS, make sure to obey the 8.3 limitations.  On
+Windows, turn Cygwin names into native names, and also turn
+slashes into backslashes if the shell requires it (see
+`w32-shell-dos-semantics')."
   filename)
 
 (defun read-directory-name (prompt &optional dir default-dirname mustmatch initial)
@@ -642,9 +647,10 @@
 
 (defun file-remote-p (file)
   "Test whether FILE specifies a location on a remote system."
-  (let ((handler (find-file-name-handler file 'file-local-copy)))
+  (let ((handler (find-file-name-handler file 'file-remote-p)))
     (if handler
-	(get handler 'file-remote-p))))
+	(funcall handler 'file-remote-p file)
+      nil)))
 
 (defun file-local-copy (file)
   "Copy the file FILE into a temporary file on this machine.
@@ -905,8 +911,11 @@
 type M-n to pull it into the minibuffer.
 
 Interactively, or if WILDCARDS is non-nil in a call from Lisp,
-expand wildcards (if any) and visit multiple files.  Wildcard expansion
-can be suppressed by setting `find-file-wildcards'."
+expand wildcards (if any) and visit multiple files.  You can
+suppress wildcard expansion by setting `find-file-wildcards'.
+
+To visit a file without any kind of conversion and without
+automatically choosing a major mode, use \\[find-file-literally]."
   (interactive
    (find-file-read-args "Find file: " nil))
   (let ((value (find-file-noselect filename nil nil wildcards)))
@@ -2903,10 +2912,8 @@
 	  (file-name-as-directory (expand-file-name (or directory
 							default-directory))))
     (setq filename (expand-file-name filename))
-    (let ((hf (find-file-name-handler filename 'file-local-copy))
-          (hd (find-file-name-handler directory 'file-local-copy)))
-      (when (and hf (not (get hf 'file-remote-p))) (setq hf nil))
-      (when (and hd (not (get hd 'file-remote-p))) (setq hd nil))
+    (let ((hf (find-file-name-handler filename 'file-remote-p))
+          (hd (find-file-name-handler directory 'file-remote-p)))
       (if ;; Conditions for separate trees
 	  (or
 	   ;; Test for different drives on DOS/Windows
--- a/lisp/font-lock.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/font-lock.el	Mon May 31 13:48:26 2004 +0000
@@ -1910,6 +1910,7 @@
 		    "proclaim" "declaim" "declare" "symbol-macrolet"
 		    "lexical-let" "lexical-let*" "flet" "labels" "compiler-let"
 		    "destructuring-bind" "macrolet" "tagbody" "block"
+		    "multiple-value-bind"
 		    "return" "return-from"
 		    "with-accessors" "with-compilation-unit"
 		    "with-condition-restarts" "with-hash-table-iterator"
--- a/lisp/imenu.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/imenu.el	Mon May 31 13:48:26 2004 +0000
@@ -890,6 +890,7 @@
       (setq name (completing-read prompt
 				  prepared-index-alist
 				  nil t nil 'imenu--history-list name)))
+
     (cond ((not (stringp name)) nil)
 	  ((string= name (car imenu--rescan-item)) t)
 	  (t
@@ -1015,7 +1016,10 @@
   (if (equal item imenu--rescan-item)
       (progn
 	(imenu--cleanup)
+	;; Make sure imenu-update-menubar redoes everything.
+	(setq imenu-menubar-modified-tick -1)
 	(setq imenu--index-alist nil)
+	(setq imenu--last-menubar-index-alist nil)
 	(imenu-update-menubar)
 	t)
     (imenu item)
--- a/lisp/net/ange-ftp.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/net/ange-ftp.el	Mon May 31 13:48:26 2004 +0000
@@ -4116,6 +4116,9 @@
 				       (format "Getting %s" fn1))
 	  tmp1))))
 
+(defun ange-ftp-file-remote-p (file)
+  (when (ange-ftp-ftp-name file) t))
+
 (defun ange-ftp-load (file &optional noerror nomessage nosuffix)
   (if (ange-ftp-ftp-name file)
       (let ((tryfiles (if nosuffix
@@ -4257,9 +4260,6 @@
   (let ((fn (get operation 'ange-ftp)))
     (if fn (save-match-data (apply fn args))
       (ange-ftp-run-real-handler operation args))))
-;;;###autoload
-;;; These file names are remote file names.
-(put 'ange-ftp-hook-function 'file-remote-p t)
 
 ;; The following code is commented out because Tramp now deals with
 ;; Ange-FTP filenames, too.
@@ -4327,6 +4327,7 @@
 (put 'file-name-completion 'ange-ftp 'ange-ftp-file-name-completion)
 (put 'insert-directory 'ange-ftp 'ange-ftp-insert-directory)
 (put 'file-local-copy 'ange-ftp 'ange-ftp-file-local-copy)
+(put 'file-remote-p 'ange-ftp 'ange-ftp-file-remote-p)
 (put 'unhandled-file-name-directory 'ange-ftp
      'ange-ftp-unhandled-file-name-directory)
 (put 'file-name-sans-versions 'ange-ftp 'ange-ftp-file-name-sans-versions)
--- a/lisp/net/browse-url.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/net/browse-url.el	Mon May 31 13:48:26 2004 +0000
@@ -578,11 +578,12 @@
 (defun browse-url-interactive-arg (prompt)
   "Read a URL from the minibuffer, prompting with PROMPT.
 If `transient-mark-mode' is non-nil and the mark is active,
-defaults to the current region, else to the URL at or before
-point.  If invoked with a mouse button, set point to the
-position clicked first.  Return a list for use in `interactive'
-containing the URL and `browse-url-new-window-flag' or its
-negation if a prefix argument was given."
+it defaults to the current region, else to the URL at or before
+point.  If invoked with a mouse button, it moves point to the
+position clicked before acting.
+
+This function returns a list (URL NEW-WINDOW-FLAG)
+for use in `interactive'."
   (let ((event (elt (this-command-keys) 0)))
     (and (listp event) (mouse-set-point event)))
   (list (read-string prompt (or (and transient-mark-mode mark-active
--- a/lisp/net/tramp-smb.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/net/tramp-smb.el	Mon May 31 13:48:26 2004 +0000
@@ -144,6 +144,7 @@
     (file-executable-p . tramp-smb-handle-file-exists-p)
     (file-exists-p . tramp-smb-handle-file-exists-p)
     (file-local-copy . tramp-smb-handle-file-local-copy)
+    (file-remote-p . tramp-handle-file-remote-p)
     (file-modes . tramp-handle-file-modes)
     (file-name-all-completions . tramp-smb-handle-file-name-all-completions)
     ;; `file-name-as-directory' performed by default handler
@@ -1003,7 +1004,7 @@
 		       tramp-smb-program args)))
 
 	(tramp-message 9 "Started process %s" (process-command p))
-	(process-kill-without-query p)
+	(tramp-set-process-query-on-exit-flag p nil)
 	(set-buffer buffer)
 	(setq tramp-smb-share share)
 
--- a/lisp/net/tramp-uu.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/net/tramp-uu.el	Mon May 31 13:48:26 2004 +0000
@@ -1,7 +1,7 @@
 ;;; -*- coding: iso-2022-7bit; -*-
 ;;; tramp-uu.el --- uuencode in Lisp
 
-;; Copyright (C) 2002  Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2004  Free Software Foundation, Inc.
 
 ;; Author: Kai Gro,A_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
 ;; Keywords: comm, terminals
@@ -63,10 +63,10 @@
 	(setq c (char-after (point)))
 	(delete-char 1)
 	(if (equal c ?=)
-	    ;; "=" means padding.  Insert "`" instead.
-	    (insert "`")
-	  (insert (tramp-uu-byte-to-uu-char (tramp-uu-b64-char-to-byte c))))
-	(setq i (1+ i))
+	    ;; "=" means padding.  Insert "`" instead.  Not counted for length.
+	    (progn (insert "`") (setq len (1- len)))
+	  (insert (tramp-uu-byte-to-uu-char (tramp-uu-b64-char-to-byte c)))
+	  (setq i (1+ i)))
 	;; Every 60 characters, add "M" at beginning of line (as
 	;; length byte) and insert a newline.
 	(when (zerop (% i 60))
--- a/lisp/net/tramp.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/net/tramp.el	Mon May 31 13:48:26 2004 +0000
@@ -911,12 +911,13 @@
   :group 'tramp
   :type 'regexp)
 
-(defcustom tramp-out-of-band-prompt-regexp
+(defcustom tramp-process-alive-regexp
   ""
-  "Regular expression indicating an out-of-band copy has finished.
+  "Regular expression indicating a process has finished.
 In fact this expression is empty by intention, it will be used only to
 check regularly the status of the associated process.
-The answer will be provided by `tramp-action-out-of-band', which see."
+The answer will be provided by `tramp-action-process-alive' and
+`tramp-action-out-of-band', which see."
   :group 'tramp
   :type 'regexp)
 
@@ -1146,7 +1147,7 @@
 
 ;;;###autoload
 (defconst tramp-completion-file-name-regexp-unified
-  "^/[^/]*$"
+  "^/$\\|^/[^/:][^/]*$"
   "Value for `tramp-completion-file-name-regexp' for unified remoting.
 Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and
 Tramp.  See `tramp-file-name-structure-unified' for more explanations.")
@@ -1288,7 +1289,8 @@
     (tramp-wrong-passwd-regexp tramp-action-permission-denied)
     (tramp-yesno-prompt-regexp tramp-action-yesno)
     (tramp-yn-prompt-regexp tramp-action-yn)
-    (tramp-terminal-prompt-regexp tramp-action-terminal))
+    (tramp-terminal-prompt-regexp tramp-action-terminal)
+    (tramp-process-alive-regexp tramp-action-process-alive))
   "List of pattern/action pairs.
 Whenever a pattern matches, the corresponding action is performed.
 Each item looks like (PATTERN ACTION).
@@ -1306,7 +1308,7 @@
 (defcustom tramp-actions-copy-out-of-band
   '((tramp-password-prompt-regexp tramp-action-password)
     (tramp-wrong-passwd-regexp tramp-action-permission-denied)
-    (tramp-out-of-band-prompt-regexp tramp-action-out-of-band))
+    (tramp-process-alive-regexp tramp-action-out-of-band))
   "List of pattern/action pairs.
 This list is used for copying/renaming with out-of-band methods.
 See `tramp-actions-before-shell' for more info."
@@ -1318,7 +1320,8 @@
     (tramp-login-prompt-regexp tramp-multi-action-login)
     (shell-prompt-pattern tramp-multi-action-succeed)
     (tramp-shell-prompt-pattern tramp-multi-action-succeed)
-    (tramp-wrong-passwd-regexp tramp-multi-action-permission-denied))
+    (tramp-wrong-passwd-regexp tramp-multi-action-permission-denied)
+    (tramp-process-alive-regexp tramp-action-process-alive))
   "List of pattern/action pairs.
 This list is used for each hop in multi-hop connections.
 See `tramp-actions-before-shell' for more info."
@@ -1326,7 +1329,8 @@
   :type '(repeat (list variable function)))
 
 (defcustom tramp-initial-commands
-  '("unset correct"
+  '("unset HISTORY"
+    "unset correct"
     "unset autocorrect")
   "List of commands to send to the first remote shell that we see.
 These commands will be sent to any shell, and thus they should be
@@ -1768,6 +1772,7 @@
     (insert-directory . tramp-handle-insert-directory)
     (expand-file-name . tramp-handle-expand-file-name)
     (file-local-copy . tramp-handle-file-local-copy)
+    (file-remote-p . tramp-handle-file-remote-p)
     (insert-file-contents . tramp-handle-insert-file-contents)
     (write-region . tramp-handle-write-region)
     (find-backup-file-name . tramp-handle-find-backup-file-name)
@@ -1880,6 +1885,16 @@
 ;; To be activated for debugging containing this macro
 (def-edebug-spec with-parsed-tramp-file-name t)
 
+(defmacro tramp-let-maybe (variable value &rest body)
+  "Let-bind VARIABLE to VALUE in BODY, but only if VARIABLE is not obsolete.
+BODY is executed whether or not the variable is obsolete.
+The intent is to protect against `obsolete variable' warnings."
+  `(if (get ',variable 'byte-obsolete-variable)
+       (progn ,@body)
+     (let ((,variable ,value))
+       ,@body)))
+(put 'tramp-let-maybe 'lisp-indent-function 2)
+
 ;;; Config Manipulation Functions:
 
 (defun tramp-set-completion-function (method function-list)
@@ -2042,8 +2057,8 @@
   "Like `file-truename' for tramp files."
   (with-parsed-tramp-file-name filename nil
     (let* ((steps        (tramp-split-string localname "/"))
-	   (localnamedir (let ((directory-sep-char ?/))
-		      (file-name-as-directory localname)))
+	   (localnamedir (tramp-let-maybe directory-sep-char ?/	;for XEmacs
+			   (file-name-as-directory localname)))
 	   (is-dir (string= localname localnamedir))
 	   (thisstep nil)
 	   (numchase 0)
@@ -2984,7 +2999,7 @@
       ;; Use rcp-like program for file transfer.
       (let ((p (apply 'start-process (buffer-name trampbuf) trampbuf
 		      copy-program copy-args)))
-	(process-kill-without-query p)
+	(tramp-set-process-query-on-exit-flag p nil)
 	(tramp-process-actions p multi-method method user host
 			       tramp-actions-copy-out-of-band))
       (kill-buffer trampbuf)
@@ -3297,7 +3312,7 @@
 	;; expand-file-name (this does "/./" and "/../").  We bind
 	;; directory-sep-char here for XEmacs on Windows, which
 	;; would otherwise use backslash.
-	(let ((directory-sep-char ?/))
+	(tramp-let-maybe directory-sep-char ?/
 	  (tramp-make-tramp-file-name
 	   multi-method (or method (tramp-find-default-method user host))
 	   user host
@@ -3525,6 +3540,9 @@
 	    (t (error "Wrong method specification for `%s'" method)))
       tmpfil)))
 
+(defun tramp-handle-file-remote-p (filename)
+  "Like `file-remote-p' for tramp files."
+  (when (tramp-tramp-file-p filename) t))
 
 (defun tramp-handle-insert-file-contents
   (filename &optional visit beg end replace)
@@ -3845,10 +3863,10 @@
 
 ;; We handle here all file primitives.  Most of them have the file
 ;; name as first parameter; nevertheless we check for them explicitly
-;; in order to be be signalled if a new primitive appears.  This
+;; in order to be signalled if a new primitive appears.  This
 ;; scenario is needed because there isn't a way to decide by
 ;; syntactical means whether a foreign method must be called.  It would
-;; ease the live if `file-name-handler-alist' would support a decision
+;; ease the life if `file-name-handler-alist' would support a decision
 ;; function as well but regexp only.
 (defun tramp-file-name-for-operation (operation &rest args)
   "Return file name related to OPERATION file primitive.
@@ -3862,16 +3880,16 @@
 		  'dired-compress-file 'dired-uncache
 		  'file-accessible-directory-p 'file-attributes
 		  'file-directory-p 'file-executable-p 'file-exists-p
-		  'file-local-copy 'file-modes 'file-name-as-directory
-		  'file-name-directory 'file-name-nondirectory
-		  'file-name-sans-versions 'file-ownership-preserved-p
-		  'file-readable-p 'file-regular-p 'file-symlink-p
-		  'file-truename 'file-writable-p 'find-backup-file-name
-		  'find-file-noselect 'get-file-buffer 'insert-directory
-		  'insert-file-contents 'load 'make-directory
-		  'make-directory-internal 'set-file-modes
-		  'substitute-in-file-name 'unhandled-file-name-directory
-		  'vc-registered
+		  'file-local-copy 'file-remote-p 'file-modes
+		  'file-name-as-directory 'file-name-directory
+		  'file-name-nondirectory 'file-name-sans-versions
+		  'file-ownership-preserved-p 'file-readable-p
+		  'file-regular-p 'file-symlink-p 'file-truename
+		  'file-writable-p 'find-backup-file-name 'find-file-noselect
+		  'get-file-buffer 'insert-directory 'insert-file-contents
+		  'load 'make-directory 'make-directory-internal
+		  'set-file-modes 'substitute-in-file-name
+		  'unhandled-file-name-directory 'vc-registered
 		  ; XEmacs only
 		  'abbreviate-file-name 'create-file-buffer
 		  'dired-file-modtime 'dired-make-compressed-filename
@@ -3940,9 +3958,6 @@
        (foreign (apply foreign operation args))
        (t (tramp-run-real-handler operation args))))))
 
-;;;###autoload
-(put 'tramp-file-name-handler 'file-remote-p t)	;for file-remote-p
-
 (defun tramp-sh-file-name-handler (operation &rest args)
   "Invoke remote-shell Tramp file name handler.
 Fall back to normal file name handler if no Tramp handler exists."
@@ -4887,16 +4902,16 @@
   "Checks whether the given `ls' executable in one of the dirs groks `-n'.
 Returns nil if none was found, else the command is returned."
   (let ((dl dirlist)
-        (result nil)
-	(directory-sep-char ?/))	;for XEmacs
-    ;; It would be better to use the CL function `find', but
-    ;; we don't want run-time dependencies on CL.
-    (while (and dl (not result))
-      (let ((x (concat (file-name-as-directory (car dl)) cmd)))
-        (when (tramp-check-ls-command multi-method method user host x)
-          (setq result x)))
-      (setq dl (cdr dl)))
-    result))
+        (result nil))
+    (tramp-let-maybe directory-sep-char ?/ ;for XEmacs
+      ;; It would be better to use the CL function `find', but
+      ;; we don't want run-time dependencies on CL.
+      (while (and dl (not result))
+	(let ((x (concat (file-name-as-directory (car dl)) cmd)))
+	  (when (tramp-check-ls-command multi-method method user host x)
+	    (setq result x)))
+	(setq dl (cdr dl)))
+      result)))
 
 (defun tramp-find-ls-command (multi-method method user host)
   "Finds an `ls' command which groks the `-n' option, returning nil if failed.
@@ -4976,6 +4991,11 @@
   (process-send-string nil (concat tramp-terminal-type
 				   tramp-rsh-end-of-line)))
 
+(defun tramp-action-process-alive (p multi-method method user host)
+  "Check whether a process has finished."
+  (unless (memq (process-status p) '(run open))
+    (throw 'tramp-action 'process-died)))
+
 (defun tramp-action-out-of-band (p multi-method method user host)
   "Check whether an out-of-band copy has finished."
   (cond ((and (memq (process-status p) '(stop exit))
@@ -5165,7 +5185,7 @@
 			user host 'tramp-login-args)))
              (found nil)
              (pw nil))
-        (process-kill-without-query p)
+        (tramp-set-process-query-on-exit-flag p nil)
 	(set-buffer (tramp-get-buffer multi-method method user host))
 	(erase-buffer)
 	(tramp-process-actions p multi-method method user host
@@ -5232,7 +5252,7 @@
                   (apply #'start-process bufnam buf login-program 
                          host login-args)))
              (found nil))
-        (process-kill-without-query p)
+        (tramp-set-process-query-on-exit-flag p nil)
 
 	(set-buffer buf)
 	(tramp-process-actions p multi-method method user host
@@ -5293,7 +5313,7 @@
 			 user host 'tramp-login-args))))
              (found nil)
              (pw nil))
-        (process-kill-without-query p)
+        (tramp-set-process-query-on-exit-flag p nil)
 	(set-buffer (tramp-get-buffer multi-method method user host))
 	(tramp-process-actions p multi-method method user host
 			       tramp-actions-before-shell)
@@ -5346,7 +5366,7 @@
                                tramp-multi-sh-program))
              (num-hops (length method))
              (i 0))
-        (process-kill-without-query p)
+        (tramp-set-process-query-on-exit-flag p nil)
         (tramp-message 9 "Waiting 60s for local shell to come up...")
         (unless (tramp-wait-for-regexp
 		 p 60 (format "\\(%s\\)\\'\\|\\(%s\\)\\'"
@@ -5466,12 +5486,16 @@
              (with-timeout (timeout)
                (while (not found)
                  (accept-process-output proc 1)
+		 (unless (memq (process-status proc) '(run open))
+		   (error "Process has died"))
                  (goto-char (point-min))
                  (setq found (when (re-search-forward regexp nil t)
                                (tramp-match-string-list)))))))
           (t
            (while (not found)
              (accept-process-output proc 1)
+	     (unless (memq (process-status proc) '(run open))
+	       (error "Process has died"))
              (goto-char (point-min))
              (setq found (when (re-search-forward regexp nil t)
                            (tramp-match-string-list))))))
@@ -5526,7 +5550,7 @@
 
 ;; HHH: Not Changed.  This might handle the case where USER is not
 ;;      given in the "File name" very poorly.  Then, the local
-;;      variable tramp-current user will be set to nil.
+;;      variable tramp-current-user will be set to nil.
 (defun tramp-pre-connection (multi-method method user host)
   "Do some setup before actually logging in.
 METHOD, USER and HOST specify the connection."
@@ -5621,9 +5645,10 @@
 				     "stty -onlcr"))))
   (erase-buffer)
   (tramp-message
-   9 "Waiting 30s for `HISTFILE=$HOME/.tramp_history; HISTSIZE=1'")
-  (tramp-send-command-internal multi-method method user host
-			       "HISTFILE=$HOME/.tramp_history; HISTSIZE=1")
+   9 "Waiting 30s for `HISTFILE=$HOME/.tramp_history; HISTSIZE=1; export HISTFILE; export HISTSIZE'")
+  (tramp-send-command-internal
+   multi-method method user host
+   "HISTFILE=$HOME/.tramp_history; HISTSIZE=1; export HISTFILE; export HISTSIZE")
   (erase-buffer)
   (tramp-message 9 "Waiting 30s for `set +o vi +o emacs'")
   (tramp-send-command-internal multi-method method user host
@@ -6079,12 +6104,16 @@
                (with-timeout (timeout)
                  (while (not found)
                    (accept-process-output proc 1)
+		   (unless (memq (process-status proc) '(run open))
+		     (error "Process has died"))
                    (goto-char (point-max))
                    (forward-line -1)
                    (setq found (looking-at end-of-output))))))
             (t
              (while (not found)
                (accept-process-output proc 1)
+	       (unless (memq (process-status proc) '(run open))
+		 (error "Process has died"))
                (goto-char (point-max))
                (forward-line -1)
                (setq found (looking-at end-of-output))))))
@@ -6762,6 +6791,16 @@
 it does the right thing."
   (delete "" (split-string string pattern)))
 
+(defun tramp-set-process-query-on-exit-flag (process flag)
+  "Specify if query is needed for process when Emacs is exited.
+If the second argument flag is non-nil, Emacs will query the user before
+exiting if process is running."
+  (if (fboundp 'set-process-query-on-exit-flag)
+      (set-process-query-on-exit-flag process flag)
+    (funcall (symbol-function 'process-kill-without-query)
+	     process flag)))
+
+
 ;; ------------------------------------------------------------ 
 ;; -- Kludges section -- 
 ;; ------------------------------------------------------------ 
--- a/lisp/progmodes/gdb-ui.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/progmodes/gdb-ui.el	Mon May 31 13:48:26 2004 +0000
@@ -40,8 +40,15 @@
 ;; Kingdon and uses GDB's annotation interface. You don't need to know about
 ;; annotations to use this mode as a debugger, but if you are interested
 ;; developing the mode itself, then see the Annotations section in the GDB
-;; info manual. Some GDB/MI commands are also used through th CLI command
-;; 'interpreter mi <mi-command>'.
+;; info manual. 
+;;
+;; GDB developers plan to make the annotation interface obsolete. A new
+;; interface called GDB/MI (machine interface) has been designed to replace
+;; it. Some GDB/MI commands are used in this file through the CLI command
+;; 'interpreter mi <mi-command>'. A file called gdb-mi.el is included in the
+;; GDB repository for future releases (6.2 onwards) that uses GDB/MI as the
+;; primary interface to GDB. It is still under development and is part of a
+;; process to migrate Emacs from annotations to GDB/MI.
 ;;
 ;; Known Bugs:
 ;;
@@ -53,7 +60,7 @@
 (defvar gdb-current-address "main" "Initialisation for Assembler buffer.")
 (defvar gdb-previous-address nil)
 (defvar gdb-previous-frame nil)
-(defvar gdb-current-frame "main")
+(defvar gdb-current-frame nil)
 (defvar gdb-current-language nil)
 (defvar gdb-view-source t "Non-nil means that source code can be viewed.")
 (defvar gdb-selected-view 'source "Code type that user wishes to view.")
@@ -175,7 +182,7 @@
   (setq gdb-current-address "main")
   (setq gdb-previous-address nil)
   (setq gdb-previous-frame nil)
-  (setq gdb-current-frame "main")
+  (setq gdb-current-frame nil)
   (setq gdb-view-source t)
   (setq gdb-selected-view 'source)
   (setq gdb-var-list nil)
@@ -214,7 +221,7 @@
   (require 'tooltip)
   (let ((expr (tooltip-identifier-from-point (point))))
     (if (and (string-equal gdb-current-language "c")
-	     gdb-use-colon-colon-notation)
+	     gdb-use-colon-colon-notation gdb-current-frame)
 	(setq expr (concat gdb-current-frame "::" expr)))
     (catch 'already-watched
       (dolist (var gdb-var-list)
@@ -1219,8 +1226,10 @@
   (interactive)
   (save-excursion
     (beginning-of-line 1)
-    (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+" nil t)
-    (looking-at "\\(\\S-*\\):\\([0-9]+\\)"))
+    (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdbmi))
+	(looking-at "[0-9]*\\s-*\\S-*\\s-*\\S-*\\s-*.\\s-*\\S-*\\s-*\\(\\S-*\\):\\([0-9]+\\)")
+      (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+" nil t)
+      (looking-at "\\(\\S-*\\):\\([0-9]+\\)")))
   (if (match-string 2)
       (let ((line (match-string 2))
 	    (file (match-string 1)))
@@ -1311,7 +1320,7 @@
 
 (defun gdb-get-frame-number ()
   (save-excursion
-    (let* ((pos (re-search-backward "^#\\([0-9]*\\)" nil t))
+    (let* ((pos (re-search-backward "^#*\\([0-9]*\\)" nil t))
 	   (n (or (and pos (match-string-no-properties 1)) "0")))
       n)))
 
@@ -1502,7 +1511,7 @@
 
 \\{gdb-locals-mode-map}"
   (setq major-mode 'gdb-locals-mode)
-  (setq mode-name "Locals")
+  (setq mode-name (concat "Locals:" gdb-current-frame))
   (setq buffer-read-only t)
   (use-local-map gdb-locals-mode-map)
   (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
@@ -1999,6 +2008,9 @@
     (if (looking-at ".*=\\s-+0x\\(\\S-*\\)\\s-+in\\s-+\\(\\S-*?\\);? ")
 	(progn
 	  (setq gdb-current-frame (match-string 2))
+	  (if (gdb-get-buffer 'gdb-locals-buffer)
+	      (with-current-buffer (gdb-get-buffer 'gdb-locals-buffer)
+		(setq mode-name (concat "Locals:" gdb-current-frame))))
 	  (let ((address (match-string 1)))
 	    ;; remove leading 0s from output of info frame command.
 	    (if (string-match "^0+\\(.*\\)" address)
--- a/lisp/replace.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/replace.el	Mon May 31 13:48:26 2004 +0000
@@ -36,9 +36,11 @@
 
 (defvar query-replace-history nil)
 
-(defvar query-replace-interactive nil
+(defcustom query-replace-interactive nil
   "Non-nil means `query-replace' uses the last search string.
-That becomes the \"string to replace\".")
+That becomes the \"string to replace\"."
+  :type 'boolean
+  :group 'matching)
 
 (defcustom query-replace-from-history-variable 'query-replace-history
   "History list to use for the FROM argument of `query-replace' commands.
--- a/lisp/subr.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/subr.el	Mon May 31 13:48:26 2004 +0000
@@ -1796,10 +1796,21 @@
 This does not alter the buffer list ordering.
 See also `with-temp-buffer'."
   (declare (indent 1) (debug t))
-  `(let ((save-selected-window-window (selected-window)))
+  ;; Most of this code is a copy of save-selected-window.
+  `(let ((save-selected-window-window (selected-window))
+	 ;; It is necessary to save all of these, because calling
+	 ;; select-window changes frame-selected-window for whatever
+	 ;; frame that window is in.
+	 (save-selected-window-alist
+	  (mapcar (lambda (frame) (list frame (frame-selected-window frame)))
+		  (frame-list))))
      (unwind-protect
 	 (progn (select-window ,window 'norecord)
 		,@body)
+       (dolist (elt save-selected-window-alist)
+	 (and (frame-live-p (car elt))
+	      (window-live-p (cadr elt))
+	      (set-frame-selected-window (car elt) (cadr elt))))
        (if (window-live-p save-selected-window-window)
 	   (select-window save-selected-window-window 'norecord)))))
 
--- a/lisp/thumbs.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/thumbs.el	Mon May 31 13:48:26 2004 +0000
@@ -1,15 +1,10 @@
 ;;; thumbs.el --- Thumbnails previewer for images files
-;;;
+
+;; Copyright 2004 Free Software Foundation, Inc
+
 ;; Author: Jean-Philippe Theberge <jphiltheberge@videotron.ca>
-;;
-;; Thanks: Alex Schroeder <alex@gnu.org> for maintaining the package at some time
-;;         The peoples at #emacs@freenode.net for numerous help
-;;         RMS for emacs and the GNU project.
-;;
 ;; Keywords: Multimedia
 
-(defconst thumbs-version "2.0")
-
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
@@ -26,6 +21,11 @@
 ;; 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.
+;;              
+;; Thanks: Alex Schroeder <alex@gnu.org> for maintaining the package at some time
+;;         The peoples at #emacs@freenode.net for numerous help
+;;         RMS for emacs and the GNU project.
+;;
 
 ;;; Commentary:
 
@@ -56,19 +56,8 @@
 
 ;;; Code:
 
-(eval-when-compile
-  (require 'cl))
 (require 'dired)
 
-;; Abort if in-line imaging isn't supported (i.e. Emacs-20.7)
-
-(when (not (display-images-p))
-  (error "Your Emacs version (%S) doesn't support in-line images,
-was not compiled with image support or is run in console mode.
-Upgrade to Emacs 21.1 or newer, compile it with image support
-or use a window-system"
-	 emacs-version))
-
 ;; CUSTOMIZATIONS
 
 (defgroup thumbs nil
@@ -212,9 +201,9 @@
 	 (dirsize (apply '+ (mapcar (lambda (x) (cadr x)) filesL))))
     (while (> dirsize thumbs-thumbsdir-max-size)
       (progn
-	(message "Deleting file %s" (caddar filesL)))
-      (delete-file (caddar filesL))
-      (setq dirsize (- dirsize (cadar filesL)))
+	(message "Deleting file %s" (cadr (cdar filesL))))
+      (delete-file (cadr (cdar filesL)))
+      (setq dirsize (- dirsize (car (cdar filesL))))
       (setq filesL (cdr filesL)))))
 
 ;; Check the thumbsnail directory size and clean it if necessary.
@@ -272,11 +261,12 @@
 Or, alternatively, a SIZE may be specified."
   (interactive)
   ;; cleaning of old temp file
-  (ignore-errors
+  (condition-case nil
     (apply 'delete-file
 	   (directory-files
 	    thumbs-temp-dir t
-	    thumbs-temp-prefix)))
+	    thumbs-temp-prefix))
+    (error nil))
   (let ((buffer-read-only nil)
 	(x (if size
 	       size
@@ -309,22 +299,10 @@
   (interactive)
   (thumbs-resize-image t))
 
-(defun thumbs-subst-char-in-string (orig rep string)
-  "Replace occurrences of character ORIG with character REP in STRING.
-Return the resulting (new) string.  -- (defun borowed to Dave Love)"
-  (let ((string (copy-sequence string))
-	(l (length string))
-	(i 0))
-    (while (< i l)
-      (if (= (aref string i) orig)
-	  (aset string i rep))
-      (setq i (1+ i)))
-    string))
-
 (defun thumbs-thumbname (img)
   "Return a thumbnail name for the image IMG."
   (concat thumbs-thumbsdir "/"
-	  (thumbs-subst-char-in-string
+	  (subst-char-in-string
 	   ?\  ?\_
 	   (apply
 	    'concat
@@ -336,7 +314,11 @@
   (let* ((fn (expand-file-name img))
 	 (tn (thumbs-thumbname img)))
     (if (or (not (file-exists-p tn))
-	    (not (equal (thumbs-file-size tn) thumbs-geometry)))
+	    ;;  This is not the right fix, but I don't understand
+	    ;;  the external program or why it produces a geometry
+	    ;;  unequal to the one requested -- rms.
+;;;	    (not (equal (thumbs-file-size tn) thumbs-geometry))
+	    )
 	(thumbs-call-convert fn tn "sample" thumbs-geometry))
     tn))
 
@@ -380,30 +362,28 @@
   "Insert the thumbnail for IMG at point.
 if MARKED is non-nil, the image is marked"
   (thumbs-insert-image
-   (thumbs-make-thumb img) 'jpeg thumbs-relief marked))
+   (thumbs-make-thumb img) 'jpeg thumbs-relief marked)
+  (put-text-property (1- (point)) (point)
+		     'thumb-image-file img))
 
 (defun thumbs-do-thumbs-insertion (L)
   "Insert all thumbs in list L."
-  (setq thumbs-fileL nil)
   (let ((i 0))
-    (while L
+    (dolist (img L)
+      (thumbs-insert-thumb img
+			   (member img thumbs-markedL))
       (when (= 0 (mod (setq i (1+ i)) thumbs-per-line))
-	(newline))
-      (setq thumbs-fileL (cons (cons (point)
-				     (car L))
-			       thumbs-fileL))
-      (thumbs-insert-thumb (car L)
-			   (member (car L) thumbs-markedL))
-      (setq L (cdr L)))))
+	(newline)))
+    (unless (bobp) (newline))))
 
 (defun thumbs-show-thumbs-list (L &optional buffer-name same-window)
+  (when (not (display-images-p))
+    (error "Images are not supported in this Emacs session"))
   (funcall (if same-window 'switch-to-buffer 'pop-to-buffer)
 	   (or buffer-name "*THUMB-View*"))
   (let ((inhibit-read-only t))
     (erase-buffer)
     (thumbs-mode)
-    (make-variable-buffer-local 'thumbs-fileL)
-    (setq thumbs-fileL nil)
     (thumbs-do-thumbs-insertion L)
     (goto-char (point-min))
     (setq thumbs-current-dir default-directory)
@@ -435,8 +415,8 @@
 ;;;###autoload
 (defalias 'thumbs 'thumbs-show-all-from-dir)
 
-(defun thumbs-find-image (img L &optional num otherwin)
-  (funcall
+(defun thumbs-find-image (img &optional num otherwin)
+  (funcall 
    (if otherwin 'switch-to-buffer-other-window 'switch-to-buffer)
    (concat "*Image: " (file-name-nondirectory img) " - "
 	   (number-to-string (or num 0)) "*"))
@@ -449,8 +429,6 @@
     (make-variable-buffer-local 'thumbs-current-tmp-filename)
     (make-variable-buffer-local 'thumbs-current-image-size)
     (make-variable-buffer-local 'thumbs-image-num)
-    (make-variable-buffer-local 'thumbs-fileL)
-    (setq thumbs-fileL L)
     (delete-region (point-min)(point-max))
     (thumbs-insert-image img (thumbs-image-type img) 0)))
 
@@ -458,10 +436,8 @@
   "Display image IMG for thumbnail at point.
 use another window it OTHERWIN is t."
   (interactive)
-  (let* ((L thumbs-fileL)
-	 (n (point))
-	 (i (or img (cdr (assoc n L)))))
-    (thumbs-find-image i L n otherwin)))
+  (let* ((i (or img (thumbs-current-image))))
+    (thumbs-find-image i (point) otherwin)))
 
 (defun thumbs-find-image-at-point-other-window ()
   "Display image for thumbnail at point in the preview buffer.
@@ -469,6 +445,12 @@
   (interactive)
   (thumbs-find-image-at-point nil t))
 
+(defun thumbs-mouse-find-image (event)
+  "Display image for thumbnail at mouse click EVENT."
+  (interactive "e")
+  (mouse-set-point event)
+  (thumbs-find-image-at-point))
+
 (defun thumbs-call-setroot-command (img)
   "Call the setroot program for IMG."
   (run-hooks 'thumbs-before-setroot-hook)
@@ -481,7 +463,8 @@
 (defun thumbs-set-image-at-point-to-root-window ()
   "Set the image at point as the desktop wallpaper."
   (interactive)
-  (thumbs-call-setroot-command (cdr (assoc (point) thumbs-fileL))))
+  (thumbs-call-setroot-command
+   (thumbs-current-image)))
 
 (defun thumbs-set-root ()
   "Set the current image as root."
@@ -490,36 +473,102 @@
    (or thumbs-current-tmp-filename
        thumbs-current-image-filename)))
 
+(defun thumbs-file-alist ()
+  "Make an alist of elements (POS . FILENAME) for all images in thumb buffer."
+  (save-excursion
+    (let (list)
+      (goto-char (point-min))
+      (while (not (eobp))
+	(if (thumbs-current-image)
+	    (push (cons (point-marker)
+			(thumbs-current-image))
+		  list))
+	(forward-char 1))
+      list)))
+
+(defun thumbs-file-list ()
+  "Make a list of file names for all images in thumb buffer."
+  (save-excursion
+    (let (list)
+      (goto-char (point-min))
+      (while (not (eobp))
+	(if (thumbs-current-image)
+	    (push (thumbs-current-image) list))
+	(forward-char 1))
+      (nreverse list))))
+
 (defun thumbs-delete-images ()
   "Delete the image at point (and it's thumbnail) (or marked files if any)."
   (interactive)
-  (let ((f (or thumbs-markedL (list (cdr (assoc (point) thumbs-fileL))))))
-    (if (yes-or-no-p (format "Really delete %d files? " (length f)))
-	(progn
-	  (mapcar (lambda (x)
-		    (setq thumbs-fileL (delete (rassoc x thumbs-fileL) thumbs-fileL))
+  (let ((files (or thumbs-markedL (list (thumbs-current-image)))))
+    (if (yes-or-no-p (format "Really delete %d files? " (length files)))
+	(let ((thumbs-fileL (thumbs-file-alist))
+	      (inhibit-read-only t))
+	  (dolist (x files)
+	    (let (failure)
+	      (condition-case ()
+		  (progn
 		    (delete-file x)
-		    (delete-file (thumbs-thumbname x))) f)
-	  (thumbs-redraw-buffer)))))
+		    (delete-file (thumbs-thumbname x)))
+		(file-error (setq failure t)))
+	      (unless failure
+		(when (rassoc x thumbs-fileL)
+		  (goto-char (car (rassoc x thumbs-fileL)))
+		  (delete-region (point) (1+ (point))))
+		(setq thumbs-markedL
+		      (delq x thumbs-markedL)))))))))
+
+(defun thumbs-rename-images (newfile)
+  "Rename the image at point (and it's thumbnail) (or marked files if any)."
+  (interactive "FRename to file or directory: ")
+  (let ((files (or thumbs-markedL (list (thumbs-current-image))))
+	failures)
+    (if (and (not (file-directory-p newfile))
+	     thumbs-markedL)
+	(if (file-exists-p newfile)
+	    (error "Renaming marked files to file name `%s'" newfile)
+	  (make-directory newfile t)))
+    (if (yes-or-no-p (format "Really rename %d files? " (length files)))
+	(let ((thumbs-fileL (thumbs-file-alist))
+	      (inhibit-read-only t))
+	  (dolist (file files)
+	    (let (failure)
+	      (condition-case ()
+		  (if (file-directory-p newfile)
+		      (rename-file file
+				   (expand-file-name
+				    (file-name-nondirectory file)
+				    newfile))
+		    (rename-file file newfile))
+		(file-error (setq failure t)
+			    (push file failures)))
+	      (unless failure
+		(when (rassoc file thumbs-fileL)
+		  (goto-char (car (rassoc file thumbs-fileL)))
+		  (delete-region (point) (1+ (point))))
+		(setq thumbs-markedL
+		      (delq file thumbs-markedL)))))))
+    (if failures
+	(display-warning 'file-error
+			 (format "Rename failures for %s into %s"
+				 failures newfile)
+			 :error))))
 
 (defun thumbs-kill-buffer ()
   "Kill the current buffer."
   (interactive)
   (let ((buffer (current-buffer)))
-    (ignore-errors (delete-window (selected-window)))
+    (condition-case nil
+	(delete-window (selected-window))
+      (error nil))
     (kill-buffer buffer)))
 
 (defun thumbs-show-image-num (num)
   "Show the image with number NUM."
-  (let ((inhibit-read-only t))
-    (delete-region (point-min)(point-max))
-    (let ((i (cdr (assoc num thumbs-fileL))))
-      (thumbs-insert-image i (thumbs-image-type i) 0)
-      (sleep-for 2)
-      (rename-buffer (concat "*Image: "
-			     (file-name-nondirectory i)
-			     " - "
-			     (number-to-string num) "*"))
+  (let ((image-buffer (get-buffer-create "*Image*")))
+    (let ((i (thumbs-current-image)))
+      (with-current-buffer image-buffer
+	(thumbs-insert-image i (thumbs-image-type i) 0))
       (setq thumbs-image-num num
 	    thumbs-current-image-filename i))))
 
@@ -527,40 +576,54 @@
   "Show next image."
   (interactive)
   (let* ((i (1+ thumbs-image-num))
-	 (l (caar thumbs-fileL))
-	 (num
-	  (cond ((assoc i thumbs-fileL) i)
-		((>= i l) 1)
-		(t (1+ i)))))
-    (thumbs-show-image-num num)))
+	 (list (thumbs-file-alist))
+	 (l (caar list)))
+    (while (and (/= i thumbs-image-num) (not (assoc i list)))
+      (setq i (if (>= i l) 1 (1+ i))))
+    (thumbs-show-image-num i)))
 
 (defun thumbs-previous-image ()
   "Show the previous image."
   (interactive)
   (let* ((i (- thumbs-image-num 1))
-	 (l (caar thumbs-fileL))
-	 (num
-	  (cond ((assoc i thumbs-fileL) i)
-		((<= i 1) l)
-		(t (- i 1)))))
-    (thumbs-show-image-num num)))
+	 (list (thumbs-file-alist))
+	 (l (caar list)))
+    (while (and (/= i thumbs-image-num) (not (assoc i list)))
+      (setq i (if (<= i 1) l (1- i))))
+    (thumbs-show-image-num i)))
 
 (defun thumbs-redraw-buffer ()
   "Redraw the current thumbs buffer."
   (let ((p (point))
-	(inhibit-read-only t))
-    (delete-region (point-min)(point-max))
-    (thumbs-do-thumbs-insertion (reverse (mapcar 'cdr thumbs-fileL)))
-    (goto-char (1+ p))))
+	(inhibit-read-only t)
+	(files (thumbs-file-list)))
+    (erase-buffer)
+    (thumbs-do-thumbs-insertion files)
+    (goto-char p)))
 
 (defun thumbs-mark ()
   "Mark the image at point."
   (interactive)
-  (setq thumbs-markedL (cons (cdr (assoc (point) thumbs-fileL)) thumbs-markedL))
-  (let ((inhibit-read-only t))
-    (delete-char 1)
-    (thumbs-insert-thumb (cdr (assoc (point) thumbs-fileL)) t))
-  (when (eolp)(forward-char)))
+  (let ((elt (thumbs-current-image)))
+    (unless elt
+      (error "No image here"))
+    (push elt thumbs-markedL)
+    (let ((inhibit-read-only t))
+      (delete-char 1)
+      (thumbs-insert-thumb elt t)))
+  (when (eolp) (forward-char)))
+
+(defun thumbs-unmark ()
+  "Unmark the image at point."
+  (interactive)
+  (let ((elt (thumbs-current-image)))
+    (unless elt
+      (error "No image here"))
+    (setq thumbs-markedL (delete elt thumbs-markedL))
+    (let ((inhibit-read-only t))
+      (delete-char 1)
+      (thumbs-insert-thumb elt nil)))
+  (when (eolp) (forward-char)))
 
 ;; Image modification routines
 
@@ -587,8 +650,8 @@
 (defun thumbs-emboss-image (emboss)
   "Emboss the image with value EMBOSS."
   (interactive "nEmboss value: ")
-  (if (or (< emboss 3) (> emboss 31) (zerop (logand emboss 1)))
-      (error "Arg must be a odd number between 3 and 31"))
+  (if (or (< emboss 3) (> emboss 31) (zerop (% emboss 2)))
+      (error "Arg must be an odd number between 3 and 31"))
   (thumbs-modify-image "emboss" (number-to-string emboss)))
 
 (defun thumbs-monochrome-image ()
@@ -611,17 +674,24 @@
   (interactive)
   (thumbs-modify-image "rotate" "90"))
 
+(defun thumbs-current-image ()
+  "Return the name of the image file name at point."
+  (get-text-property (point) 'thumb-image-file))
+
 (defun thumbs-forward-char ()
   "Move forward one image."
   (interactive)
   (forward-char)
-  (when (eolp)(forward-char))
+  (while (and (not (eobp)) (not (thumbs-current-image)))
+    (forward-char))
   (thumbs-show-name))
 
 (defun thumbs-backward-char ()
   "Move backward one image."
   (interactive)
   (forward-char -1)
+  (while (and (not (bobp)) (not (thumbs-current-image)))
+    (forward-char -1))
   (thumbs-show-name))
 
 (defun thumbs-forward-line ()
@@ -639,15 +709,15 @@
 (defun thumbs-show-name ()
   "Show the name of the current file."
   (interactive)
-  (let ((f (cdr (assoc (point) thumbs-fileL))))
-    (message "%s [%s]" f (thumbs-file-size f))))
+  (let ((f (thumbs-current-image)))
+    (and f (message "%s [%s]" f (thumbs-file-size f)))))
 
 (defun thumbs-save-current-image ()
   "Save the current image."
   (interactive)
   (let ((f (or thumbs-current-tmp-filename
 	       thumbs-current-image-filename))
-	(sa (read-from-minibuffer "save file as: "
+	(sa (read-from-minibuffer "Save image file as: "
 				  thumbs-current-image-filename)))
     (copy-file f sa)))
 
@@ -661,6 +731,7 @@
 (defvar thumbs-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map [return] 'thumbs-find-image-at-point)
+    (define-key map [mouse-2] 'thumbs-mouse-find-image)
     (define-key map [(meta return)] 'thumbs-find-image-at-point-other-window)
     (define-key map [(control return)] 'thumbs-set-image-at-point-to-root-window)
     (define-key map [delete] 'thumbs-delete-images)
@@ -670,15 +741,20 @@
     (define-key map [down] 'thumbs-forward-line)
     (define-key map "d" 'thumbs-dired)
     (define-key map "m" 'thumbs-mark)
+    (define-key map "u" 'thumbs-unmark)
+    (define-key map "R" 'thumbs-rename-images)
+    (define-key map "x" 'thumbs-delete-images)
     (define-key map "s" 'thumbs-show-name)
     (define-key map "q" 'thumbs-kill-buffer)
     map)
   "Keymap for `thumbs-mode'.")
 
+(put 'thumbs-mode 'mode-class 'special)
 (define-derived-mode thumbs-mode
   fundamental-mode "thumbs"
   "Preview images in a thumbnails buffer"
   (make-variable-buffer-local 'thumbs-markedL)
+  (setq buffer-read-only t)
   (setq thumbs-markedL nil))
 
 (defvar thumbs-view-image-mode-map
@@ -698,6 +774,7 @@
   "Keymap for `thumbs-view-image-mode'.")
 
 ;; thumbs-view-image-mode
+(put 'thumbs-view-image-mode 'mode-class 'special)
 (define-derived-mode thumbs-view-image-mode
   fundamental-mode "image-view-mode")
 
--- a/lisp/w32-fns.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/w32-fns.el	Mon May 31 13:48:26 2004 +0000
@@ -230,9 +230,13 @@
 
 (defun convert-standard-filename (filename)
   "Convert a standard file's name to something suitable for the current OS.
-This function's standard definition is trivial; it just returns the argument.
-However, on some systems, the function is redefined
-with a definition that really does change some file names."
+This means to guarantee valid names and perhaps to canonicalize
+certain patterns.
+
+On Windows and DOS, replace invalid characters.  On DOS, make
+sure to obey the 8.3 limitations.  On Windows, turn Cygwin names
+into native names, and also turn slashes into backslashes if the
+shell requires it (see `w32-shell-dos-semantics')."
   (let ((name
          (save-match-data
            (if (string-match "\\`/cygdrive/\\([a-zA-Z]\\)/" filename)
--- a/lisp/window.el	Sun May 30 21:11:48 2004 +0000
+++ b/lisp/window.el	Mon May 31 13:48:26 2004 +0000
@@ -36,6 +36,9 @@
 However, if a window has become dead, don't get an error,
 just refrain from reselecting it."
   `(let ((save-selected-window-window (selected-window))
+	 ;; It is necessary to save all of these, because calling
+	 ;; select-window changes frame-selected-window for whatever
+	 ;; frame that window is in.
 	 (save-selected-window-alist
 	  (mapcar (lambda (frame) (list frame (frame-selected-window frame)))
 		  (frame-list))))
--- a/lispref/ChangeLog	Sun May 30 21:11:48 2004 +0000
+++ b/lispref/ChangeLog	Mon May 31 13:48:26 2004 +0000
@@ -1,3 +1,20 @@
+2004-05-30  Richard M. Stallman  <rms@gnu.org>
+
+	* loading.texi (Named Features): Clarify return value
+	and meaning of NOERROR.
+
+	* variables.texi (File Local Variables): Minor cleanup.
+
+2004-05-30  Michael Albinus  <michael.albinus@gmx.de>
+
+	* files.texi (Magic File Names): Add `file-remote-p' as operation
+	of file name handlers.
+
+2004-05-29  Richard M. Stallman  <rms@gnu.org>
+
+	* modes.texi (Minor Mode Conventions): (-) has no special meaning
+	as arg to a minor mode command.
+
 2004-05-22  Richard M. Stallman  <rms@gnu.org>
 
 	* syntax.texi (Syntax Class Table): Word syntax not just for English.
--- a/lispref/files.texi	Sun May 30 21:11:48 2004 +0000
+++ b/lispref/files.texi	Mon May 31 13:48:26 2004 +0000
@@ -2493,7 +2493,7 @@
 @code{file-attributes},
 @code{file-directory-p},
 @code{file-executable-p}, @code{file-exists-p},
-@code{file-local-copy},
+@code{file-local-copy}, @code{file-remote-p},
 @code{file-modes}, @code{file-name-all-completions},
 @code{file-name-as-directory},
 @code{file-name-completion},
@@ -2537,7 +2537,7 @@
 @code{file-attributes},
 @code{file-direct@discretionary{}{}{}ory-p},
 @code{file-executable-p}, @code{file-exists-p},
-@code{file-local-copy},
+@code{file-local-copy}, @code{file-remote-p},
 @code{file-modes}, @code{file-name-all-completions},
 @code{file-name-as-directory},
 @code{file-name-completion},
@@ -2645,8 +2645,7 @@
 @end defun
 
 @defun file-remote-p filename
-This function returns @code{t} if @var{filename} is a remote file---that is,
-a magic file name that handles @code{file-local-copy}.
+This function returns @code{t} if @var{filename} is a remote file.
 @end defun
 
 @defun unhandled-file-name-directory filename
--- a/lispref/loading.texi	Sun May 30 21:11:48 2004 +0000
+++ b/lispref/loading.texi	Mon May 31 13:48:26 2004 +0000
@@ -687,9 +687,14 @@
 with an added suffix; a file whose name is just @var{feature} won't be
 used.
 
-If loading the file fails to provide @var{feature}, @code{require}
-signals an error, @samp{Required feature @var{feature} was not
-provided}, unless @var{noerror} is non-@code{nil}.
+If @var{noerror} is non-@code{nil}, that suppresses errors from actual
+loading of the file.  In that case, @code{require} returns @code{nil}
+if loading the file fails.  Normally, @code{require} returns
+@var{feature}.
+
+If loading the file succeeds but does not provide @var{feature},
+@code{require} signals an error, @samp{Required feature @var{feature}
+was not provided}.
 @end defun
 
 @defun featurep feature &optional subfeature
--- a/lispref/modes.texi	Sun May 30 21:11:48 2004 +0000
+++ b/lispref/modes.texi	Mon May 31 13:48:26 2004 +0000
@@ -879,8 +879,9 @@
 off if it is on).  It should turn the mode on if the argument is a
 positive integer, the symbol @code{t}, or a list whose @sc{car} is one
 of those.  It should turn the mode off if the argument is a negative
-integer or zero, the symbol @code{-}, or a list whose @sc{car} is one
-of those.  The meaning of other arguments is not specified.
+integer or zero, the symbol @code{-}, or a list whose @sc{car} is a
+negative integer or zero.  The meaning of other arguments is not
+specified.
 
 Here is an example taken from the definition of @code{transient-mark-mode}.
 It shows the use of @code{transient-mark-mode} as a variable that enables or
--- a/lispref/variables.texi	Sun May 30 21:11:48 2004 +0000
+++ b/lispref/variables.texi	Mon May 31 13:48:26 2004 +0000
@@ -1769,8 +1769,8 @@
 is specified in the local variables list at the end of the file.
 @end defun
 
-  If a file local variable list could specify a function that will
-be called later, or an expression that will be executed later, simply
+  If a file local variable list could specify a function that would
+be called later, or an expression that would be executed later, simply
 visiting a file could take over your Emacs.  To prevent this, Emacs
 takes care not to allow local variable lists to set such variables.
 
--- a/mac/ChangeLog	Sun May 30 21:11:48 2004 +0000
+++ b/mac/ChangeLog	Mon May 31 13:48:26 2004 +0000
@@ -1,3 +1,9 @@
+2004-05-29  Steven Tamm  <steventamm@mac.com>
+
+	* INSTALL: Fixing typos
+	* README: Updating list of TODOs to remove image support and 
+	environment variable problem.
+
 2004-01-14  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* src/Emacs.r: Update TOO_MUCH_RAM error message.
--- a/mac/INSTALL	Sun May 30 21:11:48 2004 +0000
+++ b/mac/INSTALL	Mon May 31 13:48:26 2004 +0000
@@ -165,7 +165,7 @@
 In either case, you will need MPW-GM to build the make-docfile utility
 and to generate the doc string file DOC.
 
-### IMPORTANT ### You can use StuffIf Expander to decompress and untar
+### IMPORTANT ### You can use StuffIt Expander to decompress and untar
 the distribution.  However, you *must* set the radio button in the
 Preferences->Cross Platform->Convert text files to Macintosh format to
 "Never".  Otherwise the compiled Lisp files will be corrupted.
@@ -200,7 +200,7 @@
 
 * NOTES
 
-Emacs should build and run on a PowerMac running Mac OS 8.6 - 10.2.
+Emacs should build and run on a PowerMac running Mac OS 8.6 - 10.3.
 
 You will need around 100 MB of disk space for the source files and
 intermediate files.
--- a/mac/README	Sun May 30 21:11:48 2004 +0000
+++ b/mac/README	Mon May 31 13:48:26 2004 +0000
@@ -1,6 +1,6 @@
 Emacs for Mac OS 8/9 and Mac OS X
 
-Copyright (c) 2001, 2002 Free Software Foundation, Inc.
+Copyright (c) 2001-4 Free Software Foundation, Inc.
 
    Permission is granted to anyone to make or distribute verbatim
    copies of this document as received, in any medium, provided that
@@ -45,18 +45,18 @@
 
 A number of things do not work yet:
 
-+ On Mac OS X, environment variables are not set up correctly when
-  Emacs is started from the Finder.
++ Emacs does not respond correctly to C-g under certain circumstances.  
+  Sending the Emacs process a SIGINT externally will cause it 
+  to interrupt.  This is due to the architecture of OSX's 
+  Window Manager.
 
-+ Emacs does not respond correctly to C-g when it is not reading
-  input.
-
-+ No image support yet.
++ Support for certain image types (such as XPM) is not as extensive as 
+  on other plaforms. 
 
 If your Mac is connected to the Internet, report bugs by typing `M-x
 report-emacs-bug' or by choosing the entry `Send Bug Report...'  in
 the `Help' menu.  This will send the bug report to the address
 emacs-pretest-bug@gnu.org.
 
-Andrew.
-<akochoi@mac.com>
+Steven
+<steven.tamm@mac.com>
--- a/man/ChangeLog	Sun May 30 21:11:48 2004 +0000
+++ b/man/ChangeLog	Mon May 31 13:48:26 2004 +0000
@@ -1,3 +1,57 @@
+2004-05-29  Michael Albinus  <michael.albinus@gmx.de>
+
+	Version 2.0.41 of Tramp released.
+
+2004-05-29  Juanma Barranquero  <lektu@terra.es>
+
+	* makefile.w32-in (../info/flymake, flymake.dvi): New targets.
+	(INFO_TARGETS, DVI_TARGETS): Add Flymake.
+
+2004-05-29  Richard M. Stallman  <rms@gnu.org>
+
+	* custom.texi (Init File): Two dashes start --no-site-file.
+
+	* cl.texi (Top): Call this chapter `Introduction'.
+	(Overview): In TeX, no section heading here.
+
+	* cc-mode.texi: Put commas after i.e. and e.g.  Minor cleanups.
+
+2004-05-29  Alan Mackenzie  <acm@muc.de>
+
+	* programs.texi: Update for CC Mode 5.30 and incidental amendments.
+	("AWK"): Is consistently thus spelt throughout.
+	(AWK, Pike): Document as "C-like modes".
+	(@kbd{M-j}): Document as alternative to @kbd{C-M-j}.
+	(M-x man): Supersedes M-x manual-entry.
+	Add numerous index entries.  Correct "ESC a/e" to "M-a/e".
+
+	("Comments in C"): Delete node; the info is in CC Mode manual.
+	(c-comment-only-line-offset): Remove description.
+
+	(C-c ., C-c C-c): Describe new C Mode bindings.
+
+	(C-u TAB, indent-code-rigidly, c-indent-exp, c-tab-always-indent)
+	(@dfn{Style}, c-default-style, comment-column, comment-padding)
+	(c-up-conditional, c-beginning-of-statement, c-end-of-statement):
+	Amend definitions.
+
+	(c-beginning-of-defun, c-end-of-defun, c-context-line-break):
+	Describe functions.
+
+	(c-comment-start-regexp, c-hanging-comment-ender-p)
+	(c-hanging-comment-starter-p): Remove obsolete definitions.
+
+	* emacs.texi: Remove the menu entry "Comments in C".
+
+2004-05-29  Eli Zaretskii  <eliz@gnu.org>
+
+	* Makefile.in (../info/flymake, flymake.dvi): New targets.
+	(INFO_TARGETS, DVI_TARGETS): Add Flymake.
+
+2004-05-29  Pavel Kobiakov  <pk_at_work@yahoo.com>
+
+	* flymake.texi: New file.
+
 2004-05-28  Simon Josefsson  <jas@extundo.com>
 
 	* smtpmail.texi (Authentication): Improve STARTTLS discussion.
@@ -28,7 +82,8 @@
 
 	* tramp.texi (Auto-save and Backup): Explain exploitation of new
 	variables `tramp-backup-directory-alist' and
-	`tramp-bkup-backup-directory-info'. (Overview, Connection types)
+	`tramp-bkup-backup-directory-info'.
+	(Overview, Connection types)
 	(External transfer methods, Default Method)
 	(Windows setup hints): Remove restriction of password entering
 	with external methods.
@@ -46,7 +101,7 @@
 
 2004-05-04  Jason Rumney  <jasonr@gnu.org>
 
-	* makefile.w32-in: Revert last change
+	* makefile.w32-in: Revert last change.
 
 2004-05-03  Jason Rumney  <jasonr@gnu.org>
 
@@ -54,8 +109,7 @@
 
 2004-04-28  Masatake YAMATO  <jet@gyve.org>
 
-	* widget.texi (Programming Example): Remove
-	overlays.
+	* widget.texi (Programming Example): Remove overlays.
 
 2004-04-27  Jesper Harder  <harder@ifa.au.dk>
 
@@ -192,7 +246,7 @@
 
 	* ses.texi (Advanced Features): New functionality for
 	ses-set-header-row (defaults to current row unless C-u used).
-	(Acknowledgements): Added Stefan Monnier.
+	(Acknowledgements): Add Stefan Monnier.
 
 2004-02-03  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
@@ -254,7 +308,7 @@
 
 2003-11-29  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
-	* frames.texi (Dialog Boxes): Added use-file-dialog.
+	* frames.texi (Dialog Boxes): Add use-file-dialog.
 
 2003-11-26  Thien-Thi Nguyen  <ttn@gnu.org>
 
@@ -267,7 +321,7 @@
 
 2003-11-22  Martin Stjernholm  <bug-cc-mode@gnu.org>
 
-	* cc-mode.texi: Updated for CC Mode 5.30.
+	* cc-mode.texi: Update for CC Mode 5.30.
 
 	Note: Please refrain from doing purely cosmetic changes like
 	removing trailing whitespace in this manual; it clobbers cvs
@@ -320,8 +374,8 @@
 
 2003-10-12  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
-	* xresources.texi (GTK resources): Added a note that some themes
-	disallow customizations.  Added scroll theme example.
+	* xresources.texi (GTK resources): Add a note that some themes
+	disallow customizations.  Add scroll theme example.
 
 2003-10-08  Nick Roberts  <nick@nick.uklinux.net>
 
@@ -379,7 +433,7 @@
 
 2003-09-21  Karl Berry  <karl@gnu.org>
 
-	* info.texi (] and [ commands): no period at end of section title.
+	* info.texi (] and [ commands): No period at end of section title.
 
 2003-09-08  Lute Kamstra  <lute@gnu.org>
 
@@ -392,7 +446,7 @@
 2003-09-07  Luc Teirlinck  <teirllm@mail.auburn.edu>
 
 	* xresources.texi (Resources): Refer to `editres' man page.
-	(Lucid Resources): Update defaults.  Expand desciption of
+	(Lucid Resources): Update defaults.  Expand description of
 	`shadowThickness'.
 
 2003-09-04  Miles Bader  <miles@gnu.org>
@@ -432,7 +486,7 @@
 	section.
 	* emacs.texi (Intro): Include kmacro.texi after custom.texi.
 	(Suggested by Kim Storm.)
-	* Makefile (EMACSSOURCES): Add kmacro.texi. (Suggested by Kim
+	* Makefile (EMACSSOURCES): Add kmacro.texi.  (Suggested by Kim
 	Storm.)
 
 2003-08-18  Kim F. Storm  <storm@cua.dk>
@@ -472,7 +526,7 @@
 
 2003-08-03  Karl Berry  <karl@gnu.org>
 
-	* info.texi: need @contents.
+	* info.texi: Need @contents.
 
 2003-08-03  Glenn Morris  <gmorris@ast.cam.ac.uk>
 
@@ -610,7 +664,7 @@
 2003-03-29  Richard M. Stallman  <rms@gnu.org>
 
 	* tramp.texi (Top): Undo the previous renaming.
-	(emacs-other-name, emacs-other-dir, emacs-other-file-name): Deleted.
+	(emacs-other-name, emacs-other-dir, emacs-other-file-name): Delete.
 
 2003-03-29  Kai Gro,A_(Bjohann  <kai.grossjohann@gmx.net>
 
@@ -714,7 +768,7 @@
 
 2003-01-09  Francesco Potort,Al(B  <pot@gnu.org>
 
-	* maintaining.texi (Create Tags Table): Added reference to the new
+	* maintaining.texi (Create Tags Table): Add reference to the new
 	`etags --help --lang=LANG' option.
 
 2002-12-26  Kai Gro,A_(Bjohann  <kai.grossjohann@uni-duisburg.de>
@@ -724,7 +778,7 @@
 
 2002-11-05  Karl Berry  <karl@gnu.org>
 
-	* info.texi (Info-fontify): reorder face list to avoid bad line
+	* info.texi (Info-fontify): Reorder face list to avoid bad line
 	breaks.
 
 2002-10-06  Kai Gro,A_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
@@ -742,8 +796,8 @@
 	Per rms, update all manuals to use @copying instead of @ifinfo.
 	Also use @ifnottex instead of @ifinfo around the top node, where
 	needed for the sake of the HTML output.
-	(The gnus manual is not fixed since it's not clear to me how it
-	 works; and the tramp manual already uses @copying, although in an
+	(The Gnus manual is not fixed since it's not clear to me how it
+	 works; and the Tramp manual already uses @copying, although in an
 	 unusual way.  All others were changed.)
 
 2002-09-10  Jonathan Yavner  <jyavner@engineer.com>
@@ -754,7 +808,7 @@
 
 2002-09-06  Pavel Jan,Bm(Bk  <Pavel@Janik.cz>
 
-	* texinfo.tex: Updated to texinfo 4.2.
+	* texinfo.tex: Update to texinfo 4.2.
 
 2002-08-27  Carsten Dominik  <dominik@sand.science.uva.nl>
 
@@ -812,11 +866,11 @@
 
 2000-10-19  Eric M. Ludlam  <zappo@ultranet.com>
 
-	* Makefile.in (Speedbar): Added build targets for speedbar.texi.
+	* Makefile.in (Speedbar): Add build targets for speedbar.texi.
 
 2000-10-13  John Wiegley  <johnw@gnu.org>
 
-	* Makefile.in: Added build targets for eshell.texi.
+	* Makefile.in: Add build targets for eshell.texi.
 
 2000-09-25  Gerd Moellmann  <gerd@gnu.org>
 
@@ -848,14 +902,14 @@
 2000-01-13  Gerd Moellmann  <gerd@gnu.org>
 
 	* Makefile.in (INFO_TARGETS): Add eudc.
-	(DVI_TARGETS): Add eudc.dvi
+	(DVI_TARGETS): Add eudc.dvi.
 	(../info/eudc, eudc.dvi): New targets.
 
 2000-01-05  Eli Zaretskii  <eliz@is.elta.co.il>
 
 	* Makefile.in (INFO_TARGETS): Rename emacs-faq to efaq (for
 	compatibility with 8+3 filesystems).
-	(../info/efaq): Renamed from emacs-faq.
+	(../info/efaq): Rename from emacs-faq.
 
 2000-01-03  Eli Zaretskii  <eliz@is.elta.co.il>
 
@@ -868,7 +922,7 @@
 
 1999-10-12  Stefan Monnier  <monnier@cs.yale.edu>
 
-	* Makefile.in (faq): use ../info/emacs-faq.info (as specified in the
+	* Makefile.in (faq): Use ../info/emacs-faq.info (as specified in the
 	  faq.texi file) rather than ../info/faq.
 
 1999-10-07  Gerd Moellmann  <gerd@gnu.org>
@@ -907,7 +961,7 @@
 
 1998-03-11  Carsten Dominik  <cd@delysid.gnu.org>
 
-	* reftex.texi Updated for RefTeX version 3.22.
+	* reftex.texi: Update for RefTeX version 3.22.
 
 1998-02-08  Richard Stallman  <rms@psilocin.gnu.org>
 
@@ -918,7 +972,7 @@
 
 	* Makefile.in: Merge changes mistakenly made to `Makefile'.
 	(INFO_TARGETS): Change ../info/custom to ../info/customize.
-	(../info/customize): Renamed from ../info/custom.
+	(../info/customize): Rename from ../info/custom.
 	(../info/viper, viper.dvi): Remove dependency on viper-cmd.texi.
 
 1997-09-19  Richard Stallman  <rms@psilocin.gnu.ai.mit.edu>
@@ -973,7 +1027,7 @@
 
 1996-01-07  Richard Stallman  <rms@whiz-bang.gnu.ai.mit.edu>
 
-	* Makefile.in (../info/ccmode): Renamed from ../info/cc-mode.
+	* Makefile.in (../info/ccmode): Rename from ../info/cc-mode.
 	(INFO_TARGETS): Use new name.  This avoids name conflict on MSDOS.
 
 1995-11-29  Richard Stallman  <rms@mole.gnu.ai.mit.edu>
@@ -1022,7 +1076,7 @@
 
 1995-02-07  Richard Stallman  <rms@pogo.gnu.ai.mit.edu>
 
-	* Makefile.in (maintainer-clean): Renamed from realclean.
+	* Makefile.in (maintainer-clean): Rename from realclean.
 
 1994-11-23  Richard Stallman  <rms@mole.gnu.ai.mit.edu>
 
@@ -1073,7 +1127,7 @@
 
 1994-01-08  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
 
-	* Makefile (../info/sc): Renamed frin sc.info.
+	* Makefile (../info/sc): Rename frin sc.info.
 	(../info/cl): Likewise.
 	(INFO_TARGETS): Use new names.
 
@@ -1088,7 +1142,7 @@
 
 1993-12-03  Richard Stallman  (rms@srarc2)
 
-	* Makefile (../info/sc.info): Renamed from ../info/sc.
+	* Makefile (../info/sc.info): Rename from ../info/sc.
 	(TEXI2DVI): New variable.
 	(emacs.dvi, cl.dvi forms.dvi, sc.dvi, vip.dvi, gnus.dvi, info.dvi):
 	Add explicit commands.
@@ -1108,7 +1162,7 @@
 
 1993-11-15  Paul Eggert  (eggert@twinsun.com)
 
-	* man/Makefile (../info/cl.info): Renamed from ../info/cl.
+	* man/Makefile (../info/cl.info): Rename from ../info/cl.
 
 1993-11-15  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
 
@@ -1122,7 +1176,7 @@
 1993-10-25  Brian Fox  (bfox@albert.gnu.ai.mit.edu)
 
 	* forms.texi: Fix forms.texi so that it will format correctly.
-	Added missing `@end iftex', fixed bad reference.
+	Add missing `@end iftex', fix bad reference.
 
 	* info.texi, info-stn.texi: New files implement texinfo version of
 	`info' file.
@@ -1135,7 +1189,7 @@
 	* Makefile: Fix targets for texindex, new info.texi files.
 	* info-stnd.texi: New file implements info for standalone info
 	reader.
-	* info.texi: Updated to include recent changes to "../info/info".
+	* info.texi: Update to include recent changes to "../info/info".
 	New source file for ../info/info; includes info-stnd.texi.
 
 	* texindex.c: Include "../src/config.h" if building in emacs.
@@ -1155,8 +1209,8 @@
 
 	* sc.texinfo: Fix info file name.
 
-	* Makefile (info): Added gnus and sc.
-	(dvi): Added gnus.dvi and sc.dvi.
+	* Makefile (info): Add gnus and sc.
+	(dvi): Add gnus.dvi and sc.dvi.
 	(../info/sc, sc.dvi): New targets.
 
 1993-08-08  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
@@ -1228,42 +1282,42 @@
 
 1993-04-25  Eric S. Raymond  (eric@mole.gnu.ai.mit.edu)
 
-	* basic.texi: Documented next-line-add-lines variable used to
+	* basic.texi: Document next-line-add-lines variable used to
 	implement down-arrow.
 
-	* killing.texi: Documented kill-whole-line.
+	* killing.texi: Document kill-whole-line.
 
 1993-04-18  Noah Friedman  (friedman@nutrimat.gnu.ai.mit.edu)
 
-	* text.texi: Updated unix TeX ordering information.
+	* text.texi: Update unix TeX ordering information.
 
 1993-03-26  Eric S. Raymond  (eric@geech.gnu.ai.mit.edu)
 
-	* news.texi: Mentioned fill-rectangle in keybinding list.
+	* news.texi: Mention fill-rectangle in keybinding list.
 
-	* killing.texi: Documented fill-rectangle.
+	* killing.texi: Document fill-rectangle.
 
 1993-03-17  Eric S. Raymond  (eric@mole.gnu.ai.mit.edu)
 
-	* vc.texi: Brought the docs up to date with VC 5.2.
+	* vc.texi: Bring the docs up to date with VC 5.2.
 
 1992-01-10  Eric S. Raymond  (eric@mole.gnu.ai.mit.edu)
 
-	* emacs.tex: Mentioned blackbox and gomoku under Amusements.
-		     Assembler mode is now mentioned and appropriately
-		     indexed under Programming Modes.
+	* emacs.tex: Mention blackbox and gomoku under Amusements.
+	Assembler mode is now mentioned and appropriately indexed
+	under Programming Modes.
 
 1991-02-15  Robert J. Chassell  (bob@wookumz.ai.mit.edu)
 
-        * emacs.tex: Updated TeX ordering information.
+	* emacs.tex: Update TeX ordering information.
 
 1990-08-30  David Lawrence  (tale@pogo.ai.mit.edu)
 
-	* gnus.texinfo:  New file.  Removed installation instructions.
+	* gnus.texinfo: New file.  Removed installation instructions.
 
 1990-06-26  David Lawrence  (tale@geech)
 
-	* emacs.tex:  Noted that completion-ignored-extensions is not used
+	* emacs.tex:  Note that completion-ignored-extensions is not used
 	to filter out names when all completions are displayed in
 	*Completions*.
 
@@ -1277,22 +1331,22 @@
 
 1989-01-17  Robert J. Chassell  (bob@rice-chex.ai.mit.edu)
 
-	* texinfo.tex:  Changed spelling of `\sc' font to `\smallcaps' and
-	then defined `\sc' as the command for smallcaps in Texinfo.  This
-	measns that the @sc command will produce small caps.  bfox has
+	* texinfo.tex: Change spelling of `\sc' font to `\smallcaps' and
+	then define `\sc' as the command for smallcaps in Texinfo.  This
+	means that the @sc command will produce small caps.  bfox has
 	made the corresponding change to makeinfo and texinfm.el.
 
 1988-08-16  Robert J. Chassell  (bob@frosted-flakes.ai.mit.edu)
 
-	* emacs.tex:  Corrected two typos.  No other changes before
+	* emacs.tex: Correct two typos.  No other changes before
 	Version 19 will be made.
 
-	* vip.texinfo: Removed menu entry Adding Lisp Code in node
+	* vip.texinfo: Remove menu entry Adding Lisp Code in node
 	Customization since the menu entry did not point to anything.
-	Also added an @finalout command to remove overfull hboxes from the
+	Also add an @finalout command to remove overfull hboxes from the
 	printed output.
 
-	* cl.texinfo:  Added @bye, \input line and @settitle to file.
+	* cl.texinfo:  Add @bye, \input line and @settitle to file.
 	This file is clearly intended to be a chapter of some other work,
 	but the other work does not yet exist.
 
--- a/man/Makefile.in	Sun May 30 21:11:48 2004 +0000
+++ b/man/Makefile.in	Mon May 31 13:48:26 2004 +0000
@@ -40,13 +40,14 @@
 		../info/efaq ../info/ada-mode ../info/autotype ../info/calc \
 		../info/idlwave ../info/eudc ../info/ebrowse ../info/pcl-cvs \
 		../info/woman ../info/emacs-mime ../info/eshell \
-		../info/speedbar ../info/tramp ../info/ses ../info/smtpmail
+		../info/speedbar ../info/tramp ../info/ses ../info/smtpmail \
+		../info/flymake
 DVI_TARGETS = 	emacs.dvi calc.dvi cc-mode.dvi cl.dvi dired-x.dvi \
 		 ediff.dvi forms.dvi gnus.dvi message.dvi mh-e.dvi \
 		 reftex.dvi sc.dvi vip.dvi viper.dvi widget.dvi faq.dvi \
 		 ada-mode.dvi autotype.dvi idlwave.dvi eudc.dvi ebrowse.dvi \
 		 pcl-cvs.dvi woman.dvi emacs-mime.dvi eshell.dvi \
-		 speedbar.dvi tramp.dvi ses.dvi smtpmail.dvi
+		 speedbar.dvi tramp.dvi ses.dvi smtpmail.dvi flymake.dvi
 INFOSOURCES = info.texi
 
 # The following rule does not work with all versions of `make'.
@@ -287,6 +288,11 @@
 smtpmail.dvi: smtpmail.texi
 	$(ENVADD) $(TEXI2DVI) ${srcdir}/smtpmail.texi
 
+../info/flymake: flymake.texi
+	cd $(srcdir); $(MAKEINFO) flymake.texi
+flymake.dvi: flymake.texi
+	$(ENVADD) $(TEXI2DVI) ${srcdir}/flymake.texi
+
 mostlyclean:
 	rm -f *.log *.cp *.fn *.ky *.pg *.vr core *.tp *.core gnustmp.*
 
--- a/man/cc-mode.texi	Sun May 30 21:11:48 2004 +0000
+++ b/man/cc-mode.texi	Mon May 31 13:48:26 2004 +0000
@@ -354,7 +354,7 @@
 indented to the same level as the previous one, and @kbd{TAB}
 (@code{c-indent-command}) adjusts the indentation in steps of
 @code{c-basic-offset}.  The indentation style has no effect, nor any of
-the indentation associated variables, e.g. @code{c-special-indent-hook}.
+the indentation associated variables, e.g., @code{c-special-indent-hook}.
 @end defopt
 
 @menu
@@ -381,7 +381,7 @@
 a @dfn{syntactic symbol}, the second being a @dfn{relative
 buffer position}.  Syntactic symbols describe elements of C code
 @footnote{Unless otherwise noted, the term ``C code'' refers to all
-the C-like languages.}, e.g. @code{statement}, @code{substatement},
+the C-like languages.}, e.g., @code{statement}, @code{substatement},
 @code{class-open}, @code{class-close}, etc.  @xref{Syntactic Symbols},
 for a complete list of currently recognized syntactic symbols and their
 semantics.  The style variable @code{c-offsets-alist} also contains the
@@ -411,7 +411,7 @@
 @code{c-show-syntactic-information}) to simply report what the
 syntactic analysis is for the current line.  Running this command on
 line 4 of this example, we'd see in the echo area@footnote{With a
-universal argument (i.e. @kbd{C-u C-c C-s}) the analysis is inserted
+universal argument (i.e., @kbd{C-u C-c C-s}) the analysis is inserted
 into the buffer as a comment on the current line.}:
 
 @example
@@ -677,7 +677,7 @@
 whitespace} since they are usually ignored when scanning C code.}.
 
 @item
-No numeric argument was supplied to the command (i.e. it was typed as
+No numeric argument was supplied to the command (i.e., it was typed as
 normal, with no @kbd{C-u} prefix).
 @end itemize
 
@@ -702,7 +702,7 @@
 @kindex @{
 @kindex @}
 
-When you type either an open or close brace (i.e. @kbd{@{} or @kbd{@}}),
+When you type either an open or close brace (i.e., @kbd{@{} or @kbd{@}}),
 the electric command @code{c-electric-brace} gets run.  This command has
 two electric formatting behaviors.  First, it will perform some
 reindentation of the line the brace was typed on, and second, it will
@@ -973,7 +973,7 @@
 @dfn{Clean-ups} are mechanisms complementary to colon and brace hanging.
 On the surface, it would seem that clean-ups overlap the functionality
 provided by the @code{c-hanging-*-alist} variables.  Clean-ups are
-however used to adjust code ``after-the-fact,'' i.e. to adjust the
+however used to adjust code ``after-the-fact,'' i.e., to adjust the
 whitespace in constructs after they are typed.
 
 Most of the clean-ups are only applicable to counteract automatically
@@ -1146,7 +1146,7 @@
 @item space-before-funcall
 Insert a space between the function name and the opening parenthesis of
 a function call.  This produces function calls in the style mandated by
-the GNU coding standards, e.g. @samp{signal (SIGINT, SIG_IGN)} and
+the GNU coding standards, e.g., @samp{signal (SIGINT, SIG_IGN)} and
 @samp{abort ()}.  Clean up occurs when the opening parenthesis is typed.
 
 @item compact-empty-funcall
@@ -1154,7 +1154,7 @@
 of a function call that has no arguments.  This is typically used
 together with @code{space-before-funcall} if you prefer the GNU function
 call style for functions with arguments but think it looks ugly when
-it's only an empty parenthesis pair.  I.e. you will get @samp{signal
+it's only an empty parenthesis pair.  I.e., you will get @samp{signal
 (SIGINT, SIG_IGN)}, but @samp{abort()}.  Clean up occurs when the
 closing parenthesis is typed.
 @end table
@@ -1278,7 +1278,7 @@
 
 Since there's a lot of normal text in comments and string literals,
 @ccmode{} provides features to edit these like in text mode.  The goal
-is to do it as seamlessly as possible, i.e. you can use auto fill mode,
+is to do it as seamlessly as possible, i.e., you can use auto fill mode,
 sentence and paragraph movement, paragraph filling, adaptive filling etc
 wherever there's a piece of normal text without having to think much
 about it.  @ccmode{} should keep the indentation, fix the comment line
@@ -1333,7 +1333,7 @@
 @noindent
 with zero or more stars at the beginning of every line.  If you change
 this variable, please make sure it still matches the comment starter
-(i.e. @code{//}) of line comments @emph{and} the line prefix inside
+(i.e., @code{//}) of line comments @emph{and} the line prefix inside
 block comments.
 
 @findex c-setup-paragraph-variables
@@ -1352,7 +1352,7 @@
 @cindex paragraph filling
 Line breaks are by default handled (almost) the same regardless whether
 they are made by auto fill mode (@pxref{Auto Fill,,, emacs, The Emacs
-Editor}), paragraph filling (e.g. with @kbd{M-q}), or explicitly with
+Editor}), paragraph filling (e.g., with @kbd{M-q}), or explicitly with
 @kbd{M-j} or similar methods.  In string literals, the new line gets the
 same indentation as the previous nonempty line (may be changed with the
 @code{string} syntactic symbol).  In comments, @ccmode{} uses
@@ -1364,7 +1364,7 @@
 @ccmode{} uses adaptive fill mode (@pxref{Adaptive Fill,,, emacs, The
 Emacs Editor}) to make Emacs correctly keep the line prefix when filling
 paragraphs.  That also makes Emacs preserve the text indentation
-@emph{inside} the comment line prefix.  E.g. in the following comment,
+@emph{inside} the comment line prefix.  e.g., in the following comment,
 both paragraphs will be filled with the left margins of the texts kept
 intact:
 
@@ -1394,7 +1394,7 @@
 @uref{http://cc-mode.sourceforge.net/,, the CC Mode web site}.},
 which handles things like bulleted lists nicely.  There's a convenience
 function @code{c-setup-filladapt} that tunes the relevant variables in
-Filladapt for use in @ccmode{}.  Call it from a mode hook, e.g. with
+Filladapt for use in @ccmode{}.  Call it from a mode hook, e.g., with
 something like this in your @file{.emacs}:
 
 @example
@@ -1443,7 +1443,7 @@
 @defopt c-ignore-auto-fill
 @vindex ignore-auto-fill (c-)
 When auto fill mode is enabled, @ccmode{} can selectively ignore it
-depending on the context the line break would occur in, e.g. to never
+depending on the context the line break would occur in, e.g., to never
 break a line automatically inside a string literal.  This variable
 takes a list of symbols for the different contexts where auto-filling
 never should occur:
@@ -1458,7 +1458,7 @@
 @item cpp
 Inside a preprocessor directive.
 @item code
-Anywhere else, i.e. in normal code.
+Anywhere else, i.e., in normal code.
 @end table
 
 By default, @code{c-ignore-auto-fill} is set to @code{'(string cpp
@@ -1514,7 +1514,7 @@
 startup.  The reason is that @kbd{M-j} could otherwise produce sequences
 of single line block comments for texts that should logically be treated
 as one comment, and the rest of the paragraph handling code
-(e.g. @kbd{M-q} and @kbd{M-a}) can't cope with that, which would lead to
+(e.g., @kbd{M-q} and @kbd{M-a}) can't cope with that, which would lead to
 inconsistent behavior.
 
 @item @kbd{M-x c-context-line-break}
@@ -1523,7 +1523,7 @@
 This is a function that works like @code{indent-new-comment-line} in
 comments and @code{newline-and-indent} elsewhere, thus combining those
 two in a way that uses each one in the context it's best suited for.
-I.e. in comments the comment line prefix and indentation is kept for
+I.e., in comments the comment line prefix and indentation is kept for
 the new line, and in normal code it's indented according to context by
 the indentation engine.
 
@@ -1540,7 +1540,7 @@
 @findex c-context-open-line
 @findex context-open-line (c-)
 This is to @kbd{C-o} (@kbd{M-x open-line}) as
-@code{c-context-line-break} is to @kbd{RET}.  I.e. it works just like
+@code{c-context-line-break} is to @kbd{RET}.  I.e., it works just like
 @code{c-context-line-break} but leaves the point before the inserted
 line break.
 @end table
@@ -1555,13 +1555,13 @@
 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
 Preprocessor directives are handled as syntactic whitespace from other
-code, i.e. they can be interspersed anywhere without affecting the
+code, i.e., they can be interspersed anywhere without affecting the
 syntactic analysis, just like comments.
 
 The code inside macro definitions is still analyzed syntactically so
 that you get relative indentation there just as you'd get if the same
 code was outside a macro.  However, since there is no hint about the
-syntactic context, i.e. whether the macro expands to an expression, to some
+syntactic context, i.e., whether the macro expands to an expression, to some
 statements, or perhaps to whole functions, the syntactic recognition can be
 wrong.  @ccmode{} manages to figure it out correctly most of the time,
 though.  @xref{Syntactic Symbols}, for details about the indentation.
@@ -1601,7 +1601,7 @@
 These variables control the alignment columns for line continuation
 backslashes in multiline macros.  They are used by the functions that
 automatically insert or align such backslashes,
-e.g. @code{c-backslash-region} and @code{c-context-line-break}.
+e.g., @code{c-backslash-region} and @code{c-context-line-break}.
 
 @code{c-backslash-column} specifies the minimum column for the
 backslashes.  If any line in the macro exceeds it then the next tab
@@ -1616,7 +1616,7 @@
 @vindex auto-align-backslashes (c-)
 Align automatically inserted line continuation backslashes if
 non-@code{nil}.  When line continuation backslashes are inserted
-automatically for line breaks in multiline macros, e.g. by
+automatically for line breaks in multiline macros, e.g., by
 @code{c-context-line-break}, they are aligned with the other backslashes
 in the same macro if this flag is set.  Otherwise the inserted
 backslashes are preceded by a single space.
@@ -1738,7 +1738,7 @@
 For each language there's a variable @code{*-font-lock-extra-types},
 where @samp{*} stands for the language in question.  It contains a list
 of regexps that matches identifiers that should be recognized as types,
-e.g. @samp{\\sw+_t} to recognize all identifiers ending with @samp{_t}
+e.g., @samp{\\sw+_t} to recognize all identifiers ending with @samp{_t}
 as is customary in C code.  Each regexp should not match more than a
 single identifier.
 
@@ -1835,7 +1835,7 @@
 @vindex font-lock-builtin-face
 @vindex font-lock-reference-face
 Preprocessor directives get @code{font-lock-preprocessor-face} if it
-exists (i.e. XEmacs).  In Emacs they get @code{font-lock-builtin-face}
+exists (i.e., XEmacs).  In Emacs they get @code{font-lock-builtin-face}
 or @code{font-lock-reference-face}, for lack of a closer equivalent.
 
 @item
@@ -1861,14 +1861,14 @@
 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
 There are various tools to supply documentation in the source as
-specially structured comments, e.g. the standard Javadoc tool in Java.
+specially structured comments, e.g., the standard Javadoc tool in Java.
 @ccmode{} provides an extensible mechanism to fontify such comments and
 the special markup inside them.
 
 @defopt c-doc-comment-style
 @vindex doc-comment-style (c-)
 This is a style variable that specifies which documentation comment
-style to recognize, e.g. @code{javadoc} for Javadoc comments.
+style to recognize, e.g., @code{javadoc} for Javadoc comments.
 
 The value may also be a list of styles, in which case all of them are
 recognized simultaneously (presumably with markup cues that don't
@@ -1883,7 +1883,7 @@
 Note that @ccmode{} uses this variable to set other variables that
 handle fontification etc.  That's done at mode initialization or when
 you switch to a style which sets this variable.  Thus, if you change it
-in some other way, e.g. interactively in a CC Mode buffer, you will need
+in some other way, e.g., interactively in a CC Mode buffer, you will need
 to do @kbd{M-x java-mode} (or whatever mode you're currently using) to
 reinitialize.
 
@@ -1993,7 +1993,7 @@
 encompassing point.  It leaves point unchanged.  This function can't be
 used to reindent a nested brace construct, such as a nested class or
 function, or a Java method.  The top-level construct being reindented
-must be complete, i.e. it must have both a beginning brace and an ending
+must be complete, i.e., it must have both a beginning brace and an ending
 brace.
 
 @item @kbd{C-M-\} (@code{indent-region})
@@ -2239,7 +2239,7 @@
 A popular programming style, especially for object-oriented languages
 such as C++ is to write symbols in a mixed case format, where the first
 letter of each word is capitalized, and not separated by underscores.
-E.g. @samp{SymbolsWithMixedCaseAndNoUnderlines}.
+e.g., @samp{SymbolsWithMixedCaseAndNoUnderlines}.
 
 This command moves point forward to next capitalized word.  With prefix
 argument @var{n}, move @var{n} times.
@@ -2295,7 +2295,7 @@
 Only syntactic symbols not already bound on @code{c-offsets-alist} will
 be set from styles.  This means that any association you set on it, be
 it before or after mode initialization, will not be changed.  The
-@code{c-offsets-alist} variable may therefore be used from e.g. the
+@code{c-offsets-alist} variable may therefore be used from e.g., the
 Customization interface@footnote{Available in Emacs 20 and later, and
 XEmacs 19.15 and later.} to easily change indentation offsets without
 having to bother about styles.  Initially @code{c-offsets-alist} is
@@ -2563,7 +2563,7 @@
 
 Variables set like this at the top level in @file{.emacs} take effect in
 all @ccmode{} buffers, regardless of language.  The indentation style
-related variables, e.g. @code{c-offsets-alist}, that you don't set this
+related variables, e.g., @code{c-offsets-alist}, that you don't set this
 way get their value from the style system (@pxref{Styles}), and they
 therefore depend on the setting of @code{c-default-style}.  Note that if
 you use Customize, this means that the greyed-out default values
@@ -2571,7 +2571,7 @@
 values depend on the style, which may very well be different for
 different languages.
 
-If you want to make more advanced configurations, e.g. language-specific
+If you want to make more advanced configurations, e.g., language-specific
 customization, setting global variables isn't enough.  For that you can
 use the language hooks, see @ref{Hooks}, and/or the style system, see
 @ref{Styles}.
@@ -2940,8 +2940,8 @@
 automatically institute these offsets using @code{c-set-offset}.
 @end defvar
 
-Note that file style settings (i.e. @code{c-file-style}) are applied
-before file offset settings (i.e. @code{c-file-offsets}).  Also, if
+Note that file style settings (i.e., @code{c-file-style}) are applied
+before file offset settings (i.e., @code{c-file-offsets}).  Also, if
 either of these are set in a file's local variable section, all the
 style variable values are made local to that buffer.
 
@@ -3086,7 +3086,7 @@
 syntactic symbol for the brace, and the buffer position at which the
 brace was inserted.  The @var{action} function is expected to return a
 list containing some combination of @code{before} and @code{after},
-including neither of them (i.e. @code{nil}).  This return value has the
+including neither of them (i.e., @code{nil}).  This return value has the
 normal brace hanging semantics.
 
 As an example, @ccmode{} itself uses this feature to dynamically
@@ -3181,7 +3181,7 @@
 If every function in the list is called without a determination being
 made, then no newline is added. The default value for this variable is a
 list containing a single function which inserts newlines only after
-semicolons which do not appear inside parenthesis lists (i.e. those
+semicolons which do not appear inside parenthesis lists (i.e., those
 that separate @code{for}-clause statements).
 @end defopt
 
@@ -3215,7 +3215,7 @@
 @ccmode{} also comes with the criteria function
 @code{c-semi&comma-no-newlines-for-oneline-inliners}, which suppresses
 newlines after semicolons inside one-line inline method definitions
-(e.g. in C++ or Java).
+(e.g., in C++ or Java).
 @end defun
 
 
@@ -3242,7 +3242,7 @@
 indentation or line adjustments your style dictates, such as adding
 extra indentation to constructors or destructor declarations in a
 class definition, etc.  Note that you should not change point or mark
-inside your @code{c-special-indent-hook} functions, i.e. you'll
+inside your @code{c-special-indent-hook} functions, i.e., you'll
 probably want to wrap your function in a @code{save-excursion}.
 
 Setting @code{c-special-indent-hook} in your style definition is
@@ -3388,7 +3388,7 @@
 @item objc-method-call-cont
 Lines continuing an Objective-C method call.
 @item extern-lang-open
-Brace that opens an @code{extern} block (e.g. @code{extern "C" @{...@}}).
+Brace that opens an @code{extern} block (e.g., @code{extern "C" @{...@}}).
 @item extern-lang-close
 Brace that closes an @code{extern} block.
 @item inextern-lang
@@ -3411,9 +3411,9 @@
 C++ template argument list continuations.
 @item inlambda
 Analogous to @code{inclass} syntactic symbol, but used inside lambda
-(i.e. anonymous) functions.  Only used in Pike mode.
+(i.e., anonymous) functions.  Only used in Pike mode.
 @item lambda-intro-cont
-Lines continuing the header of a lambda function, i.e. between the
+Lines continuing the header of a lambda function, i.e., between the
 @code{lambda} keyword and the function body.  Only used in Pike mode.
 @item inexpr-statement
 A statement block inside an expression.  The gcc C extension of this is
@@ -3468,7 +3468,7 @@
 the brace that opens a top-level function definition.  Line 9 is the
 corresponding
 @code{defun-close} since it contains the brace that closes the top-level
-function definition.  Line 4 is a @code{defun-block-intro}, i.e. it is
+function definition.  Line 4 is a @code{defun-block-intro}, i.e., it is
 the first line of a brace-block, enclosed in a
 top-level function definition.
 
@@ -3793,7 +3793,7 @@
 
 There are various other top level blocks like @code{extern}, and they
 are all treated in the same way except that the symbols are named after
-the keyword that introduces the block.  E.g. C++ namespace blocks get
+the keyword that introduces the block.  e.g., C++ namespace blocks get
 the three symbols @code{namespace-open}, @code{namespace-close} and
 @code{innamespace}.  The currently recognized top level blocks are:
 
@@ -3950,9 +3950,9 @@
 @cindex syntactic whitespace
 @ssindex cpp-define-intro
 Multiline preprocessor macro definitions are normally handled just like
-other code, i.e. the lines inside them are indented according to the
+other code, i.e., the lines inside them are indented according to the
 syntactic analysis of the preceding lines inside the macro.  The first
-line inside a macro definition (i.e. the line after the starting line of
+line inside a macro definition (i.e., the line after the starting line of
 the cpp directive itself) gets @code{cpp-define-intro}.  In this example:
 
 @example
@@ -3968,7 +3968,7 @@
 of a cpp directive is always given that symbol.  Line 2 is given
 @code{cpp-define-intro}, so that you can give the macro body as a whole
 some extra indentation.  Lines 3 through 5 are then analyzed as normal
-code, i.e. @code{substatement} on lines 3 and 4, and @code{else-clause}
+code, i.e., @code{substatement} on lines 3 and 4, and @code{else-clause}
 on line 5.
 
 The syntactic analysis inside macros can be turned off with
@@ -4094,7 +4094,7 @@
 
 Here, line 2 is the first line in an argument declaration list and so is
 given the @code{knr-argdecl-intro} syntactic symbol.  Subsequent lines
-(i.e. lines 3 and 4 in this example), are given @code{knr-argdecl}
+(i.e., lines 3 and 4 in this example), are given @code{knr-argdecl}
 syntax.
 
 
@@ -4322,7 +4322,7 @@
 
 Since this function doesn't do anything for lines without an infix
 operator you typically want to use it together with some other lineup
-settings, e.g. as follows (the @code{arglist-close} setting is just a
+settings, e.g., as follows (the @code{arglist-close} setting is just a
 suggestion to get a consistent style):
 
 @example
@@ -4383,7 +4383,7 @@
 @end example
 
 The style variable @code{c-comment-prefix-regexp} is used to recognize
-the comment line prefix, e.g. the @samp{*} that usually starts every
+the comment line prefix, e.g., the @samp{*} that usually starts every
 line inside a comment.
 
 @workswith The @code{c} syntactic symbol.
@@ -4512,7 +4512,7 @@
 
 If @code{c-syntactic-indentation-in-macros} is non-@code{nil}, the
 function returns the relative indentation to the macro start line to
-allow accumulation with other offsets.  E.g. in the following cases,
+allow accumulation with other offsets.  e.g., in the following cases,
 @code{cpp-define-intro} is combined with the
 @code{statement-block-intro} that comes from the @samp{do @{} that hangs
 on the @samp{#define} line:
@@ -4611,7 +4611,7 @@
 @defun c-lineup-inexpr-block
 @findex lineup-inexpr-block (c-)
 This can be used with the in-expression block symbols to indent the
-whole block to the column where the construct is started.  E.g. for Java
+whole block to the column where the construct is started.  e.g., for Java
 anonymous classes, this lines up the class under the @samp{new} keyword,
 and in Pike it lines up the lambda function body under the @samp{lambda}
 keyword.  Returns @code{nil} if the block isn't part of such a
@@ -4828,7 +4828,7 @@
 
 @defun c-lineup-streamop
 @findex lineup-streamop (c-)
-Line up C++ stream operators (i.e. @samp{<<} and @samp{>>}).
+Line up C++ stream operators (i.e., @samp{<<} and @samp{>>}).
 
 @workswith @code{stream-op}.
 @end defun
@@ -4956,7 +4956,7 @@
 @workswith @code{defun-close}, @code{defun-block-intro},
 @code{block-close}, @code{brace-list-close}, @code{brace-list-intro},
 @code{statement-block-intro} and all @code{in*} symbols,
-e.g. @code{inclass} and @code{inextern-lang}.
+e.g., @code{inclass} and @code{inextern-lang}.
 @end defun
 
 
@@ -5050,7 +5050,7 @@
 work on AWK ``defuns''.
 
 Since there is no preprocessor in AWK, the commands which move to
-preprocessor directives (e.g. @code{c-up-conditional}) are meaningless
+preprocessor directives (e.g., @code{c-up-conditional}) are meaningless
 in AWK mode and are not bound in the AWK mode keymap.
 
 @item Auto-newline Insertion and Clean-ups
@@ -5230,7 +5230,7 @@
 
 The default is to set @code{require-final-newline} to @code{t} in the
 languages that mandates that source files should end with newlines,
-i.e. C, C++ and Objective-C.
+i.e., C, C++ and Objective-C.
 @end defopt
 
 @defopt c-echo-syntactic-information-p
@@ -5271,9 +5271,9 @@
 section gives some insight in how @ccmode{} operates, how that interacts
 with some coding styles, and what you can use to improve performance.
 
-The overall goal is that @ccmode{} shouldn't be overly slow (i.e. take
+The overall goal is that @ccmode{} shouldn't be overly slow (i.e., take
 more than a fraction of a second) in any interactive operation.
-I.e. it's tuned to limit the maximum response time in single operations,
+i.e., it's tuned to limit the maximum response time in single operations,
 which sometimes is at the expense of batch-like operations like
 reindenting whole blocks.  If you find that @ccmode{} gradually gets
 slower and slower in certain situations, perhaps as the file grows in
@@ -5292,7 +5292,7 @@
 @findex beginning-of-defun
 @findex defun-prompt-regexp
 One of the simplest things you can do to reduce scan time, is make sure
-any brace that opens a top-level construct@footnote{E.g. a function in
+any brace that opens a top-level construct@footnote{e.g., a function in
 C, or outermost class definition in C++ or Java.} always appears in the
 leftmost column.  This is actually an Emacs constraint, as embodied in
 the @code{beginning-of-defun} function which @ccmode{} uses heavily.  If
@@ -5334,7 +5334,7 @@
 tells @ccmode{} to use XEmacs-specific built-in functions which, in some
 circumstances, can locate the top-most opening brace much more quickly than
 @code{beginning-of-defun}.  Preliminary testing has shown that for
-styles where these braces are hung (e.g. most JDK-derived Java styles),
+styles where these braces are hung (e.g., most JDK-derived Java styles),
 this hack can improve performance of the core syntax parsing routines
 from 3 to 60 times.  However, for styles which @emph{do} conform to
 Emacs' recommended style of putting top-level braces in column zero,
@@ -5345,7 +5345,7 @@
 21.3 as of this writing in May 2003).
 
 Text properties are used to speed up skipping over syntactic whitespace,
-i.e. comments and preprocessor directives.  Indenting a line after a
+i.e., comments and preprocessor directives.  Indenting a line after a
 huge macro definition can be slow the first time, but after that the
 text properties are in place and it should be fast (even after you've
 edited other parts of the file and then moved back).
@@ -5353,7 +5353,7 @@
 Font locking can be a CPU hog, especially the font locking done on
 decoration level 3 which tries to be very accurate.  Note that that
 level is designed to be used with a font lock support mode that only
-fontifies the text that's actually shown, i.e. Lazy Lock or Just-in-time
+fontifies the text that's actually shown, i.e., Lazy Lock or Just-in-time
 Lock mode, so make sure you use one of them.  Fontification of a whole
 buffer with some thousand lines can often take over a minute.  That is
 a known weakness; the idea is that it never should happen.
@@ -5386,7 +5386,7 @@
 intention to change this goal.
 
 If you want to reformat old code, you're probably better off using some
-other tool instead, e.g. @ref{Top, , GNU indent, indent, The `indent'
+other tool instead, e.g., @ref{Top, , GNU indent, indent, The `indent'
 Manual}, which has more powerful reformatting capabilities than
 @ccmode{}.
 
@@ -5526,7 +5526,7 @@
 you think it might affect our ability to reproduce it.
 
 Please try to produce the problem in an Emacs instance without any
-customizations loaded (i.e. start it with the @code{-q -no-site-file}
+customizations loaded (i.e., start it with the @samp{-q --no-site-file}
 arguments).  If it works correctly there, the problem might be caused by
 faulty customizations in either your own or your site configuration.  In
 that case, we'd appreciate if you isolate the Emacs Lisp code that trigs
--- a/man/cl.texi	Sun May 30 21:11:48 2004 +0000
+++ b/man/cl.texi	Mon May 31 13:48:26 2004 +0000
@@ -50,7 +50,7 @@
 @end titlepage
 
 @node Top, Overview, (dir), (dir)
-@chapter Overview
+@chapter Introduction
 
 @noindent
 This document describes a set of Emacs Lisp facilities borrowed from
@@ -82,12 +82,9 @@
 @end menu
 
 @node Overview, Program Structure, Top, Top
-@ifinfo
+@ifnottex
 @chapter Overview
-@end ifinfo
-@iftex
-@section Overview
-@end iftex
+@end ifnottex
 
 @noindent
 Common Lisp is a huge language, and Common Lisp systems tend to be
--- a/man/custom.texi	Sun May 30 21:11:48 2004 +0000
+++ b/man/custom.texi	Mon May 31 13:48:26 2004 +0000
@@ -1946,7 +1946,7 @@
 @file{site-start.el}, if it exists.  Like @file{default.el}, Emacs
 finds this file via the standard search path for Lisp libraries.
 Emacs loads this library before it loads your init file.  To inhibit
-loading of this library, use the option @samp{-no-site-file}.
+loading of this library, use the option @samp{--no-site-file}.
 @xref{Initial Options}.
 
   You can place @file{default.el} and @file{site-start.el} in any of
--- a/man/emacs.texi	Sun May 30 21:11:48 2004 +0000
+++ b/man/emacs.texi	Mon May 31 13:48:26 2004 +0000
@@ -541,7 +541,6 @@
 * Hungry Delete::       A more powerful DEL command.
 * Other C Commands::    Filling comments, viewing expansion of macros,
                           and other neat features.
-* Comments in C::       Options for customizing comment style.
 
 Fortran Mode
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/man/flymake.texi	Mon May 31 13:48:26 2004 +0000
@@ -0,0 +1,771 @@
+\input texinfo   @c -*-texinfo-*-
+@comment %**start of header
+@setfilename ../info/flymake
+@set VERSION 0.3
+@set UPDATED April 2004
+@settitle GNU Flymake @value{VERSION}
+@syncodeindex pg cp
+@comment %**end of header
+
+@copying
+This manual is for GNU Flymake (version @value{VERSION}, @value{UPDATED}),
+which is a universal on-the-fly syntax checker for GNU Emacs.
+
+Copyright @copyright{} 2004 Free Software Foundation, Inc.
+
+@quotation
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.1 or
+any later version published by the Free Software Foundation; with no
+Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
+and with the Back-Cover Texts as in (a) below.  A copy of the license
+is included in the section entitled ``GNU Free Documentation License''
+in the Emacs manual.
+
+(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
+this GNU Manual, like GNU software.  Copies published by the Free
+Software Foundation raise funds for GNU development.''
+
+This document is part of a collection distributed under the GNU Free
+Documentation License.  If you want to distribute this document
+separately from the collection, you can do so by adding a copy of the
+license to the document, as described in section 6 of the license.
+@end quotation
+@end copying
+
+@dircategory Emacs
+@direntry
+* Flymake: (flymake). A universal on-the-fly syntax checker.
+@end direntry
+
+@titlepage
+@title GNU Flymake
+@subtitle for version @value{VERSION}, @value{UPDATED}
+@author Pavel Kobiakov(@email{pk_at_work@@yahoo.com})
+@page
+@vskip 0pt plus 1filll
+@end titlepage
+
+@contents
+
+@ifnottex
+@node Top
+@top GNU Flymake
+@end ifnottex
+
+@menu
+* Overview of Flymake::
+* Obtaining Flymake::
+* Installing Flymake::
+* Using Flymake::
+* Configuring Flymake::
+* Flymake Implementation::
+* Index::
+@end menu
+
+@node Overview of Flymake
+@chapter Overview
+@cindex Overview of Flymake
+
+Flymake is a universal on-the-fly syntax checker implemented as an
+Emacs minor mode. Flymake runs the pre-configured syntax check tool
+(compiler for C++ files, @code{perl} for perl files, etc.) in the
+background, passing it a temporary copy of the current buffer, and
+parses the output for known error/warning message patterns. Flymake
+then highlights erroneous lines (i.e. lines for which at least one
+error or warning has been reported by the syntax check tool), and
+displays an overall buffer status in the mode line. Status information
+displayed by Flymake contains total number of errors and warnings
+reported for the buffer during the last syntax check.
+
+@code{flymake-goto-next-error} and @code{flymake-goto-prev-error}
+functions allow for easy navigation to the next/previous erroneous
+line, respectively.
+
+Calling @code{flymake-display-err-menu-for-current-line} will popup a
+menu containing error messages reported by the syntax check tool for
+the current line. Errors/warnings belonging to another file, such as a
+@code{.h} header file included by a @code{.c} file, are shown in the
+current buffer as belonging to the first line. Menu items for such
+messages also contain a filename and a line number. Selecting such a
+menu item will automatically open the file and jump to the line with
+error.
+
+Syntax check is done 'on-the-fly'. It is started whenever
+
+@itemize @bullet
+@item buffer is loaded
+@item a newline character is added to the buffer
+@item some changes were made to the buffer more than @code{0.5} seconds ago (the
+delay is configurable).
+@end itemize
+
+Flymake is a universal syntax checker in the sense that it's easily
+extended to support new syntax check tools and error message
+patterns. @xref{Configuring Flymake}.
+
+@node Obtaining Flymake
+@chapter Obtaining Flymake
+@cindex Getting Flymake
+
+Release versions of Flymake can be downloaded from
+@* @url{https://sourceforge.net/project/showfiles.php?group_id=77501}.
+You can also try current version available via CVS at @url{https://}.
+
+Flymake's homepage is at @url{http://flymake.sourceforge.net}.
+
+@node Installing Flymake
+@chapter Installing
+@cindex Installing Flymake
+
+
+Flymake is packaged in a single file, @code{flymake.el}.
+
+To install/update Flymake, place @code{flymake.el} to a directory
+somewhere on Emacs load path. You might also want to byte-compile
+@code{flymake.el} to improve performance.
+
+Also, place the following line in the @code{.emacs} file.
+
+@lisp
+(require 'flymake)
+@end lisp
+
+You might also map the most frequently used Flymake functions, such as
+@code{flymake-goto-next-error}, to some keyboard shortcuts:
+
+@lisp
+(global-set-key [f3] 'flymake-display-err-menu-for-current-line)
+(global-set-key [f4] 'flymake-goto-next-error)
+@end lisp
+
+@node Using Flymake
+@chapter Using Flymake
+@cindex Using Flymake
+
+@menu
+* Flymake mode::
+* Running the syntax check::
+* Navigating to error lines::
+* Viewing error messages::
+* Syntax check statuses::
+* Troubleshooting::
+@end menu
+
+@node Flymake mode
+@section Flymake mode
+@cindex flymake-mode
+
+Flymake is an Emacs minor mode. To use Flymake, you
+must first activate @code{flymake-mode} by using the
+@code{flymake-mode} function.
+
+Instead of manually activating @code{flymake-mode}, you can configure
+Flymake to automatically enable @code{flymake-mode} upon opening any
+file for which syntax check is possible. To do so, place the following
+line in @code{.emacs}:
+
+@lisp
+(add-hook 'find-file-hooks 'flymake-find-file-hook)
+@end lisp
+
+@node Running the syntax check
+@section Running the syntax check
+@cindex Manually starting the syntax check
+
+When @code{flymake-mode} is active, syntax check is started
+automatically on any of the three conditions mentioned above. Syntax
+check can also be started manually by using the
+@code{flymake-start-syntax-check-for-current-buffer} function. This
+can be used, for example, when changes were made to some other buffer
+affecting the current buffer.
+
+@node Navigating to error lines
+@section Navigating to error lines
+@cindex Navigating to error lines
+
+After syntax check is completed, lines for which at least one error or
+warning has been reported are highlighted, and total number of errors
+and warning is shown in the mode line. Use the following functions to
+navigate the highlighted lines.
+
+@multitable @columnfractions 0.25 0.75
+
+@item @code{flymake-goto-next-error}
+@tab Moves point to the next erroneous line, if any.
+
+@item @code{flymake-goto-prev-error}
+@tab Moves point to the previous erroneous line.
+
+@end multitable
+
+These functions treat erroneous lines as a linked list. Therefore,
+@code{flymake-goto-next-error} will go to the first erroneous line
+when invoked in the end of the buffer.
+
+@node Viewing error messages
+@section Viewing error messages
+@cindex Viewing error messages
+
+To view error messages belonging to the current line, use the
+@code{flymake-display-err-menu-for-current-line} function. If there's
+at least one error or warning reported for the current line, this
+function will display a popup menu with error/warning texts.
+Selecting the menu item whose error belongs to another file brings
+forward that file with the help of the
+@code{flymake-goto-file-and-line} function.
+
+@node Syntax check statuses
+@section Syntax check statuses
+@cindex Syntax check statuses
+
+After syntax check is finished, its status is displayed in the mode line.
+The following statuses are defined.
+
+@multitable @columnfractions 0.25 0.75
+@item Flymake* or Flymake:E/W*
+@tab  Flymake is currently running. For the second case, E/W contains the
+      error and warning count for the previous run.
+
+@item Flymake
+@tab  Syntax check is not running. Usually this means syntax check was
+      successfully passed (no errors, no warnings). Other possibilities are:
+      syntax check was killed as a result of executing
+      @code{flymake-compile}, or syntax check cannot start as compilation
+      is currently in progress.
+
+@item Flymake:E/W
+@tab  Number of errors/warnings found by the syntax check process.
+
+@item Flymake:!
+@tab  Flymake was unable to find master file for the current buffer.
+@end multitable
+
+The following errors cause a warning message and switch flymake mode
+OFF for the buffer.
+
+@multitable @columnfractions 0.25 0.75
+@item CFGERR
+@tab  Syntax check process returned nonzero exit code, but no
+      errors/warnings were reported. This indicates a possible configuration
+      error (for example, no suitable error message patterns for the
+      syntax check tool).
+
+@item NOMASTER
+@tab  Flymake was unable to find master file for the current buffer.
+
+@item NOMK
+@tab  Flymake was unable to find a suitable buildfile for the current buffer.
+
+@item PROCERR
+@tab  Flymake was unable to launch a syntax check process.
+@end multitable
+
+
+@node Troubleshooting
+@section Troubleshooting
+@cindex Logging
+@cindex Troubleshooting
+
+Flymake uses a simple logging facility for indicating important points
+in the control flow. The logging facility sends logging messages to
+the @code{*Messages*} buffer. The information logged can be used for
+resolving various problems related to Flymake.
+
+Logging output is controlled by the @code{flymake-log-level}
+variable. @code{3} is the  most verbose level, and @code{-1} switches
+logging off.
+
+@node Configuring Flymake
+@chapter Configuring and Extending Flymake
+@cindex Configuring and Extending Flymake
+
+@menu
+* Customizable variables::
+* Adding support for a new syntax check tool::
+@end menu
+
+Flymake was designed to be easily extended for supporting new syntax
+check tools and error message patterns.
+
+@node Customizable variables
+@section Customizable variables
+@cindex Customizable variables
+
+This section summarises variables used for Flymake
+configuration.
+
+@table @code
+@item flymake-log-level
+Controls logging output, see @ref{Troubleshooting}.
+
+@item flymake-allowed-file-name-masks
+A list of @code{(filename-regexp, init-function, cleanup-function
+getfname-function)} for configuring syntax check tools. @xref{Adding
+support for a new syntax check tool}.
+
+@item flymake-buildfile-dirs
+A list of directories (relative paths) for searching a
+buildfile. @xref{Locating the buildfile}.
+
+@item flymake-master-file-dirs
+A list of directories for searching a master file. @xref{Locating a
+master file}.
+
+@item flymake-get-project-include-dirs-function
+A function used for obtaining a list of project include dirs (C/C++
+specific). @xref{Getting the include directories}.
+
+@item flymake-master-file-count-limit
+@itemx flymake-check-file-limit
+Used when looking for a master file. @xref{Locating a master file}.
+
+@item flymake-err-line-patterns
+Patterns for error/warning messages in the form @code{(regexp file-idx
+line-idx err-text-idx)}. @xref{Parsing the output}.
+
+@item flymake-compilation-prevents-syntax-check
+A flag indicating whether compilation and syntax check of the same
+file cannot be run simultaneously.
+
+@item flymake-no-changes-timeout
+If any changes are made to the buffer, syntax check is automatically
+started after @code{flymake-no-changes-timeout} seconds.
+
+@item flymake-gui-warnings-enabled
+A boolean flag indicating whether Flymake will show message boxes for
+non-recoverable errors. If @code{flymake-gui-warnings-enabled} is
+@code{nil}, these errors will only be logged to the @code{*Messages*}
+buffer.
+
+@item flymake-start-syntax-check-on-newline
+A boolean flag indicating whether to start syntax check after a
+newline character is added to the buffer.
+
+@item flymake-errline-face
+A custom face for highlighting lines for which at least one error has
+been reported.
+
+@item flymake-warnline-face
+A custom face for highlighting lines for which at least one warning
+and no errors have been reported.
+
+@end table
+
+@node Adding support for a new syntax check tool
+@section Adding support for a new syntax check tool
+@cindex Adding support for a new syntax check tool
+
+@menu
+* Example -- Configuring a tool called directly::
+* Example -- Configuring a tool called via make::
+@end menu
+
+Syntax check tools are configured using the
+@code{flymake-allowed-file-name-masks} list. Each item of this list
+has the following format:
+
+@lisp
+(filename-regexp, init-function, cleanup-function, getfname-function)
+@end lisp
+
+@table @code
+@item filename-regexp
+This field is used as a key for locating init/cleanup/getfname
+functions for the buffer.  Items in
+@code{flymake-allowed-file-name-masks} are searched sequentially. The
+first item with @code{filename-regexp} matching buffer filename is
+selected. If no match is found, @code{flymake-mode} is switched off.
+
+@item init-function
+@code{init-function} is required to initialise the syntax check,
+usually by creating a temporary copy of the buffer contents. The
+function must return @code{(list cmd-name arg-list)}. If
+@code{init-function} returns null, syntax check is aborted, by
+@code{flymake-mode} is not switched off.
+
+@item cleanup-function
+@code{cleanup-function} is called after the syntax check process is
+complete and should take care of proper deinitialization, which is
+usually deleting a temporary copy created by the @code{init-function}.
+
+@item getfname-function
+This function is used for translating filenames reported by the syntax
+check tool into ``real'' filenames. Filenames reported by the tool
+will be different from the real ones, as actually the tool works with
+the temporary copy.  In most cases, the default implementation
+provided by Flymake, @code{flymake-get-real-file-name}, can be used as
+@code{getfname-function}.
+
+@end table
+
+To add support for a new syntax check tool, write corresponding
+@code{init-function}, and, optionally @code{cleanup-function} and
+@code{getfname-function}.  If the format of error messages reported by
+the new tool is not yet supported by Flymake, add a new entry to
+the @code{flymake-err-line-patterns} list.
+
+The following sections contain some examples of configuring Flymake
+support for various syntax check tools.
+
+@node Example -- Configuring a tool called directly
+@subsection Example -- Configuring a tool called directly
+@cindex Adding support for perl
+
+In this example, we will add support for @code{perl} as a syntax check
+tool. @code{perl} supports the @code{-c} option which does syntax
+checking.
+
+First, we write the @code{init-function}:
+
+@lisp
+(defun flymake-perl-init(buffer)
+    (let* ((temp-file   (flymake-init-create-temp-buffer-copy
+			     buffer
+			     'flymake-create-temp-inplace))
+		   (local-file  (concat (flymake-build-relative-path
+				  (file-name-directory
+				    (buffer-file-name
+				      (current-buffer)))
+							      (file-name-directory temp-file))
+								(file-name-nondirectory temp-file))))
+	(list "perl" (list "-wc " local-file))
+	)
+)
+@end lisp
+
+@code{flymake-perl-init} creates a temporary copy of the buffer
+contents with the help of
+@code{flymake-init-create-temp-buffer-copy}, and builds an appropriate
+command line.
+
+Next, we add a new entry to the
+@code{flymake-allowed-file-name-masks}:
+
+@lisp
+(setq flymake-allowed-file-name-masks
+	  (cons '(".+\\.pl$"
+	  flymake-perl-init
+	  flymake-simple-cleanup
+	  flymake-get-real-file-name)
+	flymake-allowed-file-name-masks))
+@end lisp
+
+Note that we use standard @code{cleanup-function} and
+@code{getfname-function}.
+
+Finally, we add an entry to @code{flymake-err-line-patterns}:
+
+@lisp
+(setq flymake-err-line-patterns
+	  (cons '("\\(.*\\) at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]" 2 3 nil 1)
+			flymake-err-line-patterns))
+@end lisp
+
+@node Example -- Configuring a tool called via make
+@subsection Example -- Configuring a tool called via make
+@cindex Adding support for C (gcc+make)
+
+In this example we will add support for C files syntax checked by
+@code{gcc} called via @code{make}.
+
+We're not required to write any new functions, as Flymake already has
+functions for @code{make}. We just add a new entry to the
+@code{flymake-allowed-file-name-masks}:
+
+@lisp
+(setq flymake-allowed-file-name-masks
+	  (cons '(".+\\.c$"
+	    flymake-simple-make-init
+	    flymake-simple-cleanup
+	    flymake-get-real-file-name)
+      flymake-allowed-file-name-masks))
+@end lisp
+
+@code{flymake-simple-make-init} builds the following @code{make}
+command line:
+
+@lisp
+(list "make"
+    (list "-s"
+		  "-C"
+		   base-dir
+		  (concat "CHK_SOURCES=" source)
+		  "SYNTAX_CHECK_MODE=1"
+		  "check-syntax"))
+@end lisp
+
+@code{base-dir} is a directory containing @code{Makefile}, see @ref{Locating the buildfile}.
+
+Thus, @code{Makefile} must contain the @code{check-syntax} target. In
+our case this target might look like this:
+
+@verbatim
+check-syntax:
+	gcc -o nul -S ${CHK_SOURCES}
+@end verbatim
+
+The format of error messages reported by @code{gcc} is already
+supported by Flymake, so we don't have to add a new entry to
+@code{flymake-err-line-patterns}.
+
+@node Flymake Implementation
+@chapter Flymake Implementation
+@cindex Implementation details
+
+@menu
+* Determining whether syntax check is possible::
+* Making a temporary copy::
+* Locating a master file::
+* Getting the include directories::
+* Locating the buildfile::
+* Starting the syntax check process::
+* Parsing the output::
+* Highlighting erroneous lines::
+* Interaction with other modes::
+@end menu
+
+Syntax check is started by calling @code{flymake-start-syntax-check-for-current-buffer}.
+Flymake first determines whether it is able to do syntax
+check. It then saves a copy of the buffer in a temporary file in the
+buffer's directory (or in the system temp directory -- for java
+files), creates a syntax check command and launches a process with
+this command. The output is parsed using a list of error message patterns,
+and error information (file name, line number, type and text) is
+saved. After the process has finished, Flymake highlights erroneous
+lines in the buffer using the accumulated error information.
+
+@node Determining whether syntax check is possible
+@section Determining whether syntax check is possible
+@cindex Syntax check models
+@cindex Master file
+
+Syntax check is considered possible if there's an entry in
+@code{flymake-allowed-file-name-masks} matching buffer's filename and
+its @code{init-function} returns non-nil value.
+
+Two syntax check modes are distinguished:
+
+@enumerate
+
+@item
+Buffer can be syntax checked in a standalone fashion, that is, the
+file (its temporary copy, in fact) can be passed over to the compiler to
+do the syntax check. Examples are C/C++ (.c, .cpp) and Java (.java)
+sources.
+
+@item
+Buffer can be syntax checked, but additional file, called master file,
+is required to perform this operation. A master file is a file that
+includes the current file, so that running a syntax check tool on it
+will also check syntax in the current file. Examples are C/C++ (.h,
+.hpp) headers.
+
+@end enumerate
+
+These modes are handled inside init/cleanup/getfname functions, see
+@ref{Adding support for a new syntax check tool}.
+
+Flymake contains implementations of all functionality required to
+support different syntax check modes described above (making
+temporary copies, finding master files, etc.), as well as some
+tool-specific (routines for @code{make}, @code{Ant}, etc.) code.
+
+
+@node Making a temporary copy
+@section Making a temporary copy
+@cindex Temporary copy of the buffer
+@cindex Master file
+
+After the possibility of the syntax check has been determined, a
+temporary copy of the current buffer is made so that the most recent
+unsaved changes could be seen by the syntax check tool. Making a copy
+is quite straightforward in a standalone case (mode @code{1}), as it's
+just saving buffer contents to a temporary file.
+
+Things get trickier, however, when master file is involved, as it
+requires to
+
+@itemize @bullet
+@item locate a master file
+@item patch it to include the current file using its new (temporary)
+name.
+@end itemize
+
+Locating a master file is discussed in the following section.
+
+Patching just changes all appropriate lines of the master file so that they
+use the new (temporary) name of the current file. For example, suppose current
+file name is @code{file.h}, the master file is @code{file.cpp}, and
+it includes current file via @code{#include "file.h"}. Current file's copy
+is saved to file @code{file_flymake.h}, so the include line must be
+changed to @code{#include "file_flymake.h"}. Finally, patched master file
+is saved to @code{file_flymake_master.cpp}, and the last one is passed to
+the syntax check tool.
+
+@node Locating a master file
+@section Locating a master file
+@cindex Master file
+
+Master file is located in two steps.
+
+First, a list of possible master files is built. A simple name
+matching is used to find the files. For a C++ header @code{file.h},
+Flymake searches for all @code{.cpp} files in the directories whose relative paths are
+stored in a customizable variable @code{flymake-master-file-dirs}, which
+usually contains something like @code{("." "./src")}. No more than
+@code{flymake-master-file-count-limit} entries is added to the master file
+list. The list is then sorted to move files with names @code{file.cpp} to
+the top.
+
+Next, each master file in a list is checked to contain the appropriate
+include directives. No more than @code{flymake-check-file-limit} of each
+file are parsed.
+
+For @code{file.h}, the include directives to look for are
+@code{#include "file.h"}, @code{#include "../file.h"}, etc. Each
+include is checked against a list of include directories
+(see @ref{Getting the include directories}) to be sure it points to the
+correct @code{file.h}.
+
+First matching master file found stops the search. The master file is then
+patched and saved to disk. In case no master file is found, syntax check is
+aborted, and corresponding status (!) is reported in the mode line.
+
+@node Getting the include directories
+@section Getting the include directories
+@cindex Include directories (C/C++ specific)
+
+Two sets of include directories are distinguished: system include directories
+and project include directories. The former is just the contents of the
+@code{INCLUDE} environment variable. The latter is not so easy to obtain,
+and the way it can be obtained can vary greatly for different projects.
+Therefore, a customizable variable
+@code{flymake-get-project-include-dirs-function} is used to provide the
+way to implement the desired behaviour.
+
+The default implementation, @code{flymake-get-project-include-dirs-imp},
+uses a @code{make} call. This requires a correct base directory, that is, a
+directory containing a correct @code{Makefile}, to be determined.
+
+As obtaining the project include directories might be a costly operation, its
+return value is cached in the hash table. The cache is cleared in the beginning
+of every syntax check attempt.
+
+@node Locating the buildfile
+@section Locating the buildfile
+@cindex Locating the buildfile
+@cindex buildfile, locating
+@cindex Makefile, locating
+
+Flymake can be configured to use different tools for performing syntax
+checks. For example, it can use direct compiler call to syntax check a perl
+script or a call to @code{make} for a more complicated case of a
+@code{C/C++} source.  The general idea is that simple files, like perl
+scripts and html pages, can be checked by directly invoking a
+corresponding tool. Files that are usually more complex and generally
+used as part of larger projects, might require non-trivial options to
+be passed to the syntax check tool, like include directories for
+C++. The latter files are syntax checked using some build tool, like
+@code{make} or @code{Ant}.
+
+All @code{make} configuration data is usually stored in a file called
+@code{Makefile}. To allow for future extensions, flymake uses a notion of
+buildfile to reference the 'project configuration' file.
+
+Special function, @code{flymake-find-buildfile} is provided for locating buildfiles.
+Searching for a buildfile is done in a manner similar to that of searching
+for possible master files. A customizable variable
+@code{flymake-buildfile-dirs} holds a list of relative paths to the
+buildfile. They are checked sequentially until a buildfile is found. In case
+there's no build file, syntax check is aborted.
+
+Buildfile values are also cached.
+
+@node Starting the syntax check process
+@section Starting the syntax check process
+@cindex Syntax check process
+
+The command line (command name and the list of arguments) for launching a process is returned by the
+initialization function. Flymake then just calls @code{start-process}
+to start an asynchronous process and configures process filter and
+sentinel which is used for processing the output of the syntax check
+tool.
+
+@node Parsing the output
+@section Parsing the output
+@cindex Parsing the output
+
+The output generated by the syntax check tool is parsed in the process
+filter/sentinel using the error message patterns stored in the
+@code{flymake-err-line-patterns} variable. This variable contains a
+list of items of the form @code{(regexp file-idx line-idx
+err-text-idx)}, used to determine whether a particular line is an
+error message and extract file name, line number and error text,
+respectively. Error type (error/warning) is also guessed by matching
+error text with the '@code{^[wW]arning}' pattern. Anything that was not
+classified as a warning is considered an error. Type is then used to
+sort error menu items, which shows error messages first.
+
+Flymake is also able to interpret error message patterns missing err-text-idx
+information. This is done by merely taking the rest of the matched line
+(@code{(substring line (match-end 0))}) as error text. This trick allows
+to make use of a huge collection of error message line patterns from
+@code{compile.el}. All these error patterns are appended to
+the end of @code{flymake-err-line-patterns}.
+
+The error information obtained is saved in a buffer local
+variable. The buffer for which the process output belongs is
+determined from the process-id@w{}->@w{}buffer mapping updated
+after every process launch/exit.
+
+@node Highlighting erroneous lines
+@section Highlighting erroneous lines
+@cindex Erroneous lines, faces
+
+Highlighting is implemented with overlays and happens in the process
+sentinel, after calling the cleanup function. Two customizable faces
+are used: @code{flymake-errline-face} and
+@code{flymake-warnline-face}.  Errors belonging outside the current
+buffer are considered to belong to line 1 of the current buffer.
+
+@node Interaction with other modes
+@section Interaction with other modes
+@cindex Interaction with other modes
+@cindex Interaction with compile mode
+
+The only mode flymake currently knows about is @code{compile}.
+
+Flymake can be configured to not start syntax check if it thinks the
+compilation is in progress. The check is made by the
+@code{flymake-compilation-is-running}, which tests the
+@code{compilation-in-progress} variable. The reason why this might be
+useful is saving CPU time in case both syntax check and compilation
+are very CPU intensive. The original reason for adding this feature,
+though, was working around a locking problem with MS Visual C++ compiler.
+
+Flymake also provides an alternative command for starting compilation,
+@code{flymake-compile}:
+
+@lisp
+(defun flymake-compile()
+    "kill all flymake syntax checks, start compilation"
+    (interactive)
+    (flymake-stop-all-syntax-checks)
+    (call-interactively 'compile)
+)
+@end lisp
+
+It just kills all the active syntax check processes before calling
+@code{compile}.
+
+@node Index
+@unnumbered Index
+
+@printindex cp
+
+@bye
+
+@ignore
+   arch-tag: 9f0db077-5598-49ab-90b9-8df9248a63ec
+@end ignore
--- a/man/makefile.w32-in	Sun May 30 21:11:48 2004 +0000
+++ b/man/makefile.w32-in	Mon May 31 13:48:26 2004 +0000
@@ -1,6 +1,6 @@
 #### -*- Makefile -*- for the Emacs Manual and other documentation.
 
-# Copyright (C) 2003
+# Copyright (C) 2003, 2004
 #  Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
@@ -45,13 +45,14 @@
 		$(infodir)/pcl-cvs $(infodir)/woman \
 		$(infodir)/emacs-mime $(infodir)/eshell \
 		$(infodir)/speedbar $(infodir)/tramp \
-		$(infodir)/ses $(infodir)/smtpmail
+		$(infodir)/ses $(infodir)/smtpmail \
+		$(infodir)/flymake
 DVI_TARGETS = 	emacs.dvi calc.dvi cc-mode.dvi cl.dvi dired-x.dvi \
 		 ediff.dvi forms.dvi gnus.dvi message.dvi mh-e.dvi \
 		 reftex.dvi sc.dvi vip.dvi viper.dvi widget.dvi faq.dvi \
 		 ada-mode.dvi autotype.dvi idlwave.dvi eudc.dvi ebrowse.dvi \
 		 pcl-cvs.dvi woman.dvi emacs-mime.dvi eshell.dvi \
-		 speedbar.dvi tramp.dvi ses.dvi smtpmail.dvi
+		 speedbar.dvi tramp.dvi ses.dvi smtpmail.dvi flymake.dvi
 INFOSOURCES = info.texi
 
 # The following rule does not work with all versions of `make'.
@@ -177,6 +178,11 @@
 ediff.dvi: ediff.texi
 	$(ENVADD) $(TEXI2DVI) $(srcdir)/ediff.texi
 
+$(infodir)/flymake: flymake.texi
+	$(MAKEINFO) flymake.texi
+flymake.dvi: flymake.texi
+	$(ENVADD) $(TEXI2DVI) $(srcdir)/flymake.texi
+
 $(infodir)/forms: forms.texi
 	$(MAKEINFO) forms.texi
 forms.dvi: forms.texi
@@ -185,7 +191,7 @@
 $(infodir)/gnus: gnus.texi
 	$(MAKEINFO) gnus.texi
 gnus.dvi: gnus.texi
-	sed -e '/@iflatex/,/@end iflatex/d' $(srcdir)/gnus.texi > gnustmp.texi 
+	sed -e '/@iflatex/,/@end iflatex/d' $(srcdir)/gnus.texi > gnustmp.texi
 	$(ENVADD) $(TEXI2DVI) gnustmp.texi
 	cp gnustmp.dvi $*.dvi
 	rm gnustmp.*
--- a/man/trampver.texi	Sun May 30 21:11:48 2004 +0000
+++ b/man/trampver.texi	Mon May 31 13:48:26 2004 +0000
@@ -4,7 +4,7 @@
 @c In the Tramp CVS, the version number is auto-frobbed from
 @c configure.ac, so you should edit that file and run
 @c "autoconf && ./configure" to change the version number.
-@set trampver 2.0.40
+@set trampver 2.0.41
 
 @c Other flags from configuration
 @set prefix /usr/local
--- a/src/ChangeLog	Sun May 30 21:11:48 2004 +0000
+++ b/src/ChangeLog	Mon May 31 13:48:26 2004 +0000
@@ -1,3 +1,92 @@
+2004-05-29  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* macfns.c: Don't include ccl.h.
+	[MAC_OSX]: Don't include QuickTime/QuickTime.h.
+	[!MAC_OSX]: Don't include alloca.h, Windows.h, Gestalt.h, or
+	TextUtils.h.
+	(Fx_create_frame): Sync with xfns.c.  Initialize cursor
+	descriptors.
+	(Fx_display_mm_height, Fx_display_mm_width): Calculate length from
+	display height/width.
+	(compute_tip_xy, Vx_max_tooltip_size): Declare.
+	(unwind_create_tip_frame, compute_tip_xy): New functions.
+	(x_create_tip_frame, Fx_show_tip, Fx_hide_tip): Sync with xfns.c.
+	(syms_of_macfns): Initialize Qcancel_timer, Vx_max_tooltip_size,
+	and last_show_tip_args.
+	
+	* macgui.h [!MAC_OSX]: Include Gestalt.h.
+	(Cursor, No_Cursor): New defines.
+	[!TARGET_API_MAC_CARBON] (SetPortWindowPort): New compatibility
+	macro.
+	[!TARGET_API_MAC_CARBON] (arrow_cursor): Declare.
+
+	* macmenu.c (mac_menu_show, mac_dialog): Use SetPortWindowPort.
+
+	* macterm.c: Don't include Gestalt.h.
+	(enum mouse_tracking_type, mouse_tracking_in_progress): Remove.
+	(XDrawLine, XClearArea, XClearWindow, mac_draw_bitmap)
+	(mac_set_clip_rectangle, mac_reset_clipping, XCreatePixmap)
+	(XFillRectangle, mac_draw_rectangle, mac_draw_string_common)
+	(mac_copy_area, mac_copy_area_with_mask, x_update_end)
+	(construct_mouse_click, XTmouse_position)
+	(x_scroll_bar_report_motion, x_calc_absolute_position)
+	(do_mouse_moved, do_zoom_window, mac_do_receive_drag)
+	(XTread_socket, make_mac_frame): Use SetPortWindowPort.
+	(note_mouse_movement): Clear the mouse face and reset the pointer
+	shape when the pointer goes outside the frame without grabbing.
+	(mac_front_window): New function.
+	(mac_window_to_frame): New macro.
+	(XTmouse_position, x_scroll_bar_report_motion, do_window_update)
+	(do_window_activate, do_window_deactivate, do_app_resume)
+	(do_app_suspend, do_mouse_moved, do_menu_choice, do_grow_window)
+	(do_zoom_window, mac_do_receive_drag, XTread_socket)
+	(mac_check_for_quit_char): Use mac_front_window and/or
+	mac_window_to_frame.
+	(x_scroll_bar_handle_click): Set `(PORTION . WHOLE)' part in a
+	scroll-bar click event.
+	(mac_define_frame_cursor): Change the pointer shape.
+	(x_free_frame_resources): Reset tip_window to NULL when it is
+	disposed.
+	[!TARGET_API_MAC_CARBON] (arrow_cursor): New variable.
+	[!TARGET_API_MAC_CARBON] (do_init_managers): Initialize
+	arrow_cursor.
+	(do_window_update): Don't do anything if the updated window is the
+	tooltip window.
+	(do_mouse_moved): Handle mouse movement events here (previously in
+	XTread_socket).  Clear the mouse face if
+	dpyinfo->mouse_face_hidden is set.
+	(do_os_event, do_events): Remove (now in XTread_socket).
+	(XTread_socket): Immediately return if interrupt_input_blocked.
+	Loop until all the events in the queue are processed.  Rearrange
+	codes for mouse grabbing.  Add tooltip support.  Include the
+	contents of do_os_event and do_events.  Remove mouse movement
+	handling (now in do_mouse_moved).  Add the case where
+	Vmouse_highlight has an integer value.
+	(NewMacWindow): Remove.
+	(make_mac_frame): Do what NewMacWindow previously did.  Don't do
+	excess initializations.
+	(make_mac_terminal_frame): Previous initializations in
+	make_mac_frame are moved here.
+	(mac_initialize_display_info): Initialize
+	dpyinfo->mouse_face_overlay and dpyinfo->mouse_face_hidden.
+
+	* xdisp.c [MAC_OS] (No_Cursor): Remove variable.
+	(define_frame_cursor1): Don't treat HAVE_CARBON as a special case.
+
+2004-05-29  Richard M. Stallman  <rms@gnu.org>
+
+	* lisp.h (truncate_undo_list): Update decl.
+
+	* alloc.c (undo_outer_limit): New variable.
+	(syms_of_alloc): Defvar it.
+	(Fgarbage_collect): Pass undo_outer_limit to truncate_undo_list.
+
+	* undo.c (truncate_undo_list): New arg LIMITSIZE.
+
+	* alloc.c (lisp_align_malloc): Check for base == 0
+	regardless of HAVE_POSIX_MEMALIGN.
+	Clean up HAVE_POSIX_MEMALIGN handling of `err'.
+
 2004-05-28  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* alloc.c: Undo Kim's recent changes and fix the same bug differently.
--- a/src/alloc.c	Sun May 30 21:11:48 2004 +0000
+++ b/src/alloc.c	Mon May 31 13:48:26 2004 +0000
@@ -155,6 +155,7 @@
 
 EMACS_INT undo_limit;
 EMACS_INT undo_strong_limit;
+EMACS_INT undo_outer_limit;
 
 /* Number of live and free conses etc.  */
 
@@ -755,17 +756,20 @@
 #ifdef HAVE_POSIX_MEMALIGN
       {
 	int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES);
-	abase = err ? (base = NULL) : base;
+	if (err)
+	  base = NULL;
+	abase = base;
       }
 #else
       base = malloc (ABLOCKS_BYTES);
       abase = ALIGN (base, BLOCK_ALIGN);
+#endif
+
       if (base == 0)
 	{
 	  UNBLOCK_INPUT;
 	  memory_full ();
 	}
-#endif
 
       aligned = (base == abase);
       if (!aligned)
@@ -4381,7 +4385,7 @@
 	if (! EQ (nextb->undo_list, Qt))
 	  nextb->undo_list
 	    = truncate_undo_list (nextb->undo_list, undo_limit,
-				  undo_strong_limit);
+				  undo_strong_limit, undo_outer_limit);
 
 	/* Shrink buffer gaps, but skip indirect and dead buffers.  */
 	if (nextb->base_buffer == 0 && !NILP (nextb->name))
@@ -5668,12 +5672,20 @@
 
   DEFVAR_INT ("undo-strong-limit", &undo_strong_limit,
 	      doc: /* Don't keep more than this much size of undo information.
-A command which pushes past this size is itself forgotten.
-This limit is applied when garbage collection happens.
+A previous command which pushes the undo list past this size
+is entirely forgotten when GC happens.
 The size is counted as the number of bytes occupied,
 which includes both saved text and other data.  */);
   undo_strong_limit = 30000;
 
+  DEFVAR_INT ("undo-outer-limit", &undo_outer_limit,
+	      doc: /* Don't keep more than this much size of undo information.
+If the current command has produced more than this much undo information,
+GC discards it.  This is a last-ditch limit to prevent memory overflow.
+The size is counted as the number of bytes occupied,
+which includes both saved text and other data.  */);
+  undo_outer_limit = 300000;
+
   DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages,
 	       doc: /* Non-nil means display messages at start and end of garbage collection.  */);
   garbage_collection_messages = 0;
--- a/src/lisp.h	Sun May 30 21:11:48 2004 +0000
+++ b/src/lisp.h	Mon May 31 13:48:26 2004 +0000
@@ -3009,7 +3009,7 @@
 /* defined in undo.c */
 extern Lisp_Object Qinhibit_read_only;
 EXFUN (Fundo_boundary, 0);
-extern Lisp_Object truncate_undo_list P_ ((Lisp_Object, int, int));
+extern Lisp_Object truncate_undo_list P_ ((Lisp_Object, int, int, int));
 extern void record_marker_adjustment P_ ((Lisp_Object, int));
 extern void record_insert P_ ((int, int));
 extern void record_delete P_ ((int, Lisp_Object));
--- a/src/macfns.c	Sun May 30 21:11:48 2004 +0000
+++ b/src/macfns.c	Mon May 31 13:48:26 2004 +0000
@@ -42,7 +42,6 @@
 #include "epaths.h"
 #include "termhooks.h"
 #include "coding.h"
-#include "ccl.h"
 #include "systime.h"
 
 /* #include "bitmaps/gray.xbm" */
@@ -59,17 +58,6 @@
 
 #include <stdlib.h>
 #include <string.h>
-#ifndef MAC_OSX
-#include <alloca.h>
-#endif
-
-#ifdef MAC_OSX
-#include <QuickTime/QuickTime.h>
-#else /* not MAC_OSX */
-#include <Windows.h>
-#include <Gestalt.h>
-#include <TextUtils.h>
-#endif /* not MAC_OSX */
 
 /*extern void free_frame_menubar ();
 extern double atof ();
@@ -2580,8 +2568,6 @@
   f->output_data.mac = (struct mac_output *) xmalloc (sizeof (struct mac_output));
   bzero (f->output_data.mac, sizeof (struct mac_output));
   FRAME_FONTSET (f) = -1;
-  f->output_data.mac->scroll_bar_foreground_pixel = -1;
-  f->output_data.mac->scroll_bar_background_pixel = -1;
   record_unwind_protect (unwind_create_frame, frame);
 
   f->icon_name
@@ -2717,25 +2703,32 @@
 
   f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
 
-  /* MAC_TODO: specify 1 below when toolbars are implemented.  */
-  window_prompting = x_figure_window_size (f, parms, 0);
+#if TARGET_API_MAC_CARBON
+  f->output_data.mac->text_cursor = kThemeIBeamCursor;
+  f->output_data.mac->nontext_cursor = kThemeArrowCursor;
+  f->output_data.mac->modeline_cursor = kThemeArrowCursor;
+  f->output_data.mac->hand_cursor = kThemePointingHandCursor;
+  f->output_data.mac->hourglass_cursor = kThemeWatchCursor;
+  f->output_data.mac->horizontal_drag_cursor = kThemeResizeLeftRightCursor;
+#else
+  f->output_data.mac->text_cursor = GetCursor (iBeamCursor);
+  f->output_data.mac->nontext_cursor = &arrow_cursor;
+  f->output_data.mac->modeline_cursor = &arrow_cursor;
+  f->output_data.mac->hand_cursor = &arrow_cursor;
+  f->output_data.mac->hourglass_cursor = GetCursor (watchCursor);
+  f->output_data.mac->horizontal_drag_cursor = &arrow_cursor;
+#endif
+
+  /* Compute the size of the window.  */
+  window_prompting = x_figure_window_size (f, parms, 1);
 
   tem = mac_get_arg (parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
   f->no_split = minibuffer_only || EQ (tem, Qt);
 
-  /* Create the window. Add the tool-bar height to the initial frame
-     height so that the user gets a text display area of the size he
-     specified with -g or via the registry. Later changes of the
-     tool-bar height don't change the frame size. This is done so that
-     users can create tall Emacs frames without having to guess how
-     tall the tool-bar will get. */
-  FRAME_LINES (f) += FRAME_TOOL_BAR_LINES (f);
-
   /* mac_window (f, window_prompting, minibuffer_only); */
   make_mac_frame (f);
 
   x_icon (f, parms);
-
   x_make_gc (f);
 
   /* Now consider the frame official.  */
@@ -2754,7 +2747,8 @@
   x_default_parameter (f, parms, Qcursor_type, Qbox,
 		       "cursorType", "CursorType", RES_TYPE_SYMBOL);
   x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
-		       "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);
+		       "scrollBarWidth", "ScrollBarWidth",
+		       RES_TYPE_NUMBER);
 
   /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
      Change will not be effected unless different from the current
@@ -2762,13 +2756,10 @@
   width = FRAME_COLS (f);
   height = FRAME_LINES (f);
 
+  SET_FRAME_COLS (f, 0);
   FRAME_LINES (f) = 0;
-  SET_FRAME_COLS (f, 0);
   change_frame_size (f, height, width, 1, 0, 0);
 
-  /* Set up faces after all frame parameters are known.  */
-  call1 (Qface_set_after_frame_default, frame);
-
 #if 0 /* MAC_TODO: when we have window manager hints */
   /* Tell the server what size and position, etc, we want, and how
      badly we want them.  This should be done after we have the menu
@@ -3025,11 +3016,8 @@
   /* MAC_TODO: this is an approximation, and only of the main display */
 
   struct mac_display_info *dpyinfo = check_x_display_info (display);
-  short h, v;
-
-  ScreenRes (&h, &v);
-
-  return make_number ((int) (v / 72.0 * 25.4));
+
+  return make_number ((int) (dpyinfo->height * 25.4 / dpyinfo->resy));
 }
 
 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
@@ -3043,11 +3031,8 @@
   /* MAC_TODO: this is an approximation, and only of the main display */
 
   struct mac_display_info *dpyinfo = check_x_display_info (display);
-  short h, v;
-
-  ScreenRes (&h, &v);
-
-  return make_number ((int) (h / 72.0 * 25.4));
+
+  return make_number ((int) (dpyinfo->width * 25.4 / dpyinfo->resx));
 }
 
 DEFUN ("x-display-backing-store", Fx_display_backing_store,
@@ -3595,9 +3580,11 @@
  ***********************************************************************/
 
 static Lisp_Object x_create_tip_frame P_ ((struct mac_display_info *,
-					   Lisp_Object));
-
-/* The frame of a currently visible tooltip, or null.  */
+					   Lisp_Object, Lisp_Object));
+static void compute_tip_xy P_ ((struct frame *, Lisp_Object, Lisp_Object,
+				Lisp_Object, int, int, int *, int *));
+
+/* The frame of a currently visible tooltip.  */
 
 Lisp_Object tip_frame;
 
@@ -3612,15 +3599,42 @@
 
 Lisp_Object last_show_tip_args;
 
-/* Create a frame for a tooltip on the display described by DPYINFO.
-   PARMS is a list of frame parameters.  Value is the frame.  */
+/* Maximum size for tooltips; a cons (COLUMNS . ROWS).  */
+
+Lisp_Object Vx_max_tooltip_size;
+
 
 static Lisp_Object
-x_create_tip_frame (dpyinfo, parms)
+unwind_create_tip_frame (frame)
+     Lisp_Object frame;
+{
+  Lisp_Object deleted;
+
+  deleted = unwind_create_frame (frame);
+  if (EQ (deleted, Qt))
+    {
+      tip_window = NULL;
+      tip_frame = Qnil;
+    }
+
+  return deleted;
+}
+
+
+/* Create a frame for a tooltip on the display described by DPYINFO.
+   PARMS is a list of frame parameters.  TEXT is the string to
+   display in the tip frame.  Value is the frame.
+
+   Note that functions called here, esp. x_default_parameter can
+   signal errors, for instance when a specified color name is
+   undefined.  We have to make sure that we're in a consistent state
+   when this happens.  */
+
+static Lisp_Object
+x_create_tip_frame (dpyinfo, parms, text)
      struct mac_display_info *dpyinfo;
-     Lisp_Object parms;
+     Lisp_Object parms, text;
 {
-#if 0 /* MAC_TODO : Mac version */
   struct frame *f;
   Lisp_Object frame, tem;
   Lisp_Object name;
@@ -3629,8 +3643,11 @@
   int count = SPECPDL_INDEX ();
   struct gcpro gcpro1, gcpro2, gcpro3;
   struct kboard *kb;
-
-  check_x ();
+  int face_change_count_before = face_change_count;
+  Lisp_Object buffer;
+  struct buffer *old_buffer;
+
+  check_mac ();
 
   /* Use this general default value to start with until we know if
      this frame has a specified name.  */
@@ -3643,7 +3660,7 @@
 #endif
 
   /* Get the name of the frame to use for resource lookup.  */
-  name = w32_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING);
+  name = mac_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING);
   if (!STRINGP (name)
       && !EQ (name, Qunbound)
       && !NILP (name))
@@ -3652,31 +3669,50 @@
 
   frame = Qnil;
   GCPRO3 (parms, name, frame);
-  tip_frame = f = make_frame (1);
+  f = make_frame (1);
   XSETFRAME (frame, f);
+
+  buffer = Fget_buffer_create (build_string (" *tip*"));
+  Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer, Qnil);
+  old_buffer = current_buffer;
+  set_buffer_internal_1 (XBUFFER (buffer));
+  current_buffer->truncate_lines = Qnil;
+  specbind (Qinhibit_read_only, Qt);
+  specbind (Qinhibit_modification_hooks, Qt);
+  Ferase_buffer ();
+  Finsert (1, &text);
+  set_buffer_internal_1 (old_buffer);
+
   FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
-
-  f->output_method = output_w32;
-  f->output_data.w32 =
-    (struct w32_output *) xmalloc (sizeof (struct w32_output));
-  bzero (f->output_data.w32, sizeof (struct w32_output));
-#if 0
-  f->output_data.w32->icon_bitmap = -1;
-#endif
-  FRAME_FONTSET (f) = -1;
+  record_unwind_protect (unwind_create_tip_frame, frame);
+
+  /* By setting the output method, we're essentially saying that
+     the frame is live, as per FRAME_LIVE_P.  If we get a signal
+     from this point on, x_destroy_window might screw up reference
+     counts etc.  */
+  f->output_method = output_mac;
+  f->output_data.mac =
+    (struct mac_output *) xmalloc (sizeof (struct mac_output));
+  bzero (f->output_data.mac, sizeof (struct mac_output));
+
+  FRAME_FONTSET (f)  = -1;
   f->icon_name = Qnil;
 
+#if 0 /* GLYPH_DEBUG TODO: image support.  */
+  image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
+  dpyinfo_refcount = dpyinfo->reference_count;
+#endif /* GLYPH_DEBUG */
 #ifdef MULTI_KBOARD
   FRAME_KBOARD (f) = kb;
 #endif
-  f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window;
-  f->output_data.w32->explicit_parent = 0;
+  f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
+  f->output_data.mac->explicit_parent = 0;
 
   /* Set the name; the functions to which we pass f expect the name to
      be set.  */
   if (EQ (name, Qunbound) || NILP (name))
     {
-      f->name = build_string (dpyinfo->x_id_name);
+      f->name = build_string (dpyinfo->mac_id_name);
       f->explicit_name = 0;
     }
   else
@@ -3687,12 +3723,12 @@
       specbind (Qx_resource_name, name);
     }
 
-  /* Extract the window parameters from the supplied values
-     that are needed to determine window geometry.  */
+  /* Extract the window parameters from the supplied values that are
+     needed to determine window geometry.  */
   {
     Lisp_Object font;
 
-    font = w32_get_arg (parms, Qfont, "font", "Font", RES_TYPE_STRING);
+    font = mac_get_arg (parms, Qfont, "font", "Font", RES_TYPE_STRING);
 
     BLOCK_INPUT;
     /* First, try whatever font the caller has specified.  */
@@ -3706,22 +3742,16 @@
       }
 
     /* Try out a font which we hope has bold and italic variations.  */
-    if (!STRINGP (font))
-      font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");
-    if (!STRINGP (font))
-      font = x_new_font (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
     if (! STRINGP (font))
-      font = x_new_font (f, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
-    if (! STRINGP (font))
-      /* This was formerly the first thing tried, but it finds too many fonts
-	 and takes too long.  */
-      font = x_new_font (f, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1");
+      font = x_new_font (f, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1");
     /* If those didn't work, look for something which will at least work.  */
     if (! STRINGP (font))
-      font = x_new_font (f, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1");
+      font = x_new_font (f, "-*-monaco-*-12-*-mac-roman");
+    if (! STRINGP (font))
+      font = x_new_font (f, "-*-courier-*-10-*-mac-roman");
     UNBLOCK_INPUT;
     if (! STRINGP (font))
-      font = build_string ("fixed");
+      error ("Cannot find any usable font");
 
     x_default_parameter (f, parms, Qfont, font,
 			 "font", "Font", RES_TYPE_STRING);
@@ -3737,7 +3767,7 @@
     {
       Lisp_Object value;
 
-      value = w32_get_arg (parms, Qinternal_border_width,
+      value = mac_get_arg (parms, Qinternal_border_width,
 			 "internalBorder", "internalBorder", RES_TYPE_NUMBER);
       if (! EQ (value, Qunbound))
 	parms = Fcons (Fcons (Qinternal_border_width, value),
@@ -3768,34 +3798,26 @@
      happen.  */
   init_frame_faces (f);
 
-  f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window;
+  f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
 
   window_prompting = x_figure_window_size (f, parms, 0);
 
   {
-    XSetWindowAttributes attrs;
-    unsigned long mask;
-
     BLOCK_INPUT;
-    mask = CWBackPixel | CWOverrideRedirect | CWSaveUnder | CWEventMask;
-    /* Window managers looks at the override-redirect flag to
-       determine whether or net to give windows a decoration (Xlib
-       3.2.8).  */
-    attrs.override_redirect = True;
-    attrs.save_under = True;
-    attrs.background_pixel = FRAME_BACKGROUND_PIXEL (f);
-    /* Arrange for getting MapNotify and UnmapNotify events.  */
-    attrs.event_mask = StructureNotifyMask;
-    tip_window
-      = FRAME_W32_WINDOW (f)
-      = XCreateWindow (FRAME_W32_DISPLAY (f),
-		       FRAME_W32_DISPLAY_INFO (f)->root_window,
-		       /* x, y, width, height */
-		       0, 0, 1, 1,
-		       /* Border.  */
-		       1,
-		       CopyFromParent, InputOutput, CopyFromParent,
-		       mask, &attrs);
+    Rect r;
+
+    SetRect (&r, 0, 0, 1, 1);
+    if (CreateNewWindow (kHelpWindowClass,
+			 kWindowNoActivatesAttribute
+			 | kWindowIgnoreClicksAttribute,
+			 &r, &tip_window) == noErr)
+      {
+	FRAME_MAC_WINDOW (f) = tip_window;
+	SetWRefCon (tip_window, (long) f->output_data.mac);
+	/* so that update events can find this mac_output struct */
+	f->output_data.mac->mFP = f;
+	ShowWindow (tip_window);
+      }
     UNBLOCK_INPUT;
   }
 
@@ -3813,8 +3835,8 @@
      FRAME_LINES (f).  */
   width = FRAME_COLS (f);
   height = FRAME_LINES (f);
+  SET_FRAME_COLS (f, 0);
   FRAME_LINES (f) = 0;
-  SET_FRAME_COLS (f, 0);
   change_frame_size (f, height, width, 1, 0, 0);
 
   /* Add `tooltip' frame parameter's default value. */
@@ -3822,6 +3844,26 @@
     Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt),
 					    Qnil));
 
+  /* Set up faces after all frame parameters are known.  This call
+     also merges in face attributes specified for new frames.
+
+     Frame parameters may be changed if .Xdefaults contains
+     specifications for the default font.  For example, if there is an
+     `Emacs.default.attributeBackground: pink', the `background-color'
+     attribute of the frame get's set, which let's the internal border
+     of the tooltip frame appear in pink.  Prevent this.  */
+  {
+    Lisp_Object bg = Fframe_parameter (frame, Qbackground_color);
+
+    /* Set tip_frame here, so that */
+    tip_frame = frame;
+    call1 (Qface_set_after_frame_default, frame);
+
+    if (!EQ (bg, Fframe_parameter (frame, Qbackground_color)))
+      Fmodify_frame_parameters (frame, Fcons (Fcons (Qbackground_color, bg),
+					      Qnil));
+  }
+
   f->no_split = 1;
 
   UNGCPRO;
@@ -3833,17 +3875,80 @@
 
   /* Now that the frame is official, it counts as a reference to
      its display.  */
-  FRAME_W32_DISPLAY_INFO (f)->reference_count++;
-
+  FRAME_MAC_DISPLAY_INFO (f)->reference_count++;
+
+  /* Setting attributes of faces of the tooltip frame from resources
+     and similar will increment face_change_count, which leads to the
+     clearing of all current matrices.  Since this isn't necessary
+     here, avoid it by resetting face_change_count to the value it
+     had before we created the tip frame.  */
+  face_change_count = face_change_count_before;
+
+  /* Discard the unwind_protect.  */
   return unbind_to (count, frame);
-#endif /* MAC_TODO */
-  return Qnil;
+}
+
+
+/* Compute where to display tip frame F.  PARMS is the list of frame
+   parameters for F.  DX and DY are specified offsets from the current
+   location of the mouse.  WIDTH and HEIGHT are the width and height
+   of the tooltip.  Return coordinates relative to the root window of
+   the display in *ROOT_X, and *ROOT_Y.  */
+
+static void
+compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y)
+     struct frame *f;
+     Lisp_Object parms, dx, dy;
+     int width, height;
+     int *root_x, *root_y;
+{
+  Lisp_Object left, top;
+
+  /* User-specified position?  */
+  left = Fcdr (Fassq (Qleft, parms));
+  top  = Fcdr (Fassq (Qtop, parms));
+
+  /* Move the tooltip window where the mouse pointer is.  Resize and
+     show it.  */
+  if (!INTEGERP (left) || !INTEGERP (top))
+    {
+      Point mouse_pos;
+
+      BLOCK_INPUT;
+      GetMouse (&mouse_pos);
+      LocalToGlobal (&mouse_pos);
+      *root_x = mouse_pos.h;
+      *root_y = mouse_pos.v;
+      UNBLOCK_INPUT;
+    }
+
+  if (INTEGERP (top))
+    *root_y = XINT (top);
+  else if (*root_y + XINT (dy) - height < 0)
+    *root_y -= XINT (dy);
+  else
+    {
+      *root_y -= height;
+      *root_y += XINT (dy);
+    }
+
+  if (INTEGERP (left))
+    *root_x = XINT (left);
+  else if (*root_x + XINT (dx) + width <= FRAME_MAC_DISPLAY_INFO (f)->width)
+    /* It fits to the right of the pointer.  */
+    *root_x += XINT (dx);
+  else if (width + XINT (dx) <= *root_x)
+    /* It fits to the left of the pointer.  */
+    *root_x -= width + XINT (dx);
+  else
+    /* Put it left-justified on the screen -- it ought to fit that way.  */
+    *root_x = 0;
 }
 
 
 DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
-       doc : /* Show STRING in a "tooltip" window on frame FRAME.
-A tooltip window is a small window displaying a string.
+       doc: /* Show STRING in a "tooltip" window on frame FRAME.
+A tooltip window is a small X window displaying a string.
 
 FRAME nil or omitted means use the selected frame.
 
@@ -3859,19 +3964,19 @@
 DX isn't specified).  Likewise for the y-position; if a `top' frame
 parameter is specified, it determines the y-position of the tooltip
 window, otherwise it is displayed at the mouse position, with offset
-DY added (default is 10).  */)
-  (string, frame, parms, timeout, dx, dy)
+DY added (default is -10).
+
+A tooltip's maximum size is specified by `x-max-tooltip-size'.
+Text larger than the specified size is clipped.  */)
+     (string, frame, parms, timeout, dx, dy)
      Lisp_Object string, frame, parms, timeout, dx, dy;
 {
   struct frame *f;
   struct window *w;
-  Window root, child;
-  Lisp_Object buffer, top, left;
+  int root_x, root_y;
   struct buffer *old_buffer;
   struct text_pos pos;
   int i, width, height;
-  int root_x, root_y, win_x, win_y;
-  unsigned pmask;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
   int old_windows_or_buffers_changed = windows_or_buffers_changed;
   int count = SPECPDL_INDEX ();
@@ -3920,13 +4025,11 @@
 	      call1 (Qcancel_timer, timer);
 	    }
 
-#if 0 /* MAC_TODO : Mac specifics */
 	  BLOCK_INPUT;
-	  compute_tip_xy (f, parms, dx, dy, &root_x, &root_y);
-	  XMoveWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-		       root_x, root_y - FRAME_PIXEL_HEIGHT (f));
+	  compute_tip_xy (f, parms, dx, dy, FRAME_PIXEL_WIDTH (f),
+			  FRAME_PIXEL_HEIGHT (f), &root_x, &root_y);
+	  MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false);
 	  UNBLOCK_INPUT;
-#endif /* MAC_TODO */
 	  goto start_timer;
 	}
     }
@@ -3953,26 +4056,36 @@
 
   /* Create a frame for the tooltip, and record it in the global
      variable tip_frame.  */
-  frame = x_create_tip_frame (FRAME_MAC_DISPLAY_INFO (f), parms);
+  frame = x_create_tip_frame (FRAME_MAC_DISPLAY_INFO (f), parms, string);
   f = XFRAME (frame);
 
-  /* Set up the frame's root window.  Currently we use a size of 80
-     columns x 40 lines.  If someone wants to show a larger tip, he
-     will loose.  I don't think this is a realistic case.  */
+  /* Set up the frame's root window.  */
   w = XWINDOW (FRAME_ROOT_WINDOW (f));
   w->left_col = w->top_line = make_number (0);
-  w->total_cols = make_number (80);
-  w->total_lines = make_number (40);
+
+  if (CONSP (Vx_max_tooltip_size)
+      && INTEGERP (XCAR (Vx_max_tooltip_size))
+      && XINT (XCAR (Vx_max_tooltip_size)) > 0
+      && INTEGERP (XCDR (Vx_max_tooltip_size))
+      && XINT (XCDR (Vx_max_tooltip_size)) > 0)
+    {
+      w->total_cols = XCAR (Vx_max_tooltip_size);
+      w->total_lines = XCDR (Vx_max_tooltip_size);
+    }
+  else
+    {
+      w->total_cols = make_number (80);
+      w->total_lines = make_number (40);
+    }
+
+  FRAME_TOTAL_COLS (f) = XINT (w->total_cols);
   adjust_glyphs (f);
   w->pseudo_window_p = 1;
 
   /* Display the tooltip text in a temporary buffer.  */
-  buffer = Fget_buffer_create (build_string (" *tip*"));
-  Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer, Qnil);
   old_buffer = current_buffer;
-  set_buffer_internal_1 (XBUFFER (buffer));
-  Ferase_buffer ();
-  Finsert (1, &string);
+  set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->buffer));
+  current_buffer->truncate_lines = Qnil;
   clear_glyph_matrix (w->desired_matrix);
   clear_glyph_matrix (w->current_matrix);
   SET_TEXT_POS (pos, BEGV, BEGV_BYTE);
@@ -3993,7 +4106,7 @@
       /* Let the row go over the full width of the frame.  */
       row->full_width_p = 1;
 
-      /* There's a glyph at the end of rows that is use to place
+      /* There's a glyph at the end of rows that is used to place
 	 the cursor there.  Don't include the width of this glyph.  */
       if (row->used[TEXT_AREA])
 	{
@@ -4014,17 +4127,13 @@
 
   /* Move the tooltip window where the mouse pointer is.  Resize and
      show it.  */
-#if 0 /* TODO : Mac specifics */
-  compute_tip_xy (f, parms, dx, dy, &root_x, &root_y);
+  compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y);
 
   BLOCK_INPUT;
-  XQueryPointer (FRAME_W32_DISPLAY (f), FRAME_W32_DISPLAY_INFO (f)->root_window,
-		 &root, &child, &root_x, &root_y, &win_x, &win_y, &pmask);
-  XMoveResizeWindow (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
-		     root_x + 5, root_y - height - 5, width, height);
-  XMapRaised (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f));
+  MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false);
+  SizeWindow (FRAME_MAC_WINDOW (f), width, height, true);
+  BringToFront (FRAME_MAC_WINDOW (f));
   UNBLOCK_INPUT;
-#endif /* MAC_TODO */
 
   /* Draw into the window.  */
   w->must_be_updated_p = 1;
@@ -4046,8 +4155,8 @@
 
 DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0,
        doc: /* Hide the current tooltip window, if there is any.
-Value is t is tooltip was open, nil otherwise.  */)
-  ()
+Value is t if tooltip was open, nil otherwise.  */)
+     ()
 {
   int count;
   Lisp_Object deleted, frame, timer;
@@ -4249,7 +4358,8 @@
   staticpro (&Qsuppress_icon);
   Qundefined_color = intern ("undefined-color");
   staticpro (&Qundefined_color);
-  /* This is the end of symbol initialization.  */
+  Qcancel_timer = intern ("cancel-timer");
+  staticpro (&Qcancel_timer);
 
   Qhyper = intern ("hyper");
   staticpro (&Qhyper);
@@ -4265,6 +4375,7 @@
   staticpro (&Qcontrol);
   Qshift = intern ("shift");
   staticpro (&Qshift);
+  /* This is the end of symbol initialization.  */
 
   /* Text property `display' should be nonsticky by default.  */
   Vtext_property_default_nonsticky
@@ -4314,6 +4425,11 @@
 	       doc: /* A string indicating the foreground color of the cursor box.  */);
   Vx_cursor_fore_pixel = Qnil;
 
+  DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size,
+    doc: /* Maximum size for tooltips.  Value is a pair (COLUMNS . ROWS).
+Text larger than this is clipped.  */);
+  Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
+
   DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
 	       doc: /* Non-nil if no window manager is in use.
 Emacs doesn't try to figure this out; this is always nil
@@ -4386,6 +4502,9 @@
   tip_frame = Qnil;
   staticpro (&tip_frame);
 
+  last_show_tip_args = Qnil;
+  staticpro (&last_show_tip_args);
+
 #if 0 /* MAC_TODO */
   defsubr (&Sx_file_dialog);
 #endif
--- a/src/macgui.h	Sun May 30 21:11:48 2004 +0000
+++ b/src/macgui.h	Mon May 31 13:48:26 2004 +0000
@@ -57,16 +57,27 @@
 #undef init_process
 #define init_process emacs_init_process
 #undef INFINITY
-typedef struct OpaqueWindowPtr* Window;
 #else
 #include <QuickDraw.h>		/* for WindowPtr */
 #include <QDOffscreen.h>	/* for GWorldPtr */
 #include <Controls.h>		/* for ControlHandle in xdisp.c */
-typedef WindowPtr Window;
+#include <Gestalt.h>
 #endif
 
 typedef GWorldPtr Pixmap;
 
+#if TARGET_API_MAC_CARBON
+typedef struct OpaqueWindowPtr *Window;
+#define Cursor ThemeCursor
+#define No_Cursor (-1)
+#else
+typedef WindowPtr Window;
+#define SetPortWindowPort(w) SetPort(w)
+#define Cursor CursHandle
+#define No_Cursor (0)
+extern CursPtr arrow_cursor;
+#endif
+
 #define FACE_DEFAULT (~0)
 
 
--- a/src/macmenu.c	Sun May 30 21:11:48 2004 +0000
+++ b/src/macmenu.c	Mon May 31 13:48:26 2004 +0000
@@ -1784,11 +1784,7 @@
   pos.h = x;
   pos.v = y;
 
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));
-#else
-  SetPort (FRAME_MAC_WINDOW (f));
-#endif
+  SetPortWindowPort (FRAME_MAC_WINDOW (f));
 
   LocalToGlobal (&pos);
 
@@ -1942,11 +1938,7 @@
 
   window_ptr = GetNewCWindow (DIALOG_WINDOW_RESOURCE, NULL, (WindowPtr) -1);
 
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (window_ptr));
-#else
-  SetPort (window_ptr);
-#endif
+  SetPortWindowPort (window_ptr);
 
   TextFont (0);
   /* Left and right margins in the dialog are 13 pixels each.*/
@@ -1964,11 +1956,7 @@
   SizeWindow (window_ptr, dialog_width, 78, 0);
   ShowWindow (window_ptr);
 
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (window_ptr));
-#else
-  SetPort (window_ptr);
-#endif
+  SetPortWindowPort (window_ptr);
 
   TextFont (0);
 
--- a/src/macterm.c	Sun May 30 21:11:48 2004 +0000
+++ b/src/macterm.c	Mon May 31 13:48:26 2004 +0000
@@ -53,7 +53,6 @@
 #if defined (__MRC__) || (__MSL__ >= 0x6000)
 #include <ControlDefinitions.h>
 #endif
-#include <Gestalt.h>
 
 #if __profile__
 #include <profiler.h>
@@ -196,14 +195,6 @@
 
 static Time last_mouse_movement_time;
 
-enum mouse_tracking_type {
-  mouse_tracking_none,
-  mouse_tracking_mouse_movement,
-  mouse_tracking_scroll_bar
-};
-
-enum mouse_tracking_type mouse_tracking_in_progress = mouse_tracking_none;
-
 struct scroll_bar *tracked_scroll_bar = NULL;
 
 /* Incremented by XTread_socket whenever it really tries to read
@@ -364,11 +355,7 @@
      GC gc;
      int x1, y1, x2, y2;
 {
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (w));
-#else
-  SetPort (w);
-#endif
+  SetPortWindowPort (w);
 
   mac_set_colors (gc);
 
@@ -416,11 +403,7 @@
   xgc.foreground = mwp->x_compatible.foreground_pixel;
   xgc.background = mwp->x_compatible.background_pixel;
 
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (w));
-#else
-  SetPort (w);
-#endif
+  SetPortWindowPort (w);
 
   mac_set_colors (&xgc);
   SetRect (&r, x, y, x + width, y + height);
@@ -441,11 +424,7 @@
   xgc.foreground = mwp->x_compatible.foreground_pixel;
   xgc.background = mwp->x_compatible.background_pixel;
 
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (w));
-#else
-  SetPort (w);
-#endif
+  SetPortWindowPort (w);
 
   mac_set_colors (&xgc);
 
@@ -480,11 +459,7 @@
   bitmap.baseAddr = (char *)bits;
   SetRect (&(bitmap.bounds), 0, 0, width, height);
 
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (w));
-#else
-  SetPort (w);
-#endif
+  SetPortWindowPort (w);
 
   mac_set_colors (gc);
   SetRect (&r, x, y, x + width, y + height);
@@ -509,11 +484,7 @@
      WindowPtr w;
      Rect *r;
 {
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (w));
-#else
-  SetPort (w);
-#endif
+  SetPortWindowPort (w);
 
   ClipRect (r);
 }
@@ -528,11 +499,7 @@
 {
   Rect r;
 
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (w));
-#else
-  SetPort (w);
-#endif
+  SetPortWindowPort (w);
 
   SetRect (&r, -32767, -32767, 32767, 32767);
   ClipRect (&r);
@@ -601,11 +568,7 @@
   Rect r;
   QDErr err;
 
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (w));
-#else
-  SetPort (w);
-#endif
+  SetPortWindowPort (w);
 
   SetRect (&r, 0, 0, width, height);
   err = NewGWorld (&pixmap, depth, &r, NULL, NULL, 0);
@@ -666,11 +629,7 @@
 {
   Rect r;
 
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (w));
-#else
-  SetPort (w);
-#endif
+  SetPortWindowPort (w);
 
   mac_set_colors (gc);
   SetRect (&r, x, y, x + width, y + height);
@@ -716,11 +675,7 @@
 {
   Rect r;
 
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (w));
-#else
-  SetPort (w);
-#endif
+  SetPortWindowPort (w);
 
   mac_set_colors (gc);
   SetRect (&r, x, y, x + width + 1, y + height + 1);
@@ -766,11 +721,7 @@
      char *buf;
      int nchars, mode, bytes_per_char;
 {
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (w));
-#else
-  SetPort (w);
-#endif
+  SetPortWindowPort (w);
 
   mac_set_colors (gc);
 
@@ -861,11 +812,7 @@
 {
   Rect src_r, dest_r;
 
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (dest));
-#else
-  SetPort (dest);
-#endif
+  SetPortWindowPort (dest);
 
   SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
   SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
@@ -901,11 +848,7 @@
 {
   Rect src_r, dest_r;
 
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (dest));
-#else
-  SetPort (dest);
-#endif
+  SetPortWindowPort (dest);
 
   SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
   SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
@@ -965,7 +908,7 @@
   SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
   SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
 
-  SetPort (GetWindowPort (w));
+  SetPortWindowPort (w);
 
   ForeColor (blackColor);
   BackColor (whiteColor);
@@ -1290,7 +1233,7 @@
 	{
 	  int i;
 
-          for (i = 0; i < w->desired_matrix->nrows; ++i)
+	  for (i = 0; i < w->desired_matrix->nrows; ++i)
 	    if (MATRIX_ROW_ENABLED_P (w->desired_matrix, i))
 	      break;
 
@@ -1385,11 +1328,7 @@
   /* Reset the background color of Mac OS Window to that of the frame after
      update so that it is used by Mac Toolbox to clear the update region before
      an update event is generated.  */
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));
-#else
-  SetPort (FRAME_MAC_WINDOW (f));
-#endif
+  SetPortWindowPort (FRAME_MAC_WINDOW (f));
 
   mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));
 
@@ -3745,11 +3684,7 @@
 
   mouseLoc = event->where;
 
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));
-#else
-  SetPort (FRAME_MAC_WINDOW (f));
-#endif
+  SetPortWindowPort (FRAME_MAC_WINDOW (f));
 
   GlobalToLocal (&mouseLoc);
   XSETINT (result->x, mouseLoc.h);
@@ -3778,6 +3713,7 @@
      FRAME_PTR frame;
      Point *pos;
 {
+  struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (frame);
 #if TARGET_API_MAC_CARBON
   Rect r;
 #endif
@@ -3792,9 +3728,17 @@
   if (!PtInRect (*pos, &FRAME_MAC_WINDOW (frame)->portRect))
 #endif
     {
-      frame->mouse_moved = 1;
-      last_mouse_scroll_bar = Qnil;
-      note_mouse_highlight (frame, -1, -1);
+      if (frame == dpyinfo->mouse_face_mouse_frame)
+	/* This case corresponds to LeaveNotify in X11.  */
+	{
+	  /* If we move outside the frame, then we're certainly no
+	     longer on any text in the frame.  */
+	  clear_mouse_face (dpyinfo);
+	  dpyinfo->mouse_face_mouse_frame = 0;
+	  if (!dpyinfo->grabbed)
+	    rif->define_frame_cursor (frame,
+				      frame->output_data.mac->nontext_cursor);
+	}
     }
   /* Has the mouse moved off the glyph it was on at the last sighting?  */
   else if (pos->h < last_mouse_glyph.left
@@ -3942,6 +3886,23 @@
 }
 
 
+static WindowPtr
+mac_front_window ()
+{
+#if TARGET_API_MAC_CARBON
+  return GetFrontWindowOfClass (kDocumentWindowClass, true);
+#else
+  WindowPtr front_window = FrontWindow ();
+
+  if (tip_window && front_window == tip_window)
+    return GetNextWindow (front_window);
+  else
+    return front_window;
+#endif
+}
+
+#define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
+
 /* Return the current position of the mouse.
    *fp should be a frame which indicates which display to ask about.
 
@@ -3973,12 +3934,12 @@
 {
   Point mouse_pos;
   int ignore1, ignore2;
-  WindowPtr wp = FrontWindow ();
+  WindowPtr wp = mac_front_window ();
   struct frame *f;
   Lisp_Object frame, tail;
 
   if (is_emacs_window(wp))
-    f = ((mac_output *) GetWRefCon (wp))->mFP;
+    f = mac_window_to_frame (wp);
 
   BLOCK_INPUT;
 
@@ -3992,11 +3953,7 @@
 
       last_mouse_scroll_bar = Qnil;
 
-#if TARGET_API_MAC_CARBON
-      SetPort (GetWindowPort (wp));
-#else
-      SetPort (wp);
-#endif
+      SetPortWindowPort (wp);
 
       GetMouse (&mouse_pos);
 
@@ -4491,6 +4448,8 @@
      EventRecord *er;
      struct input_event *bufp;
 {
+  int win_y, top_range;
+
   if (! GC_WINDOWP (bar->window))
     abort ();
 
@@ -4525,6 +4484,24 @@
       bufp->part = scroll_bar_handle;
       break;
     }
+
+  win_y = XINT (bufp->y) - XINT (bar->top);
+  top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (0/*dummy*/, XINT (bar->height));
+
+  win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER;
+
+  win_y -= 24;
+
+  if (! NILP (bar->dragging))
+    win_y -= XINT (bar->dragging);
+
+  if (win_y < 0)
+    win_y = 0;
+  if (win_y > top_range)
+    win_y = top_range;
+
+  XSETINT (bufp->x, win_y);
+  XSETINT (bufp->y, top_range);
 }
 
 
@@ -4574,16 +4551,12 @@
      unsigned long *time;
 {
   struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
-  WindowPtr wp = FrontWindow ();
+  WindowPtr wp = mac_front_window ();
   Point mouse_pos;
-  struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP;
+  struct frame *f = mac_window_to_frame (wp);
   int win_y, top_range;
 
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (wp));
-#else
-  SetPort (wp);
-#endif
+  SetPortWindowPort (wp);
 
   GetMouse (&mouse_pos);
 
@@ -4810,7 +4783,11 @@
      struct frame *f;
      Cursor cursor;
 {
-  /* MAC TODO */
+#if TARGET_API_MAC_CARBON
+  SetThemeCursor (cursor);
+#else
+  SetCursor (*cursor);
+#endif
 }
 
 
@@ -5078,11 +5055,7 @@
       GrafPtr savePort;
       GetPort (&savePort);
 
-#if TARGET_API_MAC_CARBON
-      SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));
-#else
-      SetPort (FRAME_MAC_WINDOW (f));
-#endif
+      SetPortWindowPort (FRAME_MAC_WINDOW (f));
 
 #if TARGET_API_MAC_CARBON
       {
@@ -5457,10 +5430,15 @@
      struct frame *f;
 {
   struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
+  WindowPtr wp = FRAME_MAC_WINDOW (f);
 
   BLOCK_INPUT;
 
-  DisposeWindow (FRAME_MAC_WINDOW (f));
+  DisposeWindow (wp);
+  if (wp == tip_window)
+    /* Neither WaitNextEvent nor ReceiveNextEvent receives `window
+       closed' event.  So we reset tip_window here.  */
+    tip_window = NULL;
 
   free_frame_menubar (f);
 
@@ -6984,6 +6962,11 @@
 
 Point saved_menu_event_location;
 
+#if !TARGET_API_MAC_CARBON
+/* Place holder for the default arrow cursor.  */
+CursPtr arrow_cursor;
+#endif
+
 /* Apple Events */
 static void init_required_apple_events (void);
 static pascal OSErr
@@ -7170,6 +7153,8 @@
   InitCursor ();
 
 #if !TARGET_API_MAC_CARBON
+  arrow_cursor = &qd.arrow;
+
   /* set up some extra stack space for use by emacs */
   SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC));
 
@@ -7198,8 +7183,12 @@
 static void
 do_window_update (WindowPtr win)
 {
-  struct mac_output *mwp = (mac_output *) GetWRefCon (win);
-  struct frame *f = mwp->mFP;
+  struct frame *f = mac_window_to_frame (win);
+
+  if (win == tip_window)
+    /* The tooltip has been drawn already.  Avoid the
+       SET_FRAME_GARBAGED below.  */
+    return;
 
   if (f)
     {
@@ -7250,13 +7239,11 @@
 static void
 do_window_activate (WindowPtr win)
 {
-  mac_output *mwp;
   struct frame *f;
 
   if (is_emacs_window (win))
     {
-      mwp = (mac_output *) GetWRefCon (win);
-      f = mwp->mFP;
+      f = mac_window_to_frame (win);
 
       if (f)
 	{
@@ -7269,13 +7256,11 @@
 static void
 do_window_deactivate (WindowPtr win)
 {
-  mac_output *mwp;
   struct frame *f;
 
   if (is_emacs_window (win))
     {
-      mwp = (mac_output *) GetWRefCon (win);
-      f = mwp->mFP;
+      f = mac_window_to_frame (win);
 
       if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)
 	{
@@ -7289,14 +7274,12 @@
 do_app_resume ()
 {
   WindowPtr wp;
-  mac_output *mwp;
   struct frame *f;
 
-  wp = FrontWindow();
+  wp = mac_front_window ();
   if (is_emacs_window (wp))
     {
-      mwp = (mac_output *) GetWRefCon (wp);
-      f = mwp->mFP;
+      f = mac_window_to_frame (wp);
 
       if (f)
 	{
@@ -7313,14 +7296,12 @@
 do_app_suspend ()
 {
   WindowPtr wp;
-  mac_output *mwp;
   struct frame *f;
 
-  wp = FrontWindow();
+  wp = mac_front_window ();
   if (is_emacs_window (wp))
     {
-      mwp = (mac_output *) GetWRefCon (wp);
-      f = mwp->mFP;
+      f = mac_window_to_frame (wp);
 
       if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)
 	{
@@ -7335,67 +7316,38 @@
 
 
 static void
-do_mouse_moved (Point mouse_pos)
-{
-  WindowPtr wp = FrontWindow ();
-  struct frame *f;
+do_mouse_moved (mouse_pos, f)
+     Point mouse_pos;
+     FRAME_PTR *f;
+{
+  WindowPtr wp = mac_front_window ();
+  struct x_display_info *dpyinfo;
 
   if (is_emacs_window (wp))
     {
-      f = ((mac_output *) GetWRefCon (wp))->mFP;
-
-#if TARGET_API_MAC_CARBON
-      SetPort (GetWindowPort (wp));
-#else
-      SetPort (wp);
-#endif
+      *f = mac_window_to_frame (wp);
+      dpyinfo = FRAME_MAC_DISPLAY_INFO (*f);
+
+      if (dpyinfo->mouse_face_hidden)
+	{
+	  dpyinfo->mouse_face_hidden = 0;
+	  clear_mouse_face (dpyinfo);
+	}
+
+      SetPortWindowPort (wp);
 
       GlobalToLocal (&mouse_pos);
 
-      note_mouse_movement (f, &mouse_pos);
-    }
-}
-
-
-static void
-do_os_event (EventRecord *erp)
-{
-  switch((erp->message >> 24) & 0x000000FF)
-    {
-    case suspendResumeMessage:
-      if((erp->message & resumeFlag) == 1)
-	do_app_resume ();
+      if (dpyinfo->grabbed && tracked_scroll_bar)
+	x_scroll_bar_note_movement (tracked_scroll_bar,
+				    mouse_pos.v
+				    - XINT (tracked_scroll_bar->top),
+				    TickCount() * (1000 / 60));
       else
-	do_app_suspend ();
-      break;
-
-    case mouseMovedMessage:
-      do_mouse_moved (erp->where);
-      break;
-    }
-}
-
-static void
-do_events (EventRecord *erp)
-{
-  switch (erp->what)
-    {
-    case updateEvt:
-      do_window_update ((WindowPtr) erp->message);
-      break;
-
-    case osEvt:
-      do_os_event (erp);
-      break;
-
-    case activateEvt:
-      if ((erp->modifiers & activeFlag) != 0)
-	do_window_activate ((WindowPtr) erp->message);
-      else
-	do_window_deactivate ((WindowPtr) erp->message);
-      break;
-    }
-}
+	note_mouse_movement (*f, &mouse_pos);
+    }
+}
+
 
 static void
 do_apple_menu (SInt16 menu_item)
@@ -7433,8 +7385,7 @@
 
     default:
       {
-        WindowPtr wp = FrontWindow ();
-        struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP;
+        struct frame *f = mac_window_to_frame (mac_front_window ());
         MenuHandle menu = GetMenuHandle (menu_id);
         if (menu)
           {
@@ -7459,8 +7410,7 @@
   long grow_size;
   Rect limit_rect;
   int rows, columns;
-  mac_output *mwp = (mac_output *) GetWRefCon (w);
-  struct frame *f = mwp->mFP;
+  struct frame *f = mac_window_to_frame (w);
 
   SetRect(&limit_rect, MIN_DOC_SIZE, MIN_DOC_SIZE, MAX_DOC_SIZE, MAX_DOC_SIZE);
 
@@ -7489,16 +7439,11 @@
   Rect zoom_rect, port_rect;
   Point top_left;
   int w_title_height, columns, rows, width, height, dummy, x, y;
-  mac_output *mwp = (mac_output *) GetWRefCon (w);
-  struct frame *f = mwp->mFP;
+  struct frame *f = mac_window_to_frame (w);
 
   GetPort (&save_port);
 
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (w));
-#else
-  SetPort (w);
-#endif
+  SetPortWindowPort (w);
 
   /* Clear window to avoid flicker.  */
 #if TARGET_API_MAC_CARBON
@@ -7551,7 +7496,7 @@
     }
 #endif /* not TARGET_API_MAC_CARBON */
 
-  ZoomWindow (w, zoom_in_or_out, w == FrontWindow ());
+  ZoomWindow (w, zoom_in_or_out, w == mac_front_window ());
 
   /* retrieve window size and update application values */
 #if TARGET_API_MAC_CARBON
@@ -7561,7 +7506,7 @@
 #endif
   rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, port_rect.bottom - port_rect.top);
   columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, port_rect.right - port_rect.left);
-  x_set_window_size (mwp->mFP, 0, columns, rows);
+  x_set_window_size (f, 0, columns, rows);
 
   SetPort (save_port);
 }
@@ -7892,8 +7837,8 @@
     {
       struct input_event event;
       Lisp_Object frame;
-      struct frame *f = ((mac_output *) GetWRefCon(window))->mFP;
-      SetPort (GetWindowPort (window));
+      struct frame *f = mac_window_to_frame (window);
+      SetPortWindowPort (window);
       GlobalToLocal (&mouse);
 
       event.kind = DRAG_N_DROP_EVENT;
@@ -8067,26 +8012,26 @@
 /* Emacs calls this whenever it wants to read an input event from the
    user. */
 int
-XTread_socket (int sd, int expected, struct input_event *hold_quit)
+XTread_socket (sd, expected, hold_quit)
+     int sd, expected;
+     struct input_event *hold_quit;
 {
   struct input_event inev;
   int count = 0;
 #if USE_CARBON_EVENTS
-  OSStatus rneResult;
   EventRef eventRef;
-  EventMouseButton mouseBtn;
+  EventTargetRef toolbox_dispatcher = GetEventDispatcherTarget ();
+#else
+  EventMask event_mask;
 #endif
   EventRecord er;
-  int the_modifiers;
-  EventMask event_mask;
-
-#if 0
+  struct mac_display_info *dpyinfo = &one_mac_display_info;
+
   if (interrupt_input_blocked)
     {
       interrupt_input_pending = 1;
       return -1;
     }
-#endif
 
   interrupt_input_pending = 0;
   BLOCK_INPUT;
@@ -8108,26 +8053,33 @@
   if (terminate_flag)
     Fkill_emacs (make_number (1));
 
-  /* It is necessary to set this (additional) argument slot of an
-     event to nil because keyboard.c protects incompletely processed
-     event from being garbage collected by placing them in the
-     kbd_buffer_gcpro vector.  */
-  EVENT_INIT (inev);
-  inev.kind = NO_EVENT;
-  inev.arg = Qnil;
-
+#if !USE_CARBON_EVENTS
   event_mask = everyEvent;
   if (NILP (Fboundp (Qmac_ready_for_drag_n_drop)))
     event_mask -= highLevelEventMask;
 
+  while (WaitNextEvent (event_mask, &er,
+			(expected ? app_sleep_time : 0L), NULL))
+#else
+  while (!ReceiveNextEvent (0, NULL,
+			    (expected ? TicksToEventTime (app_sleep_time) : 0),
+			    kEventRemoveFromQueue, &eventRef))
+#endif /* !USE_CARBON_EVENTS */
+    {
+      int do_help = 0;
+      struct frame *f;
+
+      expected = 0;
+
+      /* It is necessary to set this (additional) argument slot of an
+	 event to nil because keyboard.c protects incompletely
+	 processed event from being garbage collected by placing them
+	 in the kbd_buffer_gcpro vector.  */
+      EVENT_INIT (inev);
+      inev.kind = NO_EVENT;
+      inev.arg = Qnil;
+
 #if USE_CARBON_EVENTS
-  rneResult = ReceiveNextEvent (0, NULL,
-				expected
-				? TicksToEventTime (app_sleep_time)
-				: 0,
-				kEventRemoveFromQueue, &eventRef);
-  if (!rneResult)
-    {
       /* Handle new events */
       if (!mac_convert_event_ref (eventRef, &er))
 	switch (GetEventClass (eventRef))
@@ -8137,13 +8089,12 @@
 	      {
 		SInt32 delta;
 		Point point;
-		WindowPtr window_ptr = FrontNonFloatingWindow ();
-		struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr);
+		WindowPtr window_ptr = mac_front_window ();
+
 		if (!IsValidWindowPtr (window_ptr))
 		  {
 		    SysBeep(1);
-		    UNBLOCK_INPUT;
-		    return 0;
+		    break;
 		  }
 
 		GetEventParameter(eventRef, kEventParamMouseWheelDelta,
@@ -8154,458 +8105,556 @@
 				  NULL, &point);
 		inev.kind = WHEEL_EVENT;
 		inev.code = 0;
-		inev.modifiers = (mac_event_to_emacs_modifiers(eventRef)
+		inev.modifiers = (mac_event_to_emacs_modifiers (eventRef)
 				  | ((delta < 0) ? down_modifier
 				     : up_modifier));
-		SetPort (GetWindowPort (window_ptr));
+		SetPortWindowPort (window_ptr);
 		GlobalToLocal (&point);
 		XSETINT (inev.x, point.h);
 		XSETINT (inev.y, point.v);
-		XSETFRAME (inev.frame_or_window, mwp->mFP);
+		XSETFRAME (inev.frame_or_window,
+			   mac_window_to_frame (window_ptr));
 		inev.timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60);
 	      }
 	    else
-	      SendEventToEventTarget (eventRef, GetEventDispatcherTarget ());
+	      SendEventToEventTarget (eventRef, toolbox_dispatcher);
 
 	    break;
 	  default:
 	    /* Send the event to the appropriate receiver.  */
-	    SendEventToEventTarget (eventRef, GetEventDispatcherTarget ());
+	    SendEventToEventTarget (eventRef, toolbox_dispatcher);
 	  }
       else
+#endif /* USE_CARBON_EVENTS */
+      switch (er.what)
+	{
+	case mouseDown:
+	case mouseUp:
+	  {
+	    WindowPtr window_ptr;
+	    SInt16 part_code;
+	    int tool_bar_p = 0;
+
+	    if (dpyinfo->grabbed && last_mouse_frame
+		&& FRAME_LIVE_P (last_mouse_frame))
+	      {
+		window_ptr = FRAME_MAC_WINDOW (last_mouse_frame);
+		part_code = inContent;
+	      }
+	    else
+	      {
+		window_ptr = FrontWindow ();
+		if (tip_window && window_ptr == tip_window)
+		  {
+		    HideWindow (tip_window);
+		    window_ptr = FrontWindow ();
+		  }
+
+#if USE_CARBON_EVENTS
+		/* This is needed to send mouse events like aqua
+		   window buttons to the correct handler.  */
+		if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
+		    != eventNotHandledErr)
+		  break;
+
+		if (!is_emacs_window (window_ptr))
+		  break;
+#endif
+		part_code = FindWindow (er.where, &window_ptr);
+	      }
+
+	    switch (part_code)
+	      {
+	      case inMenuBar:
+		if (er.what == mouseDown)
+		  {
+		    f = mac_window_to_frame (mac_front_window ());
+		    saved_menu_event_location = er.where;
+		    inev.kind = MENU_BAR_ACTIVATE_EVENT;
+		    XSETFRAME (inev.frame_or_window, f);
+		  }
+		break;
+
+	      case inContent:
+		if (window_ptr != mac_front_window ())
+		  SelectWindow (window_ptr);
+		else
+		  {
+		    SInt16 control_part_code;
+		    ControlHandle ch;
+		    Point mouse_loc = er.where;
+
+		    f = mac_window_to_frame (window_ptr);
+		    /* convert to local coordinates of new window */
+		    SetPortWindowPort (window_ptr);
+
+		    GlobalToLocal (&mouse_loc);
+#if TARGET_API_MAC_CARBON
+		    ch = FindControlUnderMouse (mouse_loc, window_ptr,
+						&control_part_code);
 #else
-  if (WaitNextEvent (event_mask, &er, (expected ? app_sleep_time : 0L), NULL))
-#endif /* USE_CARBON_EVENTS */
-    switch (er.what)
-      {
-      case mouseDown:
-      case mouseUp:
-	{
-	  WindowPtr window_ptr = FrontWindow ();
-	  SInt16 part_code;
+		    control_part_code = FindControl (mouse_loc, window_ptr,
+						     &ch);
+#endif
 
 #if USE_CARBON_EVENTS
-	  /* This is needed to send mouse events like aqua window buttons
-	     to the correct handler.  */
-	  if (eventNotHandledErr != SendEventToEventTarget (eventRef, GetEventDispatcherTarget ())) {
+		    inev.code = mac_get_mouse_btn (eventRef);
+		    inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
+#else
+		    inev.code = mac_get_emulated_btn (er.modifiers);
+		    inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
+#endif
+		    XSETINT (inev.x, mouse_loc.h);
+		    XSETINT (inev.y, mouse_loc.v);
+		    inev.timestamp = er.when * (1000 / 60);
+		    /* ticks to milliseconds */
+
+		    if (dpyinfo->grabbed && tracked_scroll_bar
+#if TARGET_API_MAC_CARBON
+			|| ch != 0
+#else
+			|| control_part_code != 0
+#endif
+			)
+		      {
+			struct scroll_bar *bar;
+
+			if (dpyinfo->grabbed && tracked_scroll_bar)
+			  {
+			    bar = tracked_scroll_bar;
+			    control_part_code = kControlIndicatorPart;
+			  }
+			else
+			  bar = (struct scroll_bar *) GetControlReference (ch);
+			x_scroll_bar_handle_click (bar, control_part_code,
+						   &er, &inev);
+			if (er.what == mouseDown
+			    && control_part_code == kControlIndicatorPart)
+			  tracked_scroll_bar = bar;
+			else
+			  tracked_scroll_bar = NULL;
+		      }
+		    else
+		      {
+			Lisp_Object window;
+			int x = mouse_loc.h;
+			int y = mouse_loc.v;
+
+			window = window_from_coordinates (f, x, y, 0, 0, 0, 1);
+			if (EQ (window, f->tool_bar_window))
+			  {
+			    if (er.what == mouseDown)
+			      handle_tool_bar_click (f, x, y, 1, 0);
+			    else
+			      handle_tool_bar_click (f, x, y, 0,
+						     inev.modifiers);
+			    tool_bar_p = 1;
+			  }
+			else
+			  {
+			    XSETFRAME (inev.frame_or_window, f);
+			    inev.kind = MOUSE_CLICK_EVENT;
+			  }
+		      }
+
+		    if (er.what == mouseDown)
+		      {
+			dpyinfo->grabbed |= (1 << inev.code);
+			last_mouse_frame = f;
+			/* Ignore any mouse motion that happened
+			   before this event; any subsequent
+			   mouse-movement Emacs events should reflect
+			   only motion after the ButtonPress.  */
+			if (f != 0)
+			  f->mouse_moved = 0;
+
+			if (!tool_bar_p)
+			  last_tool_bar_item = -1;
+		      }
+		    else
+		      {
+			if (dpyinfo->grabbed & (1 << inev.code) == 0)
+			  /* If a button is released though it was not
+			     previously pressed, that would be because
+			     of multi-button emulation.  */
+			  dpyinfo->grabbed = 0;
+			else
+			  dpyinfo->grabbed &= ~(1 << inev.code);
+		      }
+
+		    switch (er.what)
+		      {
+		      case mouseDown:
+			inev.modifiers |= down_modifier;
+			break;
+		      case mouseUp:
+			inev.modifiers |= up_modifier;
+			break;
+		      }
+		  }
+		break;
+
+	      case inDrag:
+#if TARGET_API_MAC_CARBON
+		if (er.what == mouseDown)
+		  {
+		    BitMap bm;
+
+		    GetQDGlobalsScreenBits (&bm);
+		    DragWindow (window_ptr, er.where, &bm.bounds);
+		  }
+#else /* not TARGET_API_MAC_CARBON */
+		DragWindow (window_ptr, er.where, &qd.screenBits.bounds);
+#endif /* not TARGET_API_MAC_CARBON */
+		break;
+
+	      case inGoAway:
+		if (TrackGoAway (window_ptr, er.where))
+		  {
+		    inev.kind = DELETE_WINDOW_EVENT;
+		    XSETFRAME (inev.frame_or_window,
+			       mac_window_to_frame (window_ptr));
+		  }
+		break;
+
+		/* window resize handling added --ben */
+	      case inGrow:
+		if (er.what == mouseDown)
+		  {
+		    do_grow_window(window_ptr, &er);
+		    break;
+		  }
+
+		/* window zoom handling added --ben */
+	      case inZoomIn:
+	      case inZoomOut:
+		if (TrackBox (window_ptr, er.where, part_code))
+		  do_zoom_window (window_ptr, part_code);
+		break;
+
+	      default:
+		break;
+	      }
+	  }
+	  break;
+
+	case updateEvt:
+#if USE_CARBON_EVENTS
+	  if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
+	      != eventNotHandledErr)
 	    break;
-	  }
-
-	  if (!is_emacs_window(window_ptr))
+#endif
+	  do_window_update ((WindowPtr) er.message);
+	  break;
+
+	case osEvt:
+#if USE_CARBON_EVENTS
+	  if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
+	      != eventNotHandledErr)
 	    break;
 #endif
-
-          if (mouse_tracking_in_progress == mouse_tracking_scroll_bar
-	      && er.what == mouseUp)
-            {
-	      struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr);
-	      Point mouse_loc = er.where;
-
-	      /* Convert to local coordinates of new window.  */
-#if TARGET_API_MAC_CARBON
-              SetPort (GetWindowPort (window_ptr));
-#else
-              SetPort (window_ptr);
+	  switch ((er.message >> 24) & 0x000000FF)
+	    {
+	    case suspendResumeMessage:
+	      if ((er.message & resumeFlag) == 1)
+		do_app_resume ();
+	      else
+		do_app_suspend ();
+	      break;
+
+	    case mouseMovedMessage:
+	      previous_help_echo_string = help_echo_string;
+	      help_echo_string = help_echo_object = help_echo_window = Qnil;
+	      help_echo_pos = -1;
+
+	      do_mouse_moved (er.where, &f);
+
+	      /* If the contents of the global variable
+		 help_echo_string has changed, generate a
+		 HELP_EVENT.  */
+	      if (!NILP (help_echo_string) || !NILP (previous_help_echo_string))
+		do_help = 1;
+	      break;
+	    }
+	  break;
+
+	case activateEvt:
+	  {
+	    WindowPtr window_ptr = (WindowPtr) er.message;
+
+#if USE_CARBON_EVENTS
+	    if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
+		!= eventNotHandledErr)
+	      break;
 #endif
-
-	      GlobalToLocal (&mouse_loc);
+	    if (window_ptr == tip_window)
+	      {
+		HideWindow (tip_window);
+		break;
+	      }
+
+	    if ((er.modifiers & activeFlag) != 0)
+	      {
+		Point mouse_loc = er.where;
+
+		do_window_activate (window_ptr);
+
+		SetPortWindowPort (window_ptr);
+		GlobalToLocal (&mouse_loc);
+		/* activateEvt counts as mouse movement,
+		   so update things that depend on mouse position.  */
+		note_mouse_movement (mac_window_to_frame (window_ptr),
+				     &mouse_loc);
+	      }
+	    else
+	      {
+		do_window_deactivate (window_ptr);
+
+		f = mac_window_to_frame (window_ptr);
+		if (f == dpyinfo->mouse_face_mouse_frame)
+		  {
+		    /* If we move outside the frame, then we're
+		       certainly no longer on any text in the
+		       frame.  */
+		    clear_mouse_face (dpyinfo);
+		    dpyinfo->mouse_face_mouse_frame = 0;
+		  }
+
+		/* Generate a nil HELP_EVENT to cancel a help-echo.
+		   Do it only if there's something to cancel.
+		   Otherwise, the startup message is cleared when the
+		   mouse leaves the frame.  */
+		if (any_help_event_p)
+		  do_help = -1;
+	      }
+	  }
+	  break;
+
+	case keyDown:
+	case autoKey:
+	  {
+	    int keycode = (er.message & keyCodeMask) >> 8;
+	    int xkeysym;
 
 #if USE_CARBON_EVENTS
-	      inev.code = mac_get_mouse_btn (eventRef);
-#else
-	      inev.code = mac_get_emulate_btn (er.modifiers);
+	    /* When using Carbon Events, we need to pass raw keyboard
+	       events to the TSM ourselves.  If TSM handles it, it
+	       will pass back noErr, otherwise it will pass back
+	       "eventNotHandledErr" and we can process it
+	       normally.  */
+	    if ((!NILP (Vmac_pass_command_to_system)
+		 || !(er.modifiers & cmdKey))
+		&& (!NILP (Vmac_pass_control_to_system)
+		    || !(er.modifiers & controlKey)))
+	      if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
+		  != eventNotHandledErr)
+		break;
+#endif
+
+#if TARGET_API_MAC_CARBON
+	    if (!IsValidWindowPtr (mac_front_window ()))
+	      {
+		SysBeep (1);
+		break;
+	      }
 #endif
-              inev.kind = SCROLL_BAR_CLICK_EVENT;
-              inev.frame_or_window = tracked_scroll_bar->window;
-              inev.part = scroll_bar_handle;
+
+	    ObscureCursor ();
+
+	    if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight))
+	      {
+		clear_mouse_face (dpyinfo);
+		dpyinfo->mouse_face_hidden = 1;
+	      }
+
+	    if (keycode_to_xkeysym (keycode, &xkeysym))
+	      {
+		inev.code = 0xff00 | xkeysym;
+		inev.kind = NON_ASCII_KEYSTROKE_EVENT;
+	      }
+	    else
+	      {
+		if (er.modifiers & (controlKey |
+				    (NILP (Vmac_command_key_is_meta) ? optionKey
+				     : cmdKey)))
+		  {
+		    /* This code comes from Keyboard Resource,
+		       Appendix C of IM - Text.  This is necessary
+		       since shift is ignored in KCHR table
+		       translation when option or command is pressed.
+		       It also does not translate correctly
+		       control-shift chars like C-% so mask off shift
+		       here also */
+		    int new_modifiers = er.modifiers & 0xe600;
+		    /* mask off option and command */
+		    int new_keycode = keycode | new_modifiers;
+		    Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
+		    unsigned long some_state = 0;
+		    inev.code = KeyTranslate (kchr_ptr, new_keycode,
+					      &some_state) & 0xff;
+		  }
+		else
+		  inev.code = er.message & charCodeMask;
+		inev.kind = ASCII_KEYSTROKE_EVENT;
+	      }
+	  }
+
+	  /* If variable mac-convert-keyboard-input-to-latin-1 is
+	     non-nil, convert non-ASCII characters typed at the Mac
+	     keyboard (presumed to be in the Mac Roman encoding) to
+	     iso-latin-1 encoding before they are passed to Emacs.
+	     This enables the Mac keyboard to be used to enter
+	     non-ASCII iso-latin-1 characters directly.  */
+	  if (mac_keyboard_text_encoding != kTextEncodingMacRoman
+	      && inev.kind == ASCII_KEYSTROKE_EVENT && inev.code >= 128)
+	    {
+	      static TECObjectRef converter = NULL;
+	      OSStatus the_err = noErr;
+	      OSStatus convert_status = noErr;
+
+	      if (converter ==  NULL)
+		{
+		  the_err = TECCreateConverter (&converter,
+						kTextEncodingMacRoman,
+						mac_keyboard_text_encoding);
+		  current_mac_keyboard_text_encoding
+		    = mac_keyboard_text_encoding;
+		}
+	      else if (mac_keyboard_text_encoding
+		       != current_mac_keyboard_text_encoding)
+		{
+		  /* Free the converter for the current encoding
+		     before creating a new one.  */
+		  TECDisposeConverter (converter);
+		  the_err = TECCreateConverter (&converter,
+						kTextEncodingMacRoman,
+						mac_keyboard_text_encoding);
+		  current_mac_keyboard_text_encoding
+		    = mac_keyboard_text_encoding;
+		}
+
+	      if (the_err == noErr)
+		{
+		  unsigned char ch = inev.code;
+		  ByteCount actual_input_length, actual_output_length;
+		  unsigned char outch;
+
+		  convert_status = TECConvertText (converter, &ch, 1,
+						   &actual_input_length,
+						   &outch, 1,
+						   &actual_output_length);
+		  if (convert_status == noErr
+		      && actual_input_length == 1
+		      && actual_output_length == 1)
+		    inev.code = outch;
+		}
+	    }
+
+#if USE_CARBON_EVENTS
+	  inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
+#else
+	  inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
+#endif
+	  XSETFRAME (inev.frame_or_window,
+		     mac_window_to_frame (mac_front_window ()));
+	  inev.timestamp = er.when * (1000 / 60);  /* ticks to milliseconds */
+	  break;
+
+	case kHighLevelEvent:
+	  drag_and_drop_file_list = Qnil;
+
+	  AEProcessAppleEvent(&er);
+
+	  /* Build a DRAG_N_DROP_EVENT type event as is done in
+	     constuct_drag_n_drop in w32term.c.  */
+	  if (!NILP (drag_and_drop_file_list))
+	    {
+	      struct frame *f = NULL;
+	      WindowPtr wp;
+	      Lisp_Object frame;
+
+	      wp = mac_front_window ();
+
+	      if (!wp)
+		{
+		  struct frame *f = XFRAME (XCAR (Vframe_list));
+		  CollapseWindow (FRAME_MAC_WINDOW (f), false);
+		  wp = mac_front_window ();
+		}
+
+	      if (wp && is_emacs_window (wp))
+		f = mac_window_to_frame (wp);
+
+	      inev.kind = DRAG_N_DROP_EVENT;
+	      inev.code = 0;
+	      inev.timestamp = er.when * (1000 / 60);
+	      /* ticks to milliseconds */
 #if USE_CARBON_EVENTS
 	      inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
 #else
 	      inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
 #endif
-              inev.modifiers |= up_modifier;
-	      inev.timestamp = er.when * (1000 / 60);
-	        /* ticks to milliseconds */
-
-              XSETINT (inev.x, XFASTINT (tracked_scroll_bar->left) + 2);
-              XSETINT (inev.y, mouse_loc.v - 24);
-              tracked_scroll_bar->dragging = Qnil;
-              mouse_tracking_in_progress = mouse_tracking_none;
-              tracked_scroll_bar = NULL;
-              break;
-            }
-
-	  part_code = FindWindow (er.where, &window_ptr);
-
-	  switch (part_code)
-	    {
-	    case inMenuBar:
-	      if (er.what == mouseDown)
-		{
-		  struct frame *f = ((mac_output *)
-				     GetWRefCon (FrontWindow ()))->mFP;
-		  saved_menu_event_location = er.where;
-		  inev.kind = MENU_BAR_ACTIVATE_EVENT;
-		  XSETFRAME (inev.frame_or_window, f);
-		}
-	      break;
-
-	    case inContent:
-	      if (window_ptr != FrontWindow ())
-		SelectWindow (window_ptr);
-	      else
-	        {
-		  SInt16 control_part_code;
-		  ControlHandle ch;
-		  struct mac_output *mwp = (mac_output *)
-		    GetWRefCon (window_ptr);
-		  Point mouse_loc = er.where;
-
-		  /* convert to local coordinates of new window */
-#if TARGET_API_MAC_CARBON
-                  SetPort (GetWindowPort (window_ptr));
-#else
-                  SetPort (window_ptr);
-#endif
-
-		  GlobalToLocal (&mouse_loc);
-#if TARGET_API_MAC_CARBON
-		  ch = FindControlUnderMouse (mouse_loc, window_ptr,
-					      &control_part_code);
-#else
-		  control_part_code = FindControl (mouse_loc, window_ptr, &ch);
-#endif
-
-#if USE_CARBON_EVENTS
-		  inev.code = mac_get_mouse_btn (eventRef);
-#else
-		  inev.code = mac_get_emulate_btn (er.modifiers);
-#endif
-		  XSETINT (inev.x, mouse_loc.h);
-		  XSETINT (inev.y, mouse_loc.v);
-		  inev.timestamp = er.when * (1000 / 60);
-		    /* ticks to milliseconds */
-
+
+	      XSETINT (inev.x, 0);
+	      XSETINT (inev.y, 0);
+
+	      XSETFRAME (frame, f);
+	      inev.frame_or_window = Fcons (frame, drag_and_drop_file_list);
+
+	      /* Regardless of whether Emacs was suspended or in the
+		 foreground, ask it to redraw its entire screen.
+		 Otherwise parts of the screen can be left in an
+		 inconsistent state.  */
+	      if (wp)
 #if TARGET_API_MAC_CARBON
-		  if (ch != 0)
-#else
-		  if (control_part_code != 0)
-#endif
-		    {
-		      struct scroll_bar *bar = (struct scroll_bar *)
-			GetControlReference (ch);
-		      x_scroll_bar_handle_click (bar, control_part_code, &er,
-						 &inev);
-		      if (er.what == mouseDown
-			  && control_part_code == kControlIndicatorPart)
-		        {
-		          mouse_tracking_in_progress
-			    = mouse_tracking_scroll_bar;
-		          tracked_scroll_bar = bar;
-		        }
-		      else
-		        {
-		          mouse_tracking_in_progress = mouse_tracking_none;
-		          tracked_scroll_bar = NULL;
-		        }
-		    }
-		  else
-	            {
-		      Lisp_Object window;
-		      int x = mouse_loc.h;
-		      int y = mouse_loc.v;
-
-		      XSETFRAME (inev.frame_or_window, mwp->mFP);
-		      if (er.what == mouseDown)
-			mouse_tracking_in_progress
-			  = mouse_tracking_mouse_movement;
-		      else
-			mouse_tracking_in_progress = mouse_tracking_none;
-		      window = window_from_coordinates (mwp->mFP, x, y, 0, 0, 0, 1);
-
-		      if (EQ (window, mwp->mFP->tool_bar_window))
-			{
-			  if (er.what == mouseDown)
-			    handle_tool_bar_click (mwp->mFP, x, y, 1, 0);
-			  else
-			    handle_tool_bar_click (mwp->mFP, x, y, 0,
-#if USE_CARBON_EVENTS
-						   mac_event_to_emacs_modifiers (eventRef)
-#else
-						   er.modifiers
-#endif
-						   );
-			  break;
-			}
-		      else
-			inev.kind = MOUSE_CLICK_EVENT;
-		    }
-
-#if USE_CARBON_EVENTS
-		  inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
-#else
-		  inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
-#endif
-
-	          switch (er.what)
-		    {
-		    case mouseDown:
-		      inev.modifiers |= down_modifier;
-		      break;
-		    case mouseUp:
-		      inev.modifiers |= up_modifier;
-		      break;
-		    }
-	        }
-	      break;
-
-	    case inDrag:
-#if TARGET_API_MAC_CARBON
-              if (er.what == mouseDown)
 		{
-		  BitMap bm;
-
-		  GetQDGlobalsScreenBits (&bm);
-		  DragWindow (window_ptr, er.where, &bm.bounds);
+		  Rect r;
+
+		  GetWindowPortBounds (wp, &r);
+		  InvalWindowRect (wp, &r);
 		}
 #else /* not TARGET_API_MAC_CARBON */
-	      DragWindow (window_ptr, er.where, &qd.screenBits.bounds);
+                InvalRect (&(wp->portRect));
 #endif /* not TARGET_API_MAC_CARBON */
-	      break;
-
-	    case inGoAway:
-	      if (TrackGoAway (window_ptr, er.where))
-	        {
-	          inev.kind = DELETE_WINDOW_EVENT;
-	          XSETFRAME (inev.frame_or_window,
-			     ((mac_output *) GetWRefCon (window_ptr))->mFP);
-	        }
-	      break;
-
-	    /* window resize handling added --ben */
-	    case inGrow:
-              if (er.what == mouseDown)
-		{
-		  do_grow_window(window_ptr, &er);
-		  break;
-		}
-
-	    /* window zoom handling added --ben */
-	    case inZoomIn:
-	    case inZoomOut:
-	      if (TrackBox (window_ptr, er.where, part_code))
-	        do_zoom_window (window_ptr, part_code);
-	      break;
-
-	    default:
-	      break;
 	    }
+	default:
+	  break;
 	}
-	break;
-
-      case updateEvt:
-      case osEvt:
-      case activateEvt:
 #if USE_CARBON_EVENTS
-	if (eventNotHandledErr == SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()))
+      ReleaseEvent (eventRef);
 #endif
-    	do_events (&er);
-	break;
-
-      case keyDown:
-      case autoKey:
+
+      if (inev.kind != NO_EVENT)
 	{
-	  int keycode = (er.message & keyCodeMask) >> 8;
-	  int xkeysym;
-
-#if USE_CARBON_EVENTS
-	  /* When using Carbon Events, we need to pass raw keyboard events
-	     to the TSM ourselves.  If TSM handles it, it will pass back
-	     noErr, otherwise it will pass back "eventNotHandledErr" and
-	     we can process it normally.   */
-	  if ((!NILP (Vmac_pass_command_to_system)
-	       || !(er.modifiers & cmdKey))
-	      && (!NILP (Vmac_pass_control_to_system)
-		  || !(er.modifiers & controlKey)))
+	  kbd_buffer_store_event_hold (&inev, hold_quit);
+	  count++;
+	}
+
+      if (do_help
+	  && !(hold_quit && hold_quit->kind != NO_EVENT))
+	{
+	  Lisp_Object frame;
+
+	  if (f)
+	    XSETFRAME (frame, f);
+	  else
+	    frame = Qnil;
+
+	  if (do_help > 0)
 	    {
-	      OSStatus err;
-	      err = SendEventToEventTarget (eventRef,
-					    GetEventDispatcherTarget ());
-	      if (err != eventNotHandledErr)
-		break;
-	    }
-#endif
-
-	  if (!IsValidWindowPtr (FrontNonFloatingWindow ()))
-	    {
-	      SysBeep (1);
-	      UNBLOCK_INPUT;
-	      return 0;
-	    }
-
-	  ObscureCursor ();
-
-	  if (keycode_to_xkeysym (keycode, &xkeysym))
-	    {
-	      inev.code = 0xff00 | xkeysym;
-	      inev.kind = NON_ASCII_KEYSTROKE_EVENT;
+	      any_help_event_p = 1;
+	      gen_help_event (help_echo_string, frame, help_echo_window,
+			      help_echo_object, help_echo_pos);
 	    }
 	  else
 	    {
-	      if (er.modifiers & (controlKey |
-				  (NILP (Vmac_command_key_is_meta) ? optionKey
-				   : cmdKey)))
-		{
-		  /* This code comes from Keyboard Resource, Appendix
-		     C of IM - Text.  This is necessary since shift is
-		     ignored in KCHR table translation when option or
-		     command is pressed.  It also does not translate
-		     correctly control-shift chars like C-% so mask off
-		     shift here also */
-		  int new_modifiers = er.modifiers & 0xe600;
-		  /* mask off option and command */
-		  int new_keycode = keycode | new_modifiers;
-		  Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
-		  unsigned long some_state = 0;
-		  inev.code = KeyTranslate (kchr_ptr, new_keycode,
-					    &some_state) & 0xff;
-		}
-	      else
-		inev.code = er.message & charCodeMask;
-	      inev.kind = ASCII_KEYSTROKE_EVENT;
+	      help_echo_string = Qnil;
+	      gen_help_event (Qnil, frame, Qnil, Qnil, 0);
 	    }
+	  count++;
 	}
 
-	/* If variable mac-convert-keyboard-input-to-latin-1 is non-nil,
-	   convert non-ASCII characters typed at the Mac keyboard
-	   (presumed to be in the Mac Roman encoding) to iso-latin-1
-	   encoding before they are passed to Emacs.  This enables the
-	   Mac keyboard to be used to enter non-ASCII iso-latin-1
-	   characters directly.  */
-	if (mac_keyboard_text_encoding != kTextEncodingMacRoman
-	    && inev.kind == ASCII_KEYSTROKE_EVENT && inev.code >= 128)
-	  {
-	    static TECObjectRef converter = NULL;
-	    OSStatus the_err = noErr;
-	    OSStatus convert_status = noErr;
-
-	    if (converter ==  NULL)
-	      {
-		the_err = TECCreateConverter (&converter,
-					      kTextEncodingMacRoman,
-					      mac_keyboard_text_encoding);
-		current_mac_keyboard_text_encoding
-		  = mac_keyboard_text_encoding;
-	      }
-	    else if (mac_keyboard_text_encoding
-		     != current_mac_keyboard_text_encoding)
-	      {
-		/* Free the converter for the current encoding before
-		   creating a new one.  */
-		TECDisposeConverter (converter);
-		the_err = TECCreateConverter (&converter,
-					      kTextEncodingMacRoman,
-					      mac_keyboard_text_encoding);
-		current_mac_keyboard_text_encoding
-		  = mac_keyboard_text_encoding;
-	      }
-
-	    if (the_err == noErr)
-	      {
-		unsigned char ch = inev.code;
-		ByteCount actual_input_length, actual_output_length;
-		unsigned char outch;
-
-		convert_status = TECConvertText (converter, &ch, 1,
-						 &actual_input_length,
-						 &outch, 1,
-						 &actual_output_length);
-		if (convert_status == noErr
-		    && actual_input_length == 1
-		    && actual_output_length == 1)
-		  inev.code = outch;
-	      }
-	  }
-
-#if USE_CARBON_EVENTS
-	inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
-#else
-	inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
-#endif
-
-	{
-	  mac_output *mwp
-	    = (mac_output *) GetWRefCon (FrontNonFloatingWindow ());
-	  XSETFRAME (inev.frame_or_window, mwp->mFP);
-	}
-
-	inev.timestamp = er.when * (1000 / 60);  /* ticks to milliseconds */
-	break;
-
-      case kHighLevelEvent:
-        drag_and_drop_file_list = Qnil;
-
-        AEProcessAppleEvent(&er);
-
-        /* Build a DRAG_N_DROP_EVENT type event as is done in
-           constuct_drag_n_drop in w32term.c.  */
-        if (!NILP (drag_and_drop_file_list))
-          {
-            struct frame *f = NULL;
-            WindowPtr wp;
-            Lisp_Object frame;
-
-            wp = FrontNonFloatingWindow ();
-
-	    if (!wp)
-	      {
-		struct frame *f = XFRAME (XCAR (Vframe_list));
-		CollapseWindow (FRAME_MAC_WINDOW (f), false);
-		wp = FrontNonFloatingWindow ();
-	      }
-
-            if (wp && is_emacs_window(wp))
-	        f = ((mac_output *) GetWRefCon (wp))->mFP;
-
-            inev.kind = DRAG_N_DROP_EVENT;
-            inev.code = 0;
-            inev.timestamp = er.when * (1000 / 60);
-	      /* ticks to milliseconds */
-#if USE_CARBON_EVENTS
-	    inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
-#else
-	    inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
-#endif
-
-            XSETINT (inev.x, 0);
-            XSETINT (inev.y, 0);
-
-            XSETFRAME (frame, f);
-            inev.frame_or_window = Fcons (frame, drag_and_drop_file_list);
-
-            /* Regardless of whether Emacs was suspended or in the
-               foreground, ask it to redraw its entire screen.
-               Otherwise parts of the screen can be left in an
-               inconsistent state.  */
-            if (wp)
-#if TARGET_API_MAC_CARBON
-	      {
-	        Rect r;
-
-	        GetWindowPortBounds (wp, &r);
-	        InvalWindowRect (wp, &r);
-	      }
-#else /* not TARGET_API_MAC_CARBON */
-              InvalRect (&(wp->portRect));
-#endif /* not TARGET_API_MAC_CARBON */
-          }
-      default:
-	break;
-      }
-#if USE_CARBON_EVENTS
-      ReleaseEvent (eventRef);
-    }
-#endif
+    }
 
   /* If the focus was just given to an autoraising frame,
      raise it now.  */
@@ -8620,58 +8669,6 @@
   check_alarm ();  /* simulate the handling of a SIGALRM */
 #endif
 
-  {
-    static Point old_mouse_pos = { -1, -1 };
-
-    if (app_is_suspended)
-      {
-        old_mouse_pos.h = -1;
-        old_mouse_pos.v = -1;
-      }
-    else
-      {
-        Point mouse_pos;
-        WindowPtr wp;
-        struct frame *f;
-        Lisp_Object bar;
-        struct scroll_bar *sb;
-
-        wp = FrontWindow ();
-	if (is_emacs_window (wp))
-	  {
-	    f = ((mac_output *) GetWRefCon (wp))->mFP;
-
-#if TARGET_API_MAC_CARBON
-	    SetPort (GetWindowPort (wp));
-#else
-	    SetPort (wp);
-#endif
-
-	    GetMouse (&mouse_pos);
-
-	    if (!EqualPt (mouse_pos, old_mouse_pos))
-	      {
-		if (mouse_tracking_in_progress == mouse_tracking_scroll_bar
-		    && tracked_scroll_bar)
-		  x_scroll_bar_note_movement (tracked_scroll_bar,
-					      mouse_pos.v
-					      - XINT (tracked_scroll_bar->top),
-					      TickCount() * (1000 / 60));
-		else
-		  note_mouse_movement (f, &mouse_pos);
-
-		old_mouse_pos = mouse_pos;
-	      }
-	  }
-      }
-  }
-
-  if (inev.kind != NO_EVENT)
-    {
-      kbd_buffer_store_event_hold (&inev, hold_quit);
-      count++;
-    }
-
   UNBLOCK_INPUT;
   return count;
 }
@@ -8700,7 +8697,7 @@
    ROWS Macintosh window, using font with name FONTNAME and size
    FONTSIZE.  */
 void
-NewMacWindow (FRAME_PTR fp)
+make_mac_frame (FRAME_PTR fp)
 {
   mac_output *mwp;
 #if TARGET_API_MAC_CARBON
@@ -8719,57 +8716,30 @@
       making_terminal_window = 0;
     }
   else
-    if (!(mwp->mWP = GetNewCWindow (WINDOW_RESOURCE, NULL, (WindowPtr) -1)))
-      abort ();
+    {
+#if TARGET_API_MAC_CARBON
+      Rect r;
+
+      SetRect (&r, 0, 0, 1, 1);
+      if (CreateNewWindow (kDocumentWindowClass,
+			   kWindowStandardDocumentAttributes
+			   /* | kWindowToolbarButtonAttribute */,
+			   &r, &mwp->mWP) != noErr)
+#else
+      if (!(mwp->mWP = GetNewCWindow (WINDOW_RESOURCE, NULL, (WindowPtr) -1)))
+#endif
+	abort ();
+    }
 
   SetWRefCon (mwp->mWP, (long) mwp);
     /* so that update events can find this mac_output struct */
   mwp->mFP = fp;  /* point back to emacs frame */
 
-#if TARGET_API_MAC_CARBON
-  SetPort (GetWindowPort (mwp->mWP));
-#else
-  SetPort (mwp->mWP);
-#endif
-
-  mwp->fontset = -1;
+  SetPortWindowPort (mwp->mWP);
 
   SizeWindow (mwp->mWP, FRAME_PIXEL_WIDTH (fp), FRAME_PIXEL_HEIGHT (fp), false);
-  ShowWindow (mwp->mWP);
-
-}
-
-
-void
-make_mac_frame (struct frame *f)
-{
-  FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR;
-
-  NewMacWindow(f);
-
-  f->output_data.mac->cursor_pixel = 0;
-  f->output_data.mac->border_pixel = 0x00ff00;
-  f->output_data.mac->mouse_pixel = 0xff00ff;
-  f->output_data.mac->cursor_foreground_pixel = 0x0000ff;
-
-  FRAME_FONTSET (f) = -1;
-  f->output_data.mac->scroll_bar_foreground_pixel = -1;
-  f->output_data.mac->scroll_bar_background_pixel = -1;
-  f->output_data.mac->explicit_parent = 0;
-  f->left_pos = 4;
-  f->top_pos = 4;
-  f->border_width = 0;
-
-  f->internal_border_width = 0;
-
-  f->output_method = output_mac;
-
-  f->auto_raise = 1;
-  f->auto_lower = 1;
-
-  f->new_text_cols = 0;
-  f->new_text_lines = 0;
-}
+}
+
 
 void
 make_mac_terminal_frame (struct frame *f)
@@ -8782,9 +8752,6 @@
   f->output_data.mac = (struct mac_output *)
     xmalloc (sizeof (struct mac_output));
   bzero (f->output_data.mac, sizeof (struct mac_output));
-  FRAME_FONTSET (f) = -1;
-  f->output_data.mac->scroll_bar_foreground_pixel = -1;
-  f->output_data.mac->scroll_bar_background_pixel = -1;
 
   XSETFRAME (FRAME_KBOARD (f)->Vdefault_minibuffer_frame, f);
 
@@ -8794,6 +8761,27 @@
   FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
   FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_right;
 
+  FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR;
+
+  f->output_data.mac->cursor_pixel = 0;
+  f->output_data.mac->border_pixel = 0x00ff00;
+  f->output_data.mac->mouse_pixel = 0xff00ff;
+  f->output_data.mac->cursor_foreground_pixel = 0x0000ff;
+
+  FRAME_FONTSET (f) = -1;
+  f->output_data.mac->explicit_parent = 0;
+  f->left_pos = 4;
+  f->top_pos = 4;
+  f->border_width = 0;
+
+  f->internal_border_width = 0;
+
+  f->auto_raise = 1;
+  f->auto_lower = 1;
+
+  f->new_text_cols = 0;
+  f->new_text_lines = 0;
+
   make_mac_frame (f);
 
   x_make_gc (f);
@@ -8810,6 +8798,8 @@
   Fmodify_frame_parameters (frame,
                             Fcons (Fcons (Qbackground_color,
                                           build_string ("white")), Qnil));
+
+  ShowWindow (f->output_data.mac->mWP);
 }
 
 
@@ -8864,6 +8854,8 @@
   dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
   dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID;
   dpyinfo->mouse_face_window = Qnil;
+  dpyinfo->mouse_face_overlay = Qnil;
+  dpyinfo->mouse_face_hidden = 0;
 }
 
 struct mac_display_info *
@@ -9020,8 +9012,7 @@
   if (event)
     {
       struct input_event e;
-      struct mac_output *mwp =
-	(mac_output *) GetWRefCon (FrontNonFloatingWindow ());
+
       /* Use an input_event to emulate what the interrupt handler does. */
       EVENT_INIT (e);
       e.kind = ASCII_KEYSTROKE_EVENT;
@@ -9029,7 +9020,7 @@
       e.arg = Qnil;
       e.modifiers = NULL;
       e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60);
-      XSETFRAME (e.frame_or_window, mwp->mFP);
+      XSETFRAME (e.frame_or_window, mac_window_to_frame (mac_front_window ()));
       /* Remove event from queue to prevent looping. */
       RemoveEventFromQueue (GetMainEventQueue (), event);
       ReleaseEvent (event);
--- a/src/undo.c	Sun May 30 21:11:48 2004 +0000
+++ b/src/undo.c	Mon May 31 13:48:26 2004 +0000
@@ -292,14 +292,15 @@
 
 /* At garbage collection time, make an undo list shorter at the end,
    returning the truncated list.
-   MINSIZE and MAXSIZE are the limits on size allowed, as described below.
-   In practice, these are the values of undo-limit and
-   undo-strong-limit.  */
+   MINSIZE, MAXSIZE and LIMITSIZE are the limits on size allowed,
+   as described below.
+   In practice, these are the values of undo-limit,
+   undo-strong-limit, and undo-outer-limit.  */
 
 Lisp_Object
-truncate_undo_list (list, minsize, maxsize)
+truncate_undo_list (list, minsize, maxsize, limitsize)
      Lisp_Object list;
-     int minsize, maxsize;
+     int minsize, maxsize, limitsize;
 {
   Lisp_Object prev, next, last_boundary;
   int size_so_far = 0;
@@ -308,7 +309,8 @@
   next = list;
   last_boundary = Qnil;
 
-  /* Always preserve at least the most recent undo record.
+  /* Always preserve at least the most recent undo record
+     unless it is really horribly big.
      If the first element is an undo boundary, skip past it.
 
      Skip, skip, skip the undo, skip, skip, skip the undo,
@@ -323,6 +325,7 @@
       prev = next;
       next = XCDR (next);
     }
+
   while (CONSP (next) && ! NILP (XCAR (next)))
     {
       Lisp_Object elt;
@@ -338,13 +341,20 @@
 			    + SCHARS (XCAR (elt)));
 	}
 
+      /* If we reach LIMITSIZE before the first boundary,
+	 we're heading for memory full, so truncate the list to nothing.  */
+      if (size_so_far > limitsize)
+	return Qnil;
+
       /* Advance to next element.  */
       prev = next;
       next = XCDR (next);
     }
+
   if (CONSP (next))
     last_boundary = prev;
 
+  /* Keep more if it fits.  */
   while (CONSP (next))
     {
       Lisp_Object elt;
--- a/src/xdisp.c	Sun May 30 21:11:48 2004 +0000
+++ b/src/xdisp.c	Mon May 31 13:48:26 2004 +0000
@@ -198,8 +198,6 @@
 #endif
 #ifdef MAC_OS
 #include "macterm.h"
-
-Cursor No_Cursor;
 #endif
 
 #ifndef FRAME_X_OUTPUT
@@ -20636,11 +20634,7 @@
 	cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
     }
 
-#ifndef HAVE_CARBON
   if (cursor != No_Cursor)
-#else
-  if (bcmp (&cursor, &No_Cursor, sizeof (Cursor)))
-#endif
     FRAME_RIF (f)->define_frame_cursor (f, cursor);
 }