changeset 89969:3219f94257bc

Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-34 Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-514 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-522 Update from CVS
author Miles Bader <miles@gnu.org>
date Sat, 04 Sep 2004 09:14:28 +0000
parents 1e9fa4848335 (current diff) 9cd521d53335 (diff)
children a849e5779b8c
files admin/ChangeLog etc/NEWS lisp/ChangeLog lisp/autorevert.el lisp/emacs-lisp/lisp-mode.el lisp/emacs-lisp/lisp.el lisp/emulation/cua-base.el lisp/emulation/cua-rect.el lisp/help-fns.el lisp/help.el lisp/indent.el lisp/info.el lisp/isearch.el lisp/macros.el lisp/progmodes/compile.el lisp/progmodes/etags.el lisp/progmodes/grep.el lisp/simple.el lisp/startup.el lisp/subr.el lisp/term/mac-win.el lisp/textmodes/ispell.el lisp/textmodes/tex-mode.el lisp/x-dnd.el lispref/ChangeLog lispref/abbrevs.texi lwlib/ChangeLog lwlib/lwlib.h man/ChangeLog man/ack.texi man/building.texi man/cmdargs.texi man/commands.texi man/doclicense.texi man/emacs.texi man/entering.texi man/faq.texi man/frames.texi man/indent.texi man/killing.texi man/misc.texi man/programs.texi man/search.texi man/trouble.texi man/windows.texi src/ChangeLog src/fileio.c src/gtkutil.c src/gtkutil.h src/macfns.c src/macmenu.c src/macterm.c src/s/darwin.h src/w32fns.c src/w32menu.c src/xdisp.c src/xfns.c src/xmenu.c
diffstat 60 files changed, 2063 insertions(+), 1048 deletions(-) [+]
line wrap: on
line diff
--- a/admin/ChangeLog	Wed Sep 01 21:21:18 2004 +0000
+++ b/admin/ChangeLog	Sat Sep 04 09:14:28 2004 +0000
@@ -1,6 +1,15 @@
+2004-08-29  Kim F. Storm  <storm@cua.dk>
+
+	* FOR-RELEASE (Documentation): Add man/ack.texi and AUTHORS.
+
+2004-08-28  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* FOR-RELEASE (Indications): Remove entry about GTK and geometry,
+	(now behaves as well as other ports).
+
 2004-06-28  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
-	* FOR-RELEASE: Removed entry about GTK and monochrome displays (done).
+	* FOR-RELEASE: Remove entry about GTK and monochrome displays (done).
 
 2002-06-26  Eli Zaretskii  <eliz@is.elta.co.il>
 
--- a/admin/FOR-RELEASE	Wed Sep 01 21:21:18 2004 +0000
+++ b/admin/FOR-RELEASE	Sat Sep 04 09:14:28 2004 +0000
@@ -14,6 +14,10 @@
 
 ** Update man/info.texi.
 
+** Update man/ack.texi.
+
+** Update AUTHORS.
+
 
 * NEW FEATURES
 
@@ -38,8 +42,6 @@
 
 * GTK RELATED BUGS
 
-** Make geometry specifications work correctly for GTK.
-
 ** Make GTK scrollbars behave like others w.r.t. overscrolling.
 
 
--- a/etc/NEWS	Wed Sep 01 21:21:18 2004 +0000
+++ b/etc/NEWS	Sat Sep 04 09:14:28 2004 +0000
@@ -173,6 +173,10 @@
 
 * Changes in Emacs 21.4
 
++++
+** `apply-macro-to-region-lines' now operates on all lines that begin
+in the region, rather than on all complete lines in the region.
+
 ** global-whitespace-mode is a new alias for whitespace-global-mode.
 
 +++
@@ -590,6 +594,13 @@
 *** A numeric prefix argument of `info' selects an Info buffer
 with the number appended to the *info* buffer name.
 
+*** Regexp isearch (C-M-s and C-M-r) can search through multiple nodes.
+Failed isearch wraps to the top/final node.
+
+*** New search commands: `Info-search-case-sensitively' (bound to S),
+`Info-search-backward', and `Info-search-next' which repeats the last
+search without prompting for a new search string.
+
 *** New command `Info-history' (bound to L) displays a menu of visited nodes.
 
 *** New command `Info-toc' (bound to T) creates a node with table of contents
@@ -603,11 +614,6 @@
 the current Info node name into the kill ring.  With a zero prefix
 arg, puts the node name inside the `info' function call.
 
-*** New command `Info-search-case-sensitively' (bound to S).
-
-*** New command `Info-search-next' (unbound) repeats the last search
-without prompting for a new search string.
-
 *** New face `info-xref-visited' distinguishes visited nodes from unvisited
 and a new option `Info-fontify-visited-nodes' to control this.
 
@@ -1184,9 +1190,9 @@
 and to type `C-f' at the end of the search string in the minibuffer.
 
 +++
-** M-% and C-M-% typed in isearch mode invoke `query-replace' and
-`query-replace-regexp' with the current search string inserted
-in the minibuffer as initial input for the string to replace.
+** M-% typed in isearch mode invokes `query-replace' or
+`query-replace-regexp' (depending on search mode) with the current
+search string used as the string to replace.
 
 +++
 ** Yanking text now discards certain text properties that can
@@ -1933,7 +1939,9 @@
 compilation processes without affecting the environment that all
 subprocesses inherit.
 
-*** `next-error' now temporarily highlights the corresponding source line.
+*** New options `next-error-highlight' and `next-error-highlight-no-select'
+specify the method of highlighting of the corresponding source line
+in new face `next-error'.
 
 ** Grep has been decoupled from compilation mode setup.
 
@@ -1945,7 +1953,12 @@
 `grep-scroll-output' can be used to override the corresponding
 compilation mode settings for grep commands.
 
-*** Source line is temporarily highlighted when going to next match.
+*** New option `grep-highlight-matches' highlightes matches in *grep*
+buffer.  It uses a special feature of some grep programs which accept
+--color option to output markers around matches.  When going to the next
+match with `next-error' the exact match is highlighted in the source
+buffer.  Otherwise, if `grep-highlight-matches' is nil, the whole
+source line is highlighted.
 
 *** New key bindings in grep output window:
 SPC and DEL scrolls window up and down.  C-n and C-p moves to next and
--- a/lisp/ChangeLog	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/ChangeLog	Sat Sep 04 09:14:28 2004 +0000
@@ -1,3 +1,218 @@
+2004-09-03  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* autorevert.el (auto-revert-handler): Bind `buffer-read-only'
+	locally around the call to `revert-buffer'.
+
+2004-09-03  Juri Linkov  <juri@jurta.org>
+
+	* isearch.el (isearch-toggle-regexp): Set `isearch-success' and
+	`isearch-adjusted' to `t'.
+	(isearch-toggle-case-fold): Set `isearch-success' to `t'.
+	(isearch-message-prefix): Add "pending" for isearch-adjusted.
+	(isearch-other-meta-char): Restore isearch-point unconditionally.
+	(isearch-query-replace): Add new arg `regexp-flag' and use it.
+	Set point to start of match if region is not active in transient
+	mark mode (to include the current match to region boundaries).
+	Push the search string to `query-replace-from-history-variable'.
+	Add prompt "Query replace regexp" for isearch-regexp.
+	Add region beginning/end as last arguments of `perform-replace.'
+	(isearch-query-replace-regexp): Replace code by the call to
+	`isearch-query-replace' with arg `t'.
+
+2004-09-03  Richard M. Stallman  <rms@gnu.org>
+
+	* startup.el (normal-top-level): Undo previous TERM change.
+
+2004-09-03  Kim F. Storm  <storm@cua.dk>
+
+	* emulation/cua-rect.el (cua--overlay-keymap): New keymap for
+	highlight overlays; allow using RET when cursor is over a button.
+	(cua--highlight-rectangle): Use it.
+	(cua--rectangle-set-corners): Don't move backwards at eol.
+	(cua--forward-line): Don't move into void after eob.
+
+	* emulation/cua-rect.el (cua--rectangle-set-corners): Ensure that
+	point is set (and displayed) inside rectangle.
+	(cua--rectangle-operation): Fix for highlight of empty lines.
+	(cua--highlight-rectangle): Fix highlight for tabs.
+	Position cursor at left/right edge of rectangle using new `cursor'
+	property on overlay strings.
+	(cua--indent-rectangle): Don't tabify.
+	(cua-rotate-rectangle): Ignore that point has moved.
+
+2004-09-02  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* term/mac-win.el: Add ASCII equivalents for some function keys.
+	(mode-line-frame-identification): Sync with x-win.el.
+
+2004-09-02  Juri Linkov  <juri@jurta.org>
+
+	* progmodes/compile.el (compilation-buffer-name): Compare major
+	mode with second element of compilation-arguments instead of third
+	to reflect latest changes in compilation-arguments structure.
+	(recompile): Use global variable `compilation-directory' to get
+	recent compilation directory only when `recompile' is invoked NOT
+	in the compilation buffer.  Otherwise, use `default-directory' of
+	the compilation buffer.
+	(compilation-error-properties): Allow to funcall col and end-col.
+	(compilation-mode-font-lock-keywords): Check col and end-col by
+	`integerp'.
+	(compilation-goto-locus): If end-mk is non-nil in transient mark
+	mode don't activate the mark (and don't display message in
+	push-mark), but highlight overlay between mk and end-mk.
+
+	* progmodes/grep.el (grep-highlight-matches): New defcustom.
+	(grep-regexp-alist): Add rule to highlight grep matches.
+	(grep-process-setup): Set env-vars GREP_OPTIONS and GREP_COLOR.
+
+	* info.el (Info-fontify-node): Don't compute other-tag
+	if Info-hide-note-references=hide.
+
+	* help.el (function-called-at-point):
+	* help-fns.el (variable-at-point):
+	Try `find-tag-default' when other methods failed.
+
+	* emacs-lisp/lisp.el (beginning-of-defun, end-of-defun):
+	Do not push mark if inhibit-mark-movement is non-nil.
+
+	* textmodes/ispell.el (ispell-html-skip-alists):
+	Fix backslashes in docstring.
+
+2004-09-01  Juri Linkov  <juri@jurta.org>
+
+	* isearch.el (isearch-wrap-function)
+	(isearch-push-state-function): New defvars.
+	(isearch-pop-fun-state): New defsubst.
+	(isearch-top-state): Call function saved in `isearch-pop-fun-state'.
+	(isearch-push-state): Set the result of calling
+	`isearch-push-state-function' to the `isearch-pop-fun-state' field.
+	(isearch-cancel): Call function saved in `isearch-pop-fun-state' to
+	restore the mode-specific starting point of terminated search.
+	(isearch-abort): Call `isearch-cancel' instead of its duplicated code.
+	(isearch-repeat): Call `isearch-wrap-function' if defined.
+	(isearch-message-prefix): Don't add prefix "over" to the message
+	for wrapped search if `isearch-wrap-function' is defined.
+	(isearch-search): Call function saved in `isearch-pop-fun-state' to
+	restore the mode-specific starting point of failed search.
+
+	* info.el (Info-search-whitespace-regexp): Fix backslashes.
+	(Info-search): Add new optional arguments for the sake of isearch.
+	Replace whitespace in Info-search-whitespace-regexp literally.
+	Add backward search.  Don't call `Info-select-node' if regexp is
+	found in the same Info node.  Don't add node to Info-history for
+	wrapped isearch.
+	(Info-search-backward, Info-isearch-search, Info-isearch-wrap)
+	(Info-isearch-push-state, Info-isearch-pop-state): New funs.
+	(Info-mode): Set local variables `isearch-search-fun-function',
+	`isearch-wrap-function', `isearch-push-state-function',
+	`search-whitespace-regexp'.
+
+	* isearch.el: Remove ancient Change Log section.
+	(isearch-string, isearch-message-string, isearch-point)
+	(isearch-success, isearch-forward-flag, isearch-other-end)
+	(isearch-word, isearch-invalid-regexp, isearch-wrapped)
+	(isearch-barrier, isearch-within-brackets)
+	(isearch-case-fold-search): Add suffix `-state' to state-related
+	defsubsts to avoid name clashes with other function names.
+
+	* simple.el (next-error): New defgroup and defface.
+	(next-error-highlight, next-error-highlight-no-select):
+	New defcustoms.
+	(next-error-no-select): Let-bind next-error-highlight to the value
+	of next-error-highlight-no-select before calling `next-error'.
+
+	* progmodes/compile.el (compilation-goto-locus):
+	Use `next-error' face instead of `region'.  Set 4-th argument of
+	`move-overlay' to `current-buffer' to move overlay to different
+	source buffers.  Use new variable `next-error-highlight'.
+
+	* simple.el (next-error-find-buffer): Move the rule
+	"if current buffer is a next-error capable buffer" after the
+	rule "if next-error-last-buffer is set to a live buffer".
+	Simplify to test all rules in one `or'.
+	(next-error): Doc fix.
+	(next-error, previous-error, first-error)
+	(next-error-no-select, previous-error-no-select):
+	Make arguments optional.
+
+2004-08-31  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* macros.el (apply-macro-to-region-lines): Make it operate on all
+	lines that begin in the region, rather than on all complete lines
+	in the region.
+
+2004-08-31  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* x-dnd.el (x-dnd-protocol-alist): Document update.
+	(x-dnd-known-types): Defcustom it.
+	(x-dnd-handle-motif): Print message-atom in error message.
+
+2004-08-30  John Paul Wallington  <jpw@gnu.org>
+
+	* textmodes/tex-mode.el (tex-validate-buffer): Use distinct
+	strings rather than programatically constructing message.
+
+2004-08-30  Richard M. Stallman  <rms@gnu.org>
+
+	* emacs-lisp/lisp-mode.el (prin1-char): Don't turn S-a into A.
+	Don't return a string that would read as the wrong character code.
+
+2004-08-29  Kim F. Storm  <storm@cua.dk>
+
+	* emulation/cua-base.el (cua-auto-expand-rectangles): Remove
+	automatic rectangle padding feature; replace by non-destructive
+	virtual rectangle edges feature.
+	(cua-virtual-rectangle-edges): New defcustom.
+	(cua-auto-tabify-rectangles): New defcustom.
+	(cua-paste): If paste into a marked rectangle, insert rectangle at
+	current column, even if virtual; also paste exactly as many lines
+	as has been marked (ignore additional lines or add empty lines),
+	but paste whole source if only one line is marked.
+	(cua--update-indications): No longer use overwrite-cursor to
+	indicate rectangle padding
+
+	* emulation/cua-rect.el (cua--rectangle-padding): Remove.
+	(cua--rectangle-virtual-edges): New defun.
+	(cua--rectangle-get-corners): Remove optional PAD arg.
+	(cua--rectangle-set-corners): Never do padding.
+	(cua--forward-line): Remove optional PAD arg.  Simplify.
+	(cua-resize-rectangle-right, cua-resize-rectangle-left)
+	(cua-resize-rectangle-down, cua-resize-rectangle-up):
+	(cua-resize-rectangle-bot, cua-resize-rectangle-top)
+	(cua-resize-rectangle-page-up, cua-resize-rectangle-page-down)
+	(cua--rectangle-move): Never do padding.  Simplify.
+	(cua--tabify-start): New defun.
+	(cua--rectangle-operation): Add tabify arg.  All callers changed.
+	(cua--pad-rectangle): Remove.
+	(cua--delete-rectangle): Handle delete with virtual edges.
+	(cua--extract-rectangle): Add spaces if rectangle has virtual edges.
+	(cua--insert-rectangle): Handle insert at virtual column.
+	Perform auto-tabify if necessary.
+	(cua--activate-rectangle): Remove optional FORCE arg.
+	Never do padding.  Simplify.
+	(cua--highlight-rectangle): Enhance for virtual edges.
+	(cua-toggle-rectangle-padding): Remove command.
+	(cua-toggle-rectangle-virtual-edges): New command.
+	(cua-sequence-rectangle): Add optional TABIFY arg.  Callers changed.
+	(cua--rectangle-post-command): Don't force rectangle padding.
+	(cua--init-rectangles): Bind M-p to cua-toggle-rectangle-virtual-edges.
+
+2004-08-28  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* indent.el (edit-tab-stops-buffer): Doc fix.
+
+2004-08-28  Richard M. Stallman  <rms@gnu.org>
+
+	* progmodes/grep.el (grep-default-command): Use find-tag-default.
+	(grep-tag-default): Function deleted.
+
+	* subr.el (find-tag-default): Moved from etags.el.
+
+	* progmodes/etags.el (find-tag-default): Moved to subr.el.
+
+	* emacs-lisp/lisp-mode.el (prin1-char): Put `shift' modifier
+	into the basic character if it has an uppercase form.
+
 2004-08-27  Kenichi Handa  <handa@m17n.org>
 
 	* international/utf-8.el (utf-8-post-read-conversion): If the
@@ -534,7 +749,6 @@
 	(ps-generate-string-list): Comment fix.
 	(ps-message-log-max): Code fix.
 
-
 2004-07-22  Michael Piotrowski  <mxp@dynalabs.de>  (tiny change)
 
 	* ps-print.el (ps-begin-file): Improve the DSC compliance of the
@@ -554,11 +768,9 @@
 
 2004-07-20  Richard M. Stallman  <rms@gnu.org>
 
-	* textmodes/fill.el (fill-comment-paragraph): Handle indent-tabs-mode.
-	(fill-delete-newlines): Call sentence-end as function.
-	(fill-nobreak-p, canonically-space-region): Likewise.
-	(fill-nobreak-p): If this break point is at the end of the line,
-	don't consider the newline which follows as a reason to return t.
+	* textmodes/fill.el (fill-nobreak-p): If this break point is
+	at the end of the line, don't consider the newline which follows
+	as a reason to return t.
 
 2004-07-19  John Paul Wallington  <jpw@gnu.org>
 
--- a/lisp/autorevert.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/autorevert.el	Sat Sep 04 09:14:28 2004 +0000
@@ -421,7 +421,8 @@
 	   'no-mini t))
 	(if auto-revert-tail-mode
 	    (auto-revert-tail-handler)
-	  (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes))
+	  (let ((buffer-read-only buffer-read-only))
+	    (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes)))
 	(when buffer-file-name
 	  (when eob (goto-char (point-max)))
 	  (dolist (window eoblist)
--- a/lisp/emacs-lisp/lisp-mode.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/emacs-lisp/lisp-mode.el	Sat Sep 04 09:14:28 2004 +0000
@@ -363,7 +363,7 @@
     (when (stringp default)
       (if (string-match ":+" default)
           (substring default (match-end 0))
-          default))))
+	default))))
 
 ;; Used in old LispM code.
 (defalias 'common-lisp-mode 'lisp-mode)
@@ -459,21 +459,37 @@
 If CHAR is not a character, return nil."
   (and (integerp char)
        (eventp char)
-       (let ((c (event-basic-type char)))
-	 (concat
-	  "?"
-	  (mapconcat
-	   (lambda (modif)
-	     (cond ((eq modif 'super) "\\s-")
-		   (t (string ?\\ (upcase (aref (symbol-name modif) 0)) ?-))))
-	   (event-modifiers char) "")
-	  (cond
-	   ((memq c '(?\; ?\( ?\) ?\{ ?\} ?\[ ?\] ?\" ?\' ?\\)) (string ?\\ c))
-	   ((eq c 127) "\\C-?")
-	   (t
-	    (condition-case nil
-		(string c)
-	      (error nil))))))))
+       (let ((c (event-basic-type char))
+	     (mods (event-modifiers char))
+	     string)
+	 ;; Prevent ?A from turning into ?\S-a.
+	 (if (and (memq 'shift mods)
+		  (zerop (logand char ?\S-\^@))
+		  (not (let ((case-fold-search nil))
+			 (char-equal c (upcase c)))))
+	     (setq c (upcase c) mods nil))
+	 ;; What string are we considering using?
+	 (condition-case nil
+	     (setq string
+		   (concat
+		    "?"
+		    (mapconcat
+		     (lambda (modif)
+		       (cond ((eq modif 'super) "\\s-")
+			     (t (string ?\\ (upcase (aref (symbol-name modif) 0)) ?-))))
+		     mods "")
+		    (cond
+		     ((memq c '(?\; ?\( ?\) ?\{ ?\} ?\[ ?\] ?\" ?\' ?\\)) (string ?\\ c))
+		     ((eq c 127) "\\C-?")
+		     (t
+		      (string c)))))
+	   (error nil))
+	 ;; Verify the string reads a CHAR, not to some other character.
+	 ;; If it doesn't, return nil instead.
+	 (and string
+	      (= (car (read-from-string string)) char)
+	      string))))
+	 
 
 (defun eval-last-sexp-1 (eval-last-sexp-arg-internal)
   "Evaluate sexp before point; print value in minibuffer.
--- a/lisp/emacs-lisp/lisp.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/emacs-lisp/lisp.el	Sat Sep 04 09:14:28 2004 +0000
@@ -176,7 +176,8 @@
 is called as a function to find the defun's beginning."
   (interactive "p")
   (and (eq this-command 'beginning-of-defun)
-       (or (eq last-command 'beginning-of-defun) (push-mark)))
+       (or inhibit-mark-movement (eq last-command 'beginning-of-defun)
+           (push-mark)))
   (and (beginning-of-defun-raw arg)
        (progn (beginning-of-line) t)))
 
@@ -226,7 +227,8 @@
 is called as a function to find the defun's end."
   (interactive "p")
   (and (eq this-command 'end-of-defun)
-       (or (eq last-command 'end-of-defun) (push-mark)))
+       (or inhibit-mark-movement (eq last-command 'end-of-defun)
+           (push-mark)))
   (if (or (null arg) (= arg 0)) (setq arg 1))
   (if end-of-defun-function
       (if (> arg 0)
--- a/lisp/emulation/cua-base.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/emulation/cua-base.el	Sat Sep 04 09:14:28 2004 +0000
@@ -141,30 +141,39 @@
 ;; completely separate set of "rectangle commands" [C-x r ...] on the
 ;; region to copy, kill, fill a.s.o. the virtual rectangle.
 ;;
-;; cua-mode's superior rectangle support is based on using a true visual
-;; representation of the selected rectangle. To start a rectangle, use
-;; [S-return] and extend it using the normal movement keys (up, down,
-;; left, right, home, end, C-home, C-end). Once the rectangle has the
-;; desired size, you can cut or copy it using C-x and C-c (or C-w and M-w),
-;; and you can subsequently insert it - as a rectangle - using C-v (or
-;; C-y).  So the only new command you need to know to work with
-;; cua-mode rectangles is S-return!
+;; cua-mode's superior rectangle support uses a true visual
+;; representation of the selected rectangle, i.e. it highlights the
+;; actual part of the buffer that is currently selected as part of the
+;; rectangle.  Unlike emacs' traditional rectangle commands, the
+;; selected rectangle always as straight left and right edges, even
+;; when those are in the middle of a TAB character or beyond the end
+;; of the current line.  And it does this without actually modifying
+;; the buffer contents (it uses display overlays to visualize the
+;; virtual dimensions of the rectangle).
+;;
+;; This means that cua-mode's rectangles are not limited to the actual
+;; contents of the buffer, so if the cursor is currently at the end of a
+;; short line, you can still extend the rectangle to include more columns
+;; of longer lines in the same rectangle.  And you can also have the
+;; left edge of a rectangle start in the middle of a TAB character.
+;; Sounds strange? Try it!
+;;
+;; To start a rectangle, use [S-return] and extend it using the normal
+;; movement keys (up, down, left, right, home, end, C-home,
+;; C-end). Once the rectangle has the desired size, you can cut or
+;; copy it using C-x and C-c (or C-w and M-w), and you can
+;; subsequently insert it - as a rectangle - using C-v (or C-y).  So
+;; the only new command you need to know to work with cua-mode
+;; rectangles is S-return!
 ;;
 ;; Normally, when you paste a rectangle using C-v (C-y), each line of
 ;; the rectangle is inserted into the existing lines in the buffer.
 ;; If overwrite-mode is active when you paste a rectangle, it is
 ;; inserted as normal (multi-line) text.
 ;;
-;; Furthermore, cua-mode's rectangles are not limited to the actual
-;; contents of the buffer, so if the cursor is currently at the end of a
-;; short line, you can still extend the rectangle to include more columns
-;; of longer lines in the same rectangle.  Sounds strange? Try it!
-;;
-;; You can enable padding for just this rectangle by pressing [M-p];
-;; this works like entering `picture-mode' where the tabs and spaces
-;; are automatically converted/inserted to make the rectangle truly
-;; rectangular. Or you can do it for all rectangles by setting the
-;; `cua-auto-expand-rectangles' variable.
+;; If you prefer the traditional rectangle marking (i.e. don't want
+;; straight edges), [M-p] toggles this for the current rectangle,
+;; or you can customize cua-virtual-rectangle-edges.
 
 ;; And there's more: If you want to extend or reduce the size of the
 ;; rectangle in one of the other corners of the rectangle, just use
@@ -204,8 +213,8 @@
 ;;       a supplied format string (prompt)
 ;; [M-o] opens the rectangle by moving the highlighted text to the
 ;;       right of the rectangle and filling the rectangle with blanks.
-;; [M-p] toggles rectangle padding, i.e. insert tabs and spaces to
-;;       make rectangles truly rectangular
+;; [M-p] toggles virtual straight rectangle edges
+;; [M-P] inserts tabs and spaces (padding) to make real straight edges
 ;; [M-q] performs text filling on the rectangle
 ;; [M-r] replaces REGEXP (prompt) by STRING (prompt) in rectangle
 ;; [M-R] reverse the lines in the rectangle
@@ -347,14 +356,27 @@
 
 ;;; Rectangle Customization
 
-(defcustom cua-auto-expand-rectangles nil
-  "*If non-nil, rectangles are padded with spaces to make straight edges.
-This implies modifying buffer contents by expanding tabs and inserting spaces.
-Consequently, this is inhibited in read-only buffers.
-Can be toggled by [M-p] while the rectangle is active,"
+(defcustom cua-virtual-rectangle-edges t
+  "*If non-nil, rectangles have virtual straight edges.
+Note that although rectangles are always DISPLAYED with straight edges, the
+buffer is NOT modified, until you execute a command that actually modifies it.
+\[M-p] toggles this feature when a rectangle is active."
   :type 'boolean
   :group 'cua)
 
+(defcustom cua-auto-tabify-rectangles 1000
+  "*If non-nil, automatically tabify after rectangle commands.
+This basically means that `tabify' is applied to all lines that
+are modified by inserting or deleting a rectangle.  If value is
+an integer, cua will look for existing tabs in a region around
+the rectangle, and only do the conversion if any tabs are already
+present.  The number specifies then number of characters before
+and after the region marked by the rectangle to search."
+  :type '(choice (number :tag "Auto detect (limit)")
+		 (const :tag "Disabled" nil)
+		 (other :tag "Enabled" t))
+  :group 'cua)
+
 (defcustom cua-enable-rectangle-auto-help t
   "*If non-nil, automatically show help for region, rectangle and global mark."
   :type 'boolean
@@ -412,7 +434,6 @@
 				       (frame-parameter nil 'cursor-color)
 				       "red")
   "Normal (non-overwrite) cursor color.
-Also used to indicate that rectangle padding is not in effect.
 Default is to load cursor color from initial or default frame parameters.
 
 If the value is a COLOR name, then only the `cursor-color' attribute will be
@@ -462,7 +483,6 @@
 
 (defcustom cua-overwrite-cursor-color "yellow"
   "*Cursor color used when overwrite mode is set, if non-nil.
-Also used to indicate that rectangle padding is in effect.
 Only used when `cua-enable-cursor-indications' is non-nil.
 
 If the value is a COLOR name, then only the `cursor-color' attribute will be
@@ -806,7 +826,8 @@
   (interactive "P")
   (setq arg (cua--prefix-arg arg))
   (let ((regtxt (and cua--register (get-register cua--register)))
-	(count (prefix-numeric-value arg)))
+	(count (prefix-numeric-value arg))
+	paste-column paste-lines)
     (cond
      ((and cua--register (not regtxt))
       (message "Nothing in register %c" cua--register))
@@ -825,7 +846,12 @@
 	  ;; the same region that we are going to delete.
 	  ;; That would make yank a no-op.
 	  (if cua--rectangle
-	      (cua--delete-rectangle)
+	      (progn
+		(goto-char (min (mark) (point)))
+		(setq paste-column (cua--rectangle-left))
+		(setq paste-lines (cua--delete-rectangle))
+		(if (= paste-lines 1)
+		    (setq paste-lines nil))) ;; paste all
 	    (if (string= (buffer-substring (point) (mark))
 			 (car kill-ring))
 		(current-kill 1))
@@ -843,7 +869,8 @@
 	    (setq this-command 'cua--paste-rectangle)
 	    (undo-boundary)
 	    (setq buffer-undo-list (cons pt buffer-undo-list)))
-	  (cua--insert-rectangle (cdr cua--last-killed-rectangle))
+	  (cua--insert-rectangle (cdr cua--last-killed-rectangle)
+				 nil paste-column paste-lines)
 	  (if arg (goto-char pt))))
        (t (yank arg)))))))
 
@@ -1033,9 +1060,7 @@
 	   ((and buffer-read-only
 		 cua-read-only-cursor-color)
 	    cua-read-only-cursor-color)
-	   ((and cua-overwrite-cursor-color
-		 (or overwrite-mode
-		     (and cua--rectangle (cua--rectangle-padding))))
+	   ((and cua-overwrite-cursor-color overwrite-mode)
 	    cua-overwrite-cursor-color)
 	   (t cua-normal-cursor-color)))
 	 (color (if (consp cursor) (cdr cursor) cursor))
--- a/lisp/emulation/cua-rect.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/emulation/cua-rect.el	Sat Sep 04 09:14:28 2004 +0000
@@ -44,10 +44,10 @@
 (require 'rect)
 
 ;; If non-nil, restrict current region to this rectangle.
-;; Value is a vector [top bot left right corner ins pad select].
+;; Value is a vector [top bot left right corner ins virt select].
 ;; CORNER specifies currently active corner 0=t/l 1=t/r 2=b/l 3=b/r.
 ;; INS specifies whether to insert on left(nil) or right(t) side.
-;; If PAD is non-nil, tabs are converted to spaces when necessary.
+;; If VIRT is non-nil, virtual straight edges are enabled.
 ;; If SELECT is a regexp, only lines starting with that regexp are affected.")
 (defvar cua--rectangle nil)
 (make-variable-buffer-local 'cua--rectangle)
@@ -65,6 +65,12 @@
 (defvar cua--rectangle-overlays nil)
 (make-variable-buffer-local 'cua--rectangle-overlays)
 
+(defvar cua--overlay-keymap
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\r" 'cua-rotate-rectangle)))
+
+(defvar cua--virtual-edges-debug nil)
+
 ;; Per-buffer CUA mode undo list.
 (defvar cua--undo-list nil)
 (make-variable-buffer-local 'cua--undo-list)
@@ -97,7 +103,7 @@
 (defvar cua--tidy-undo-counter 0
   "Number of times `cua--tidy-undo-lists' have run successfully.")
 
-;; Clean out danling entries from cua's undo list.
+;; Clean out dangling entries from cua's undo list.
 ;; Since this list contains pointers into the standard undo list,
 ;; such references are only meningful as undo information if the
 ;; corresponding entry is still on the standard undo list.
@@ -203,11 +209,11 @@
           (aref cua--rectangle 5))
       (cua--rectangle-left))))
 
-(defun cua--rectangle-padding (&optional set val)
-  ;; Current setting of rectangle padding
+(defun cua--rectangle-virtual-edges (&optional set val)
+  ;; Current setting of rectangle virtual-edges
   (if set
       (aset cua--rectangle 6 val))
-  (and (not buffer-read-only)
+  (and ;(not buffer-read-only)
        (aref cua--rectangle 6)))
 
 (defun cua--rectangle-restriction (&optional val bounded negated)
@@ -226,7 +232,7 @@
   (if (< (cua--rectangle-bot) (cua--rectangle-top))
       (message "rectangle bot < top")))
 
-(defun cua--rectangle-get-corners (&optional pad)
+(defun cua--rectangle-get-corners ()
   ;; Calculate the rectangular region represented by point and mark,
   ;; putting start in the upper left corner and end in the
   ;; bottom right corner.
@@ -245,12 +251,12 @@
               (setq r (1- r)))
         (setq l (prog1 r (setq r l)))
         (goto-char top)
-        (move-to-column l pad)
+        (move-to-column l)
         (setq top (point))
         (goto-char bot)
-        (move-to-column r pad)
+        (move-to-column r)
         (setq bot (point))))
-    (vector top bot l r corner 0 pad nil)))
+    (vector top bot l r corner 0 cua-virtual-rectangle-edges nil)))
 
 (defun cua--rectangle-set-corners ()
   ;; Set mark and point in opposite corners of current rectangle.
@@ -269,24 +275,31 @@
       (setq pp (cua--rectangle-bot) pc (cua--rectangle-right)
             mp (cua--rectangle-top) mc (cua--rectangle-left))))
     (goto-char mp)
-    (move-to-column mc (cua--rectangle-padding))
+    (move-to-column mc)
     (set-mark (point))
     (goto-char pp)
-    (move-to-column pc (cua--rectangle-padding))))
+    ;; Move cursor inside rectangle, except if char at rigth edge is a tab.
+    (if (and (if (cua--rectangle-right-side)
+		 (and (= (move-to-column pc) (- pc tab-width))
+		      (not (eolp)))
+	       (> (move-to-column pc) pc))
+	     (not (bolp)))
+	(backward-char 1))
+    ))
 
 ;;; Rectangle resizing
 
-(defun cua--forward-line (n pad)
+(defun cua--forward-line (n)
   ;; Move forward/backward one line.  Returns t if movement.
-  (if (or (not pad) (< n 0))
-      (= (forward-line n) 0)
-    (next-line 1)
-    t))
+  (let ((pt (point)))
+    (and (= (forward-line n) 0)
+	 ;; Deal with end of buffer
+	 (or (not (eobp))
+	     (goto-char pt)))))
 
 (defun cua--rectangle-resized ()
   ;; Refresh state after resizing rectangle
   (setq cua--buffer-and-point-before-command nil)
-  (cua--pad-rectangle)
   (cua--rectangle-insert-col 0)
   (cua--rectangle-set-corners)
   (cua--keep-active))
@@ -294,47 +307,35 @@
 (defun cua-resize-rectangle-right (n)
   "Resize rectangle to the right."
   (interactive "p")
-  (let ((pad (cua--rectangle-padding)) (resized (> n 0)))
+  (let ((resized (> n 0)))
     (while (> n 0)
       (setq n (1- n))
       (cond
-       ((and (cua--rectangle-right-side) (or pad (eolp)))
+       ((cua--rectangle-right-side)
         (cua--rectangle-right (1+ (cua--rectangle-right)))
-        (move-to-column (cua--rectangle-right) pad))
-       ((cua--rectangle-right-side)
-        (forward-char 1)
-        (cua--rectangle-right (current-column)))
-       ((or pad (eolp))
+        (move-to-column (cua--rectangle-right)))
+       (t
         (cua--rectangle-left (1+ (cua--rectangle-left)))
-        (move-to-column (cua--rectangle-right) pad))
-       (t
-        (forward-char 1)
-        (cua--rectangle-left (current-column)))))
+        (move-to-column (cua--rectangle-right)))))
     (if resized
         (cua--rectangle-resized))))
 
 (defun cua-resize-rectangle-left (n)
   "Resize rectangle to the left."
   (interactive "p")
-  (let ((pad (cua--rectangle-padding)) resized)
+  (let (resized)
     (while (> n 0)
       (setq n (1- n))
       (if (or (= (cua--rectangle-right) 0)
               (and (not (cua--rectangle-right-side)) (= (cua--rectangle-left) 0)))
           (setq n 0)
         (cond
-         ((and (cua--rectangle-right-side) (or pad (eolp) (bolp)))
+         ((cua--rectangle-right-side)
           (cua--rectangle-right (1- (cua--rectangle-right)))
-          (move-to-column (cua--rectangle-right) pad))
-         ((cua--rectangle-right-side)
-          (backward-char 1)
-          (cua--rectangle-right (current-column)))
-         ((or pad (eolp) (bolp))
+          (move-to-column (cua--rectangle-right)))
+         (t
           (cua--rectangle-left (1- (cua--rectangle-left)))
-          (move-to-column (cua--rectangle-right) pad))
-         (t
-          (backward-char 1)
-          (cua--rectangle-left (current-column))))
+          (move-to-column (cua--rectangle-right))))
         (setq resized t)))
     (if resized
         (cua--rectangle-resized))))
@@ -342,20 +343,20 @@
 (defun cua-resize-rectangle-down (n)
   "Resize rectangle downwards."
   (interactive "p")
-  (let ((pad (cua--rectangle-padding)) resized)
+  (let (resized)
     (while (> n 0)
       (setq n (1- n))
       (cond
        ((>= (cua--rectangle-corner) 2)
         (goto-char (cua--rectangle-bot))
-        (when (cua--forward-line 1 pad)
-          (move-to-column (cua--rectangle-column) pad)
+        (when (cua--forward-line 1)
+          (move-to-column (cua--rectangle-column))
           (cua--rectangle-bot t)
           (setq resized t)))
        (t
         (goto-char (cua--rectangle-top))
-        (when (cua--forward-line 1 pad)
-          (move-to-column (cua--rectangle-column) pad)
+        (when (cua--forward-line 1)
+          (move-to-column (cua--rectangle-column))
           (cua--rectangle-top t)
           (setq resized t)))))
     (if resized
@@ -364,20 +365,20 @@
 (defun cua-resize-rectangle-up (n)
   "Resize rectangle upwards."
   (interactive "p")
-  (let ((pad (cua--rectangle-padding)) resized)
+  (let (resized)
     (while (> n 0)
       (setq n (1- n))
       (cond
        ((>= (cua--rectangle-corner) 2)
         (goto-char (cua--rectangle-bot))
-        (when (cua--forward-line -1 pad)
-          (move-to-column (cua--rectangle-column) pad)
+        (when (cua--forward-line -1)
+          (move-to-column (cua--rectangle-column))
           (cua--rectangle-bot t)
           (setq resized t)))
        (t
         (goto-char (cua--rectangle-top))
-        (when (cua--forward-line -1 pad)
-          (move-to-column (cua--rectangle-column) pad)
+        (when (cua--forward-line -1)
+          (move-to-column (cua--rectangle-column))
           (cua--rectangle-top t)
           (setq resized t)))))
     (if resized
@@ -408,7 +409,7 @@
   "Resize rectangle to bottom of buffer."
   (interactive)
   (goto-char (point-max))
-  (move-to-column (cua--rectangle-column) (cua--rectangle-padding))
+  (move-to-column (cua--rectangle-column))
   (cua--rectangle-bot t)
   (cua--rectangle-resized))
 
@@ -416,31 +417,29 @@
   "Resize rectangle to top of buffer."
   (interactive)
   (goto-char (point-min))
-  (move-to-column (cua--rectangle-column) (cua--rectangle-padding))
+  (move-to-column (cua--rectangle-column))
   (cua--rectangle-top t)
   (cua--rectangle-resized))
 
 (defun cua-resize-rectangle-page-up ()
   "Resize rectangle upwards by one scroll page."
   (interactive)
-  (let ((pad (cua--rectangle-padding)))
-    (scroll-down)
-    (move-to-column (cua--rectangle-column) pad)
-    (if (>= (cua--rectangle-corner) 2)
-        (cua--rectangle-bot t)
-      (cua--rectangle-top t))
-    (cua--rectangle-resized)))
+  (scroll-down)
+  (move-to-column (cua--rectangle-column))
+  (if (>= (cua--rectangle-corner) 2)
+      (cua--rectangle-bot t)
+    (cua--rectangle-top t))
+  (cua--rectangle-resized))
 
 (defun cua-resize-rectangle-page-down ()
   "Resize rectangle downwards by one scroll page."
   (interactive)
-  (let ((pad (cua--rectangle-padding)))
-    (scroll-up)
-    (move-to-column (cua--rectangle-column) pad)
-    (if (>= (cua--rectangle-corner) 2)
-        (cua--rectangle-bot t)
-      (cua--rectangle-top t))
-    (cua--rectangle-resized)))
+  (scroll-up)
+  (move-to-column (cua--rectangle-column))
+  (if (>= (cua--rectangle-corner) 2)
+      (cua--rectangle-bot t)
+    (cua--rectangle-top t))
+  (cua--rectangle-resized))
 
 ;;; Mouse support
 
@@ -450,7 +449,8 @@
   "Set rectangle corner at mouse click position."
   (interactive "e")
   (mouse-set-point event)
-  (if (cua--rectangle-padding)
+  ;; FIX ME -- need to calculate virtual column.
+  (if (cua--rectangle-virtual-edges)
       (move-to-column (car (posn-col-row (event-end event))) t))
   (if (cua--rectangle-right-side)
       (cua--rectangle-right (current-column))
@@ -470,6 +470,7 @@
     (cua--deactivate t))
   (setq cua--last-rectangle nil)
   (mouse-set-point event)
+  ;; FIX ME -- need to calculate virtual column.
   (cua-set-rectangle-mark)
   (setq cua--buffer-and-point-before-command nil)
   (setq cua--mouse-last-pos nil))
@@ -489,13 +490,13 @@
     (let ((cua-keep-region-after-copy t))
       (cua-copy-rectangle arg)
       (setq cua--mouse-last-pos (cons (point) cua--last-killed-rectangle)))))
+
 (defun cua--mouse-ignore (event)
   (interactive "e")
   (setq this-command last-command))
 
 (defun cua--rectangle-move (dir)
-  (let ((pad (cua--rectangle-padding))
-        (moved t)
+  (let ((moved t)
         (top (cua--rectangle-top))
         (bot (cua--rectangle-bot))
         (l (cua--rectangle-left))
@@ -503,17 +504,17 @@
     (cond
      ((eq dir 'up)
       (goto-char top)
-      (when (cua--forward-line -1 pad)
+      (when (cua--forward-line -1)
         (cua--rectangle-top t)
         (goto-char bot)
         (forward-line -1)
         (cua--rectangle-bot t)))
      ((eq dir 'down)
       (goto-char bot)
-      (when (cua--forward-line 1 pad)
+      (when (cua--forward-line 1)
         (cua--rectangle-bot t)
         (goto-char top)
-        (cua--forward-line 1 pad)
+        (cua--forward-line 1)
         (cua--rectangle-top t)))
      ((eq dir 'left)
       (when (> l 0)
@@ -526,19 +527,37 @@
       (setq moved nil)))
     (when moved
       (setq cua--buffer-and-point-before-command nil)
-      (cua--pad-rectangle)
       (cua--rectangle-set-corners)
       (cua--keep-active))))
 
 
 ;;; Operations on current rectangle
 
-(defun cua--rectangle-operation (keep-clear visible undo pad &optional fct post-fct)
+(defun cua--tabify-start (start end)
+  ;; Return position where auto-tabify should start (or nil if not required).
+  (save-excursion
+    (save-restriction
+      (widen)
+      (and (not buffer-read-only)
+	   cua-auto-tabify-rectangles
+	   (if (or (not (integerp cua-auto-tabify-rectangles))
+		   (= (point-min) (point-max))
+		   (progn
+		     (goto-char (max (point-min)
+				     (- start cua-auto-tabify-rectangles)))
+		     (search-forward "\t" (min (point-max)
+					       (+ end cua-auto-tabify-rectangles)) t)))
+	       start)))))
+
+(defun cua--rectangle-operation (keep-clear visible undo pad tabify &optional fct post-fct)
   ;; Call FCT for each line of region with 4 parameters:
   ;; Region start, end, left-col, right-col
   ;; Point is at start when FCT is called
+  ;; Call fct with (s,e) = whole lines if VISIBLE non-nil.
+  ;; Only call fct for visible lines if VISIBLE==t.
   ;; Set undo boundary if UNDO is non-nil.
-  ;; Rectangle is padded if PAD = t or numeric and (cua--rectangle-padding)
+  ;; Rectangle is padded if PAD = t or numeric and (cua--rectangle-virtual-edges)
+  ;; Perform auto-tabify after operation if TABIFY is non-nil.
   ;; Mark is kept if keep-clear is 'keep and cleared if keep-clear is 'clear.
   (let* ((start (cua--rectangle-top))
          (end   (cua--rectangle-bot))
@@ -546,11 +565,12 @@
          (r (1+ (cua--rectangle-right)))
          (m (make-marker))
          (tabpad (and (integerp pad) (= pad 2)))
-         (sel (cua--rectangle-restriction)))
+         (sel (cua--rectangle-restriction))
+	 (tabify-start (and tabify (cua--tabify-start start end))))
     (if undo
         (cua--rectangle-undo-boundary))
     (if (integerp pad)
-        (setq pad (cua--rectangle-padding)))
+        (setq pad (cua--rectangle-virtual-edges)))
     (save-excursion
       (save-restriction
         (widen)
@@ -558,11 +578,13 @@
           (goto-char end)
           (and (bolp) (not (eolp)) (not (eobp))
                (setq end (1+ end))))
-        (when visible
+        (when (eq visible t)
           (setq start (max (window-start) start))
           (setq end   (min (window-end) end)))
         (goto-char end)
         (setq end (line-end-position))
+	(if (and visible (bolp) (not (eobp)))
+	    (setq end (1+ end)))
         (goto-char start)
         (setq start (line-beginning-position))
         (narrow-to-region start end)
@@ -575,7 +597,7 @@
               (forward-char 1))
           (set-marker m (point))
           (move-to-column l pad)
-          (if (and fct (>= (current-column) l) (<= (current-column) r))
+          (if (and fct (or visible (and (>= (current-column) l) (<= (current-column) r))))
               (let ((v t) (p (point)))
                 (when sel
                   (if (car (cdr sel))
@@ -585,8 +607,7 @@
                   (if (car (cdr (cdr sel)))
                       (setq v (null v))))
                 (if visible
-		    (unless (eolp)
-			(funcall fct p m l r v))
+		    (funcall fct p m l r v)
                   (if v
                       (funcall fct p m l r)))))
           (set-marker m nil)
@@ -594,7 +615,9 @@
         (if (not visible)
             (cua--rectangle-bot t))
         (if post-fct
-            (funcall post-fct l r))))
+            (funcall post-fct l r))
+	(when tabify-start
+	  (tabify tabify-start (point)))))
     (cond
      ((eq keep-clear 'keep)
       (cua--keep-active))
@@ -607,48 +630,96 @@
 
 (put 'cua--rectangle-operation 'lisp-indent-function 4)
 
-(defun cua--pad-rectangle (&optional pad)
-  (if (or pad (cua--rectangle-padding))
-      (cua--rectangle-operation nil nil t t)))
-
 (defun cua--delete-rectangle ()
-  (cua--rectangle-operation nil nil t 2
-    '(lambda (s e l r)
-       (if (and (> e s) (<= e (point-max)))
-	   (delete-region s e)))))
+  (let ((lines 0))
+    (if (not (cua--rectangle-virtual-edges))
+	(cua--rectangle-operation nil nil t 2 t
+	  '(lambda (s e l r v)
+	     (setq lines (1+ lines))
+	     (if (and (> e s) (<= e (point-max)))
+		 (delete-region s e))))
+      (cua--rectangle-operation nil 1 t nil t
+	'(lambda (s e l r v)
+	   (setq lines (1+ lines))
+	   (when (and (> e s) (<= e (point-max)))
+	     (delete-region s e)))))
+    lines))
 
 (defun cua--extract-rectangle ()
   (let (rect)
-    (cua--rectangle-operation nil nil nil 1
-     '(lambda (s e l r)
-        (setq rect (cons (buffer-substring-no-properties s e) rect))))
-      (nreverse rect)))
+    (if (not (cua--rectangle-virtual-edges))
+	(cua--rectangle-operation nil nil nil nil nil ; do not tabify
+	  '(lambda (s e l r)
+	     (setq rect (cons (buffer-substring-no-properties s e) rect))))
+      (cua--rectangle-operation nil 1 nil nil nil ; do not tabify
+	'(lambda (s e l r v)
+	   (let ((copy t) (bs 0) (as 0) row)
+	     (if (= s e) (setq e (1+ e)))
+	     (goto-char s)
+	     (move-to-column l)
+	     (if (= (point) (line-end-position))
+		 (setq bs (- r l)
+		       copy nil)
+	       (skip-chars-forward "\s\t" e)
+	       (setq bs (- (min r (current-column)) l)
+		     s (point))
+	       (move-to-column r)
+	       (skip-chars-backward "\s\t" s)
+	       (setq as (- r (max (current-column) l))
+		     e (point)))
+       	     (setq row (if (and copy (> e s))
+			   (buffer-substring-no-properties s e)
+			 ""))
+    	     (when (> bs 0)
+    	       (setq row (concat (make-string bs ?\s) row)))
+    	     (when (> as 0)
+    	       (setq row (concat row (make-string as ?\s))))
+    	     (setq rect (cons row rect))))))
+    (nreverse rect)))
 
-(defun cua--insert-rectangle (rect &optional below)
+(defun cua--insert-rectangle (rect &optional below paste-column line-count)
   ;; Insert rectangle as insert-rectangle, but don't set mark and exit with
   ;; point at either next to top right or below bottom left corner
   ;; Notice: In overwrite mode, the rectangle is inserted as separate text lines.
-  (if (and below (eq below 'auto))
+  (if (eq below 'auto)
       (setq below (and (bolp)
                        (or (eolp) (eobp) (= (1+ (point)) (point-max))))))
+  (unless paste-column
+    (setq paste-column (current-column)))
   (let ((lines rect)
-        (insertcolumn (current-column))
         (first t)
+	(tabify-start (cua--tabify-start (point) (point)))
+	last-column
         p)
     (while (or lines below)
       (or first
           (if overwrite-mode
               (insert ?\n)
             (forward-line 1)
-            (or (bolp) (insert ?\n))
-            (move-to-column insertcolumn t)))
+            (or (bolp) (insert ?\n))))
+      (unless overwrite-mode
+	(move-to-column paste-column t))
       (if (not lines)
           (setq below nil)
         (insert-for-yank (car lines))
+	(unless last-column
+	  (setq last-column (current-column)))
         (setq lines (cdr lines))
         (and first (not below)
              (setq p (point))))
-      (setq first nil))
+      (setq first nil)
+      (if (and line-count (= (setq line-count (1- line-count)) 0))
+	  (setq lines nil)))
+    (when (and line-count last-column (not overwrite-mode))
+      (while (> line-count 0)
+	(forward-line 1)
+	(or (bolp) (insert ?\n))
+	(move-to-column paste-column t)
+        (insert-char ?\s (- last-column paste-column -1))
+	(setq line-count (1- line-count))))
+    (when (and tabify-start
+	       (not overwrite-mode))
+      (tabify tabify-start (point)))
     (and p (not overwrite-mode)
          (goto-char p))))
 
@@ -662,7 +733,7 @@
                    (function (lambda (row) (concat row "\n")))
                    killed-rectangle "")))))
 
-(defun cua--activate-rectangle (&optional force)
+(defun cua--activate-rectangle ()
   ;; Turn on rectangular marking mode by disabling transient mark mode
   ;; and manually handling highlighting from a post command hook.
   ;; Be careful if we are already marking a rectangle.
@@ -671,12 +742,8 @@
                  (eq (car cua--last-rectangle) (current-buffer))
                  (eq (car (cdr cua--last-rectangle)) (point)))
             (cdr (cdr cua--last-rectangle))
-          (cua--rectangle-get-corners
-           (and (not buffer-read-only)
-                (or cua-auto-expand-rectangles
-                    force
-                    (eq major-mode 'picture-mode)))))
-        cua--status-string (if (cua--rectangle-padding) " Pad" "")
+          (cua--rectangle-get-corners))
+        cua--status-string (if (cua--rectangle-virtual-edges) " [R]" "")
         cua--last-rectangle nil))
 
 ;; (defvar cua-save-point nil)
@@ -698,7 +765,7 @@
   ;; Each overlay extends across all the columns of the rectangle.
   ;; We try to reuse overlays where possible because this is more efficient
   ;; and results in less flicker.
-  ;; If cua--rectangle-padding is nil and the buffer contains tabs or short lines,
+  ;; If cua--rectangle-virtual-edges is nil and the buffer contains tabs or short lines,
   ;; the higlighted region may not be perfectly rectangular.
   (let ((deactivate-mark deactivate-mark)
         (old cua--rectangle-overlays)
@@ -707,12 +774,67 @@
         (right (1+ (cua--rectangle-right))))
     (when (/= left right)
       (sit-for 0)  ; make window top/bottom reliable
-      (cua--rectangle-operation nil t nil nil
+      (cua--rectangle-operation nil t nil nil nil ; do not tabify
         '(lambda (s e l r v)
            (let ((rface (if v 'cua-rectangle-face 'cua-rectangle-noselect-face))
-                 overlay)
-             ;; Trim old leading overlays.
+                 overlay bs ms as)
 	     (if (= s e) (setq e (1+ e)))
+	     (when (cua--rectangle-virtual-edges)
+	       (let ((lb (line-beginning-position))
+		     (le (line-end-position))
+		     cl cl0 pl cr cr0 pr)
+		 (goto-char s)
+		 (setq cl (move-to-column l)
+		       pl (point))
+		 (setq cr (move-to-column r)
+		       pr (point))
+		 (if (= lb pl)
+		     (setq cl0 0)
+		   (goto-char (1- pl))
+		   (setq cl0 (current-column)))
+		 (if (= lb le)
+		     (setq cr0 0)
+		   (goto-char (1- pr))
+		   (setq cr0 (current-column)))
+		 (unless (and (= cl l) (= cr r))
+		   (when (/= cl l)
+		     (setq bs (propertize
+			       (make-string
+				(- l cl0 (if (and (= le pl) (/= le lb)) 1 0))
+				(if cua--virtual-edges-debug ?. ?\s))
+			       'face 'default))
+		     (if (/= pl le)
+			 (setq s (1- s))))
+		   (cond
+		    ((= cr r)
+		     (if (and (/= pr le)
+			      (/= cr0 (1- cr))
+			      (or bs (/= cr0 (- cr tab-width)))
+			      (/= (mod cr tab-width) 0))
+			 (setq e (1- e))))
+		    ((= cr cl)
+		     (setq ms (propertize
+			       (make-string
+				(- r l)
+				(if cua--virtual-edges-debug ?, ?\s))
+			       'face rface))
+		     (if (cua--rectangle-right-side)
+			 (put-text-property (1- (length ms)) (length ms) 'cursor t ms)
+		       (put-text-property 0 1 'cursor t ms))
+		     (setq bs (concat bs ms))
+		     (setq rface nil))
+ 		    (t
+		     (setq as (propertize
+			       (make-string
+				(- r cr0 (if (= le pr) 1 0))
+				(if cua--virtual-edges-debug ?~ ?\s))
+			       'face rface))
+		     (if (cua--rectangle-right-side)
+			 (put-text-property (1- (length as)) (length as) 'cursor t as)
+		       (put-text-property 0 1 'cursor t as))
+		     (if (/= pr le)
+			 (setq e (1- e))))))))
+	     ;; Trim old leading overlays.
              (while (and old
                          (setq overlay (car old))
                          (< (overlay-start overlay) s)
@@ -728,8 +850,11 @@
                    (move-overlay overlay s e)
                    (setq old (cdr old)))
                (setq overlay (make-overlay s e)))
-             (overlay-put overlay 'face rface)
-             (setq new (cons overlay new))))))
+ 	     (overlay-put overlay 'before-string bs)
+	     (overlay-put overlay 'after-string as)
+	     (overlay-put overlay 'face rface)
+	     (overlay-put overlay 'keymap cua--overlay-keymap)
+	     (setq new (cons overlay new))))))
     ;; Trim old trailing overlays.
     (mapcar (function delete-overlay) old)
     (setq cua--rectangle-overlays (nreverse new))))
@@ -737,9 +862,9 @@
 (defun cua--indent-rectangle (&optional ch to-col clear)
   ;; Indent current rectangle.
   (let ((col (cua--rectangle-insert-col))
-        (pad (cua--rectangle-padding))
+        (pad (cua--rectangle-virtual-edges))
         indent)
-    (cua--rectangle-operation (if clear 'clear 'corners) nil t pad
+    (cua--rectangle-operation (if clear 'clear 'corners) nil t pad nil
       '(lambda (s e l r)
          (move-to-column col pad)
          (if (and (eolp)
@@ -875,23 +1000,22 @@
 (defun cua-rotate-rectangle ()
   (interactive)
   (cua--rectangle-corner (if (= (cua--rectangle-left) (cua--rectangle-right)) 0 1))
-  (cua--rectangle-set-corners))
+  (cua--rectangle-set-corners)
+  (if (cua--rectangle-virtual-edges)
+      (setq cua--buffer-and-point-before-command nil)))
 
-(defun cua-toggle-rectangle-padding ()
+(defun cua-toggle-rectangle-virtual-edges ()
   (interactive)
-  (if buffer-read-only
-      (message "Cannot do padding in read-only buffer.")
-    (cua--rectangle-padding t (not (cua--rectangle-padding)))
-    (cua--pad-rectangle)
-    (cua--rectangle-set-corners))
-  (setq cua--status-string (and (cua--rectangle-padding) " Pad"))
+  (cua--rectangle-virtual-edges t (not (cua--rectangle-virtual-edges)))
+  (cua--rectangle-set-corners)
+  (setq cua--status-string (and (cua--rectangle-virtual-edges) " [R]"))
   (cua--keep-active))
 
 (defun cua-do-rectangle-padding ()
   (interactive)
   (if buffer-read-only
       (message "Cannot do padding in read-only buffer.")
-    (cua--pad-rectangle t)
+    (cua--rectangle-operation nil nil t t t)
     (cua--rectangle-set-corners))
   (cua--keep-active))
 
@@ -900,7 +1024,7 @@
 The text previously in the region is not overwritten by the blanks,
 but instead winds up to the right of the rectangle."
   (interactive)
-  (cua--rectangle-operation 'corners nil t 1
+  (cua--rectangle-operation 'corners nil t 1 nil
    '(lambda (s e l r)
       (skip-chars-forward " \t")
       (let ((ws (- (current-column) l))
@@ -915,7 +1039,7 @@
 at that column is deleted.
 With prefix arg, also delete whitespace to the left of that column."
   (interactive "P")
-  (cua--rectangle-operation 'clear nil t 1
+  (cua--rectangle-operation 'clear nil t 1 nil
    '(lambda (s e l r)
       (when arg
         (skip-syntax-backward " " (line-beginning-position))
@@ -927,7 +1051,7 @@
   "Blank out CUA rectangle.
 The text previously in the rectangle is overwritten by the blanks."
   (interactive)
-  (cua--rectangle-operation 'keep nil nil 1
+  (cua--rectangle-operation 'keep nil nil 1 nil
    '(lambda (s e l r)
       (goto-char e)
       (skip-syntax-forward " " (line-end-position))
@@ -942,7 +1066,7 @@
   "Align rectangle lines to left column."
   (interactive)
   (let (x)
-    (cua--rectangle-operation 'clear nil t t
+    (cua--rectangle-operation 'clear nil t t nil
      '(lambda (s e l r)
         (let ((b (line-beginning-position)))
           (skip-syntax-backward "^ " b)
@@ -984,7 +1108,7 @@
   "Replace CUA rectangle contents with STRING on each line.
 The length of STRING need not be the same as the rectangle width."
   (interactive "sString rectangle: ")
-  (cua--rectangle-operation 'keep nil t t
+  (cua--rectangle-operation 'keep nil t t nil
      '(lambda (s e l r)
         (delete-region s e)
         (skip-chars-forward " \t")
@@ -999,7 +1123,7 @@
 (defun cua-fill-char-rectangle (ch)
   "Replace CUA rectangle contents with CHARACTER."
   (interactive "cFill rectangle with character: ")
-  (cua--rectangle-operation 'clear nil t 1
+  (cua--rectangle-operation 'clear nil t 1 nil
    '(lambda (s e l r)
       (delete-region s e)
       (move-to-column l t)
@@ -1010,7 +1134,7 @@
   (interactive "sReplace regexp: \nsNew text: ")
   (if buffer-read-only
       (message "Cannot replace in read-only buffer")
-    (cua--rectangle-operation 'keep nil t 1
+    (cua--rectangle-operation 'keep nil t 1 nil
      '(lambda (s e l r)
         (if (re-search-forward regexp e t)
             (replace-match newtext nil nil))))))
@@ -1018,7 +1142,7 @@
 (defun cua-incr-rectangle (increment)
   "Increment each line of CUA rectangle by prefix amount."
   (interactive "p")
-  (cua--rectangle-operation 'keep nil t 1
+  (cua--rectangle-operation 'keep nil t 1 nil
      '(lambda (s e l r)
         (cond
          ((re-search-forward "0x\\([0-9a-fA-F]+\\)" e t)
@@ -1051,36 +1175,36 @@
   (if (= (length fmt) 0)
       (setq fmt cua--rectangle-seq-format)
     (setq cua--rectangle-seq-format fmt))
-  (cua--rectangle-operation 'clear nil t 1
+  (cua--rectangle-operation 'clear nil t 1 nil
      '(lambda (s e l r)
          (delete-region s e)
          (insert (format fmt first))
          (setq first (+ first incr)))))
 
-(defmacro cua--convert-rectangle-as (command)
-  `(cua--rectangle-operation 'clear nil nil nil
+(defmacro cua--convert-rectangle-as (command tabify)
+  `(cua--rectangle-operation 'clear nil nil nil ,tabify
     '(lambda (s e l r)
        (,command s e))))
 
 (defun cua-upcase-rectangle ()
   "Convert the rectangle to upper case."
   (interactive)
-  (cua--convert-rectangle-as upcase-region))
+  (cua--convert-rectangle-as upcase-region nil))
 
 (defun cua-downcase-rectangle ()
   "Convert the rectangle to lower case."
   (interactive)
-  (cua--convert-rectangle-as downcase-region))
+  (cua--convert-rectangle-as downcase-region nil))
 
 (defun cua-upcase-initials-rectangle ()
   "Convert the rectangle initials to upper case."
   (interactive)
-  (cua--convert-rectangle-as upcase-initials-region))
+  (cua--convert-rectangle-as upcase-initials-region nil))
 
 (defun cua-capitalize-rectangle ()
   "Convert the rectangle to proper case."
   (interactive)
-  (cua--convert-rectangle-as capitalize-region))
+  (cua--convert-rectangle-as capitalize-region nil))
 
 
 ;;; Replace/rearrange text in current rectangle
@@ -1116,7 +1240,7 @@
       (setq z (reverse z))
       (if cua--debug
 	  (print z auxbuf))
-      (cua--rectangle-operation nil nil t pad
+      (cua--rectangle-operation nil nil t pad nil
         '(lambda (s e l r)
            (let (cc)
              (goto-char e)
@@ -1232,9 +1356,9 @@
   "Delete char to left or right of rectangle."
   (interactive)
   (let ((col (cua--rectangle-insert-col))
-        (pad (cua--rectangle-padding))
+        (pad (cua--rectangle-virtual-edges))
         indent)
-    (cua--rectangle-operation 'corners nil t pad
+    (cua--rectangle-operation 'corners nil t pad nil
      '(lambda (s e l r)
         (move-to-column
          (if (cua--rectangle-right-side t)
@@ -1282,10 +1406,7 @@
         (cua--rectangle-left (current-column)))
       (if (>= (cua--rectangle-corner) 2)
           (cua--rectangle-bot t)
-        (cua--rectangle-top t))
-      (if (cua--rectangle-padding)
-          (setq unread-command-events
-                (cons (if cua-use-hyper-key ?\H-P ?\M-P) unread-command-events)))))
+        (cua--rectangle-top t))))
   (if cua--rectangle
       (if (and mark-active
                (not deactivate-mark))
@@ -1379,7 +1500,7 @@
   (cua--rect-M/H-key ?m	'cua-copy-rectangle-as-text)
   (cua--rect-M/H-key ?n	'cua-sequence-rectangle)
   (cua--rect-M/H-key ?o	'cua-open-rectangle)
-  (cua--rect-M/H-key ?p	'cua-toggle-rectangle-padding)
+  (cua--rect-M/H-key ?p	'cua-toggle-rectangle-virtual-edges)
   (cua--rect-M/H-key ?P	'cua-do-rectangle-padding)
   (cua--rect-M/H-key ?q	'cua-refill-rectangle)
   (cua--rect-M/H-key ?r	'cua-replace-in-rectangle)
--- a/lisp/help-fns.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/help-fns.el	Sat Sep 04 09:14:28 2004 +0000
@@ -461,18 +461,21 @@
 (defun variable-at-point ()
   "Return the bound variable symbol found around point.
 Return 0 if there is no such symbol."
-  (condition-case ()
-      (with-syntax-table emacs-lisp-mode-syntax-table
-	(save-excursion
-	  (or (not (zerop (skip-syntax-backward "_w")))
-	      (eq (char-syntax (following-char)) ?w)
-	      (eq (char-syntax (following-char)) ?_)
-	      (forward-sexp -1))
-	  (skip-chars-forward "'")
-	  (let ((obj (read (current-buffer))))
-	    (or (and (symbolp obj) (boundp obj) obj)
-		0))))
-    (error 0)))
+  (or (condition-case ()
+	  (with-syntax-table emacs-lisp-mode-syntax-table
+	    (save-excursion
+	      (or (not (zerop (skip-syntax-backward "_w")))
+		  (eq (char-syntax (following-char)) ?w)
+		  (eq (char-syntax (following-char)) ?_)
+		  (forward-sexp -1))
+	      (skip-chars-forward "'")
+	      (let ((obj (read (current-buffer))))
+		(and (symbolp obj) (boundp obj) obj))))
+	(error nil))
+      (let* ((str (find-tag-default))
+	     (obj (if str (read str))))
+	(and (symbolp obj) (boundp obj) obj))
+      0))
 
 ;;;###autoload
 (defun describe-variable (variable &optional buffer)
--- a/lisp/help.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/help.el	Sat Sep 04 09:14:28 2004 +0000
@@ -237,32 +237,35 @@
 (defun function-called-at-point ()
   "Return a function around point or else called by the list containing point.
 If that doesn't give a function, return nil."
-  (with-syntax-table emacs-lisp-mode-syntax-table
-    (or (condition-case ()
-	    (save-excursion
-	      (or (not (zerop (skip-syntax-backward "_w")))
-		  (eq (char-syntax (following-char)) ?w)
-		  (eq (char-syntax (following-char)) ?_)
-		  (forward-sexp -1))
-	      (skip-chars-forward "'")
-	      (let ((obj (read (current-buffer))))
-		(and (symbolp obj) (fboundp obj) obj)))
-	  (error nil))
-	(condition-case ()
-	    (save-excursion
-	      (save-restriction
-		(narrow-to-region (max (point-min)
-				       (- (point) 1000)) (point-max))
-		;; Move up to surrounding paren, then after the open.
-		(backward-up-list 1)
-		(forward-char 1)
-		;; If there is space here, this is probably something
-		;; other than a real Lisp function call, so ignore it.
-		(if (looking-at "[ \t]")
-		    (error "Probably not a Lisp function call"))
-		(let ((obj (read (current-buffer))))
-		  (and (symbolp obj) (fboundp obj) obj))))
-	  (error nil)))))
+  (or (with-syntax-table emacs-lisp-mode-syntax-table
+	(or (condition-case ()
+		(save-excursion
+		  (or (not (zerop (skip-syntax-backward "_w")))
+		      (eq (char-syntax (following-char)) ?w)
+		      (eq (char-syntax (following-char)) ?_)
+		      (forward-sexp -1))
+		  (skip-chars-forward "'")
+		  (let ((obj (read (current-buffer))))
+		    (and (symbolp obj) (fboundp obj) obj)))
+	      (error nil))
+	    (condition-case ()
+		(save-excursion
+		  (save-restriction
+		    (narrow-to-region (max (point-min)
+					   (- (point) 1000)) (point-max))
+		    ;; Move up to surrounding paren, then after the open.
+		    (backward-up-list 1)
+		    (forward-char 1)
+		    ;; If there is space here, this is probably something
+		    ;; other than a real Lisp function call, so ignore it.
+		    (if (looking-at "[ \t]")
+			(error "Probably not a Lisp function call"))
+		    (let ((obj (read (current-buffer))))
+		      (and (symbolp obj) (fboundp obj) obj))))
+	      (error nil))))
+      (let* ((str (find-tag-default))
+	     (obj (if str (read str))))
+	(and (symbolp obj) (fboundp obj) obj))))
 
 
 ;;; `User' help functions
--- a/lisp/indent.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/indent.el	Sat Sep 04 09:14:28 2004 +0000
@@ -442,8 +442,8 @@
   "Keymap used in `edit-tab-stops'.")
 
 (defvar edit-tab-stops-buffer nil
-  "Buffer whose tab stops are being edited--in case
-the variable `tab-stop-list' is local in that buffer.")
+  "Buffer whose tab stops are being edited.
+This matters if the variable `tab-stop-list' is local in that buffer.")
 
 (defun edit-tab-stops ()
   "Edit the tab stops used by `tab-to-tab-stop'.
--- a/lisp/info.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/info.el	Sat Sep 04 09:14:28 2004 +0000
@@ -188,7 +188,7 @@
   :type 'boolean
   :group 'info)
 
-(defcustom Info-search-whitespace-regexp "\\\\(?:\\\\s-+\\\\)"
+(defcustom Info-search-whitespace-regexp "\\(?:\\s-+\\)"
   "*If non-nil, regular expression to match a sequence of whitespace chars.
 This applies to Info search for regular expressions.
 You might want to use something like \"[ \\t\\r\\n]+\" instead.
@@ -1442,8 +1442,9 @@
 (defvar Info-search-case-fold nil
   "The value of `case-fold-search' from previous `Info-search' command.")
 
-(defun Info-search (regexp)
-  "Search for REGEXP, starting from point, and select node it's found in."
+(defun Info-search (regexp &optional bound noerror count direction)
+  "Search for REGEXP, starting from point, and select node it's found in.
+If DIRECTION is `backward', search in the reverse direction."
   (interactive (list (read-string
 		      (if Info-search-history
 			  (format "Regexp search%s (default `%s'): "
@@ -1458,31 +1459,42 @@
     (setq regexp (car Info-search-history)))
   (when regexp
     (let (found beg-found give-up
+	  (backward (eq direction 'backward))
 	  (onode Info-current-node)
 	  (ofile Info-current-file)
 	  (opoint (point))
+	  (opoint-min (point-min))
+	  (opoint-max (point-max))
 	  (ostart (window-start))
 	  (osubfile Info-current-subfile))
       (when Info-search-whitespace-regexp
-        (setq regexp (replace-regexp-in-string
-                      "[ \t\n]+" Info-search-whitespace-regexp regexp)))
+        (setq regexp
+              (mapconcat 'identity (split-string regexp "[ \t\n]+")
+                         Info-search-whitespace-regexp)))
       (setq Info-search-case-fold case-fold-search)
       (save-excursion
 	(save-restriction
 	  (widen)
 	  (while (and (not give-up)
 		      (or (null found)
-			  (isearch-range-invisible beg-found found)))
-	    (if (re-search-forward regexp nil t)
-		(setq found (point) beg-found (match-beginning 0))
+			  (if backward
+                              (isearch-range-invisible found beg-found)
+                            (isearch-range-invisible beg-found found))))
+	    (if (if backward
+                    (re-search-backward regexp bound t)
+                  (re-search-forward regexp bound t))
+		(setq found (point) beg-found (if backward (match-end 0)
+                                                (match-beginning 0)))
 	      (setq give-up t)))))
       ;; If no subfiles, give error now.
       (if give-up
 	  (if (null Info-current-subfile)
-	      (re-search-forward regexp)
+	      (if backward
+                  (re-search-backward regexp)
+                (re-search-forward regexp))
 	    (setq found nil)))
 
-      (unless found
+      (unless (or found bound)
 	(unwind-protect
 	    ;; Try other subfiles.
 	    (let ((list ()))
@@ -1498,29 +1510,39 @@
 		  ;; Find the subfile we just searched.
 		  (search-forward (concat "\n" osubfile ": "))
 		  ;; Skip that one.
-		  (forward-line 1)
+		  (forward-line (if backward 0 1))
 		  ;; Make a list of all following subfiles.
 		  ;; Each elt has the form (VIRT-POSITION . SUBFILENAME).
-		  (while (not (eobp))
-		    (re-search-forward "\\(^.*\\): [0-9]+$")
+		  (while (not (if backward (bobp) (eobp)))
+		    (if backward
+		        (re-search-backward "\\(^.*\\): [0-9]+$")
+		      (re-search-forward "\\(^.*\\): [0-9]+$"))
 		    (goto-char (+ (match-end 1) 2))
 		    (setq list (cons (cons (+ (point-min)
 					      (read (current-buffer)))
 					   (match-string-no-properties 1))
 				     list))
-		    (goto-char (1+ (match-end 0))))
+		    (goto-char (if backward
+                                   (1- (match-beginning 0))
+                                 (1+ (match-end 0)))))
 		  ;; Put in forward order
 		  (setq list (nreverse list))))
 	      (while list
 		(message "Searching subfile %s..." (cdr (car list)))
 		(Info-read-subfile (car (car list)))
+                (if backward (goto-char (point-max)))
 		(setq list (cdr list))
 		(setq give-up nil found nil)
 		(while (and (not give-up)
 			    (or (null found)
-				(isearch-range-invisible beg-found found)))
-		  (if (re-search-forward regexp nil t)
-		      (setq found (point) beg-found (match-beginning 0))
+				(if backward
+                                    (isearch-range-invisible found beg-found)
+                                  (isearch-range-invisible beg-found found))))
+		  (if (if backward
+                          (re-search-backward regexp nil t)
+                        (re-search-forward regexp nil t))
+		      (setq found (point) beg-found (if backward (match-end 0)
+                                                      (match-beginning 0)))
 		    (setq give-up t)))
 		(if give-up
 		    (setq found nil))
@@ -1534,12 +1556,20 @@
 		     (goto-char opoint)
 		     (Info-select-node)
 		     (set-window-start (selected-window) ostart)))))
-      (widen)
-      (goto-char found)
-      (Info-select-node)
+
+      (if (and (string= osubfile Info-current-subfile)
+               (> found opoint-min)
+               (< found opoint-max))
+          ;; Search landed in the same node
+          (goto-char found)
+        (widen)
+        (goto-char found)
+        (save-match-data (Info-select-node)))
+
       ;; Use string-equal, not equal, to ignore text props.
       (or (and (string-equal onode Info-current-node)
 	       (equal ofile Info-current-file))
+          (and isearch-mode isearch-wrapped (eq opoint opoint-min))
 	  (setq Info-history (cons (list ofile onode opoint)
 				   Info-history))))))
 
@@ -1556,6 +1586,48 @@
     (if Info-search-history
         (Info-search (car Info-search-history))
       (call-interactively 'Info-search))))
+
+(defun Info-search-backward (regexp &optional bound noerror count)
+  "Search for REGEXP in the reverse direction."
+  (interactive (list (read-string
+		      (if Info-search-history
+			  (format "Regexp search%s backward (default `%s'): "
+                                  (if case-fold-search "" " case-sensitively")
+				  (car Info-search-history))
+			(format "Regexp search%s backward: "
+                                (if case-fold-search "" " case-sensitively")))
+		      nil 'Info-search-history)))
+  (Info-search regexp bound noerror count 'backward))
+
+(defun Info-isearch-search ()
+  (cond
+   (isearch-word
+    (if isearch-forward 'word-search-forward 'word-search-backward))
+   (isearch-regexp
+    (lambda (regexp bound noerror)
+      (condition-case nil
+          (progn
+            (Info-search regexp bound noerror nil
+                         (unless isearch-forward 'backward))
+            (point))
+        (error nil))))
+   (t
+    (if isearch-forward 'search-forward 'search-backward))))
+
+(defun Info-isearch-wrap ()
+  (if isearch-regexp
+      (if isearch-forward (Info-top-node) (Info-final-node))
+    (goto-char (if isearch-forward (point-min) (point-max)))))
+
+(defun Info-isearch-push-state ()
+  `(lambda (cmd)
+     (Info-isearch-pop-state cmd ,Info-current-file ,Info-current-node)))
+
+(defun Info-isearch-pop-state (cmd file node)
+  (or (and (string= Info-current-file file)
+           (string= Info-current-node node))
+      (progn (Info-find-node file node) (sit-for 0))))
+
 
 (defun Info-extract-pointer (name &optional errorname)
   "Extract the value of the node-pointer named NAME.
@@ -3064,6 +3136,14 @@
   (setq desktop-save-buffer 'Info-desktop-buffer-misc-data)
   (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t)
   (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
+  (set (make-local-variable 'isearch-search-fun-function)
+       'Info-isearch-search)
+  (set (make-local-variable 'isearch-wrap-function)
+       'Info-isearch-wrap)
+  (set (make-local-variable 'isearch-push-state-function)
+       'Info-isearch-push-state)
+  (set (make-local-variable 'search-whitespace-regexp)
+       Info-search-whitespace-regexp)
   (Info-set-mode-line)
   (run-hooks 'Info-mode-hook))
 
@@ -3445,23 +3525,24 @@
                 other-tag)
             (when not-fontified-p
               (when Info-hide-note-references
-                ;; *Note is often used where *note should have been
-                (goto-char start)
-                (skip-syntax-backward " ")
-                (setq other-tag
-                      (cond ((memq (char-before) '(nil ?\. ?! ??))
-                             "See ")
-                            ((memq (char-before) '(?\, ?\; ?\: ?-))
-                             "see ")
-                            ((memq (char-before) '(?\( ?\[ ?\{))
-                             ;; Check whether the paren is preceded by
-                             ;; an end of sentence
-                             (skip-syntax-backward " (")
-                             (if (memq (char-before) '(nil ?\. ?! ??))
-                                 "See "
-                               "see "))
-                            ((save-match-data (looking-at "\n\n"))
-                             "See ")))
+                (when (not (eq Info-hide-note-references 'hide))
+                  ;; *Note is often used where *note should have been
+                  (goto-char start)
+                  (skip-syntax-backward " ")
+                  (setq other-tag
+                        (cond ((memq (char-before) '(nil ?\. ?! ??))
+                               "See ")
+                              ((memq (char-before) '(?\, ?\; ?\: ?-))
+                               "see ")
+                              ((memq (char-before) '(?\( ?\[ ?\{))
+                               ;; Check whether the paren is preceded by
+                               ;; an end of sentence
+                               (skip-syntax-backward " (")
+                               (if (memq (char-before) '(nil ?\. ?! ??))
+                                   "See "
+                                 "see "))
+                              ((save-match-data (looking-at "\n\n"))
+                               "See "))))
                 (goto-char next)
                 (add-text-properties
                  (match-beginning 1)
@@ -3471,7 +3552,7 @@
                          (if (string-match "\n" (match-string 1))
                              (+ start1 (match-beginning 0)))))
                      (match-end 1))
-                 (if (and other-tag (not (eq Info-hide-note-references 'hide)))
+                 (if other-tag
                      `(display ,other-tag front-sticky nil rear-nonsticky t)
                    '(invisible t front-sticky nil rear-nonsticky t))))
               (add-text-properties
--- a/lisp/isearch.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/isearch.el	Sat Sep 04 09:14:28 2004 +0000
@@ -57,47 +57,6 @@
 ;; keep the behavior.  No point in forcing nonincremental search until
 ;; the last possible moment.
 
-;; TODO
-;; - Integrate the emacs 19 generalized command history.
-;; - Hooks and options for failed search.
-
-;;; Change Log:
-
-;; Changes before those recorded in ChangeLog:
-
-;; Revision 1.4  92/09/14  16:26:02  liberte
-;; Added prefix args to isearch-forward, etc. to switch between
-;;    string and regular expression searching.
-;; Added some support for lemacs.
-;; Added general isearch-highlight option - but only for lemacs so far.
-;; Added support for frame switching in emacs 19.
-;; Added word search option to isearch-edit-string.
-;; Renamed isearch-quit to isearch-abort.
-;; Numerous changes to comments and doc strings.
-;;
-;; Revision 1.3  92/06/29  13:10:08  liberte
-;; Moved modal isearch-mode handling into isearch-mode.
-;; Got rid of buffer-local isearch variables.
-;; isearch-edit-string used by ring adjustments, completion, and
-;; nonincremental searching.  C-s and C-r are additional exit commands.
-;; Renamed all regex to regexp.
-;; Got rid of found-start and found-point globals.
-;; Generalized handling of upper-case chars.
-
-;; Revision 1.2  92/05/27  11:33:57  liberte
-;; Emacs version 19 has a search ring, which is supported here.
-;; Other fixes found in the version 19 isearch are included here.
-;;
-;; Also see variables search-caps-disable-folding,
-;; search-nonincremental-instead, search-whitespace-regexp, and
-;; commands isearch-toggle-regexp, isearch-edit-string.
-;;
-;; semi-modal isearching is supported.
-
-;; Changes for 1.1
-;; 3/18/92 Fixed invalid-regexp.
-;; 3/18/92 Fixed yanking in regexps.
-
 ;;; Code:
 
 
@@ -198,6 +157,15 @@
 (defvar isearch-mode-end-hook nil
   "Function(s) to call after terminating an incremental search.")
 
+(defvar isearch-wrap-function nil
+  "Function to call to wrap the search when search is failed.
+If nil, move point to the beginning of the buffer for a forward search,
+or to the end of the buffer for a backward search.")
+
+(defvar isearch-push-state-function nil
+  "Function to save a function restoring the mode-specific isearch state
+to the search status stack.")
+
 ;; Search ring.
 
 (defvar search-ring nil
@@ -772,57 +740,62 @@
 
 ;; The search status structure and stack.
 
-(defsubst isearch-string (frame)
+(defsubst isearch-string-state (frame)
   "Return the search string in FRAME."
   (aref frame 0))
-(defsubst isearch-message-string (frame)
+(defsubst isearch-message-state (frame)
   "Return the search string to display to the user in FRAME."
   (aref frame 1))
-(defsubst isearch-point (frame)
+(defsubst isearch-point-state (frame)
   "Return the point in FRAME."
   (aref frame 2))
-(defsubst isearch-success (frame)
+(defsubst isearch-success-state (frame)
   "Return the success flag in FRAME."
   (aref frame 3))
-(defsubst isearch-forward-flag (frame)
+(defsubst isearch-forward-state (frame)
   "Return the searching-forward flag in FRAME."
   (aref frame 4))
-(defsubst isearch-other-end (frame)
+(defsubst isearch-other-end-state (frame)
   "Return the other end of the match in FRAME."
   (aref frame 5))
-(defsubst isearch-word (frame)
+(defsubst isearch-word-state (frame)
   "Return the search-by-word flag in FRAME."
   (aref frame 6))
-(defsubst isearch-invalid-regexp (frame)
+(defsubst isearch-invalid-regexp-state (frame)
   "Return the regexp error message in FRAME, or nil if its regexp is valid."
   (aref frame 7))
-(defsubst isearch-wrapped (frame)
+(defsubst isearch-wrapped-state (frame)
   "Return the search-wrapped flag in FRAME."
   (aref frame 8))
-(defsubst isearch-barrier (frame)
+(defsubst isearch-barrier-state (frame)
   "Return the barrier value in FRAME."
   (aref frame 9))
-(defsubst isearch-within-brackets (frame)
+(defsubst isearch-within-brackets-state (frame)
   "Return the in-character-class flag in FRAME."
   (aref frame 10))
-(defsubst isearch-case-fold-search (frame)
+(defsubst isearch-case-fold-search-state (frame)
   "Return the case-folding flag in FRAME."
   (aref frame 11))
+(defsubst isearch-pop-fun-state (frame)
+  "Return the function restoring the mode-specific isearch state in FRAME."
+  (aref frame 12))
 
 (defun isearch-top-state ()
   (let ((cmd (car isearch-cmds)))
-    (setq isearch-string (isearch-string cmd)
-	  isearch-message (isearch-message-string cmd)
-	  isearch-success (isearch-success cmd)
-	  isearch-forward (isearch-forward-flag cmd)
-	  isearch-other-end (isearch-other-end cmd)
-	  isearch-word (isearch-word cmd)
-	  isearch-invalid-regexp (isearch-invalid-regexp cmd)
-	  isearch-wrapped (isearch-wrapped cmd)
-	  isearch-barrier (isearch-barrier cmd)
-	  isearch-within-brackets (isearch-within-brackets cmd)
-	  isearch-case-fold-search (isearch-case-fold-search cmd))
-    (goto-char (isearch-point cmd))))
+    (setq isearch-string (isearch-string-state cmd)
+	  isearch-message (isearch-message-state cmd)
+	  isearch-success (isearch-success-state cmd)
+	  isearch-forward (isearch-forward-state cmd)
+	  isearch-other-end (isearch-other-end-state cmd)
+	  isearch-word (isearch-word-state cmd)
+	  isearch-invalid-regexp (isearch-invalid-regexp-state cmd)
+	  isearch-wrapped (isearch-wrapped-state cmd)
+	  isearch-barrier (isearch-barrier-state cmd)
+	  isearch-within-brackets (isearch-within-brackets-state cmd)
+	  isearch-case-fold-search (isearch-case-fold-search-state cmd))
+    (if (functionp (isearch-pop-fun-state cmd))
+	(funcall (isearch-pop-fun-state cmd) cmd))
+    (goto-char (isearch-point-state cmd))))
 
 (defun isearch-pop-state ()
   (setq isearch-cmds (cdr isearch-cmds))
@@ -834,7 +807,9 @@
 		      isearch-success isearch-forward isearch-other-end
 		      isearch-word
 		      isearch-invalid-regexp isearch-wrapped isearch-barrier
-		      isearch-within-brackets isearch-case-fold-search)
+		      isearch-within-brackets isearch-case-fold-search
+		      (if isearch-push-state-function
+			  (funcall isearch-push-state-function)))
 	      isearch-cmds)))
 
 
@@ -1020,10 +995,13 @@
 (defun isearch-cancel ()
   "Terminate the search and go back to the starting point."
   (interactive)
+  (if (functionp (isearch-pop-fun-state (car (last isearch-cmds))))
+      (funcall (isearch-pop-fun-state (car (last isearch-cmds)))
+               (car (last isearch-cmds))))
   (goto-char isearch-opoint)
-  (isearch-done t)
+  (isearch-done t)                      ; exit isearch
   (isearch-clean-overlays)
-  (signal 'quit nil))  ; and pass on quit signal
+  (signal 'quit nil))                   ; and pass on quit signal
 
 (defun isearch-abort ()
   "Abort incremental search mode if searching is successful, signaling quit.
@@ -1035,11 +1013,9 @@
   (if isearch-success
       ;; If search is successful, move back to starting point
       ;; and really do quit.
-      (progn (goto-char isearch-opoint)
-	     (setq isearch-success nil)
-	     (isearch-done t)   ; exit isearch
-	     (isearch-clean-overlays)
-	     (signal 'quit nil))  ; and pass on quit signal
+      (progn
+        (setq isearch-success nil)
+        (isearch-cancel))
     ;; If search is failing, or has an incomplete regexp,
     ;; rub out until it is once more successful.
     (while (or (not isearch-success) isearch-invalid-regexp)
@@ -1064,7 +1040,9 @@
 	;; If already have what to search for, repeat it.
 	(or isearch-success
 	    (progn
-	      (goto-char (if isearch-forward (point-min) (point-max)))
+	      (if isearch-wrap-function
+		  (funcall isearch-wrap-function)
+	        (goto-char (if isearch-forward (point-min) (point-max))))
 	      (setq isearch-wrapped t))))
     ;; C-s in reverse or C-r in forward, change direction.
     (setq isearch-forward (not isearch-forward)))
@@ -1106,6 +1084,7 @@
   (interactive)
   (setq isearch-regexp (not isearch-regexp))
   (if isearch-regexp (setq isearch-word nil))
+  (setq isearch-success t isearch-adjusted t)
   (isearch-update))
 
 (defun isearch-toggle-case-fold ()
@@ -1118,34 +1097,39 @@
 	     (isearch-message-prefix nil nil isearch-nonincremental)
 	     isearch-message
 	     (if isearch-case-fold-search "in" "")))
-  (setq isearch-adjusted t)
+  (setq isearch-success t isearch-adjusted t)
   (sit-for 1)
   (isearch-update))
 
-(defun isearch-query-replace ()
+(defun isearch-query-replace (&optional regexp-flag)
   "Start query-replace with string to replace from last search string."
   (interactive)
   (barf-if-buffer-read-only)
+  (if regexp-flag (setq isearch-regexp t))
   (let ((case-fold-search isearch-case-fold-search))
     (isearch-done)
     (isearch-clean-overlays)
-    (and isearch-forward isearch-other-end (goto-char isearch-other-end))
+    (if (and (< isearch-other-end (point))
+             (not (and transient-mark-mode mark-active
+                       (< isearch-opoint (point)))))
+        (goto-char isearch-other-end))
+    (set query-replace-from-history-variable
+         (cons isearch-string
+               (symbol-value query-replace-from-history-variable)))
     (perform-replace
      isearch-string
-     (query-replace-read-to isearch-string "Query replace" isearch-regexp)
-     t isearch-regexp isearch-word)))
+     (query-replace-read-to
+      isearch-string
+      (if isearch-regexp "Query replace regexp" "Query replace")
+      isearch-regexp)
+     t isearch-regexp isearch-word nil nil
+     (if (and transient-mark-mode mark-active) (region-beginning))
+     (if (and transient-mark-mode mark-active) (region-end)))))
 
 (defun isearch-query-replace-regexp ()
   "Start query-replace-regexp with string to replace from last search string."
   (interactive)
-  (let ((query-replace-interactive t)
-        (case-fold-search isearch-case-fold-search))
-    ;; Put search string into the right ring
-    (setq isearch-regexp t)
-    (isearch-done)
-    (isearch-clean-overlays)
-    (and isearch-forward isearch-other-end (goto-char isearch-other-end))
-    (call-interactively 'query-replace-regexp)))
+  (isearch-query-replace t))
 
 
 (defun isearch-delete-char ()
@@ -1343,7 +1327,7 @@
 	     ;; We have to check 2 stack frames because the last might be
 	     ;; invalid just because of a backslash.
 	     (or (not isearch-invalid-regexp)
-		 (not (isearch-invalid-regexp (cadr isearch-cmds)))
+		 (not (isearch-invalid-regexp-state (cadr isearch-cmds)))
 		 allow-invalid))
     (if to-barrier
 	(progn (goto-char isearch-barrier)
@@ -1358,8 +1342,8 @@
 	;; Also skip over postfix operators -- though horrid,
 	;; 'ab?\{5,6\}+\{1,2\}*' is perfectly legal.
 	(while (and previous
-		    (or (isearch-invalid-regexp frame)
-			(let* ((string (isearch-string frame))
+		    (or (isearch-invalid-regexp-state frame)
+			(let* ((string (isearch-string-state frame))
 			       (lchar (aref string (1- (length string)))))
 			  ;; The operators aren't always operators; check
 			  ;; backslashes.  This doesn't handle the case of
@@ -1367,7 +1351,7 @@
 			  ;; being special, but then we should fall back to
 			  ;; the barrier anyway because it's all optional.
 			  (if (isearch-backslash
-			       (isearch-string (car previous)))
+			       (isearch-string-state (car previous)))
 			      (eq lchar ?\})
 			    (memq lchar '(?* ?? ?+))))))
 	  (setq stack previous previous (cdr previous) frame (car stack)))
@@ -1375,7 +1359,7 @@
 	  ;; `stack' now refers the most recent valid regexp that is not at
 	  ;; all optional in its last term.  Now dig one level deeper and find
 	  ;; what matched before that.
-	  (let ((last-other-end (or (isearch-other-end (car previous))
+	  (let ((last-other-end (or (isearch-other-end-state (car previous))
 				    isearch-barrier)))
 	    (goto-char (if isearch-forward
 			   (max last-other-end isearch-barrier)
@@ -1638,8 +1622,7 @@
            (let ((ab-bel (isearch-string-out-of-window isearch-point)))
              (if ab-bel
                  (isearch-back-into-window (eq ab-bel 'above) isearch-point)
-               (or (eq (point) isearch-point)
-                   (goto-char isearch-point))))
+               (goto-char isearch-point)))
            (isearch-update))
 	  (search-exit-option
 	   (let (window)
@@ -1913,7 +1896,9 @@
   ;; If currently failing, display no ellipsis.
   (or isearch-success (setq ellipsis nil))
   (let ((m (concat (if isearch-success "" "failing ")
+		   (if isearch-adjusted "pending " "")
 		   (if (and isearch-wrapped
+			    (not isearch-wrap-function)
 			    (if isearch-forward
 				(> (point) isearch-opoint)
 			      (< (point) isearch-opoint)))
@@ -2008,9 +1993,11 @@
   (if isearch-success
       nil
     ;; Ding if failed this time after succeeding last time.
-    (and (isearch-success (car isearch-cmds))
+    (and (isearch-success-state (car isearch-cmds))
 	 (ding))
-    (goto-char (isearch-point (car isearch-cmds)))))
+    (if (functionp (isearch-pop-fun-state (car isearch-cmds)))
+        (funcall (isearch-pop-fun-state (car isearch-cmds)) (car isearch-cmds)))
+    (goto-char (isearch-point-state (car isearch-cmds)))))
 
 
 ;; Called when opening an overlay, and we are still in isearch.
--- a/lisp/macros.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/macros.el	Sat Sep 04 09:14:28 2004 +0000
@@ -1,6 +1,6 @@
 ;;; macros.el --- non-primitive commands for keyboard macros
 
-;; Copyright (C) 1985, 86, 87, 92, 94, 95 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 86, 87, 92, 94, 95, 04 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: abbrev
@@ -151,7 +151,7 @@
 		     (cond ((= char ?\\)
 			    (insert "\\\\"))
                            ((= char ?\")
-                            (insert "\\\""))   
+                            (insert "\\\""))
 			   ((= char ?\;)
 			    (insert "\\;"))
 			   ((= char 127)
@@ -240,8 +240,9 @@
 
 ;;;###autoload
 (defun apply-macro-to-region-lines (top bottom &optional macro)
-  "For each complete line between point and mark, move to the beginning
-of the line, and run the last keyboard macro.
+  "Apply last keyboard macro to all lines in the region.
+For each line that begins in the region, move to the beginning of
+the line, and run the last keyboard macro.
 
 When called from lisp, this function takes two arguments TOP and
 BOTTOM, describing the current region.  TOP must be before BOTTOM.
@@ -277,8 +278,7 @@
     \\C-x )
 
 and then select the region of un-tablified names and use
-`\\[apply-macro-to-region-lines]' to build the table from the names.
-"
+`\\[apply-macro-to-region-lines]' to build the table from the names."
   (interactive "r")
   (or macro
       (progn
@@ -286,10 +286,7 @@
 	    (error "No keyboard macro has been defined"))
 	(setq macro last-kbd-macro)))
   (save-excursion
-    (let ((end-marker (progn
-			(goto-char bottom)
-			(beginning-of-line)
-			(point-marker)))
+    (let ((end-marker (copy-marker bottom))
 	  next-line-marker)
       (goto-char top)
       (if (not (bolp))
--- a/lisp/progmodes/compile.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/progmodes/compile.el	Sat Sep 04 09:14:28 2004 +0000
@@ -458,9 +458,9 @@
   :version "21.4")
 
 (defface compilation-info-face
-  '((((class color) (min-colors 16) (background light)) 
+  '((((class color) (min-colors 16) (background light))
      (:foreground "Green3" :weight bold))
-    (((class color) (min-colors 16) (background dark)) 
+    (((class color) (min-colors 16) (background dark))
      (:foreground "Green" :weight bold))
     (((class color)) (:foreground "green" :weight bold))
     (t (:weight bold)))
@@ -579,12 +579,17 @@
     (and end-line
 	 (setq end-line (match-string-no-properties end-line))
 	 (setq end-line (string-to-number end-line)))
-    (and col
-	 (setq col (match-string-no-properties col))
-	 (setq col (- (string-to-number col) compilation-first-column)))
-    (if (and end-col (setq end-col (match-string-no-properties end-col)))
-	(setq end-col (- (string-to-number end-col) compilation-first-column -1))
-      (if end-line (setq end-col -1)))
+    (if col
+        (if (functionp col)
+            (setq col (funcall col))
+          (and
+           (setq col (match-string-no-properties col))
+           (setq col (- (string-to-number col) compilation-first-column)))))
+    (if (and end-col (functionp end-col))
+        (setq end-col (funcall end-col))
+      (if (and end-col (setq end-col (match-string-no-properties end-col)))
+          (setq end-col (- (string-to-number end-col) compilation-first-column -1))
+        (if end-line (setq end-col -1))))
     (if (consp type)			; not a static type, check what it is.
 	(setq type (or (and (car type) (match-end (car type)) 1)
 		       (and (cdr type) (match-end (cdr type)) 0)
@@ -726,9 +731,9 @@
 	      ,@(when end-line
 		  `((,end-line compilation-line-face nil t)))
 
-	      ,@(when col
+	      ,@(when (integerp col)
 		  `((,col compilation-column-face nil t)))
-	      ,@(when end-col
+	      ,@(when (integerp end-col)
 		  `((,end-col compilation-column-face nil t)))
 
 	      ,@(nthcdr 6 item)
@@ -789,7 +794,10 @@
 original use.  Otherwise, recompile using `compile-command'."
   (interactive)
   (save-some-buffers (not compilation-ask-about-save) nil)
-  (let ((default-directory (or compilation-directory default-directory)))
+  (let ((default-directory
+          (or (and (not (eq major-mode (nth 1 compilation-arguments)))
+                   compilation-directory)
+              default-directory)))
     (apply 'compilation-start (or compilation-arguments
 				  `(,(eval compile-command))))))
 
@@ -816,8 +824,7 @@
 	 (funcall name-function mode-name))
 	(compilation-buffer-name-function
 	 (funcall compilation-buffer-name-function mode-name))
-	((and (eq major-mode 'compilation-mode)
-	      (equal mode-name (nth 2 compilation-arguments)))
+	((eq major-mode (nth 1 compilation-arguments))
 	 (buffer-name))
 	(t
 	 (concat "*" (downcase mode-name) "*"))))
@@ -1522,7 +1529,8 @@
 
 (defun compilation-goto-locus (msg mk end-mk)
   "Jump to an error corresponding to MSG at MK.
-All arguments are markers.  If END-MK is non nil, mark is set there."
+All arguments are markers.  If END-MK is non-nil, mark is set there
+and overlay is highlighted between MK and END-MK."
   (if (eq (window-buffer (selected-window))
 	  (marker-buffer msg))
       ;; If the compilation buffer window is selected,
@@ -1538,7 +1546,7 @@
     (widen)
     (goto-char mk))
   (if end-mk
-      (push-mark end-mk nil t)
+      (push-mark end-mk t)
     (if mark-active (setq mark-active)))
   ;; If hideshow got in the way of
   ;; seeing the right place, open permanently.
@@ -1559,26 +1567,32 @@
 			     compilation-highlight-regexp)))
     (compilation-set-window-height w)
 
-    (when (and highlight-regexp
-	       (not (and end-mk transient-mark-mode)))
+    (when highlight-regexp
       (unless compilation-highlight-overlay
 	(setq compilation-highlight-overlay
 	      (make-overlay (point-min) (point-min)))
-	(overlay-put compilation-highlight-overlay 'face 'region))
+	(overlay-put compilation-highlight-overlay 'face 'next-error))
       (with-current-buffer (marker-buffer mk)
 	(save-excursion
-	  (end-of-line)
+	  (if end-mk (goto-char end-mk) (end-of-line))
 	  (let ((end (point)))
-	    (beginning-of-line)
+	    (if mk (goto-char mk) (beginning-of-line))
 	    (if (and (stringp highlight-regexp)
 		     (re-search-forward highlight-regexp end t))
 		(progn
 		  (goto-char (match-beginning 0))
-		  (move-overlay compilation-highlight-overlay (match-beginning 0) (match-end 0)))
-	      (move-overlay compilation-highlight-overlay (point) end))
-	    (sit-for 0.5)
-	    (delete-overlay compilation-highlight-overlay)))))))
-
+		  (move-overlay compilation-highlight-overlay
+				(match-beginning 0) (match-end 0)
+				(current-buffer)))
+	      (move-overlay compilation-highlight-overlay
+			    (point) end (current-buffer)))
+	    (if (numberp next-error-highlight)
+		(sit-for next-error-highlight))
+	    (if (not (eq next-error-highlight t))
+		(delete-overlay compilation-highlight-overlay))))))
+    (when (and (eq next-error-highlight 'fringe-arrow))
+      (set (make-local-variable 'overlay-arrow-position)
+	   (copy-marker (line-beginning-position))))))
 
 (defun compilation-find-file (marker filename dir &rest formats)
   "Find a buffer for file FILENAME.
--- a/lisp/progmodes/etags.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/progmodes/etags.el	Sat Sep 04 09:14:28 2004 +0000
@@ -772,26 +772,6 @@
 	(all-completions string (tags-completion-table) predicate)
       (try-completion string (tags-completion-table) predicate))))
 
-;; Return a default tag to search for, based on the text at point.
-(defun find-tag-default ()
-  (save-excursion
-    (while (looking-at "\\sw\\|\\s_")
-      (forward-char 1))
-    (if (or (re-search-backward "\\sw\\|\\s_"
-				(save-excursion (beginning-of-line) (point))
-				t)
-	    (re-search-forward "\\(\\sw\\|\\s_\\)+"
-			       (save-excursion (end-of-line) (point))
-			       t))
-	(progn (goto-char (match-end 0))
-	       (buffer-substring-no-properties
-                (point)
-                (progn (forward-sexp -1)
-                       (while (looking-at "\\s'")
-                         (forward-char 1))
-                       (point))))
-      nil)))
-
 ;; Read a tag name from the minibuffer with defaulting and completion.
 (defun find-tag-tag (string)
   (let* ((completion-ignore-case (if (memq tags-case-fold-search '(t nil))
--- a/lisp/progmodes/grep.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/progmodes/grep.el	Sat Sep 04 09:14:28 2004 +0000
@@ -64,6 +64,21 @@
   :version "21.4"
   :group 'grep)
 
+(defcustom grep-highlight-matches t
+  "*Non-nil to use special markers to highlight grep matches.
+
+Some grep programs are able to surround matches with special
+markers in grep output.  Such markers can be used to highlight
+matches in grep mode.
+
+This option sets the environment variable GREP_COLOR to specify
+markers for highlighting and GREP_OPTIONS to add the --color
+option in front of any explicit grep options before starting
+the grep."
+  :type 'boolean
+  :version "21.4"
+  :group 'grep)
+
 (defcustom grep-scroll-output nil
   "*Non-nil to scroll the *grep* buffer window as output appears.
 
@@ -230,6 +245,23 @@
   '(("^\\(.+?\\)[:( \t]+\
 \\([0-9]+\\)\\([.:]?\\)\\([0-9]+\\)?\
 \\(?:-\\(?:\\([0-9]+\\)\\3\\)?\\.?\\([0-9]+\\)?\\)?[:) \t]" 1 (2 . 5) (4 . 6))
+    ("^\\(.+?\\)[:(]+\\([0-9]+\\)\\([:)]\\).*?\\(\033\\[01;41m\\)\\(.*?\\)\\(\033\\[00m\\)"
+     1 2
+     ((lambda ()
+        (setq compilation-error-screen-columns nil)
+        (- (match-beginning 5) (match-end 3) 8))
+      .
+      (lambda () (- (match-end 5) (match-end 3) 8)))
+     nil nil
+     (4 (list 'face nil 'invisible t 'intangible t))
+     (5 (list 'face compilation-column-face))
+     (6 (list 'face nil 'invisible t 'intangible t))
+     ;; highlight other matches on the same line
+     ("\\(\033\\[01;41m\\)\\(.*?\\)\\(\033\\[00m\\)"
+      nil nil
+      (1 (list 'face nil 'invisible t 'intangible t))
+      (2 (list 'face compilation-column-face) t)
+      (3 (list 'face nil 'invisible t 'intangible t))))
     ("^Binary file \\(.+\\) matches$" 1 nil nil 1))
   "Regexp used to match grep hits.  See `compilation-error-regexp-alist'.")
 
@@ -300,6 +332,10 @@
 (defun grep-process-setup ()
   "Setup compilation variables and buffer for `grep'.
 Set up `compilation-exit-message-function' and run `grep-setup-hook'."
+  (when grep-highlight-matches
+    ;; Modify `process-environment' locally bound in `compilation-start'
+    (setenv "GREP_OPTIONS" (concat (getenv "GREP_OPTIONS") " --color=always"))
+    (setenv "GREP_COLOR" "01;41"))
   (set (make-local-variable 'compilation-exit-message-function)
        (lambda (status code msg)
 	 (if (eq status 'exit)
@@ -384,9 +420,7 @@
   (let ((tag-default
 	 (funcall (or find-tag-default-function
 		      (get major-mode 'find-tag-default-function)
-		      ;; We use grep-tag-default instead of
-		      ;; find-tag-default, to avoid loading etags.
-		      'grep-tag-default)))
+		      'find-tag-default)))
 	(sh-arg-re "\\(\\(?:\"\\(?:[^\"]\\|\\\\\"\\)+\"\\|'[^']+'\\|[^\"' \t\n]\\)+\\)")
 	(grep-default (or (car grep-history) grep-command)))
     ;; Replace the thing matching for with that around cursor.
@@ -457,25 +491,6 @@
   (set (make-local-variable 'compilation-error-regexp-alist)
        grep-regexp-alist))
 
-;; This is a copy of find-tag-default from etags.el.
-;;;###autoload
-(defun grep-tag-default ()
-  (save-excursion
-    (while (looking-at "\\sw\\|\\s_")
-      (forward-char 1))
-    (when (or (re-search-backward "\\sw\\|\\s_"
-				  (save-excursion (beginning-of-line) (point))
-				  t)
-	      (re-search-forward "\\(\\sw\\|\\s_\\)+"
-				 (save-excursion (end-of-line) (point))
-				 t))
-      (goto-char (match-end 0))
-      (buffer-substring (point)
-			(progn (forward-sexp -1)
-			       (while (looking-at "\\s'")
-				 (forward-char 1))
-			       (point))))))
-
 ;;;###autoload
 (defun grep-find (command-args)
   "Run grep via find, with user-specified args COMMAND-ARGS.
--- a/lisp/simple.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/simple.el	Sat Sep 04 09:14:28 2004 +0000
@@ -65,7 +65,7 @@
 	    (setq found buffer)))
       (setq list (cdr list)))
     (switch-to-buffer found)))
-
+
 ;;; next-error support framework
 (defvar next-error-last-buffer nil
   "The most recent next-error buffer.
@@ -91,51 +91,50 @@
     (or (and extra-test (funcall extra-test))
 	next-error-function)))
 
-;; Return a next-error capable buffer according to the following rules:
-;; 1. If the current buffer is a next-error capable buffer, return it.
-;; 2. If one window on the selected frame displays such buffer, return it.
-;; 3. If next-error-last-buffer is set to a live buffer, use that.
-;; 4. Otherwise, look for a next-error capable buffer in a buffer list.
-;; 5. Signal an error if there are none.
 (defun next-error-find-buffer (&optional other-buffer extra-test)
-  (if (and (not other-buffer)
-	   (next-error-buffer-p (current-buffer) extra-test))
-      ;; The current buffer is a next-error capable buffer.
-      (current-buffer)
-    (or
-     (let ((window-buffers
-            (delete-dups
-             (delq nil
-              (mapcar (lambda (w)
-                        (and (next-error-buffer-p (window-buffer w) extra-test)
-                             (window-buffer w)))
-                      (window-list))))))
-       (if other-buffer
-           (setq window-buffers (delq (current-buffer) window-buffers)))
-       (if (eq (length window-buffers) 1)
-           (car window-buffers)))
-     (if (and next-error-last-buffer (buffer-name next-error-last-buffer)
-              (next-error-buffer-p next-error-last-buffer extra-test)
-              (or (not other-buffer) (not (eq next-error-last-buffer
-                                              (current-buffer)))))
-         next-error-last-buffer
-       (let ((buffers (buffer-list)))
-         (while (and buffers (or (not (next-error-buffer-p (car buffers) extra-test))
-                                 (and other-buffer
-                                      (eq (car buffers) (current-buffer)))))
-           (setq buffers (cdr buffers)))
-         (if buffers
-             (car buffers)
-           (or (and other-buffer
-                    (next-error-buffer-p (current-buffer) extra-test)
-                    ;; The current buffer is a next-error capable buffer.
-                    (progn
-                      (if other-buffer
-                          (message "This is the only next-error capable buffer."))
-                      (current-buffer)))
-               (error "No next-error capable buffer found"))))))))
-
-(defun next-error (arg &optional reset)
+  "Return a next-error capable buffer."
+  (or
+   ;; 1. If one window on the selected frame displays such buffer, return it.
+   (let ((window-buffers
+          (delete-dups
+           (delq nil (mapcar (lambda (w)
+                               (if (next-error-buffer-p
+                                    (window-buffer w) extra-test)
+                                   (window-buffer w)))
+                             (window-list))))))
+     (if other-buffer
+         (setq window-buffers (delq (current-buffer) window-buffers)))
+     (if (eq (length window-buffers) 1)
+         (car window-buffers)))
+   ;; 2. If next-error-last-buffer is set to a live buffer, use that.
+   (if (and next-error-last-buffer
+            (buffer-name next-error-last-buffer)
+            (next-error-buffer-p next-error-last-buffer extra-test)
+            (or (not other-buffer)
+                (not (eq next-error-last-buffer (current-buffer)))))
+       next-error-last-buffer)
+   ;; 3. If the current buffer is a next-error capable buffer, return it.
+   (if (and (not other-buffer)
+            (next-error-buffer-p (current-buffer) extra-test))
+       (current-buffer))
+   ;; 4. Look for a next-error capable buffer in a buffer list.
+   (let ((buffers (buffer-list)))
+     (while (and buffers
+                 (or (not (next-error-buffer-p (car buffers) extra-test))
+                     (and other-buffer (eq (car buffers) (current-buffer)))))
+       (setq buffers (cdr buffers)))
+     (if buffers
+         (car buffers)
+       (or (and other-buffer
+                (next-error-buffer-p (current-buffer) extra-test)
+                ;; The current buffer is a next-error capable buffer.
+                (progn
+                  (if other-buffer
+                      (message "This is the only next-error capable buffer"))
+                  (current-buffer)))
+           (error "No next-error capable buffer found"))))))
+
+(defun next-error (&optional arg reset)
   "Visit next next-error message and corresponding source code.
 
 If all the error messages parsed so far have been processed already,
@@ -153,9 +152,10 @@
 buffer with output from the \\[compile], \\[grep] commands, or,
 more generally, on any buffer in Compilation mode or with
 Compilation Minor mode enabled, or any buffer in which
-`next-error-function' is bound to an appropriate
-function.  To specify use of a particular buffer for error
-messages, type \\[next-error] in that buffer.
+`next-error-function' is bound to an appropriate function.
+To specify use of a particular buffer for error messages, type
+\\[next-error] in that buffer when it is the only one displayed
+in the current frame.
 
 Once \\[next-error] has chosen the buffer for error messages,
 it stays with that buffer until you use it in some other buffer which
@@ -175,7 +175,7 @@
 
 (define-key ctl-x-map "`" 'next-error)
 
-(defun previous-error (n)
+(defun previous-error (&optional n)
   "Visit previous next-error message and corresponding source code.
 
 Prefix arg N says how many error messages to move backwards (or
@@ -183,9 +183,9 @@
 
 This operates on the output from the \\[compile] and \\[grep] commands."
   (interactive "p")
-  (next-error (- n)))
-
-(defun first-error (n)
+  (next-error (- (or n 1))))
+
+(defun first-error (&optional n)
   "Restart at the first error.
 Visit corresponding source code.
 With prefix arg N, visit the source code of the Nth error.
@@ -193,25 +193,63 @@
   (interactive "p")
   (next-error n t))
 
-(defun next-error-no-select (n)
+(defun next-error-no-select (&optional n)
   "Move point to the next error in the next-error buffer and highlight match.
 Prefix arg N says how many error messages to move forwards (or
 backwards, if negative).
 Finds and highlights the source line like \\[next-error], but does not
 select the source buffer."
   (interactive "p")
-  (next-error n)
+  (let ((next-error-highlight next-error-highlight-no-select))
+    (next-error n))
   (pop-to-buffer next-error-last-buffer))
 
-(defun previous-error-no-select (n)
+(defun previous-error-no-select (&optional n)
   "Move point to the previous error in the next-error buffer and highlight match.
 Prefix arg N says how many error messages to move backwards (or
 forwards, if negative).
 Finds and highlights the source line like \\[previous-error], but does not
 select the source buffer."
   (interactive "p")
-  (next-error-no-select (- n)))
-
+  (next-error-no-select (- (or n 1))))
+
+(defgroup next-error nil
+  "next-error support framework."
+  :group 'compilation
+  :version "21.4")
+
+(defface next-error
+  '((t (:inherit region)))
+  "Face used to highlight next error locus."
+  :group 'next-error
+  :version "21.4")
+
+(defcustom next-error-highlight 0.1
+  "*Highlighting of locations in selected source buffers.
+If number, highlight the locus in next-error face for given time in seconds.
+If t, use persistent overlays fontified in next-error face.
+If nil, don't highlight the locus in the source buffer.
+If `fringe-arrow', indicate the locus by the fringe arrow."
+  :type '(choice (number :tag "Delay")
+                 (const :tag "Persistent overlay" t)
+                 (const :tag "No highlighting" nil)
+                 (const :tag "Fringe arrow" 'fringe-arrow))
+  :group 'next-error
+  :version "21.4")
+
+(defcustom next-error-highlight-no-select 0.1
+  "*Highlighting of locations in non-selected source buffers.
+If number, highlight the locus in next-error face for given time in seconds.
+If t, use persistent overlays fontified in next-error face.
+If nil, don't highlight the locus in the source buffer.
+If `fringe-arrow', indicate the locus by the fringe arrow."
+  :type '(choice (number :tag "Delay")
+                 (const :tag "Persistent overlay" t)
+                 (const :tag "No highlighting" nil)
+                 (const :tag "Fringe arrow" 'fringe-arrow))
+  :group 'next-error
+  :version "21.4")
+
 ;;;
 
 (defun fundamental-mode ()
--- a/lisp/startup.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/startup.el	Sat Sep 04 09:14:28 2004 +0000
@@ -348,9 +348,6 @@
     ;; `user-full-name' is now known; reset its standard-value here.
     (put 'user-full-name 'standard-value
 	 (list (default-value 'user-full-name)))
-    ;; Subprocesses of Emacs do not have direct access to the terminal,
-    ;; so unless told otherwise they should only assume a dumb terminal.
-    (setenv "TERM" "dumb")
     ;; For root, preserve owner and group when editing files.
     (if (equal (user-uid) 0)
 	(setq backup-by-copying-when-mismatch t))
--- a/lisp/subr.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/subr.el	Sat Sep 04 09:14:28 2004 +0000
@@ -1969,6 +1969,27 @@
 		(setq parent (get parent 'derived-mode-parent))))
     parent))
 
+(defun find-tag-default ()
+  "Determine default tag to search for, based on text at point.
+If there is no plausible default, return nil."
+  (save-excursion
+    (while (looking-at "\\sw\\|\\s_")
+      (forward-char 1))
+    (if (or (re-search-backward "\\sw\\|\\s_"
+				(save-excursion (beginning-of-line) (point))
+				t)
+	    (re-search-forward "\\(\\sw\\|\\s_\\)+"
+			       (save-excursion (end-of-line) (point))
+			       t))
+	(progn (goto-char (match-end 0))
+	       (buffer-substring-no-properties
+                (point)
+                (progn (forward-sexp -1)
+                       (while (looking-at "\\s'")
+                         (forward-char 1))
+                       (point))))
+      nil)))
+
 (defmacro with-syntax-table (table &rest body)
   "Evaluate BODY with syntax table of current buffer set to TABLE.
 The syntax table of the current buffer is saved, BODY is evaluated, and the
--- a/lisp/term/mac-win.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/term/mac-win.el	Sat Sep 04 09:14:28 2004 +0000
@@ -141,6 +141,9 @@
 	   (if clipboard
 	       (decode-coding-string clipboard selection-coding-system t)))))
 
+;; Don't show the frame name; that's redundant.
+(setq-default mode-line-frame-identification "  ")
+
 (defun mac-drag-n-drop (event)
   "Edit the files listed in the drag-n-drop event.\n\
 Switch to a buffer editing the last file dropped."
@@ -253,6 +256,9 @@
 
 ;; Tell read-char how to convert special chars to ASCII
 (put 'return 'ascii-character 13)
+(put 'tab 'ascii-character ?\t)
+(put 'backspace 'ascii-character 127)
+(put 'escape 'ascii-character ?\e)
 
 ;;
 ;; Available colors
--- a/lisp/textmodes/ispell.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/textmodes/ispell.el	Sat Sep 04 09:14:28 2004 +0000
@@ -1228,7 +1228,7 @@
   "*Lists of start and end keys to skip in HTML buffers.
 Same format as `ispell-skip-region-alist'
 Note - substrings of other matches must come last
- (e.g. \"<[tT][tT]/\" and \"<[^ \t\n>]\").")
+ (e.g. \"<[tT][tT]/\" and \"<[^ \\t\\n>]\").")
 
 
 (defvar ispell-local-pdict ispell-personal-dictionary
--- a/lisp/textmodes/tex-mode.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/textmodes/tex-mode.el	Sat Sep 04 09:14:28 2004 +0000
@@ -1145,9 +1145,10 @@
 	  (if no-matches
 	      (insert "None!\n"))
 	  (if (interactive-p)
-	      (message "%s mismatch%s found"
-		       (if no-matches "No" num-matches)
-		       (if (> num-matches 1) "es" ""))))))))
+	      (message (cond (no-matches "No mismatches found")
+			     ((= num-matches 1) "1 mismatch found")
+			     (t "%d mismatches found"))
+		       num-matches)))))))
 
 (defun tex-validate-region (start end)
   "Check for mismatched braces or $'s in region.
--- a/lisp/x-dnd.el	Wed Sep 01 21:21:18 2004 +0000
+++ b/lisp/x-dnd.el	Sat Sep 04 09:14:28 2004 +0000
@@ -58,8 +58,8 @@
     )
 
   "The functions to call for different protocols when a drop is made.
-This variable is used by `x-dnd-handle-uri-list' and `x-dnd-handle-moz-url'.
-The list contains of (REGEXP . FUNCTION) pairs.
+This variable is used by `x-dnd-handle-uri-list', `x-dnd-handle-file-name'
+and `x-dnd-handle-moz-url'.  The list contains of (REGEXP . FUNCTION) pairs.
 The functions shall take two arguments, URL, which is the URL dropped and
 ACTION which is the action to be performed for the drop (move, copy, link,
 private or ask).
@@ -104,9 +104,7 @@
   :type 'boolean
   :group 'x)
 
-;; Internal variables
-
-(defvar x-dnd-known-types
+(defcustom x-dnd-known-types
   '("text/uri-list"
     "text/x-moz-url"
     "_NETSCAPE_URL"
@@ -121,7 +119,12 @@
     "TEXT"
     )
   "The types accepted by default for dropped data.
-The types are chosen in the order they appear in the list.")
+The types are chosen in the order they appear in the list."
+  :type '(repeat string)
+  :group 'x
+)
+
+;; Internal variables
 
 (defvar x-dnd-current-state nil
   "The current state for a drop.
@@ -865,7 +868,7 @@
 	      timestamp)
 	     (x-dnd-forget-drop frame)))
 
-	  (t (error "Unknown Motif DND message %s %s" message data)))))
+	  (t (error "Unknown Motif DND message %s %s" message-atom data)))))
 					   
 
 ;;;
--- a/lispref/ChangeLog	Wed Sep 01 21:21:18 2004 +0000
+++ b/lispref/ChangeLog	Sat Sep 04 09:14:28 2004 +0000
@@ -1,3 +1,9 @@
+2004-08-27  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* abbrevs.texi (Abbrev Expansion): `abbrev-start-location' can be
+	an integer or a marker.
+	(Abbrev Expansion): Replace example for `pre-abbrev-expand-hook'.
+
 2004-08-22  Richard M. Stallman  <rms@gnu.org>
 
 	* modes.texi (Major Mode Conventions): Discuss rebinding of
--- a/lispref/abbrevs.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/lispref/abbrevs.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1999
+@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1999, 2004
 @c   Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @setfilename ../info/abbrevs
@@ -288,7 +288,7 @@
 @end defopt
 
 @defvar abbrev-start-location
-The value of this variable is a marker pointing to the buffer position
+The value of this variable is a buffer position (an integer or a marker)
 for @code{expand-abbrev} to use as the start of the next abbrev to be
 expanded.  The value can also be @code{nil}, which means to use the
 word before point instead.  @code{abbrev-start-location} is set to
@@ -331,31 +331,42 @@
 the abbrev to be expanded by looking in the buffer before point.
 Running the hook is the first thing that @code{expand-abbrev} does, and
 so a hook function can be used to change the current abbrev table before
-abbrev lookup happens.
+abbrev lookup happens.  (Although you have to do this carefully.  See
+the example below.)
 @end defvar
 
   The following sample code shows a simple use of
-@code{pre-abbrev-expand-hook}.  If the user terminates an abbrev with
-a punctuation character, the hook function asks for confirmation.  It
-aborts expansion if the user does not confirm.
+@code{pre-abbrev-expand-hook}.  It assumes that @code{foo-mode} is a
+mode for editing certain files in which lines that start with @samp{#}
+are comments.  You want to use Text mode abbrevs for those lines.  The
+regular local abbrev table, @code{foo-mode-abbrev-table} is
+appropriate for all other lines.  Then you can put the following code
+in your @file{.emacs} file.  @xref{Standard Abbrev Tables}, for the
+definitions of @code{local-abbrev-table} and @code{text-mode-abbrev-table}.
 
 @smallexample
-(add-hook 'pre-abbrev-expand-hook 'query-if-not-space)
-
-;; @r{This is the function invoked by @code{pre-abbrev-expand-hook}.}
+(defun foo-mode-pre-abbrev-expand ()
+  (when (save-excursion (forward-line 0) (eq (char-after) ?#))
+    (let ((local-abbrev-table text-mode-abbrev-table)
+	  ;; Avoid infinite loop.
+	  (pre-abbrev-expand-hook nil))
+      (expand-abbrev))
+    ;; We have already called `expand-abbrev' in this hook.
+    ;; Hence we want the "actual" call following this hook to be a no-op.
+    (setq abbrev-start-location (point-max)
+	  abbrev-start-location-buffer (current-buffer))))
 
-;; @r{If the user terminated the abbrev with a space, the function does}
-;; @r{nothing (that is, it returns so that the abbrev can expand).  If the}
-;; @r{user entered some other character, this function asks whether}
-;; @r{expansion should continue.}
+(add-hook 'foo-mode-hook
+	  #'(lambda ()
+	      (add-hook 'pre-abbrev-expand-hook
+			'foo-mode-pre-abbrev-expand
+			nil t)))
+@end smallexample
 
-;; @r{The function's return value makes no difference.}
-
-(defun query-if-not-space ()
-  (if (/= ?\s last-command-char)
-      (if (not (y-or-n-p "Do you want to expand this abbrev? "))
-          (error "Not expanding this abbrev"))))
-@end smallexample
+Note that @code{foo-mode-pre-abbrex-expand} just returns @code{nil}
+without doing anything for lines not starting with @samp{#}.  Hence
+abbrevs expand normally using @code{foo-mode-abbrev-table} as local
+abbrev table for such lines.
 
 @node Standard Abbrev Tables,  , Abbrev Expansion, Abbrevs
 @comment  node-name,  next,  previous,  up
--- a/lwlib/ChangeLog	Wed Sep 01 21:21:18 2004 +0000
+++ b/lwlib/ChangeLog	Sat Sep 04 09:14:28 2004 +0000
@@ -1,3 +1,7 @@
+2004-08-30  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* lwlib.h (_widget_value): Added lname and lkey.
+
 2004-01-12  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
 	* xlwmenuP.h (_XlwMenu_part): Added top_depth.
--- a/lwlib/lwlib.h	Wed Sep 01 21:21:18 2004 +0000
+++ b/lwlib/lwlib.h	Sat Sep 04 09:14:28 2004 +0000
@@ -64,10 +64,12 @@
 typedef struct _widget_value
 {
   /* name of widget */
+  Lisp_Object   lname;
   char*		name;
   /* value (meaning depend on widget type) */
   char*		value;
   /* keyboard equivalent. no implications for XtTranslations */
+  Lisp_Object   lkey;
   char*		key;
   /* Help string or nil if none.
      GC finds this string through the frame's menu_bar_vector
--- a/man/ChangeLog	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/ChangeLog	Sat Sep 04 09:14:28 2004 +0000
@@ -1,3 +1,93 @@
+2004-09-03  Juri Linkov  <juri@jurta.org>
+
+	* search.texi (Incremental Search): Update wording for M-%.
+
+2004-09-02  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* killing.texi (Killing): Correct description of kill commands in
+	read-only buffer.
+
+2004-09-02  Teodor Zlatanov  <tzz@lifelogs.com>
+
+	* building.texi (Compilation Mode): Add a paragraph about rules
+	for finding the compilation buffer for `next-error'.
+
+	* search.texi (Other Repeating Search): Mention that Occur mode
+	supports the next-error functionality.
+
+2004-09-02  Juri Linkov  <juri@jurta.org>
+
+	* search.texi (Regexp Replace): Add missing backslash to \footnote.
+
+2004-08-31  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* kmacro.texi (Basic Keyboard Macro):
+	`apply-macro-to-region-lines' now operates on all lines that begin
+	in the region, rather than on all complete lines in the region.
+
+2004-08-31  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* frames.texi (Drag and drop): Add documentation about
+	x-dnd-test-function and x-dnd-known-types.
+
+2004-08-30  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* indent.texi: Various minor changes in addition to:
+	(Indentation Commands): Correct description of `indent-relative'.
+	(Tab Stops): <TAB> is no longer bound to `tab-to-tab-stop' in Text
+	mode.  The *Tab Stops* buffer uses Overwrite Mode.
+	(Just Spaces): `untabify' converts sequences of at least two
+	spaces to tabs.
+
+2004-08-28  Eli Zaretskii  <eliz@gnu.org>
+
+	* faq.texi (Emacs for MS-DOS): Update URLs for the MS-DOS port of
+	Emacs and related programs.
+
+2004-08-27  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* frames.texi (Secondary Selection): Setting the secondary
+	selection with M-Drag-Mouse-1 does not alter the kill ring,
+	setting it with M-Mouse-1 and M-Mouse-3 does.
+	(Mode Line Mouse): C-Mouse-2 on scroll bar now also works for
+	toolkit scroll bars.
+	(Scroll Bars): Ditto.
+
+	* windows.texi (Basic Window): When using a window system, the value
+	of point in a non-selected window is indicated by a hollow box.
+	(Split Window): Side by side windows are separated by a scroll bar,
+	if scroll bars are used.
+	C-Mouse-2 on scroll bar now also works for toolkit scroll bars.
+	(Change Window): Correct Mouse-2 vs Mouse-3 mess-up.
+	(Window Convenience): Update bindings for `winner-undo' and
+	`winner-redo'.
+
+	* ack.texi (Acknowledgments): Use `@unnumbered'.
+	* misc.texi : Adapt sectioning in Info to the node structure.
+	(Invoking emacsclient): Make "Invoking emacsclient" a subsection
+	of "Using Emacs as a Server".
+	* building.texi (Building): Interchange nodes (for correct numbering).
+	* programs.texi (Programs): Interchange nodes (for correct numbering).
+	* killing.texi, entering.texi, commands.texi: Adapt sectioning in
+	Info to the node structure.
+	* emacs.texi: Make "GNU GENERAL PUBLIC LICENSE" an appendix.
+	Rearrange order of nodes and sections such that both "GNU GENERAL
+	PUBLIC LICENSE" and "GNU Free Documentation License" appear at the
+	end, as appropriate for appendices.
+	(Acknowledgments): Put inside @iftex instead of @ifnotinfo.
+	Use `@unnumberedsec'.
+	* trouble.texi: Adapt sectioning in Info to the node structure.
+	Adapt node pointers to change in emacs.texi.
+	* cmdargs.texi, doclicense.texi: Adapt node pointers.
+
+2004-08-27  Richard M. Stallman  <rms@gnu.org>
+
+	* faq.texi: Fix texinfo usage, esp. doublequotes.
+	(Difference between Emacs and XEmacs): Some clarification.
+
+	* faq.texi (Difference between Emacs and XEmacs):
+	Explain not to contrast XEmacs with GNU Emacs.
+
 2004-08-26  Richard M. Stallman  <rms@gnu.org>
 
 	* faq.texi (Difference between Emacs and XEmacs): Rewrite.
--- a/man/ack.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/ack.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -4,7 +4,7 @@
 @c See file emacs.texi for copying conditions.
 @c
 @node Acknowledgments, Screen, Concept Index, Top
-@chapter Acknowledgments
+@unnumbered Acknowledgments
 
 Many people have contributed code included in the Free Software
 Foundation's distribution of GNU Emacs.  To show our appreciation for
--- a/man/building.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/building.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -23,8 +23,8 @@
                           with different facilities for running
                           the Lisp programs.
 * Libraries: Lisp Libraries.      Creating Lisp programs to run in Emacs.
+* Eval: Lisp Eval.      Executing a single Lisp expression in Emacs.
 * Interaction: Lisp Interaction.  Executing Lisp in an Emacs buffer.
-* Eval: Lisp Eval.      Executing a single Lisp expression in Emacs.
 * External Lisp::         Communicating through Emacs with a separate Lisp.
 @end menu
 
@@ -204,6 +204,14 @@
 buffer and finds no more error messages to visit, it fails and signals
 an Emacs error.
 
+  You don't have to be in the compilation buffer in order to use
+@code{next-error}.  If one window on the selected frame can be the
+target of the @code{next-error} call, it is used.  Else, if a buffer
+previously had @code{next-error} called on it, it is used.  Else,
+if the current buffer can be the target of @code{next-error}, it is
+used.  Else, all the buffers Emacs manages are tried for
+@code{next-error} support.
+
   @kbd{C-u C-x `} starts scanning from the beginning of the compilation
 buffer.  This is one way to process the same set of errors again.
 
@@ -644,7 +652,7 @@
 @menu
 * Layout::               Control the number of displayed buffers.
 * Breakpoints Buffer::   A breakpoint control panel.
-* Stack Buffer::         Select a frame from the call stack. 
+* Stack Buffer::         Select a frame from the call stack.
 * Watch Expressions::    Monitor variable values in the speedbar.
 * Other Buffers::        Input/output, locals, registers and assembler buffers.
 @end menu
@@ -698,12 +706,12 @@
 @node Breakpoints Buffer
 @subsubsection Breakpoints Buffer
 
-The breakpoints buffer shows the existing breakpoints and watchpoints 
+The breakpoints buffer shows the existing breakpoints and watchpoints
 (@pxref{Breakpoints,,, gdb, The GNU debugger}).  It has three special
 commands:
 
 @table @kbd
-@item @key{SPC} 
+@item @key{SPC}
 @kindex SPC @r{(GDB breakpoints buffer)}
 @findex gdb-toggle-breakpoint
 Enable/disable the breakpoint at the current line
--- a/man/cmdargs.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/cmdargs.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -1,7 +1,7 @@
 @c This is part of the Emacs manual.
 @c Copyright (C) 1985,86,87,93,94,95,97,2001,03,2004 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
-@node Command Arguments, X Resources, Service, Top
+@node Command Arguments, X Resources, GNU Free Documentation License, Top
 @appendix Command Line Arguments
 @cindex command line arguments
 @cindex arguments (command line)
--- a/man/commands.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/commands.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -10,6 +10,10 @@
 how Emacs interprets your keyboard and mouse input.
 @end iftex
 
+@ifnottex
+@raisesections
+@end ifnottex
+
 @node User Input, Keys, Screen, Top
 @section Kinds of User Input
 @cindex input with the keyboard
@@ -266,6 +270,10 @@
 alphabet of non-@acronym{ASCII} characters, but they all fit in one byte.  They
 use codes 0200 through 0377.  @xref{Single-Byte Character Support}.
 
+@ifnottex
+@lowersections
+@end ifnottex
+
 @ignore
    arch-tag: 9be43eef-d1f4-4d03-a916-c741ea713a45
 @end ignore
--- a/man/doclicense.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/doclicense.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -1,6 +1,5 @@
 @c -*-texinfo-*-
-@node GNU Free Documentation License, Intro, Copying, Top
-
+@node GNU Free Documentation License, Command Arguments, Copying, Top
 @appendix GNU Free Documentation License
 @center Version 1.1, March 2000
 
--- a/man/emacs.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/emacs.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -901,7 +901,7 @@
 manual.  @xref{MS-DOS}, for information about using Emacs on MS-DOS.
 @end iftex
 
-@node Distrib, Copying, Top, Top
+@node Distrib, Intro, Top, Top
 @unnumbered Distribution
 
 GNU Emacs is @dfn{free software}; this means that everyone is free to
@@ -955,9 +955,9 @@
 might instead suggest ordering a CD-ROM from the Foundation
 occasionally, or subscribing to periodic updates.
 
-@ifnotinfo
-@node Acknowledgments, Copying, Distrib, Top
-@section Acknowledgments
+@iftex
+@node Acknowledgments, Intro, Distrib, Top
+@unnumberedsec Acknowledgments
 
 Contributors to GNU Emacs include Per Abrahamsen, Jay K. Adams, Joe
 Arceneaux, Boaz Ben-Zvi, Jim Blandy, Terrence Brannon, Frank Bresz,
@@ -1000,10 +1000,102 @@
 Wilkinson, Mike Williams, Steven A. Wood, Dale R. Worley, Felix
 S. T. Wu, Tom Wurgler, Eli Zaretskii, Jamie Zawinski, Ian T. Zimmermann,
 Reto Zimmermann, and Neal Ziring.
-@end ifnotinfo
+@end iftex
+
+@node Intro, Glossary, Distrib, Top
+@unnumbered Introduction
+
+  You are reading about GNU Emacs, the GNU incarnation of the advanced,
+self-documenting, customizable, extensible real-time display editor Emacs.
+(The `G' in `GNU' is not silent.)
+
+  We say that Emacs is a @dfn{display} editor because normally the text
+being edited is visible on the screen and is updated automatically as you
+type your commands.  @xref{Screen,Display}.
+
+  We call it a @dfn{real-time} editor because the display is updated very
+frequently, usually after each character or pair of characters you
+type.  This minimizes the amount of information you must keep in your
+head as you edit.  @xref{Basic,Real-time,Basic Editing}.
+
+  We call Emacs advanced because it provides facilities that go beyond
+simple insertion and deletion: controlling subprocesses; automatic
+indentation of programs; viewing two or more files at once; editing
+formatted text; and dealing in terms of characters, words, lines,
+sentences, paragraphs, and pages, as well as expressions and comments in
+several different programming languages.
+
+  @dfn{Self-documenting} means that at any time you can type a special
+character, @kbd{Control-h}, to find out what your options are.  You can
+also use it to find out what any command does, or to find all the commands
+that pertain to a topic.  @xref{Help}.
+
+  @dfn{Customizable} means that you can change the definitions of Emacs
+commands in little ways.  For example, if you use a programming language in
+which comments start with @samp{<**} and end with @samp{**>}, you can tell
+the Emacs comment manipulation commands to use those strings
+(@pxref{Comments}).  Another sort of customization is rearrangement of the
+command set.  For example, if you prefer the four basic cursor motion
+commands (up, down, left and right) on keys in a diamond pattern on the
+keyboard, you can rebind the keys that way.  @xref{Customization}.
 
-@node Copying, GNU Free Documentation License, Distrib, Top
-@unnumbered GNU GENERAL PUBLIC LICENSE
+  @dfn{Extensible} means that you can go beyond simple customization and
+write entirely new commands, programs in the Lisp language to be run by
+Emacs's own Lisp interpreter.  Emacs is an ``on-line extensible''
+system, which means that it is divided into many functions that call
+each other, any of which can be redefined in the middle of an editing
+session.  Almost any part of Emacs can be replaced without making a
+separate copy of all of Emacs.  Most of the editing commands of Emacs
+are written in Lisp; the few exceptions could have been written
+in Lisp but are written in C for efficiency.  Although only a programmer
+can write an extension, anybody can use it afterward.  If you want to
+learn Emacs Lisp programming, we recommend the @cite{Introduction to
+Emacs Lisp} by Robert J. Chassell, also published by the Free Software
+Foundation.
+
+   When run under the X Window System, Emacs provides its own menus and
+convenient bindings to mouse buttons.  But Emacs can provide many of the
+benefits of a window system on a text-only terminal.  For instance, you
+can look at or edit several files at once, move text between files, and
+edit files while running shell commands.
+
+@include screen.texi
+@include commands.texi
+@include entering.texi
+@include basic.texi
+@include mini.texi
+@include m-x.texi
+@include help.texi
+@include mark.texi
+@include killing.texi
+@include regs.texi
+@include display.texi
+@include search.texi
+@include fixit.texi
+@include kmacro.texi
+@include files.texi
+@include buffers.texi
+@include windows.texi
+@include frames.texi
+@include mule.texi
+@include major.texi
+@include indent.texi
+@include text.texi
+@include programs.texi
+@include building.texi
+@include maintaining.texi
+@include abbrevs.texi
+@include picture.texi
+@include sending.texi
+@include rmail.texi
+@include dired.texi
+@include calendar.texi
+@include misc.texi
+@include custom.texi
+@include trouble.texi
+
+@node Copying, GNU Free Documentation License, Service, Top
+@appendix GNU GENERAL PUBLIC LICENSE
 @center Version 2, June 1991
 
 @display
@@ -1399,98 +1491,6 @@
 Public License instead of this License.
 
 @include doclicense.texi
-
-@node Intro, Glossary, GNU Free Documentation License, Top
-@unnumbered Introduction
-
-  You are reading about GNU Emacs, the GNU incarnation of the advanced,
-self-documenting, customizable, extensible real-time display editor Emacs.
-(The `G' in `GNU' is not silent.)
-
-  We say that Emacs is a @dfn{display} editor because normally the text
-being edited is visible on the screen and is updated automatically as you
-type your commands.  @xref{Screen,Display}.
-
-  We call it a @dfn{real-time} editor because the display is updated very
-frequently, usually after each character or pair of characters you
-type.  This minimizes the amount of information you must keep in your
-head as you edit.  @xref{Basic,Real-time,Basic Editing}.
-
-  We call Emacs advanced because it provides facilities that go beyond
-simple insertion and deletion: controlling subprocesses; automatic
-indentation of programs; viewing two or more files at once; editing
-formatted text; and dealing in terms of characters, words, lines,
-sentences, paragraphs, and pages, as well as expressions and comments in
-several different programming languages.
-
-  @dfn{Self-documenting} means that at any time you can type a special
-character, @kbd{Control-h}, to find out what your options are.  You can
-also use it to find out what any command does, or to find all the commands
-that pertain to a topic.  @xref{Help}.
-
-  @dfn{Customizable} means that you can change the definitions of Emacs
-commands in little ways.  For example, if you use a programming language in
-which comments start with @samp{<**} and end with @samp{**>}, you can tell
-the Emacs comment manipulation commands to use those strings
-(@pxref{Comments}).  Another sort of customization is rearrangement of the
-command set.  For example, if you prefer the four basic cursor motion
-commands (up, down, left and right) on keys in a diamond pattern on the
-keyboard, you can rebind the keys that way.  @xref{Customization}.
-
-  @dfn{Extensible} means that you can go beyond simple customization and
-write entirely new commands, programs in the Lisp language to be run by
-Emacs's own Lisp interpreter.  Emacs is an ``on-line extensible''
-system, which means that it is divided into many functions that call
-each other, any of which can be redefined in the middle of an editing
-session.  Almost any part of Emacs can be replaced without making a
-separate copy of all of Emacs.  Most of the editing commands of Emacs
-are written in Lisp; the few exceptions could have been written
-in Lisp but are written in C for efficiency.  Although only a programmer
-can write an extension, anybody can use it afterward.  If you want to
-learn Emacs Lisp programming, we recommend the @cite{Introduction to
-Emacs Lisp} by Robert J. Chassell, also published by the Free Software
-Foundation.
-
-   When run under the X Window System, Emacs provides its own menus and
-convenient bindings to mouse buttons.  But Emacs can provide many of the
-benefits of a window system on a text-only terminal.  For instance, you
-can look at or edit several files at once, move text between files, and
-edit files while running shell commands.
-
-@include screen.texi
-@include commands.texi
-@include entering.texi
-@include basic.texi
-@include mini.texi
-@include m-x.texi
-@include help.texi
-@include mark.texi
-@include killing.texi
-@include regs.texi
-@include display.texi
-@include search.texi
-@include fixit.texi
-@include kmacro.texi
-@include files.texi
-@include buffers.texi
-@include windows.texi
-@include frames.texi
-@include mule.texi
-@include major.texi
-@include indent.texi
-@include text.texi
-@include programs.texi
-@include building.texi
-@include maintaining.texi
-@include abbrevs.texi
-@include picture.texi
-@include sending.texi
-@include rmail.texi
-@include dired.texi
-@include calendar.texi
-@include misc.texi
-@include custom.texi
-@include trouble.texi
 @include cmdargs.texi
 @include xresources.texi
 
--- a/man/entering.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/entering.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -59,6 +59,10 @@
 file in the already running Emacs.  @xref{Emacs Server}, for more
 information on editing files with Emacs from other programs.
 
+@ifnottex
+@raisesections
+@end ifnottex
+
 @node Exiting, Basic, Entering Emacs, Top
 @section Exiting Emacs
 @cindex exiting
@@ -150,6 +154,10 @@
 their only relationship with the operating system.  You can customize
 these keys to run any commands of your choice (@pxref{Keymaps}).
 
+@ifnottex
+@lowersections
+@end ifnottex
+
 @ignore
    arch-tag: df798d8b-f253-4113-b585-f528f078a944
 @end ignore
--- a/man/faq.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/faq.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -17,7 +17,7 @@
 
 @quotation
 This list of frequently asked questions about GNU Emacs with answers
-("FAQ") may be translated into other languages, transformed into other
+(``FAQ'') may be translated into other languages, transformed into other
 formats (e.g. Texinfo, Info, WWW, WAIS), and updated with new information.
 
 The same conditions apply to any derivative of the FAQ as apply to the FAQ
@@ -906,8 +906,8 @@
 Emacs General Public License
 
 @item DISTRIB
-Emacs Availability Information, including the popular "Free Software
-Foundation Order Form"
+Emacs Availability Information, including the popular Free Software
+Foundation Order Form
 
 @item FTP
 How to get GNU Software by Internet FTP or by UUCP
@@ -935,7 +935,7 @@
 GNU Service Directory
 
 @item SUN-SUPPORT
-including "Using Emacstool with GNU Emacs"
+including ``Using Emacstool with GNU Emacs''
 
 @end table
 
@@ -1045,7 +1045,7 @@
 @end example
 
 For more information, send email to @email{mail-server@@rtfm.mit.edu}
-with "help" and "index" in the body on separate lines.
+with @samp{help} and @samp{index} in the body on separate lines.
 
 @item
 As the very last resort, you can e-mail a request to
@@ -1864,7 +1864,7 @@
 @end itemize
 
 @node Overwrite mode, Turning off beeping, Horizontal scrolling, Common requests
-@section How do I make Emacs "typeover" or "overwrite" instead of inserting?
+@section How do I make Emacs ``typeover'' or ``overwrite'' instead of inserting?
 @cindex @key{Insert}
 @cindex @code{overwrite-mode}
 @cindex Overwriting existing text
@@ -2075,7 +2075,7 @@
 was compiled with the X toolkit.
 
 @node Evaluating Emacs Lisp code, Changing the length of a Tab, Valid X resources, Common requests
-@section How do I execute ("evaluate") a piece of Emacs Lisp code?
+@section How do I execute (``evaluate'') a piece of Emacs Lisp code?
 @cindex Evaluating Lisp code
 @cindex Lisp forms, evaluating
 
@@ -2162,7 +2162,7 @@
 additional information.
 
 @node Underlining paragraphs, Repeating a command as many times as possible, Inserting > at the beginning of each line, Common requests
-@section How do I insert "_^H" before each character in a region to get an underlined paragraph?
+@section How do I insert @samp{_^H} before each character in a region to get an underlined paragraph?
 @cindex Underlining a region of text
 @cindex @code{underline-region}
 
@@ -2264,7 +2264,7 @@
 You probably don't want to do this, since backups are useful, especially
 when something goes wrong.
 
-To avoid seeing backup files (and other "uninteresting" files) in Dired,
+To avoid seeing backup files (and other ``uninteresting'' files) in Dired,
 load @code{dired-x} by adding the following to your @file{.emacs} file:
 
 @lisp
@@ -2733,7 +2733,7 @@
 @end example
 
 @noindent
-This method may result in "ILLEGAL DATATYPE" and other random errors on
+This method may result in ``ILLEGAL DATATYPE'' and other random errors on
 some machines.
 
 @email{daveg@@csvax.cs.caltech.edu, David Gillespie} explains how this
@@ -2824,7 +2824,7 @@
 @end example
 
 @node Shell process exits abnormally, Problems with Shell Mode on MS-Windows, ^M in the shell buffer, Bugs and problems
-@section Why do I get "Process shell exited abnormally with code 1"?
+@section Why do I get ``Process shell exited abnormally with code 1''?
 @cindex Abnormal exits from @code{shell-mode}
 @cindex @code{shell-mode} exits
 @cindex Process shell exited
@@ -2881,7 +2881,7 @@
 the problems in those cases.
 
 @node Termcap/Terminfo entries for Emacs, Spontaneous entry into isearch-mode, Problems with Shell Mode on MS-Windows, Bugs and problems
-@section Where is the termcap/terminfo entry for terminal type "emacs"?
+@section Where is the termcap/terminfo entry for terminal type @samp{emacs}?
 @cindex Termcap
 @cindex Terminfo
 @cindex Emacs entries for termcap/terminfo
@@ -2915,7 +2915,7 @@
 @end example
 
 @node Spontaneous entry into isearch-mode, Problems talking to certain hosts, Termcap/Terminfo entries for Emacs, Bugs and problems
-@section Why does Emacs spontaneously start displaying "I-search:" and beeping?
+@section Why does Emacs spontaneously start displaying @samp{I-search:} and beeping?
 @cindex Spontaneous entry into isearch-mode
 @cindex isearch-mode, spontaneous entry into
 @cindex Beeping without obvious reason
@@ -2972,7 +2972,7 @@
 @end itemize
 
 @node Errors with init files, Emacs ignores X resources, Problems talking to certain hosts, Bugs and problems
-@section Why does Emacs say "Error in init file"?
+@section Why does Emacs say @samp{Error in init file}?
 @cindex Error in @file{.emacs}
 @cindex Error in init file
 @cindex Init file, errors in
@@ -3238,7 +3238,7 @@
 @end itemize
 
 @node Dired claims that no file is on this line,  , Security risks with Emacs, Bugs and problems
-@section Dired says, "no file on this line" when I try to do something.
+@section Dired says, @samp{no file on this line} when I try to do something.
 @cindex Dired does not see a file
 
 @c FIXME: I think this is fixed in Emacs 21, but I didn't have time to
@@ -3441,7 +3441,7 @@
 @file{libX11.a}.  This may be missing.
 
 On OpenWindows, you may need to use @code{add_services} to add the
-"OpenWindows Programmers" optional software category from the CD-ROM.
+``OpenWindows Programmers'' optional software category from the CD-ROM.
 
 On HP-UX 8.0, you may need to run @code{update} again to load the
 X11-PRG ``fileset''.  This may be missing even if you specified ``all
@@ -3580,31 +3580,37 @@
 @uref{http://www.gnu.org/order/ftp.html}
 
 @node Difference between Emacs and XEmacs, Emacs for MS-DOS, Current GNU distributions, Finding Emacs and related packages
-@section What is the difference between Emacs and XEmacs (formerly "Lucid Emacs")?
+@section What is the difference between Emacs and XEmacs (formerly Lucid Emacs)?
 @cindex XEmacs
 @cindex Difference Emacs and XEmacs
 @cindex Lucid Emacs
 @cindex Epoch
 
-XEmacs is a branch version of Emacs.  It was earlier called as Lucid
-Emacs, and it was based on a prerelease version of Emacs 19.  In this
-FAQ, we use the name ``Emacs'' only for the official version.
+XEmacs is a branch version of Emacs.  It was first called Lucid Emacs,
+and was initially derived from a prerelease version of Emacs 19.  In
+this FAQ, we use the name ``Emacs'' only for the official version.
 
 Emacs and XEmacs each come with Lisp packages that are lacking in the
 other.  The two versions have some significant differences at the Lisp
-programming level.
-
-Many XEmacs features have found their way into recent versions of Emacs,
-and more features can be expected in the future, but there are still many
-differences between the two.
-
-The FSF has used some of the code in XEmacs, and would like to use
-other parts, but the earlier XEmacs maintainers did not always keep
-track of the authors of contributed code, which makes it impossible
-for the FSF to get copyright papers signed for that code.  (The FSF
-requires these papers for all the code included in Emacs, aside from
-generic C support packages that are not integrated into the code of
-Emacs proper.)
+programming level.  Their current features are roughly comparable,
+though the support for some operating systems, character sets and
+specific packages might be quite different.
+
+Some XEmacs code has been contributed to Emacs, and we would like to
+use other parts, but the earlier XEmacs maintainers did not always
+keep track of the authors of contributed code, which makes it
+impossible for the FSF to get copyright papers signed for that code.
+(The FSF requires these papers for all the code included in the Emacs
+release, aside from generic C support packages that retain their
+separate identity and are not integrated into the code of Emacs
+proper.)
+
+If you want to talk about these two versions and distinguish them,
+please call them ``Emacs'' and ``XEmacs.''  To contrast ``XEmacs''
+with ``GNU Emacs'' would be misleading, since XEmacs too has its
+origin in the work of the GNU Project.  Terms such as ``Emacsen'' and
+``(X)Emacs'' are not wrong, but they are not very clear, so it
+is better to write ``Emacs and XEmacs.''
 
 @node Emacs for MS-DOS, Emacs for Windows, Difference between Emacs and XEmacs, Finding Emacs and related packages
 @section Where can I get Emacs for my PC running MS-DOS?
@@ -3620,17 +3626,17 @@
 Windows 9X, Windows ME, and Windows 2000.  More information is available
 from
 
-@uref{http://www.simtel.net/pub/djgpp/v2gnu/emacs.README}
+@uref{ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/emacs.README}
 
 The binary itself is available in the files @file{em*.zip} in the
 directory
 
-@uref{http://www.simtel.net/pub/djgpp/v2gnu/}
+@uref{ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/}
 
 If you prefer to compile Emacs for yourself, you can do so with the
 current distribution directly.  You will need a 386 (or
 better) processor, and to be running MS-DOS 3.0 or later.  According to
-@email{eliz@@is.elta.co.il, Eli Zaretskii} and
+@email{eliz@@gnu.org, Eli Zaretskii} and
 @email{hankedr@@dms.auburn.edu, Darrel Hankerson}, you will need the
 following:
 
@@ -3644,7 +3650,7 @@
 You can get the latest release of DJGPP by retrieving all of
 the files in
 
-@uref{http://www.simtel.net/pub/gnu/djgpp/v2*}
+@uref{ftp://ftp.delorie.com/pub/djgpp/current/v2*}
 
 @item Unpacking program
 The easiest way is to use @code{djtar} which comes with DJGPP v2.x,
@@ -3663,7 +3669,7 @@
 @item make, mv, sed, and rm
 All of these utilities are available at
 
-@uref{http://www.simtel.net/pub/gnu/djgpp/v2gnu}
+@uref{ftp://ftp.delorie.com/pub/djgpp/current/v2gnu}
 
 16-bit utilities can be found in GNUish, at
 
@@ -3680,7 +3686,7 @@
 regarding Emacs under MS-DOS.
 
 For a list of other MS-DOS implementations of Emacs (and Emacs
-look-alikes), consult the list of "Emacs implementations and literature,"
+look-alikes), consult the list of ``Emacs implementations and literature,''
 available at
 
 @uref{ftp://rtfm.mit.edu/pub/usenet/comp.emacs/}
@@ -3765,18 +3771,11 @@
 @cindex Apple computers, Emacs for
 @cindex Macintosh, Emacs for
 
-An unofficial port of GNU Emacs 18.59 to the Macintosh is available at a
-number of ftp sites, the home being
-@uref{ftp://ftp.cs.cornell.edu/pub/parmet/Emacs-1.17.sit.bin}.
-
-A port of Emacs 20.4 is available at
-@uref{http://www.cs.hku.hk/~choi/emacs/index.html}.
-
 Beginning with version 21.1, the Macintosh is supported in the official
 Emacs distribution; see the files @file{mac/README} and
 @file{mac/INSTALL} in the Emacs distribution for build instructions.
 
-Apple's forthcoming "OS X" is based largely on NeXTSTEP and OpenStep.
+Apple's ``OS X'' is based largely on NeXTSTEP and OpenStep.
 @xref{Emacs for NeXTSTEP}, for more details about that version.
 
 @node Emacs for VMS and DECwindows, Modes for various languages, Emacs for Apple computers, Finding Emacs and related packages
@@ -4171,7 +4170,7 @@
 @end table
 
 @node Patch,  , JDE, Major packages and programs
-@section Patch --- program to apply "diffs" for updating files
+@section Patch --- program to apply ``diffs'' for updating files
 @cindex Updating files with diffs
 @cindex Patching source files with diffs
 @cindex Diffs and patching
@@ -4244,8 +4243,8 @@
 
 @noindent
 can be placed directly into the @file{.emacs} file.  If the key binding is
-local, the command is used in conjunction with the "add-hook" command.
-For example, in tex-mode, a local binding might be
+local, the command is used in conjunction with the @samp{add-hook} function.
+For example, in TeX mode, a local binding might be
 
 @lisp
 (add-hook 'tex-mode-hook
@@ -4284,7 +4283,7 @@
 @end itemize
 
 @node Invalid prefix characters, Terminal setup code works after Emacs has begun, Binding keys to commands, Key bindings
-@section Why does Emacs say "Key sequence XXX uses invalid prefix characters"?
+@section Why does Emacs say @samp{Key sequence XXX uses invalid prefix characters}?
 @cindex Prefix characters, invalid
 @cindex Invalid prefix characters
 @cindex Misspecified key sequences
@@ -4679,7 +4678,7 @@
 @cindex Generating control characters
 @cindex Control characters, generating
 
-On terminals (but not under X), some common "aliases" are:
+On terminals (but not under X), some common ``aliases'' are:
 
 @table @asis
 
--- a/man/frames.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/frames.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 1985, 86, 87, 93, 94, 95, 97, 99, 2000, 2001
+@c Copyright (C) 1985, 86, 87, 93, 94, 95, 97, 99, 2000, 2001, 2004
 @c   Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Frames, International, Windows, Top
@@ -230,6 +230,8 @@
 back into the window.  This way, you can mark regions that don't fit
 entirely on the screen.
 
+This way of setting the secondary selection does not alter the kill ring.
+
 @findex mouse-start-secondary
 @kindex M-Mouse-1
 @item M-Mouse-1
@@ -240,8 +242,9 @@
 @kindex M-Mouse-3
 @item M-Mouse-3
 Make a secondary selection, using the place specified with @kbd{M-Mouse-1}
-as the other end (@code{mouse-secondary-save-then-kill}).  A second click
-at the same place kills the secondary selection just made.
+as the other end (@code{mouse-secondary-save-then-kill}).  This also
+puts the selected text in the kill ring.  A second click at the same
+place kills the secondary selection just made.
 
 @findex mouse-yank-secondary
 @kindex M-Mouse-2
@@ -376,8 +379,7 @@
 
 @kindex C-Mouse-2 @r{(scroll bar)}
   @kbd{C-Mouse-2} on a scroll bar splits the corresponding window
-vertically, unless you are using an X toolkit's implementation of
-scroll bars.  @xref{Split Window}.
+vertically.  @xref{Split Window}.
 
   The commands above apply to areas of the mode line which do not have
 special mouse bindings of their own.  Some areas, such as the buffer
@@ -747,10 +749,8 @@
 down to the level where you click.  By clicking repeatedly in the same
 place, you can scroll by the same distance over and over.
 
-  If you are using Emacs's own implementation of scroll bars, as opposed
-to scroll bars from an X toolkit, you can also click @kbd{C-Mouse-2} in
-the scroll bar to split a window vertically.  The split occurs on the
-line where you click.
+  You can also click @kbd{C-Mouse-2} in the scroll bar to split a
+window vertically.  The split occurs on the line where you click.
 
 @findex scroll-bar-mode
 @vindex scroll-bar-mode
@@ -800,15 +800,26 @@
 @section Drag and drop in Emacs.
 
 @cindex drag and drop
-  Emacs supports drag and drop so that dropping of files and text is handeled.
+  Emacs supports drag and drop so that dropping of files and text is handled.
 Currently supported drag and drop protocols are XDND, Motif and the old
-KDE 1.x protocol.  There is no drag support yet. 
+KDE 1.x protocol.  There is no drag support yet.
 When text is dropped on Emacs, Emacs inserts the text where it is dropped.
 When a file is dragged from a file manager to Emacs, Emacs opens that file.
 As a special case, if a file is dropped on a dired buffer the file is
 copied or moved (depends on exactly how it is dragged and the application
 it was dragged from) to the directory the dired buffer is displaying.
 
+@vindex x-dnd-test-function
+@vindex x-dnd-known-types
+  When a user drags something from another application over Emacs, that other
+application expects Emacs to tell it if Emacs can handle the data that is
+dragged.  The variable @code{x-dnd-test-function} is used by Emacs to determine
+what to reply.  The default value is @code{x-dnd-default-test-function}
+which accepts drops if the type of the data to be dropped is present in
+@code{x-dnd-known-types}.  You can customize @code{x-dnd-test-function} and/or
+@code{x-dnd-known-types} if you want Emacs to accept or reject drops based
+on some other criteria.
+
 @vindex x-dnd-open-file-other-window
   A file is normally opened in the window it is dropped on, but if you
 prefer the file to be opened in a new window you can customize the variable
@@ -896,7 +907,7 @@
 
   You can customize the option @code{use-file-dialog} to suppress the
 use of file selection windows even if you still want other kinds
-of dialogs.  This option has no effect if you have supressed all dialog
+of dialogs.  This option has no effect if you have suppressed all dialog
 boxes with the option @code{use-dialog-box}.
 
 
--- a/man/indent.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/indent.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997 Free Software Foundation, Inc.
+@c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997, 2004 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Indentation, Text, Major Modes, Top
 @chapter Indentation
@@ -75,7 +75,7 @@
   Normally, all of the above methods insert an optimal mix of tabs and
 spaces to align to the desired column.  @xref{Just Spaces}, for how to
 disable use of tabs.  However, @kbd{C-q @key{TAB}} always inserts a
-tab, even they are disabled for the indentation commands.
+tab, even when tabs are disabled for the indentation commands.
 
 @c   In Text mode, @key{TAB} runs the command @code{tab-to-tab-stop}, which
 @c indents to the next tab stop column.  You can set the tab stops with
@@ -95,7 +95,8 @@
 @findex back-to-indentation
   To move over the indentation on a line, do @kbd{M-m}
 (@code{back-to-indentation}).  This command, given anywhere on a line,
-positions point at the first nonblank character on the line.
+positions point at the first nonblank character on the line, if any,
+or else at the end of the line.
 
   To insert an indented line before the current line, do @kbd{C-a C-o
 @key{TAB}}.  To make an indented line after the current line, use
@@ -134,13 +135,13 @@
 @findex indent-region
 @findex indent-rigidly
   There are also commands for changing the indentation of several lines
-at once.  @kbd{C-M-\} (@code{indent-region}) applies to all the lines
-that begin in the region; it indents each line in the ``usual'' way, as
-if you had typed @key{TAB} at the beginning of the line.  A numeric
-argument specifies the column to indent to, and each line is shifted
-left or right so that its first nonblank character appears in that
-column.  @kbd{C-x @key{TAB}} (@code{indent-rigidly}) moves all of the
-lines in the region right by its argument (left, for negative
+at once.  They apply to all the lines that begin in the region.
+@kbd{C-M-\} (@code{indent-region}) indents each line in the ``usual''
+way, as if you had typed @key{TAB} at the beginning of the line.  A
+numeric argument specifies the column to indent to, and each line is
+shifted left or right so that its first nonblank character appears in
+that column.  @kbd{C-x @key{TAB}} (@code{indent-rigidly}) moves all of
+the lines in the region right by its argument (left, for negative
 arguments).  The whole group of lines moves rigidly sideways, which is
 how the command gets its name.@refill
 
@@ -152,12 +153,10 @@
 @findex indent-relative
   @kbd{M-x indent-relative} indents at point based on the previous line
 (actually, the last nonempty line).  It inserts whitespace at point, moving
-point, until it is underneath an indentation point in the previous line.
+point, until it is underneath the next indentation point in the previous line.
 An indentation point is the end of a sequence of whitespace or the end of
 the line.  If point is farther right than any indentation point in the
-previous line, the whitespace before point is deleted and the first
-indentation point then applicable is used.  If no indentation point is
-applicable even then, @code{indent-relative} runs @code{tab-to-tab-stop}
+previous line, @code{indent-relative} runs @code{tab-to-tab-stop}
 @ifinfo
 (@pxref{Tab Stops}),
 @end ifinfo
@@ -167,9 +166,6 @@
 unless it is called with a numeric argument, in which case it does
 nothing.
 
-  @code{indent-relative} is the definition of @key{TAB} in Indented Text
-mode.  @xref{Text}.
-
   @xref{Format Indentation}, for another way of specifying the
 indentation for part of your text.
 
@@ -181,10 +177,9 @@
 @cindex tables, indentation for
 @kindex M-i
 @findex tab-to-tab-stop
-  For typing in tables, you can use Text mode's definition of @key{TAB},
-@code{tab-to-tab-stop}.  This command inserts indentation before point,
-enough to reach the next tab stop column.  If you are not in Text mode,
-this command can be found on the key @kbd{M-i}.
+  For typing in tables, you can use @kbd{M-i} (@code{tab-to-tab-stop}).
+This command inserts indentation before point, enough to reach the
+next tab stop column.
 
 @findex edit-tab-stops
 @findex edit-tab-stops-note-changes
@@ -198,10 +193,11 @@
 edit-tab-stops}, which creates and selects a buffer containing a
 description of the tab stop settings.  You can edit this buffer to
 specify different tab stops, and then type @kbd{C-c C-c} to make those
-new tab stops take effect.  @code{edit-tab-stops} records which buffer
-was current when you invoked it, and stores the tab stops back in that
-buffer; normally all buffers share the same tab stops and changing them
-in one buffer affects all, but if you happen to make
+new tab stops take effect.  The buffer uses Overwrite mode
+(@pxref{Minor Modes}).  @code{edit-tab-stops} records which buffer was
+current when you invoked it, and stores the tab stops back in that
+buffer; normally all buffers share the same tab stops and changing
+them in one buffer affects all, but if you happen to make
 @code{tab-stop-list} local in one buffer then @code{edit-tab-stops} in
 that buffer will edit the local settings.
 
@@ -242,7 +238,7 @@
 @findex untabify
   There are also commands to convert tabs to spaces or vice versa, always
 preserving the columns of all nonblank text.  @kbd{M-x tabify} scans the
-region for sequences of spaces, and converts sequences of at least three
+region for sequences of spaces, and converts sequences of at least two
 spaces to tabs if that can be done without changing indentation.  @kbd{M-x
 untabify} changes all tabs in the region to appropriate numbers of spaces.
 
--- a/man/killing.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/killing.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -1,5 +1,6 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 1985,86,87,93,94,95,97,00,2001 Free Software Foundation, Inc.
+@c Copyright (C) 1985,86,87,93,94,95,97,2000,2001,2004
+@c   Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @iftex
 @chapter Killing and Moving Text
@@ -25,6 +26,10 @@
 
 @end iftex
 
+@ifnottex
+@raisesections
+@end ifnottex
+
 @node Killing, Yanking, Mark, Top
 @section Deletion and Killing
 
@@ -45,11 +50,12 @@
   You cannot kill read-only text, since such text does not allow any
 kind of modification.  But some users like to use the kill commands to
 copy read-only text into the kill ring, without actually changing it.
-If you set the variable @code{kill-read-only-ok} to a non-@code{nil}
-value, the kill commands work specially in a read-only buffer: they
-move over text, and copy it to the kill ring, without actually
-deleting it from the buffer.  When this happens, a message in the echo
-area tells you what is happening.
+Therefore, the kill commands work specially in a read-only buffer:
+they move over text, and copy it to the kill ring, without actually
+deleting it from the buffer.  Normally, Emacs beeps and prints an
+error message when this happens.  But if you set the variable
+@code{kill-read-only-ok} to a non-@code{nil} value, it just prints a
+message in the echo area, telling you what is happening.
 
   The delete commands include @kbd{C-d} (@code{delete-char}) and
 @key{DEL} (@code{delete-backward-char}), which delete only one
@@ -646,6 +652,10 @@
 @code{string-rectangle}, but inserts the string on each line,
 shifting the original text to the right.
 
+@ifnottex
+@lowersections
+@end ifnottex
+
 @ignore
    arch-tag: d8da8f96-0928-449a-816e-ff2d3497866c
 @end ignore
--- a/man/kmacro.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/kmacro.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -71,7 +71,7 @@
 @item C-x C-k e
 Edit a previously defined keyboard macro (@code{edit-kbd-macro}).
 @item C-x C-k r
-Run the last keyboard macro on each complete line in the region
+Run the last keyboard macro on each line that begins in the region
 (@code{apply-macro-to-region-lines}).
 @end table
 
@@ -174,8 +174,8 @@
 @findex apply-macro-to-region-lines
 @kindex C-x C-k r
   The command @kbd{C-x C-k r} (@code{apply-macro-to-region-lines})
-repeats the last defined keyboard macro on each complete line within
-the current region.  It does this line by line, by moving point to the
+repeats the last defined keyboard macro on each line that begins in
+the region.  It does this line by line, by moving point to the
 beginning of the line and then executing the macro.
 
 @node Keyboard Macro Ring
--- a/man/misc.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/misc.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 1985, 86, 87, 93, 94, 95, 97, 2000, 2001
+@c Copyright (C) 1985, 86, 87, 93, 94, 95, 97, 2000, 2001, 2004
 @c   Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @iftex
@@ -14,6 +14,11 @@
 various diversions and amusements.
 
 @end iftex
+
+@ifnottex
+@raisesections
+@end ifnottex
+
 @node Gnus, Shell, Calendar/Diary, Top
 @section Gnus
 @cindex Gnus
@@ -1264,7 +1269,7 @@
 @end menu
 
 @node Invoking emacsclient,, Emacs Server, Emacs Server
-@section Invoking @code{emacsclient}
+@subsection Invoking @code{emacsclient}
 
   To run the @code{emacsclient} program, specify file names as arguments,
 and optionally line numbers as well.  Do it like this:
@@ -2448,6 +2453,10 @@
 The command @kbd{M-x zone} plays games with the display when Emacs is
 idle.
 
+@ifnottex
+@lowersections
+@end ifnottex
+
 @ignore
    arch-tag: 8f094220-c0d5-4e9e-af7d-3e0da8187474
 @end ignore
--- a/man/programs.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/programs.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -31,8 +31,8 @@
 * Defuns::              Commands to operate on major top-level parts
                           of a program.
 * Program Indent::      Adjusting indentation to show the nesting.
+* Parentheses::         Commands that operate on parentheses.
 * Comments::	        Inserting, killing, and aligning comments.
-* Parentheses::         Commands that operate on parentheses.
 * Documentation::       Getting documentation of functions you plan to call.
 * Hideshow::            Displaying blocks selectively.
 * Symbol Completion::   Completion on symbol names of your program or language.
--- a/man/search.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/search.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -215,10 +215,9 @@
 there.  In Transient Mark mode, incremental search sets the mark without
 activating it, and does so only if the mark is not already active.
 
-  @kbd{M-%} or @kbd{C-M-%} exits the incremental search and starts an
-interactive command @code{query-replace} or @code{query-replace-regexp}
-with the last search string inserted in the minibuffer as initial input
-for the string to replace.
+  @kbd{M-%} typed in incremental search invokes @code{query-replace}
+or @code{query-replace-regexp} (depending on search mode) with the
+current search string used as the string to replace.
 
 @cindex lazy search highlighting
 @vindex isearch-lazy-highlight
@@ -1080,7 +1079,7 @@
 point where the @samp{\?} was.  For example,
 
 @example
-M-x replace-regexp @key{RET} \footnote@{ @key{RET}
+M-x replace-regexp @key{RET} \\footnote@{ @key{RET}
 \&\\label@{fn:\#\?@} @key{RET}
 @end example
 
@@ -1286,6 +1285,9 @@
 @kbd{o} and @kbd{C-o} display the match in another window; @kbd{C-o}
 does not select it.
 
+Occur mode supports the @code{next-error} functionality described in
+in @ref{Compilation Mode}.
+
 @item M-x list-matching-lines
 Synonym for @kbd{M-x occur}.
 
--- a/man/trouble.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/trouble.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 1985,86,87,93,94,95,1997,2001 Free Software Foundation, Inc.
+@c Copyright (C) 1985,86,87,93,94,95,1997,2001,2004 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @iftex
 @chapter Dealing with Common Problems
@@ -10,6 +10,10 @@
 also considered.
 @end iftex
 
+@ifnottex
+@raisesections
+@end ifnottex
+
 @node Quitting, Lossage, Customization, Top
 @section Quitting and Aborting
 @cindex quitting
@@ -1044,7 +1048,7 @@
 possible to suggest ways to make your extension fit in better with the
 rest of Emacs.
 
-@node Service, Command Arguments, Contributing, Top
+@node Service, Copying, Contributing, Top
 @section How To Get Help with GNU Emacs
 
 If you need help installing, using or changing GNU Emacs, there are two
@@ -1063,6 +1067,10 @@
 Emacs distribution.
 @end itemize
 
+@ifnottex
+@lowersections
+@end ifnottex
+
 @ignore
    arch-tag: c9cba76d-b2cb-4e0c-ae3f-19d5ef35817c
 @end ignore
--- a/man/windows.texi	Wed Sep 01 21:21:18 2004 +0000
+++ b/man/windows.texi	Sat Sep 04 09:14:28 2004 +0000
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 1985,86,87,93,94,95,97,2000,2001 Free Software Foundation, Inc.
+@c Copyright (C) 1985,86,87,93,94,95,97,2000,2001,2004 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Windows, Frames, Buffers, Top
 @chapter Multiple Windows
@@ -36,11 +36,11 @@
   At any time, one of the windows is the @dfn{selected window}; the
 buffer this window is displaying is the current buffer.  The terminal's
 cursor shows the location of point in this window.  Each other window
-has a location of point as well, but since the terminal has only one
-cursor there is no way to show where those locations are.  When multiple
-frames are visible in X, each frame has a cursor which appears in the
-frame's selected window.  The cursor in the selected frame is solid; the
-cursor in other frames is a hollow box.
+has a location of point as well.  On text-only terminals, there is no
+way to show where those locations are, since the terminal has only one
+cursor.  If you are using a window system, the location of point in a
+non-selected window is indicated by a hollow box.  The cursor in the
+selected window is blinking or solid.
 
   Commands to move point affect the value of point for the selected Emacs
 window only.  They do not change the value of point in any other Emacs
@@ -93,20 +93,20 @@
 @findex split-window-horizontally
   @kbd{C-x 3} (@code{split-window-horizontally}) breaks the selected
 window into two side-by-side windows.  A numeric argument specifies how
-many columns to give the one on the left.  A line of vertical bars
-separates the two windows.  Windows that are not the full width of the
-screen have mode lines, but they are truncated.  On terminals where
-Emacs does not support highlighting, truncated mode lines sometimes do
-not appear in inverse video.
+many columns to give the one on the left.  If you are not using
+scrollbars, a line of vertical bars separates the two windows.
+Windows that are not the full width of the screen have mode lines, but
+they are truncated.  On terminals where Emacs does not support
+highlighting, truncated mode lines sometimes do not appear in inverse
+video.
 
 @kindex C-Mouse-2 @r{(scroll bar)}
   You can split a window horizontally or vertically by clicking
-@kbd{C-Mouse-2} in the mode line or the scroll bar.  (This does not
-work in scroll bars implemented by X toolkits.)  The line of splitting
-goes through the place where you click: if you click on the mode line,
-the new scroll bar goes above the spot; if you click in the scroll
-bar, the mode line of the split window is side by side with your
-click.
+@kbd{C-Mouse-2} in the mode line or the scroll bar.  The line of
+splitting goes through the place where you click: if you click on the
+mode line, the new scroll bar goes above the spot; if you click in the
+scroll bar, the mode line of the split window is side by side with
+your click.
 
 @vindex truncate-partial-width-windows
   When a window is less than the full width, text lines too long to fit are
@@ -319,8 +319,8 @@
 except for the echo area.
 
   You can also delete a window by clicking on its mode line with
-@kbd{Mouse-2}, and delete all the windows in a frame except one window
-by clicking on that window's mode line with @kbd{Mouse-3}.
+@kbd{Mouse-3}, and delete all the windows in a frame except one window
+by clicking on that window's mode line with @kbd{Mouse-2}.
 
   The easiest way to adjust window heights is with a mouse.  If you
 press @kbd{Mouse-1} on a mode line, you can drag that mode line up or
@@ -370,8 +370,8 @@
   @kbd{M-x winner-mode} is a global minor mode that records the
 changes in the window configuration (i.e. how the frames are
 partitioned into windows), so that you can ``undo'' them.  To undo,
-use @kbd{C-x left} (@code{winner-undo}).  If you change your mind
-while undoing, you can redo the changes you had undone using @kbd{C-x
+use @kbd{C-c left} (@code{winner-undo}).  If you change your mind
+while undoing, you can redo the changes you had undone using @kbd{C-c
 right} (@code{M-x winner-redo}).  Another way to enable Winner mode is
 by customizing the variable @code{winner-mode}.
 
--- a/src/ChangeLog	Wed Sep 01 21:21:18 2004 +0000
+++ b/src/ChangeLog	Sat Sep 04 09:14:28 2004 +0000
@@ -1,3 +1,89 @@
+2004-09-03  Jason Rumney  <jasonr@gnu.org>
+
+	* w32menu.c (_widget_value): Added lname and lkey.
+	(digest_single_submenu): Set lname and lkey in widget_value
+	instead of name and key.
+	(update_submenu_strings): New function.
+	(set_frame_menubar): Remove call to inhibit_garbage_collection,
+	call update_submenu_strings.
+
+	* w32menu.c (globals_of_w32menu): Check for Unicode API.
+	(digest_single_submenu, w32_menu_show): Encode menu strings as
+	UTF-8 if Unicode API is available.
+	(utf8to16): New function.
+	(add_menu_item): Use it when calling Unicode API.
+	
+2004-09-03  Kim F. Storm  <storm@cua.dk>
+
+	* xdisp.c (set_cursor_from_row): Look for non-nil `cursor' property
+	in overlay or text-property strings; set cursor on corresponding
+	glyph rather than at end of the string.
+
+2004-09-02  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* macfns.c (x_real_positions): Save the current window port and
+	set a new one before obtaining the global coordinate.  Use
+	FRAME_MAC_WINDOW.
+	(x_set_name, x_set_title): Encode title to UTF8.  Use
+	SetWindowTitleWithCFString.
+	(Fx_server_version): Get correct OS version.
+
+	* macmenu.c (add_menu_item): Remove unused variable `i'.  Don't
+	let separator items destroy refence constants of other menu items.
+
+	* macterm.c (x_update_end): Move SetPortWindowPort to inside
+	BLOCK_INPUT.
+	(x_set_offset): Use FRAME_MAC_WINDOW.
+
+	* xdisp.c (note_mouse_highlight): Set the mouse pointer shape to
+	nontext_cursor if it is on a scroll bar.
+
+	* s/darwin.h (LIBS_CARBON): New define to specify libraries for
+	Carbon support.
+	(LD_SWITCH_SYSTEM_TEMACS): Don't link with unused libstdc++.  Use
+	LIBS_CARBON.
+
+2004-09-02  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* xfns.c (x_set_name_internal): New function.  Check if we shall call
+	xfree before ENCODE_UTF_8.
+	(x_set_name, x_set_title): Call x_set_name_internal.
+
+2004-08-31  NAKAMURA Toshikazu  <nr-tkz@nifty.com>  (tiny change)
+
+	* w32fns.c (w32_load_font): If a BDF font is already loaded, do not
+	reload it.
+
+2004-08-30  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* macmenu.c (_widget_value): Added lname and lkey.
+	(single_submenu): Set lname and lkey in widget_value
+	instead of name and key.
+	(update_submenu_strings): New function.
+	(set_frame_menubar): Remove call to inhibit_garbage_collection,
+	call update_submenu_strings.
+
+	* xmenu.c (digest_single_submenu): Set lname and lkey in widget_value
+	instead of name and key.
+	(update_submenu_strings): New function.
+	(set_frame_menubar): Remove call to inhibit_garbage_collection,
+	call update_submenu_strings.
+
+	* gtkutil.h (_widget_value): Added lname and lkey.
+
+2004-08-30  Steven Tamm  <steventamm@mac.com>
+
+	* macmenu.c (mac_menu_show): Remove shadowing of menu variable
+	by using different names for inner loop variables.
+
+2004-08-27  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* xmenu.c (set_frame_menubar): Reintroduce inhibit_garbage_collection
+	from 1.233 so that strings from ENCODE_UTF_8 isn't GC:ed before used.
+
+	* gtkutil.c (xg_create_frame_widgets): Compensate for tool bar when
+	tool bar items is 0.
+
 2004-08-26  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
 	* macmenu.c (ENCODE_MENU_STRING): Added to handle multibyte
--- a/src/fileio.c	Wed Sep 01 21:21:18 2004 +0000
+++ b/src/fileio.c	Sat Sep 04 09:14:28 2004 +0000
@@ -6217,7 +6217,7 @@
 
   GCPRO2 (insdef, default_filename);
 
-#if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) || defined(TARGET_API_MAC_CARBON)
+#if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) || defined (TARGET_API_MAC_CARBON)
   if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
       && use_dialog_box
       && use_file_dialog
--- a/src/gtkutil.c	Wed Sep 01 21:21:18 2004 +0000
+++ b/src/gtkutil.c	Sat Sep 04 09:14:28 2004 +0000
@@ -793,7 +793,7 @@
      up in the wrong place as tool bar height has not been taken into account.
      So we cheat a bit by setting a height that is what it will have
      later on when tool bar items are added.  */
-  if (FRAME_EXTERNAL_TOOL_BAR (f) && FRAME_TOOLBAR_HEIGHT (f) == 0)
+  if (FRAME_EXTERNAL_TOOL_BAR (f) && f->n_tool_bar_items == 0)
     FRAME_TOOLBAR_HEIGHT (f) = 34;
 
 
--- a/src/gtkutil.h	Wed Sep 01 21:21:18 2004 +0000
+++ b/src/gtkutil.h	Sat Sep 04 09:14:28 2004 +0000
@@ -96,10 +96,12 @@
 typedef struct _widget_value
 {
   /* name of widget */
+  Lisp_Object   lname;
   char		*name;
   /* value (meaning depend on widget type) */
   char		*value;
   /* keyboard equivalent. no implications for XtTranslations */
+  Lisp_Object   lkey;
   char		*key;
   /* Help string or nil if none.
      GC finds this string through the frame's menu_bar_vector
--- a/src/macfns.c	Wed Sep 01 21:21:18 2004 +0000
+++ b/src/macfns.c	Sat Sep 04 09:14:28 2004 +0000
@@ -324,19 +324,21 @@
   Point pt;
   GrafPtr oldport;
 
-#ifdef TARGET_API_MAC_CARBON
+  GetPort (&oldport);
+  SetPortWindowPort (FRAME_MAC_WINDOW (f));
+
+#if TARGET_API_MAC_CARBON
   {
     Rect r;
 
-    GetWindowPortBounds (f->output_data.mac->mWP, &r);
+    GetWindowPortBounds (FRAME_MAC_WINDOW (f), &r);
     SetPt (&pt, r.left, r.top);
   }
 #else /* not TARGET_API_MAC_CARBON */
   SetPt (&pt,
-	 f->output_data.mac->mWP->portRect.left,
-	 f->output_data.mac->mWP->portRect.top);
+	 FRAME_MAC_WINDOW (f)->portRect.left,
+	 FRAME_MAC_WINDOW (f)->portRect.top);
 #endif /* not TARGET_API_MAC_CARBON */
-  GetPort (&oldport);
   LocalToGlobal (&pt);
   SetPort (oldport);
 
@@ -1934,8 +1936,8 @@
   if (FRAME_MAC_WINDOW (f))
     {
       if (STRING_MULTIBYTE (name))
-#if 0 /* MAC_TODO: encoding title string */
-	name = ENCODE_SYSTEM (name);
+#if TARGET_API_MAC_CARBON
+	name = ENCODE_UTF_8 (name);
 #else
         return;
 #endif
@@ -1943,6 +1945,14 @@
       BLOCK_INPUT;
 
       {
+#if TARGET_API_MAC_CARBON
+	CFStringRef windowTitle =
+	  CFStringCreateWithCString (NULL, SDATA (name),
+				     kCFStringEncodingUTF8);
+
+	SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle);
+	CFRelease (windowTitle);
+#else
 	Str255 windowTitle;
 	if (strlen (SDATA (name)) < 255)
 	  {
@@ -1950,6 +1960,7 @@
 	    c2pstr (windowTitle);
 	    SetWTitle (FRAME_MAC_WINDOW (f), windowTitle);
 	  }
+#endif
       }
 
       UNBLOCK_INPUT;
@@ -2008,8 +2019,8 @@
   if (FRAME_MAC_WINDOW (f))
     {
       if (STRING_MULTIBYTE (name))
-#if 0 /* MAC_TODO: encoding title string */
-	name = ENCODE_SYSTEM (name);
+#if TARGET_API_MAC_CARBON
+	name = ENCODE_UTF_8 (name);
 #else
         return;
 #endif
@@ -2017,6 +2028,14 @@
       BLOCK_INPUT;
 
       {
+#if TARGET_API_MAC_CARBON
+	CFStringRef windowTitle =
+	  CFStringCreateWithCString (NULL, SDATA (name),
+				     kCFStringEncodingUTF8);
+
+	SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle);
+	CFRelease (windowTitle);
+#else
 	Str255 windowTitle;
 	if (strlen (SDATA (name)) < 255)
 	  {
@@ -2024,6 +2043,7 @@
 	    c2pstr (windowTitle);
 	    SetWTitle (FRAME_MAC_WINDOW (f), windowTitle);
 	  }
+#endif
       }
 
       UNBLOCK_INPUT;
@@ -2981,17 +3001,20 @@
   (display)
      Lisp_Object display;
 {
-  int mac_major_version, mac_minor_version;
+  int mac_major_version;
   SInt32 response;
 
   if (Gestalt (gestaltSystemVersion, &response) != noErr)
     error ("Cannot get Mac OS version");
 
-  mac_major_version = (response >> 8) & 0xf;
-  mac_minor_version = (response >> 4) & 0xf;
+  mac_major_version = (response >> 8) & 0xff;
+  /* convert BCD to int */
+  mac_major_version -= (mac_major_version >> 4) * 6;
 
   return Fcons (make_number (mac_major_version),
-		Fcons (make_number (mac_minor_version), Qnil));
+		Fcons (make_number ((response >> 4) & 0xf),
+		       Fcons (make_number (response & 0xf),
+			      Qnil)));
 }
 
 DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0,
--- a/src/macmenu.c	Wed Sep 01 21:21:18 2004 +0000
+++ b/src/macmenu.c	Sat Sep 04 09:14:28 2004 +0000
@@ -90,10 +90,12 @@
 typedef struct _widget_value
 {
   /* name of widget */
+  Lisp_Object   lname;
   char*		name;
   /* value (meaning depend on widget type) */
   char*		value;
   /* keyboard equivalent. no implications for XtTranslations */
+  Lisp_Object   lkey;
   char*		key;
   /* Help string or nil if none.
      GC finds this string through the frame's menu_bar_vector
@@ -1221,12 +1223,9 @@
 		save_wv->next = wv;
 	      else
 		first_wv->contents = wv;
-	      wv->name = pane_string;
-	      /* Ignore the @ that means "separate pane".
-		 This is a kludge, but this isn't worth more time.  */
-	      if (!NILP (prefix) && wv->name[0] == '@')
-		wv->name++;
-	      wv->value = 0;
+	      wv->lname = pane_name;
+              /* Set value to 1 so update_submenu_strings can handle '@'  */
+	      wv->value = (char *)1;
 	      wv->enabled = 1;
 	      wv->button_type = BUTTON_TYPE_NONE;
 	      wv->help = Qnil;
@@ -1269,9 +1268,9 @@
 	  else
 	    save_wv->contents = wv;
 
-	  wv->name = (char *) SDATA (item_name);
+	  wv->lname = item_name;
 	  if (!NILP (descrip))
-	    wv->key = (char *) SDATA (descrip);
+	    wv->lkey = descrip;
 	  wv->value = 0;
 	  /* The EMACS_INT cast avoids a warning.  There's no problem
 	     as long as pointers have enough bits to hold small integers.  */
@@ -1310,6 +1309,41 @@
 
   return first_wv;
 }
+/* Walk through the widget_value tree starting at FIRST_WV and update
+   the char * pointers from the corresponding lisp values.
+   We do this after building the whole tree, since GC may happen while the
+   tree is constructed, and small strings are relocated.  So we must wait
+   until no GC can happen before storing pointers into lisp values.  */
+static void
+update_submenu_strings (first_wv)
+     widget_value *first_wv;
+{
+  widget_value *wv;
+
+  for (wv = first_wv; wv; wv = wv->next)
+    {
+      if (wv->lname && ! NILP (wv->lname))
+        {
+          wv->name = SDATA (wv->lname);
+
+          /* Ignore the @ that means "separate pane".
+             This is a kludge, but this isn't worth more time.  */
+          if (wv->value == (char *)1)
+            {
+              if (wv->name[0] == '@')
+		wv->name++;
+              wv->value = 0;
+            }
+        }
+
+      if (wv->lkey && ! NILP (wv->lkey))
+        wv->key = SDATA (wv->lkey);
+
+      if (wv->contents)
+        update_submenu_strings (wv->contents);
+    }
+}
+
 
 /* Set the contents of the menubar widgets of frame F.
    The argument FIRST_TIME is currently ignored;
@@ -1388,8 +1422,6 @@
 
       items = FRAME_MENU_BAR_ITEMS (f);
 
-      inhibit_garbage_collection ();
-
       /* Save the frame's previous menu bar contents data.  */
       if (previous_menu_items_used)
 	bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items,
@@ -1454,6 +1486,7 @@
 	  if (NILP (string))
 	    break;
 	  wv->name = (char *) SDATA (string);
+          update_submenu_strings (wv->contents);
 	  wv = wv->next;
 	}
 
@@ -1807,9 +1840,9 @@
   /* Get the refcon to find the correct item*/
   if (menu_item_selection)
     {
-      menu = GetMenuHandle (HiWord (menu_item_choice));
-      if (menu) {
-	GetMenuItemRefCon (menu, menu_item_selection, &refcon);
+      MenuHandle sel_menu = GetMenuHandle (HiWord (menu_item_choice));
+      if (sel_menu) {
+	GetMenuItemRefCon (sel_menu, menu_item_selection, &refcon);
       }
     }
 
@@ -1831,11 +1864,11 @@
   {
     int i = MIN_POPUP_SUBMENU_ID;
     MenuHandle submenu = GetMenuHandle (i);
-    while (menu != NULL)
+    while (submenu != NULL)
       {
 	DeleteMenu (i);
-	DisposeMenu (menu);
-	menu = GetMenuHandle (++i);
+	DisposeMenu (submenu);
+	submenu = GetMenuHandle (++i);
       }
   }
 
@@ -2207,7 +2240,7 @@
 	       int force_disable)
 {
   Str255 item_name;
-  int pos, i;
+  int pos;
 
   if (name_is_separator (wv->name))
     AppendMenu (menu, "\p-");
@@ -2263,10 +2296,10 @@
       else
 	SetItemMark (menu, pos, noMark);
       }
+
+      SetMenuItemRefCon (menu, pos, (UInt32) wv->call_data);
     }
 
-  SetMenuItemRefCon (menu, pos, (UInt32) wv->call_data);
-
   if (submenu != NULL)
     SetMenuItemHierarchicalID (menu, pos, submenu);
 }
--- a/src/macterm.c	Wed Sep 01 21:21:18 2004 +0000
+++ b/src/macterm.c	Sat Sep 04 09:14:28 2004 +0000
@@ -1327,6 +1327,10 @@
 x_update_end (f)
      struct frame *f;
 {
+  /* Mouse highlight may be displayed again.  */
+  FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0;
+
+  BLOCK_INPUT;
   /* 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.  */
@@ -1334,10 +1338,6 @@
 
   mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));
 
-  /* Mouse highlight may be displayed again.  */
-  FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0;
-
-  BLOCK_INPUT;
   XFlush (FRAME_MAC_DISPLAY (f));
   UNBLOCK_INPUT;
 }
@@ -5140,7 +5140,7 @@
   modified_left = f->left_pos;
   modified_top = f->top_pos;
 
-  MoveWindow (f->output_data.mac->mWP, modified_left + 6,
+  MoveWindow (FRAME_MAC_WINDOW (f), modified_left + 6,
 	      modified_top + 42, false);
 
   UNBLOCK_INPUT;
--- a/src/s/darwin.h	Wed Sep 01 21:21:18 2004 +0000
+++ b/src/s/darwin.h	Sat Sep 04 09:14:28 2004 +0000
@@ -243,11 +243,18 @@
    specific headers.  */
 #define C_SWITCH_SYSTEM -fpascal-strings -fno-common -DMAC_OSX -I../mac/src
 
-/* Link in the Carbon lib.  The -headerpad option tells ld (see man
-   page) to leave room at the end of the header for adding load
-   commands.  Needed for dumping.  0x690 is the total size of 30
-   segment load commands (at 56 each).  */
-#define LD_SWITCH_SYSTEM_TEMACS -prebind -framework Carbon -framework QuickTime -lstdc++ -Xlinker -headerpad -Xlinker 690
+/* Link in the Carbon lib. */
+#ifdef HAVE_CARBON
+#define LIBS_CARBON -framework Carbon -framework QuickTime
+#else
+#define LIBS_CARBON -framework Carbon
+#endif
+
+/* The -headerpad option tells ld (see man page) to leave room at the
+   end of the header for adding load commands.  Needed for dumping.
+   0x690 is the total size of 30 segment load commands (at 56
+   each).  */
+#define LD_SWITCH_SYSTEM_TEMACS -prebind LIBS_CARBON -Xlinker -headerpad -Xlinker 690
 
 #define C_SWITCH_SYSTEM_TEMACS -Dtemacs
 
--- a/src/w32fns.c	Wed Sep 01 21:21:18 2004 +0000
+++ b/src/w32fns.c	Sat Sep 04 09:14:28 2004 +0000
@@ -4644,6 +4644,7 @@
 {
   Lisp_Object bdf_fonts;
   struct font_info *retval = NULL;
+  struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
 
   bdf_fonts = w32_list_bdf_fonts (build_string (fontname), 1);
 
@@ -4651,11 +4652,22 @@
     {
       char *bdf_name, *bdf_file;
       Lisp_Object bdf_pair;
+      int i;
 
       bdf_name = SDATA (XCAR (bdf_fonts));
       bdf_pair = Fassoc (XCAR (bdf_fonts), Vw32_bdf_filename_alist);
       bdf_file = SDATA (XCDR (bdf_pair));
 
+      // If the font is already loaded, do not load it again.
+      for (i = 0; i < dpyinfo->n_fonts; i++)
+	{
+	  if ((dpyinfo->font_table[i].name
+	       && !strcmp (dpyinfo->font_table[i].name, bdf_name))
+	      || (dpyinfo->font_table[i].full_name
+		  && !strcmp (dpyinfo->font_table[i].full_name, bdf_name)))
+	    return dpyinfo->font_table + i;
+	}
+
       retval = w32_load_bdf_font (f, bdf_name, size, bdf_file);
 
       bdf_fonts = XCDR (bdf_fonts);
--- a/src/w32menu.c	Wed Sep 01 21:21:18 2004 +0000
+++ b/src/w32menu.c	Sat Sep 04 09:14:28 2004 +0000
@@ -45,7 +45,6 @@
 
 #include "dispextern.h"
 
-#undef HAVE_MULTILINGUAL_MENU
 #undef HAVE_DIALOGS /* TODO: Implement native dialogs.  */
 
 /******************************************************************/
@@ -66,10 +65,12 @@
 typedef struct _widget_value
 {
   /* name of widget */
+  Lisp_Object   lname;
   char*		name;
   /* value (meaning depend on widget type) */
   char*		value;
   /* keyboard equivalent. no implications for XtTranslations */
+  Lisp_Object   lkey;
   char*		key;
   /* Help string or nil if none.
      GC finds this string through the frame's menu_bar_vector
@@ -136,17 +137,21 @@
     IN HMENU,
     IN UINT,
     IN BOOL,
-    IN OUT LPMENUITEMINFOA
-    );
+    IN OUT LPMENUITEMINFOA);
 typedef BOOL (WINAPI * SetMenuItemInfoA_Proc) (
     IN HMENU,
     IN UINT,
     IN BOOL,
-    IN LPCMENUITEMINFOA
-    );
+    IN LPCMENUITEMINFOA);
+typedef BOOL (WINAPI * AppendMenuW_Proc) (
+    IN HMENU,
+    IN UINT,
+    IN UINT_PTR,
+    IN LPCWSTR);
 
-GetMenuItemInfoA_Proc get_menu_item_info=NULL;
-SetMenuItemInfoA_Proc set_menu_item_info=NULL;
+GetMenuItemInfoA_Proc get_menu_item_info = NULL;
+SetMenuItemInfoA_Proc set_menu_item_info = NULL;
+AppendMenuW_Proc unicode_append_menu = NULL;
 
 Lisp_Object Vmenu_updating_frame;
 
@@ -1235,13 +1240,17 @@
 	  pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
 	  prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
 
-#ifndef HAVE_MULTILINGUAL_MENU
-	  if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
+	  if (STRINGP (pane_name))
 	    {
-	      pane_name = ENCODE_SYSTEM (pane_name);
+	      if (unicode_append_menu)
+		/* Encode as UTF-8 for now.  */
+		pane_name = ENCODE_UTF_8 (pane_name);
+	      else if (STRING_MULTIBYTE (pane_name))
+		pane_name = ENCODE_SYSTEM (pane_name);
+
 	      ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
 	    }
-#endif
+
 	  pane_string = (NILP (pane_name)
 			 ? "" : (char *) SDATA (pane_name));
 	  /* If there is just one top-level pane, put all its items directly
@@ -1259,12 +1268,9 @@
 		save_wv->next = wv;
 	      else
 		first_wv->contents = wv;
-	      wv->name = pane_string;
-	      /* Ignore the @ that means "separate pane".
-		 This is a kludge, but this isn't worth more time.  */
-	      if (!NILP (prefix) && wv->name[0] == '@')
-		wv->name++;
-	      wv->value = 0;
+	      wv->lname = pane_name;
+	      /* Set value to 1 so update_submenu_strings can handle '@'  */
+	      wv->value = (char *) 1;
 	      wv->enabled = 1;
 	      wv->button_type = BUTTON_TYPE_NONE;
 	      wv->help = Qnil;
@@ -1287,10 +1293,13 @@
 	  selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
 	  help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
 
-#ifndef HAVE_MULTILINGUAL_MENU
-	  if (STRING_MULTIBYTE (item_name))
+	  if (STRINGP (item_name))
 	    {
-	      item_name = ENCODE_SYSTEM (item_name);
+	      if (unicode_append_menu)
+		item_name = ENCODE_UTF_8 (item_name);
+	      else if (STRING_MULTIBYTE (item_name))
+		item_name = ENCODE_SYSTEM (item_name);
+
 	      ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
 	    }
 
@@ -1299,7 +1308,6 @@
 	      descrip = ENCODE_SYSTEM (descrip);
 	      ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
 	    }
-#endif /* not HAVE_MULTILINGUAL_MENU */
 
 	  wv = xmalloc_widget_value ();
 	  if (prev_wv)
@@ -1307,9 +1315,9 @@
 	  else
 	    save_wv->contents = wv;
 
-	  wv->name = (char *) SDATA (item_name);
+	  wv->lname = item_name;
 	  if (!NILP (descrip))
-	    wv->key = (char *) SDATA (descrip);
+	    wv->lkey = descrip;
 	  wv->value = 0;
 	  /* The EMACS_INT cast avoids a warning.  There's no problem
 	     as long as pointers have enough bits to hold small integers.  */
@@ -1348,6 +1356,43 @@
 
   return first_wv;
 }
+
+
+/* Walk through the widget_value tree starting at FIRST_WV and update
+   the char * pointers from the corresponding lisp values.
+   We do this after building the whole tree, since GC may happen while the
+   tree is constructed, and small strings are relocated.  So we must wait
+   until no GC can happen before storing pointers into lisp values.  */
+static void
+update_submenu_strings (first_wv)
+     widget_value *first_wv;
+{
+  widget_value *wv;
+
+  for (wv = first_wv; wv; wv = wv->next)
+    {
+      if (wv->lname && ! NILP (wv->lname))
+        {
+          wv->name = SDATA (wv->lname);
+
+          /* Ignore the @ that means "separate pane".
+             This is a kludge, but this isn't worth more time.  */
+          if (wv->value == (char *)1)
+            {
+              if (wv->name[0] == '@')
+		wv->name++;
+              wv->value = 0;
+            }
+        }
+
+      if (wv->lkey && ! NILP (wv->lkey))
+        wv->key = SDATA (wv->lkey);
+
+      if (wv->contents)
+        update_submenu_strings (wv->contents);
+    }
+}
+
 
 /* Set the contents of the menubar widgets of frame F.
    The argument FIRST_TIME is currently ignored;
@@ -1516,6 +1561,7 @@
 	  if (NILP (string))
 	    break;
 	  wv->name = (char *) SDATA (string);
+	  update_submenu_strings (wv->contents);
 	  wv = wv->next;
 	}
 
@@ -1729,13 +1775,17 @@
 	  char *pane_string;
 	  pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
 	  prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
-#ifndef HAVE_MULTILINGUAL_MENU
-	  if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
+
+	  if (STRINGP (pane_name))
 	    {
-	      pane_name = ENCODE_SYSTEM (pane_name);
+	      if (unicode_append_menu)
+		pane_name = ENCODE_UTF_8 (pane_name);
+	      else if (STRING_MULTIBYTE (pane_name))
+		pane_name = ENCODE_SYSTEM (pane_name);
+
 	      ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
 	    }
-#endif
+
 	  pane_string = (NILP (pane_name)
 			 ? "" : (char *) SDATA (pane_name));
 	  /* If there is just one top-level pane, put all its items directly
@@ -1784,18 +1834,21 @@
 	  selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
           help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
 
-#ifndef HAVE_MULTILINGUAL_MENU
-          if (STRINGP (item_name) && STRING_MULTIBYTE (item_name))
+          if (STRINGP (item_name))
 	    {
-	      item_name = ENCODE_SYSTEM (item_name);
+	      if (unicode_append_menu)
+		item_name = ENCODE_UTF_8 (item_name);
+	      else if (STRING_MULTIBYTE (item_name))
+		item_name = ENCODE_SYSTEM (item_name);
+
 	      ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
 	    }
-          if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
+
+	  if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
             {
 	      descrip = ENCODE_SYSTEM (descrip);
 	      ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
 	    }
-#endif /* not HAVE_MULTILINGUAL_MENU */
 
 	  wv = xmalloc_widget_value ();
 	  if (prev_wv)
@@ -1844,10 +1897,11 @@
       wv_sep->next = first_wv->contents;
       wv_sep->help = Qnil;
 
-#ifndef HAVE_MULTILINGUAL_MENU
-      if (STRING_MULTIBYTE (title))
+      if (unicode_append_menu)
+	title = ENCODE_UTF_8 (title);
+      else if (STRING_MULTIBYTE (title))
 	title = ENCODE_SYSTEM (title);
-#endif
+
       wv_title->name = (char *) SDATA (title);
       wv_title->enabled = TRUE;
       wv_title->title = TRUE;
@@ -2150,6 +2204,46 @@
   return AppendMenu (menu, MF_MENUBARBREAK, 0, NULL);
 }
 
+/* UTF8: 0xxxxxxx, 110xxxxx 10xxxxxx, 1110xxxx, 10xxxxxx, 10xxxxxx */
+static void
+utf8to16 (unsigned char * src, int len, WCHAR * dest)
+{
+  while (len > 0)
+    {
+      int utf16;
+      if (*src < 0x80)
+	{
+	  *dest = (WCHAR) *src;
+	  dest++; src++; len--;
+	}
+      /* Since we might get >3 byte sequences which we don't handle, ignore the extra parts.  */
+      else if (*src < 0xC0)
+	{
+	  src++; len--;
+	}
+      /* 2 char UTF-8 sequence.  */
+      else if (*src <  0xE0)
+	{
+	  *dest = (WCHAR) (((*src & 0x1f) << 6)
+			   | (*(src + 1) & 0x3f));
+	  src += 2; len -= 2; dest++;
+	}
+      else if (*src < 0xF0)
+	{
+	  *dest = (WCHAR) (((*src & 0x0f) << 12)
+			   | ((*(src + 1) & 0x3f) << 6)
+			   | (*(src + 2) & 0x3f));
+	  src += 3; len -= 3; dest++;
+	}
+      else /* Not encodable. Insert Unicode Substitution char.  */
+	{
+	  *dest = (WCHAR) 0xfffd;
+	  src++; len--; dest++;
+	}
+    }
+  *dest = 0;
+}
+
 static int
 add_menu_item (HMENU menu, widget_value *wv, HMENU item)
 {
@@ -2206,11 +2300,32 @@
 	fuFlags |= MF_UNCHECKED;
     }
 
-  return_value =
-    AppendMenu (menu,
-                fuFlags,
-                item != NULL ? (UINT) item : (UINT) wv->call_data,
-                out_string );
+  if (unicode_append_menu && out_string)
+    {
+      /* Convert out_string from UTF-8 to UTF-16-LE.  */
+      int utf8_len = strlen (out_string);
+      WCHAR * utf16_string;
+      if (fuFlags & MF_OWNERDRAW)
+	utf16_string = local_alloc ((utf8_len + 1) * sizeof (WCHAR));
+      else
+	utf16_string = alloca ((utf8_len + 1) * sizeof (WCHAR));
+
+      utf8to16 (out_string, utf8_len, utf16_string);
+      return_value = unicode_append_menu (menu, fuFlags,
+					  item != NULL ? (UINT) item
+					    : (UINT) wv->call_data,
+					  utf16_string);
+      if (fuFlags & MF_OWNERDRAW)
+	local_free (out_string);
+    }
+  else
+    {
+      return_value =
+	AppendMenu (menu,
+		    fuFlags,
+		    item != NULL ? (UINT) item : (UINT) wv->call_data,
+		    out_string );
+    }
 
   /* This must be done after the menu item is created.  */
   if (!wv->title && wv->call_data != 0)
@@ -2298,7 +2413,7 @@
       struct frame *f = x_window_to_frame (&one_w32_display_info, owner);
       Lisp_Object frame, help;
 
-      // No help echo on owner-draw menu items.
+      /* No help echo on owner-draw menu items.  */
       if (flags & MF_OWNERDRAW || flags & MF_POPUP)
 	help = Qnil;
       else
@@ -2422,6 +2537,7 @@
   HMODULE user32 = GetModuleHandle ("user32.dll");
   get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA");
   set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA");
+  unicode_append_menu = (AppendMenuW_Proc) GetProcAddress (user32, "AppendMenuW");
 }
 
 /* arch-tag: 0eaed431-bb4e-4aac-a527-95a1b4f1fed0
--- a/src/xdisp.c	Wed Sep 01 21:21:18 2004 +0000
+++ b/src/xdisp.c	Sat Sep 04 09:14:28 2004 +0000
@@ -307,6 +307,7 @@
 extern Lisp_Object Qheight;
 extern Lisp_Object QCwidth, QCheight, QCascent;
 extern Lisp_Object Qscroll_bar;
+extern Lisp_Object Qcursor;
 
 /* Non-nil means highlight trailing whitespace.  */
 
@@ -10747,6 +10748,7 @@
 {
   struct glyph *glyph = row->glyphs[TEXT_AREA];
   struct glyph *end = glyph + row->used[TEXT_AREA];
+  struct glyph *cursor = NULL;
   /* The first glyph that starts a sequence of glyphs from string.  */
   struct glyph *string_start;
   /* The X coordinate of string_start.  */
@@ -10756,6 +10758,7 @@
   /* The last known character position before string_start.  */
   int string_before_pos;
   int x = row->x;
+  int cursor_x = x;
   int pt_old = PT - delta;
 
   /* Skip over glyphs not having an object at the start of the row.
@@ -10788,12 +10791,29 @@
 	  string_start = glyph;
 	  string_start_x = x;
 	  /* Skip all glyphs from string.  */
-	  SKIP_GLYPHS (glyph, end, x, STRINGP (glyph->object));
-	}
-    }
-
-  if (string_start
-      && (glyph == end || !BUFFERP (glyph->object) || last_pos > pt_old))
+	  do
+	    {
+	      if ((cursor == NULL || glyph > cursor)
+		  && !NILP (Fget_char_property (make_number ((glyph)->charpos),
+						Qcursor, (glyph)->object)))
+		{
+		  cursor = glyph;
+		  cursor_x = x;
+		}
+	      x += glyph->pixel_width;
+	      ++glyph;
+	    }
+	  while (glyph < end && STRINGP (glyph->object));
+	}
+    }
+
+  if (cursor != NULL)
+    {
+      glyph = cursor;
+      x = cursor_x;
+    }
+  else if (string_start
+	   && (glyph == end || !BUFFERP (glyph->object) || last_pos > pt_old))
     {
       /* We may have skipped over point because the previous glyphs
 	 are from string.  As there's no easy way to know the
@@ -11185,8 +11205,8 @@
 	  start_display (&it, w, startp);
 
 	  if (scroll_conservatively)
-	    amount_to_scroll =
-	      max (dy, FRAME_LINE_HEIGHT (f) * max (scroll_step, temp_scroll_step));
+	    amount_to_scroll
+	      = max (dy, FRAME_LINE_HEIGHT (f) * max (scroll_step, temp_scroll_step));
 	  else if (scroll_step || temp_scroll_step)
 	    amount_to_scroll = scroll_max;
 	  else
@@ -11465,8 +11485,7 @@
 	  else if (PT < XFASTINT (w->last_point))
 	    {
 	      /* Cursor has to be moved backward.  Note that PT >=
-		 CHARPOS (startp) because of the outer
-		 if-statement.  */
+		 CHARPOS (startp) because of the outer if-statement.  */
 	      while (!row->mode_line_p
 		     && (MATRIX_ROW_START_CHARPOS (row) > PT
 			 || (MATRIX_ROW_START_CHARPOS (row) == PT
@@ -11978,8 +11997,8 @@
 	     buffer.  */
 	  || !NILP (Vwindow_scroll_functions)
 	  || MINI_WINDOW_P (w)
-	  || !(used_current_matrix_p =
-	       try_window_reusing_current_matrix (w)))
+	  || !(used_current_matrix_p
+	       = try_window_reusing_current_matrix (w)))
 	{
 	  IF_DEBUG (debug_method_add (w, "1"));
 	  try_window (window, startp);
@@ -12108,8 +12127,8 @@
       || !NILP (Vwindow_scroll_functions)
       || !just_this_one_p
       || MINI_WINDOW_P (w)
-      || !(used_current_matrix_p =
-	   try_window_reusing_current_matrix (w)))
+      || !(used_current_matrix_p
+	   = try_window_reusing_current_matrix (w)))
     try_window (window, startp);
 
   /* If new fonts have been loaded (due to fontsets), give up.  We
@@ -15774,7 +15793,8 @@
    The mode_line_string_face face property is always added to the string.
  */
 
-static int store_mode_line_string (string, lisp_string, copy_string, field_width, precision, props)
+static int
+store_mode_line_string (string, lisp_string, copy_string, field_width, precision, props)
      char *string;
      Lisp_Object lisp_string;
      int copy_string;
@@ -15886,32 +15906,32 @@
 
   if (NILP (format) || EQ (format, Qt))
     {
-      face_id = NILP (format)
-	? CURRENT_MODE_LINE_FACE_ID (w) :
-	HEADER_LINE_FACE_ID;
-      format = NILP (format)
-	? current_buffer->mode_line_format
-	: current_buffer->header_line_format;
+      face_id = (NILP (format)
+		 ? CURRENT_MODE_LINE_FACE_ID (w)
+		 : HEADER_LINE_FACE_ID);
+      format = (NILP (format)
+		? current_buffer->mode_line_format
+		: current_buffer->header_line_format);
     }
 
   init_iterator (&it, w, -1, -1, NULL, face_id);
 
   if (NILP (no_props))
     {
-      mode_line_string_face =
-	(face_id == MODE_LINE_FACE_ID ? Qmode_line :
-	 face_id == MODE_LINE_INACTIVE_FACE_ID ? Qmode_line_inactive :
-	 face_id == HEADER_LINE_FACE_ID ? Qheader_line : Qnil);
-
-      mode_line_string_face_prop =
-	NILP (mode_line_string_face) ? Qnil :
-	Fcons (Qface, Fcons (mode_line_string_face, Qnil));
+      mode_line_string_face
+	= (face_id == MODE_LINE_FACE_ID ? Qmode_line
+	   : face_id == MODE_LINE_INACTIVE_FACE_ID ? Qmode_line_inactive
+	   : face_id == HEADER_LINE_FACE_ID ? Qheader_line : Qnil);
+
+      mode_line_string_face_prop
+	= (NILP (mode_line_string_face) ? Qnil
+	   : Fcons (Qface, Fcons (mode_line_string_face, Qnil)));
 
       /* We need a dummy last element in mode_line_string_list to
 	 indicate we are building the propertized mode-line string.
 	 Using mode_line_string_face_prop here GC protects it.  */
-      mode_line_string_list =
-	Fcons (mode_line_string_face_prop, Qnil);
+      mode_line_string_list
+	= Fcons (mode_line_string_face_prop, Qnil);
       frame_title_ptr = NULL;
     }
   else
@@ -21038,7 +21058,8 @@
 
   if (part == ON_VERTICAL_BORDER)
     cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor;
-  else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE)
+  else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE
+	   || part == ON_SCROLL_BAR)
     cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
   else
     cursor = FRAME_X_OUTPUT (f)->text_cursor;
--- a/src/xfns.c	Wed Sep 01 21:21:18 2004 +0000
+++ b/src/xfns.c	Sat Sep 04 09:14:28 2004 +0000
@@ -1540,6 +1540,90 @@
 }
 
 
+/* Set the WM name to NAME for frame F. Also set the icon name.
+   If the frame already has an icon name, use that, otherwise set the
+   icon name to NAME.  */
+
+static void
+x_set_name_internal (f, name)
+     FRAME_PTR f;
+     Lisp_Object name;
+{
+  if (FRAME_X_WINDOW (f))
+    {
+      BLOCK_INPUT;
+#ifdef HAVE_X11R4
+      {
+	XTextProperty text, icon;
+	int bytes, stringp;
+        int do_free_icon_value = 0, do_free_text_value = 0;
+	Lisp_Object coding_system;
+
+	coding_system = Qcompound_text;
+	/* Note: Encoding strategy
+
+	   We encode NAME by compound-text and use "COMPOUND-TEXT" in
+	   text.encoding.  But, there are non-internationalized window
+	   managers which don't support that encoding.  So, if NAME
+	   contains only ASCII and 8859-1 characters, encode it by
+	   iso-latin-1, and use "STRING" in text.encoding hoping that
+	   such window managers at least analyze this format correctly,
+	   i.e. treat 8-bit bytes as 8859-1 characters.
+
+	   We may also be able to use "UTF8_STRING" in text.encoding
+	   in the future which can encode all Unicode characters.
+	   But, for the moment, there's no way to know that the
+	   current window manager supports it or not.  */
+	text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);
+	text.encoding = (stringp ? XA_STRING
+			 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
+	text.format = 8;
+	text.nitems = bytes;
+
+        /* Check early, because ENCODE_UTF_8 below may GC and name may be
+           relocated.  */
+        do_free_text_value = text.value != SDATA (name);
+
+	if (NILP (f->icon_name))
+	  {
+	    icon = text;
+	  }
+	else
+	  {
+	    /* See the above comment "Note: Encoding strategy".  */
+	    icon.value = x_encode_text (f->icon_name, coding_system, 0,
+					&bytes, &stringp);
+	    icon.encoding = (stringp ? XA_STRING
+			     : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
+	    icon.format = 8;
+	    icon.nitems = bytes;
+            do_free_icon_value = icon.value != SDATA (f->icon_name);
+	  }
+
+#ifdef USE_GTK
+        gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+                              SDATA (ENCODE_UTF_8 (name)));
+#else /* not USE_GTK */
+	XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text);
+#endif /* not USE_GTK */
+
+	XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &icon);
+
+	if (do_free_icon_value)
+	  xfree (icon.value);
+	if (do_free_text_value)
+	  xfree (text.value);
+      }
+#else /* not HAVE_X11R4 */
+      XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+		    SDATA (name));
+      XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+		  SDATA (name));
+#endif /* not HAVE_X11R4 */
+      UNBLOCK_INPUT;
+    }
+}
+
 /* Change the name of frame F to NAME.  If NAME is nil, set F's name to
        x_id_name.
 
@@ -1595,73 +1679,7 @@
   if (! NILP (f->title))
     name = f->title;
 
-  if (FRAME_X_WINDOW (f))
-    {
-      BLOCK_INPUT;
-#ifdef HAVE_X11R4
-      {
-	XTextProperty text, icon;
-	int bytes, stringp;
-	Lisp_Object coding_system;
-
-	/* Note: Encoding strategy
-
-	   We encode NAME by compound-text and use "COMPOUND-TEXT" in
-	   text.encoding.  But, there are non-internationalized window
-	   managers which don't support that encoding.  So, if NAME
-	   contains only ASCII and 8859-1 characters, encode it by
-	   iso-latin-1, and use "STRING" in text.encoding hoping that
-	   such window managers at least analyze this format correctly,
-	   i.e. treat 8-bit bytes as 8859-1 characters.
-
-	   We may also be able to use "UTF8_STRING" in text.encoding
-	   in the future which can encode all Unicode characters.
-	   But, for the moment, there's no way to know that the
-	   current window manager supports it or not.  */
-	coding_system = Qcompound_text;
-	text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);
-	text.encoding = (stringp ? XA_STRING
-			 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
-	text.format = 8;
-	text.nitems = bytes;
-
-	if (NILP (f->icon_name))
-	  {
-	    icon = text;
-	  }
-	else
-	  {
-	    /* See the above comment "Note: Encoding strategy".  */
-	    icon.value = x_encode_text (f->icon_name, coding_system, 0,
-					&bytes, &stringp);
-	    icon.encoding = (stringp ? XA_STRING
-			     : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
-	    icon.format = 8;
-	    icon.nitems = bytes;
-	  }
-#ifdef USE_GTK
-        gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
-                              SDATA (ENCODE_UTF_8 (name)));
-#else /* not USE_GTK */
-	XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text);
-#endif /* not USE_GTK */
-
-	XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &icon);
-
-	if (!NILP (f->icon_name)
-	    && icon.value != (unsigned char *) SDATA (f->icon_name))
-	  xfree (icon.value);
-	if (text.value != (unsigned char *) SDATA (name))
-	  xfree (text.value);
-      }
-#else /* not HAVE_X11R4 */
-      XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-		    SDATA (name));
-      XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-		  SDATA (name));
-#endif /* not HAVE_X11R4 */
-      UNBLOCK_INPUT;
-    }
+  x_set_name_internal (f, name);
 }
 
 /* This function should be called when the user's lisp code has
@@ -1715,62 +1733,7 @@
   else
     CHECK_STRING (name);
 
-  if (FRAME_X_WINDOW (f))
-    {
-      BLOCK_INPUT;
-#ifdef HAVE_X11R4
-      {
-	XTextProperty text, icon;
-	int bytes, stringp;
-	Lisp_Object coding_system;
-
-	coding_system = Qcompound_text;
-	/* See the comment "Note: Encoding strategy" in x_set_name.  */
-	text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);
-	text.encoding = (stringp ? XA_STRING
-			 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
-	text.format = 8;
-	text.nitems = bytes;
-
-	if (NILP (f->icon_name))
-	  {
-	    icon = text;
-	  }
-	else
-	  {
-	    /* See the comment "Note: Encoding strategy" in x_set_name.  */
-	    icon.value = x_encode_text (f->icon_name, coding_system, 0,
-					&bytes, &stringp);
-	    icon.encoding = (stringp ? XA_STRING
-			     : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
-	    icon.format = 8;
-	    icon.nitems = bytes;
-	  }
-
-#ifdef USE_GTK
-        gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
-                              SDATA (ENCODE_UTF_8 (name)));
-#else /* not USE_GTK */
-	XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text);
-#endif /* not USE_GTK */
-
-	XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
-                        &icon);
-
-	if (!NILP (f->icon_name)
-	    && icon.value != (unsigned char *) SDATA (f->icon_name))
-	  xfree (icon.value);
-	if (text.value != (unsigned char *) SDATA (name))
-	  xfree (text.value);
-      }
-#else /* not HAVE_X11R4 */
-      XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-		    SDATA (name));
-      XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-		  SDATA (name));
-#endif /* not HAVE_X11R4 */
-      UNBLOCK_INPUT;
-    }
+  x_set_name_internal (f, name);
 }
 
 void
--- a/src/xmenu.c	Wed Sep 01 21:21:18 2004 +0000
+++ b/src/xmenu.c	Sat Sep 04 09:14:28 2004 +0000
@@ -1701,12 +1701,9 @@
 		save_wv->next = wv;
 	      else
 		first_wv->contents = wv;
-	      wv->name = pane_string;
-	      /* Ignore the @ that means "separate pane".
-		 This is a kludge, but this isn't worth more time.  */
-	      if (!NILP (prefix) && wv->name[0] == '@')
-		wv->name++;
-	      wv->value = 0;
+	      wv->lname = pane_name;
+              /* Set value to 1 so update_submenu_strings can handle '@'  */
+	      wv->value = (char *)1;
 	      wv->enabled = 1;
 	      wv->button_type = BUTTON_TYPE_NONE;
 	      wv->help = Qnil;
@@ -1749,9 +1746,9 @@
 	  else
 	    save_wv->contents = wv;
 
-	  wv->name = (char *) SDATA (item_name);
+	  wv->lname = item_name;
 	  if (!NILP (descrip))
-	    wv->key = (char *) SDATA (descrip);
+	    wv->lkey = descrip;
 	  wv->value = 0;
 	  /* The EMACS_INT cast avoids a warning.  There's no problem
 	     as long as pointers have enough bits to hold small integers.  */
@@ -1790,6 +1787,42 @@
 
   return first_wv;
 }
+
+/* Walk through the widget_value tree starting at FIRST_WV and update
+   the char * pointers from the corresponding lisp values.
+   We do this after building the whole tree, since GC may happen while the
+   tree is constructed, and small strings are relocated.  So we must wait
+   until no GC can happen before storing pointers into lisp values.  */
+static void
+update_submenu_strings (first_wv)
+     widget_value *first_wv;
+{
+  widget_value *wv;
+
+  for (wv = first_wv; wv; wv = wv->next)
+    {
+      if (wv->lname && ! NILP (wv->lname))
+        {
+          wv->name = SDATA (wv->lname);
+
+          /* Ignore the @ that means "separate pane".
+             This is a kludge, but this isn't worth more time.  */
+          if (wv->value == (char *)1)
+            {
+              if (wv->name[0] == '@')
+		wv->name++;
+              wv->value = 0;
+            }
+        }
+
+      if (wv->lkey && ! NILP (wv->lkey))
+        wv->key = SDATA (wv->lkey);
+
+      if (wv->contents)
+        update_submenu_strings (wv->contents);
+    }
+}
+
 
 /* Recompute all the widgets of frame F, when the menu bar has been
    changed.  Value is non-zero if widgets were updated.  */
@@ -2022,9 +2055,10 @@
 	  Lisp_Object string;
 	  string = XVECTOR (items)->contents[i + 1];
 	  if (NILP (string))
-	    break;
-	  wv->name = (char *) SDATA (string);
-	  wv = wv->next;
+            break;
+          wv->name = (char *) SDATA (string);
+          update_submenu_strings (wv->contents);
+          wv = wv->next;
 	}
 
       f->menu_bar_vector = menu_items;