changeset 83288:2c2b97b30980

Merged from miles@gnu.org--gnu-2005 (patch 60-65, 246-265) Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-246 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-247 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-248 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-249 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-250 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-251 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-252 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-253 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-254 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-255 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-256 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-257 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-258 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-259 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-260 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-261 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-262 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-263 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-264 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-265 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-60 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-61 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-62 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-63 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-64 (mm-string-to-multibyte): Use Gnus trunk definition. * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-65 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-328
author Karoly Lorentey <lorentey@elte.hu>
date Mon, 18 Apr 2005 13:40:23 +0000
parents b4b67a7fcbe0 (current diff) 20086071cf3c (diff)
children 1e53ee7473e9
files ChangeLog admin/FOR-RELEASE etc/TODO lisp/ChangeLog lisp/Makefile.in lisp/faces.el lisp/files.el lisp/generic.el lisp/international/mule-cmds.el lisp/loadup.el lisp/progmodes/gdb-ui.el lisp/simple.el lisp/startup.el lisp/term/xterm.el lisp/whitespace.el lisp/x-dnd.el lispref/ChangeLog mac/makefile.MPW man/ChangeLog man/frames.texi src/Makefile.in src/keyboard.c src/macterm.c src/macterm.h src/term.c src/termhooks.h src/window.c src/xdisp.c
diffstat 90 files changed, 3001 insertions(+), 2156 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Apr 18 13:17:40 2005 +0000
+++ b/ChangeLog	Mon Apr 18 13:40:23 2005 +0000
@@ -1,3 +1,14 @@
+2005-04-14  Lute Kamstra  <lute@gnu.org>
+
+	* make-dist: Distribute all ChangeLog files in lisp/.
+	Don't distribute ldefs-boot.el.
+	lisp/makefile.nt no longer exists.
+
+2005-04-13  Lute Kamstra  <lute@gnu.org>
+
+	* make-dist: Don't use DONTCOMPILE from lisp/Makefile.in; check
+	for "no-byte-compile: t" in the file instead.
+
 2005-03-16  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* configure.in <Motif>: Don't let a special LessTif/Motif1.2 install
--- a/admin/ChangeLog	Mon Apr 18 13:17:40 2005 +0000
+++ b/admin/ChangeLog	Mon Apr 18 13:40:23 2005 +0000
@@ -1,3 +1,9 @@
+2005-04-14  Lute Kamstra  <lute@gnu.org>
+
+	* nt/makedist.bat (elfiles): Update.
+
+	* admin.el (add-release-logs): Fix require call.
+
 2005-03-30  Marcelo Toledo  <marcelo@marcelotoledo.org>
 
 	* FOR-RELEASE (Documentation): Added check the Emacs Tutorial. The
--- a/admin/FOR-RELEASE	Mon Apr 18 13:17:40 2005 +0000
+++ b/admin/FOR-RELEASE	Mon Apr 18 13:40:23 2005 +0000
@@ -20,6 +20,8 @@
 
 ** Enhance scroll-bar to handle tall line (similar to line-move).
 
+** Adapt mouse-sel-mode to mouse-1-click-follows-link.
+
 
 * FATAL ERRORS
 
@@ -80,42 +82,6 @@
 is encountered.
 
 
-** custom mode-line face makes Emacs freeze up
-
-From: Stephen Berman <Stephen.Berman@gmx.net>
-Date: Sun, 24 Oct 2004 02:08:56 +0200
-
-1. Start Emacs with -q -no-site-file.
-
-2. Type `M-x customize-face' and at the prompt `mode-line'.
-
-3. In the Custom buffer for mode-line face
-   a. check width and give it the value `narrow';
-   b. check height and give it the value 120 in 1/10 pt;
-   c. check underline and give it the value `on' (or `colored');
-   d. check overline and give it the value `on' (or `colored').
-
-4. Set for current session.
-
-5. Invoke Ediff on any two files.
-
-6. Now Emacs is frozen and consumes 95-99% of CPU.
-
-The customizations in step 3 appear to be the minimum necessary to
-induce this bug.  Leave out any one of them and Ediff runs without a
-problem.  Also if the 1/10 point value of height is 130 or greater
-there's no bug (with the default font family; with e.g. Helvetica the
-bug is induced only by a value of 100 or less).
-
-I've noticed this freeze up only when invoking Ediff.  The only thing
-I've been able to do is kill Emacs externally, via top or with kill
-when run in gdb, after interrupting.  When the freeze up happens
-within a gdb session, there is no automatic debugging feedback.  After
-interrupting I can get a backtrace, here's an example:
-
-Update: Maybe only reveals itself when compiled with GTK+
-
-
 * DOCUMENTATION
 
 ** Document Custom Themes.
@@ -272,11 +238,11 @@
 etc/TUTORIAL.pl
 etc/TUTORIAL.pt_BR       Marcelo Toledo
 etc/TUTORIAL.ro
-etc/TUTORIAL.ru
-etc/TUTORIAL.sk
+etc/TUTORIAL.ru          Alex Ott <alexott@gmail.com>
+etc/TUTORIAL.sk          Pavel JanМk <Pavel@Janik.cz>
 etc/TUTORIAL.sl          Primoz PETERLIN <primoz.peterlin@biofiz.mf.uni-lj.si>
 etc/TUTORIAL.sv          Mats Lidell <matsl@contactor.se>
-etc/TUTORIAL.th
+etc/TUTORIAL.th          Virach Sornlertlamvanich <virach@tcllab.org>
 etc/TUTORIAL.zh
 
 
--- a/admin/admin.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/admin/admin.el	Mon Apr 18 13:40:23 2005 +0000
@@ -1,6 +1,6 @@
 ;;; admin.el --- utilities for Emacs administration
 
-;; Copyright (C) 2001 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2005 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -21,8 +21,8 @@
 
 ;;; Commentary:
 
-;; add-release-log	add ``Version X released'' change log entries
-;; set-version		change Emacs version number in source tree.
+;; add-release-logs	Add ``Version X released'' change log entries.
+;; set-version		Change Emacs version number in source tree.
 
 ;;; Code:
 
@@ -43,7 +43,6 @@
 	  (forward-line 1))
 	(nreverse lines)))))
 
-
 (defun add-release-logs (root version)
   "Add \"Version VERSION released.\" change log entries in ROOT.
 Root must be the root of an Emacs source tree."
@@ -51,8 +50,8 @@
   (setq root (expand-file-name root))
   (unless (file-exists-p (expand-file-name "src/emacs.c" root))
     (error "%s doesn't seem to be the root of an Emacs source tree" root))
+  (require 'add-log)
   (let* ((logs (process-lines "find" root "-name" "ChangeLog"))
-	 (require 'add-log)
 	 (entry (format "%s  %s  <%s>\n\n\t* Version %s released.\n\n"
 			(funcall add-log-time-format)
 			(or add-log-full-name (user-full-name))
@@ -64,7 +63,6 @@
 	(goto-char (point-min))
 	(insert entry)))))
 
-
 (defun set-version-in-file (root file version rx)
   (find-file (expand-file-name file root))
   (goto-char (point-min))
@@ -72,7 +70,6 @@
     (error "Version not found in %s" file))
   (replace-match (format "%s" version) nil nil nil 1))
 
-
 (defun set-version (root version)
   "Set Emacs version to VERSION in relevant files under ROOT.
 Root must be the root of an Emacs source tree."
--- a/admin/nt/makedist.bat	Mon Apr 18 13:17:40 2005 +0000
+++ b/admin/nt/makedist.bat	Mon Apr 18 13:40:23 2005 +0000
@@ -26,9 +26,14 @@
 
 set eld=emacs-%1/lisp
 
-rem Keep this list in sync with the DONTCOMPILE list in lisp/makefile.w32-in
+rem List of Lisp files that are not compiled and that should be
+rem included in the bin distribution.
 
-set elfiles=%eld%/cus-load.el %eld%/cus-start.el %eld%/emacs-lisp/cl-specs.el %eld%/eshell/esh-maint.el %eld%/eshell/esh-groups.el %eld%/finder-inf.el %eld%/forms-d2.el %eld%/forms-pass.el %eld%/generic-x.el %eld%/international/latin-1.el %eld%/international/latin-2.el %eld%/international/latin-3.el %eld%/international/latin-4.el %eld%/international/latin-5.el %eld%/international/latin-8.el %eld%/international/latin-9.el %eld%/international/mule-conf.el %eld%/loaddefs.el %eld%/loadup.el %eld%/mail/blessmail.el %eld%/patcomp.el %eld%/paths.el %eld%/play/bruce.el %eld%/subdirs.el %eld%/version.el
+rem It would be better to generate this list automatically.  It is the
+rem list of all .el files for which there is no corresponding .elc
+rem file, minus ldefs-boot.el.  --lute
+
+set elfiles=%eld%/cus-load.el %eld%/emacs-lisp/cl-specs.el %eld%/eshell/esh-groups.el %eld%/eshell/esh-maint.el %eld%/finder-inf.el %eld%/forms-d2.el %eld%/forms-pass.el %eld%/international/latin-1.el %eld%/international/latin-2.el %eld%/international/latin-3.el %eld%/international/latin-4.el %eld%/international/latin-5.el %eld%/international/latin-8.el %eld%/international/latin-9.el %eld%/international/mule-conf.el %eld%/language/czech.el %eld%/language/devanagari.el %eld%/language/english.el %eld%/language/georgian.el %eld%/language/greek.el %eld%/language/hebrew.el %eld%/language/japanese.el %eld%/language/kannada.el %eld%/language/korean.el %eld%/language/lao.el %eld%/language/malayalam.el %eld%/language/misc-lang.el %eld%/language/romanian.el %eld%/language/slovak.el %eld%/language/tamil.el %eld%/language/thai.el %eld%/language/utf-8-lang.el %eld%/loaddefs.el %eld%/loadup.el %eld%/mail/blessmail.el %eld%/mh-e/mh-acros.el %eld%/mh-e/mh-gnus.el %eld%/mh-e/mh-loaddefs.el %eld%/obsolete/keyswap.el %eld%/patcomp.el %eld%/paths.el %eld%/play/bruce.el %eld%/subdirs.el %eld%/term/AT386.el %eld%/term/apollo.el %eld%/term/bobcat.el %eld%/term/internal.el %eld%/term/iris-ansi.el %eld%/term/linux.el %eld%/term/lk201.el %eld%/term/news.el %eld%/term/vt102.el %eld%/term/vt125.el %eld%/term/vt200.el %eld%/term/vt201.el %eld%/term/vt220.el %eld%/term/vt240.el %eld%/term/vt300.el %eld%/term/vt320.el %eld%/term/vt400.el %eld%/term/vt420.el %eld%/term/wyse50.el %eld%/version.el
 
 set fns_el=
 for %%f in (emacs-%1/bin/fns*) do set fns_el=%fns_el% emacs-%1/bin/%%f
@@ -42,7 +47,6 @@
 for %%f in (emacs-%1/bin emacs-%1/etc emacs-%1/info emacs-%1/lisp) do echo %%f>>#files#
 for %%f in (emacs-%1/lock emacs-%1/site-lisp) do echo %%f>>#files#
 for %%f in (%elfiles% emacs-%1/site-lisp/subdirs.el) do echo %%f>>#elfiles#
-for %%f in (%eld%/term/*.el) do echo %eld%/term/%%f>>#elfiles#
 
 %TAR% --exclude temacs.exe --exclude emacs.mdp --exclude *.pdb --exclude *.opt --exclude "*.el" --exclude "*~" -T #files# -cvf %2-bin-i386.tar
 %TAR% -T #elfiles# -rvf %2-bin-i386.tar
--- a/etc/ChangeLog	Mon Apr 18 13:17:40 2005 +0000
+++ b/etc/ChangeLog	Mon Apr 18 13:40:23 2005 +0000
@@ -1,3 +1,15 @@
+2005-04-13  Pavel Jan,Am(Bk  <Pavel@Janik.cz>
+
+	* TUTORIAL.sk: Updated header.
+
+2005-04-12  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* NEWS: Mention cursorBlink resource.
+
+2005-04-12  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* NEWS: Mention dynamic change of keyboard-coding-system on Mac.
+
 2005-04-10  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
 	* NEWS: Mention fontSet for Lucid menus.
--- a/etc/NEWS	Mon Apr 18 13:17:40 2005 +0000
+++ b/etc/NEWS	Mon Apr 18 13:40:23 2005 +0000
@@ -351,11 +351,13 @@
 +++
 ** Telnet now prompts you for a port number with C-u M-x telnet.
 
++++
 ** New command line option -Q or --quick.
 
 This is like using -q --no-site-file, but in addition it also disables
 the fancy startup screen.
 
++++
 ** New command line option -D or --basic-display.
 
 Disables the menu-bar, the tool-bar, the scroll-bars, tool tips, and
@@ -966,6 +968,9 @@
 XIM by default, the X resource useXIM can be used to turn it on.
 
 +++
+** The X resource cursorBlink can be used to turn off cursor blinking.
+
++++
 ** `undo-only' does an undo which does not redo any previous undo.
 
 ---
@@ -2449,6 +2454,11 @@
 ** New command `recode-region' decodes the region again by a specified
 coding system.
 
+** On Mac OS, the value of the variable `keyboard-coding-system' is
+now dynamically changed according to the current keyboard script.  The
+variable `mac-keyboard-text-encoding' and the constants
+`kTextEncodingMacRoman', `kTextEncodingISOLatin1', and
+`kTextEncodingISOLatin2' are obsolete.
 
 * New modes and packages in Emacs 22.1
 
--- a/etc/TODO	Mon Apr 18 13:17:40 2005 +0000
+++ b/etc/TODO	Mon Apr 18 13:40:23 2005 +0000
@@ -22,6 +22,11 @@
 ** The buttons at the top of a custom buffer should not omit
   variables whose values are currently hidden.
 
+** Clean up the variables in browse-url.  Perhaps use a shell command string to
+  specify the browser instead of the mushrooming set of functions.
+  See also ESR's proposal for a BROWSER environment variable
+  <URL:http://www.catb.org/~esr/BROWSER/browse-url.patch>.
+
 * Important features:
 
 ** Provide user-friendly ways to list all available font families,
@@ -54,10 +59,10 @@
 
 ** Make movemail work with IMAP.
 
-** Internationalize Emacs's messages.  [Note that this is of limited
-  use until the menus can display multilingual text.  It also doesn't
-  address important issues like using the names of symbols essentially
-  as documentation, e.g. in command names and Custom.  -- fx]
+** Internationalize Emacs's messages.
+
+** Address internationalization of symbols names essentially
+  as documentation, e.g. in command names and Custom.
 
 ** Make the Lucid menu widget display multilingual text.  [This
   probably needs to be done from actual Emacs buffers, either directly
--- a/etc/TUTORIAL.ru	Mon Apr 18 13:17:40 2005 +0000
+++ b/etc/TUTORIAL.ru	Mon Apr 18 13:40:23 2005 +0000
@@ -1,4 +1,4 @@
-учебник Emacs.
+Учебник Emacs. Условия распространения смотрите в конце файла
 Copyright (c) 1985, 1996, 2004 Free Software Foundation, Inc.
 
 Для управления Emacs обычно используется ключ (сочетание клавиш клавиатуры
--- a/etc/TUTORIAL.sk	Mon Apr 18 13:17:40 2005 +0000
+++ b/etc/TUTORIAL.sk	Mon Apr 18 13:40:23 2005 +0000
@@ -1,5 +1,5 @@
-tЗtorial k Emacsu.
-Copyright (c) 1985 Free Software Foundation, Inc; podmienky pozri na konci.
+TЗtorial k Emacsu. Podmienky pozri na konci.
+Copyright (c) 1985, 1996, 1998, 2001, 2002, 2005 Free Software Foundation.
 Do Хe╧tiny prelo╬il Milan Zamazal <pdm@zamazal.org>, do slovenХiny Miroslav
 Va╧ko <zemiak@zoznam.sk>.
 
--- a/etc/TUTORIAL.th	Mon Apr 18 13:17:40 2005 +0000
+++ b/etc/TUTORIAL.th	Mon Apr 18 13:40:23 2005 +0000
@@ -1,4 +1,4 @@
-0,T7h1R9!S0EQ1'0HV1!IR0$Yh10AW1M!RCc0*i10MU1aA!0Jl1(B.
+0,T$Yh10AW1M!RCc0*i10MU1aA!0Jl1(B. ,Tb;C40HV1!IR0Jh1G907i1RB"M'0$Yh10AW1MJSK0CQ1:`0'Wh1M9d"c9!RC7SJS`9R(B.
 ,TJ'G90ET1"0JT1708Tl1(B ,T>(B.,TH(B. 2528 ,Tb4B:0CT10IQ17?0CU1+M?05l1aG0Cl1?RG09l1`40*Q19(B (Free Software
 Foundation, Inc); ,T!0CX13R0HV1!IR`0'Wh1M9d"5M907i1RB:7(B.
 0,T7h1R9!S0EQ1'0HV1!IR0$Yh10AW1M!RCc0*i10MU1aA!0Jl1(B (Emacs tutorial) ,TM0BYh1c9"3P09Ui1(B.
--- a/lisp/ChangeLog	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/ChangeLog	Mon Apr 18 13:40:23 2005 +0000
@@ -1,3 +1,357 @@
+2005-04-17  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* startup.el (command-line): No longer enable Xterm Mouse mode by
+	default in terminals compatible with xterm.
+
+	* xt-mouse.el (xterm-mouse-mode): Set init value back to nil.
+
+2005-04-18  Nick Roberts  <nickrob@snap.net.nz>
+
+	* tooltip.el (tooltip-gud-echo-area): Rename from
+	tooltip-use-echo-area.
+	(tooltip-show, tooltip-gud-process-output, gdb-tooltip-print)
+	(tooltip-help-tips): Allow GUD tooltips to be displayed in echo
+	area independently of where help tooltips are displayed.
+
+2005-04-17  David Kastrup  <dak@gnu.org>
+
+	* cus-theme.el (custom-theme-write-variables): Quote variables
+	where necessary.
+
+2005-04-17  Richard M. Stallman  <rms@gnu.org>
+
+	* simple.el (yank-excluded-properties): Add follow-link to value.
+
+	* jka-compr.el (jka-compr-compression-info-list): Fix custom type.
+
+	* startup.el (fancy-splash-max-time): Just 30 seconds.
+	(fancy-splash-delay): Just 7.
+	(fancy-splash-screens): No time limit other than fancy-splash-max-time.
+
+	* loadhist.el (unload-feature): Update for new format of load-history.
+	Simplify the code.
+
+	* mail/rmail.el (rmail-ignored-headers): Ignore more headers
+	(rmail-font-lock-keywords): Don't fontify the text of a citation.
+
+	* mail/sendmail.el (mail-font-lock-keywords):
+	Don't fontify subject text.
+	Don't fontify the text of a citation.
+
+2005-04-17  Mark H. Weaver  <mhw@netris.org>  (tiny change)
+
+	* comint.el (comint-output-filter): Run comint-output-filter-functions
+	with point where the user had it.
+
+2005-04-16  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* international/ucs-tables.el (ucs-set-table-for-input):
+	Disable when using unify-on-decoding.
+
+2005-04-16  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* emulation/cua-base.el (cua-global-mark-face): Add special case
+	for displays supporting a high number of colors.
+
+2005-04-16  Matt Hodges  <MPHodges@member.fsf.org>  (tiny change)
+
+	* repeat.el (repeat): Invoke pre-command-hook and post-command-hook.
+
+2005-04-16  Chong Yidong  <cyd@stupidchicken.com>
+
+	* filesets.el (filesets-add-buffer): If user supplies a name of a
+	non-existing fileset, create a new fileset.
+
+2005-04-16  Carsten Dominik  <dominik@science.uva.nl>
+
+	* textmodes/org.el (org-up-heading-all): Fix bug with
+	`outline-up-heading-all'.
+
+2005-04-16  Andreas Schwab  <schwab@suse.de>
+
+	* files.el (auto-mode-alist): Handle /etc/sysconfig/*,
+	/etc/permissions.d/* and /etc/aliases.d/*.
+
+2005-04-16  Kenichi Handa  <handa@m17n.org>
+
+	* international/code-pages.el (cp-make-coding-system):
+	Set `translation-table-for-input' property value to the symbol
+	ucs-mule-to-mule-unicode, not to that value.
+	(pt154): Escape guillemet by `\'.
+
+2005-04-15  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* loadup.el: Load tooltip if x-show-tip is fboundp.
+
+	* startup.el (command-line): Add comment.
+
+	* tooltip.el (tooltip-mode): Specify correct standard value for
+	Custom in init-value.
+
+2005-04-15  Nick Roberts  <nickrob@snap.net.nz>
+
+	* progmodes/gud.el (gud-goto-info): Use existing Info buffer, if
+	possible.
+
+2005-04-15  Carsten Dominik  <dominik@science.uva.nl>
+
+	* textmodes/org.el:  (org-agenda-date-prompt): Rename from
+	`org-agenda-date-today'.
+	(org-evaluate-time-range): Insert at point instead of directly
+	after time range.
+	(org-first-headline-recenter, org-subtree-end-visible-p)
+	(org-optimize-window-after-visibility-change): New functions
+	(org-agenda-post-command-hook): Don't allow point at end of line,
+	to make sure it always hits the text properties.
+	(org-agenda-next-date-line, org-agenda-previous-date-line):
+	New commands.
+	(org-set-regexps-and-options): Category may contain white space.
+	(org-agenda-get-deadlines, org-agenda-get-scheduled):
+	Improve marker positions.
+	(org-agenda-new-marker): Argument POS made optional.
+	(org-agenda-get-timestamps): Deadlines which are done are listed
+	in org-done-face now.
+	(org-agenda-get-todos, org-agenda-get-timestamps)
+	(org-agenda-get-deadlines, org-agenda-get-scheduled):
+	Set `undone-face' and `done-face' properties.
+	(org-last-todo-state-is-todo): New variable.
+	(org-todo): Set `org-last-todo-state-is-todo'.
+	(org-agenda-todo): Change face according to
+	`org-last-todo-state-is-todo'.  And change other lines refering to
+	the same entry.
+	(org-calendar-goto-agenda): New command.
+	(org-calendar-to-agenda-key): New option.
+	(org-startup-folded): New allowed value `content'.
+	(org-set-regexps-and-options): Accept new value `content' for
+	`org-startup-folded'.
+	(org-get-current-options): Handle new value `content' for
+	`org-startup-folded'.
+	(org-insert-todo-heading): New command.
+	(org-mode): Insert first line "*-* mode: org-mode -*-" when called
+	interactively in empty file and option
+	`org-insert-mode-line-in-empty-file' has been set.
+	(org-agenda-todo,org-agenda-priority): Modify to use
+	`org-agenda-change-all-lines'.
+	(org-warning-face): Change color on dark background
+
+2005-04-14  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* international/mule-cmds.el (set-locale-environment): On Mac OS,
+	use preferences AppleLocale and AppleLanguages, and variable
+	mac-system-locale for default locale.  On Mac OS Classic, use
+	mac-system-coding-system for default coding systems.
+
+	* term/mac-win.el: Don't set file-name-coding-system.
+	Decode variables system-name, emacs-build-system, user-login-name, and
+	user-full-name by mac-system-coding-system on Mac OS Classic.
+	(mac-system-coding-system): New variable.
+
+2005-04-13  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* startup.el (command-line): Handle `xterm-mouse-mode' before
+	reading init file.
+
+	* xt-mouse.el (xterm-mouse-mode): Adapt to above change.
+
+2005-04-13  Glenn Morris  <gmorris@ast.cam.ac.uk>
+
+	* progmodes/sh-script.el (sh-here-document-word): Make it a
+	defcustom.  Doc fix.
+	(sh-add): Bash uses $(( )) for arithmetic.
+	(sh-while-getopts) <sh>: Set OPTIND back to 1 at end.
+	(sh-maybe-here-document): Remove quotes and leading whitespace
+	from heredoc word when closing.  Indent heredoc with tabs if word
+	starts with "-".
+
+2005-04-13  Richard M. Stallman  <rms@gnu.org>
+
+	* simple.el (undo): Fix previous change.
+
+	* custom.el (defface): Doc fix.
+
+2005-04-13  Lute Kamstra  <lute@gnu.org>
+
+	* Makefile.in (DONTCOMPILE): Remove list.
+	(compile, compile-always): Don't use DONTCOMPILE.
+	(update-authors): Load the library in which batch-update-authors
+	is defined.
+	* makefile.w32-in (DONTCOMPILE): Remove list.
+	(compile, compile-always): Fix comments.
+	(update-authors): Load the library in which batch-update-authors
+	is defined.
+
+	* generic-x.el (generic-mode-ini-file-find-file-hook):
+	Rename to ini-generic-mode-find-file-hook.
+	Keep generic-mode-ini-file-find-file-hook as an alias.
+	(ini-generic-mode-find-file-hook): Rename from
+	generic-mode-ini-file-find-file-hook.  Fix docstring.
+	(ini-generic-mode): Docstring change.
+	(bat-generic-mode-run-as-comint): Silence the byte compiler.
+
+	* help.el (describe-key-briefly): UNTRANSLATED can be nil when
+	called from lisp.
+
+	* generic.el: Move to the emacs-lisp subdir.
+
+2005-04-12  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* term/xterm.el (function-key-map): Add mappings for A-, C-, S-
+	and C-S- function and cursor motion keys.
+
+2005-04-12  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* startup.el (command-line): Enable Xterm Mouse mode by default.
+	* xt-mouse.el (xterm-mouse-mode): Provide correct standard value
+	for Custom.  No longer show "Mouse" in mode line when enabled.
+	Doc fix.
+
+2005-04-12  Kim F. Storm  <storm@cua.dk>
+
+	* emulation/cua-base.el (cua-rectangle-face)
+	(cua-rectangle-noselect-face): Define face attributes here.
+
+	* emulation/cua-rect.el (cua--init-rectangles): Remove face setup.
+
+2005-04-12  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* startup.el (command-line): Turn off blinking cursor if
+	cursorBlink in resources is off or false.
+
+2005-04-12  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* term/mac-win.el (dnd): Require dnd.
+	(mac-drag-n-drop): Call dnd-handle-one-url.
+	(kTextEncodingMacRoman, kTextEncodingISOLatin1)
+	(kTextEncodingISOLatin2): Remove constants.
+	(mac-script-code-coding-systems): New constant.
+	(mac-handle-language-change): New function.
+	(special-event-map): Bind it to `language-change' event.
+	(mac-centraleurroman, mac-cyrillic): New coding systems.
+	(mac-font-encoder-list, ccl-encode-mac-centraleurroman-font)
+	(ccl-encode-mac-cyrillic-font): Rename mac-centraleurroman-encoder
+	and mac-cyrillic-encoder to encode-mac-centraleurroman and
+	encode-mac-cyrillic, respectively.
+
+2005-04-12  Nick Roberts  <nickrob@snap.net.nz>
+
+	* progmodes/gud.el, progmodes/gdb-ui.el (gdb-assembler-mode):
+	Don't set overlay-arrow-string to "=>" as this is done
+	globally in C now.
+
+2005-04-12  Lute Kamstra  <lute@gnu.org>
+
+	* generic-x.el (rc-generic-mode, rul-generic-mode):
+	Fix auto-mode-alist entries.
+	(etc-fstab-generic-mode): Tweak fontification.
+
+	* generic.el (generic-make-keywords-list): Fix docstring.
+	(generic-mode-internal): Simplify generic-font-lock-keywords.
+
+2005-04-11  Rajesh Vaidheeswarran  <rv@gnu.org>
+
+	* whitespace.el (whitespace-buffer-leading)
+	(whitespace-buffer-trailing): Revert the incorrect test
+	inversion. However, fix the highlight area for the leading and
+	trailing whitespaces to show space.
+
+2005-04-11  Rajesh Vaidheeswarran  <rv@gnu.org>
+
+	* whitespace.el (whitespace-version): Bump to 3.5
+
+	(whitespace-buffer-leading, whitespace-buffer-trailing):
+	Invert sense of the test to highlight the whitespace.
+
+2005-04-12  Nick Roberts  <nickrob@snap.net.nz>
+
+	* progmodes/gud.el (gud-display-line): GUD uses its own
+	overlay arrow now so don't set overlay-arrow-string.
+	(gud-pdb-command-name): Revert back to "pdb" (2004-04-26).
+
+2005-04-11  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* term.el (term-ansi-current-bold, term-ansi-current-underline)
+	(term-ansi-current-reverse, term-ansi-current-invisible)
+	(term-ansi-face-already-done): Change to boolean.
+	(term-reset-terminal, term-handle-colors-array): Handle the above
+	vars accordingly.
+	(term-buffer-vertical-motion): Rename from buffer-vertical-motion.
+	(term-emulate-terminal): Use the new name.
+
+	* faces.el (secondary-selection): Use yellow1, not yellow.
+	(trailing-whitespace): Use red1, not red.
+
+2005-04-11  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* dired.el (dired-mode): Use dnd-* instead of x-dnd-*
+	(dired-dnd-handle-local-file): Call dnd-get-local-file-name.
+	(dired-dnd-handle-file): Call dnd-get-local-file-uri
+
+	* cus-edit.el (dnd): New group.
+
+	* term/w32-win.el (dnd): Require dnd
+	(w32-drag-n-drop): Call dnd-handle-one-url.
+
+	* x-dnd.el: Require dnd.
+	(x-dnd-handle-uri-list, x-dnd-handle-file-name):
+	Call dnd-handle-one-url.
+	(x-dnd-types-alist, x-dnd-insert-utf8-text)
+	(x-dnd-insert-utf16-text, x-dnd-insert-ctext): Change x-dnd-insert-text
+	to dnd-insert-text.
+	(x-dnd-protocol-alist, x-dnd-open-file-other-window)
+	(x-dnd-handle-one-url, x-dnd-get-local-file-uri)
+	(x-dnd-get-local-file-name,  x-dnd-open-local-file)
+	(x-dnd-open-file, x-dnd-insert-text): Move to dnd.el (without x-).
+
+	* dnd.el (dnd-protocol-alist): New file with generic DND functions.
+
+2005-04-11  JUAN-LEON Lahoz Garcia  <juanleon1@gmail.com>
+
+	* wdired.el: Doc fixes.
+	(wdired-confirm-overwrite): Rename from wdired-is-ok-overwrite.
+	(wdired-use-dired-vertical-movement): Rename from
+	wdired-always-move-to-filename-beginning.
+	(wdired-mode-map): Use `ignore' instead of `wdired-newline'.
+	(wdired-change-to-wdired-mode): Change mode name.
+	(wdired-newline): Delete.
+
+2005-04-11  Richard M. Stallman  <rms@gnu.org>
+
+	* whitespace.el (whitespace-highlight-the-space):
+	Don't call whitespace-unhighlight-the-space here.
+
+	* simple.el (undo): Record t in undo-equiv-table
+	for the redo record made by an undo-in-region.
+
+2005-04-12  Nick Roberts  <nickrob@snap.net.nz>
+
+	* progmodes/gdb-ui.el (gdb-display-inferior-io-buffer)
+	(gdb-frame-inferior-io-buffer): New Functions to control
+	display of separate IO buffer.
+	(menu): Add them to menu-bar.
+	(gdb-display-buffer): Check for buffer another frame.
+	Protect GUD buffer.
+	(gdb-setup-windows): Create IO buffer if not already there.
+	(gdb-memory-mode): Remove purecopy noops.
+
+2005-04-11  Glenn Morris  <gmorris@ast.cam.ac.uk>
+
+	* progmodes/f90.el (f90-electric-insert): Add optional prefix arg,
+	and pass to self-insert-command.
+
+2005-04-11  Lute Kamstra  <lute@gnu.org>
+
+	* generic.el: Commentary section cleanup.
+	(generic): Delete.
+	(generic-use-find-file-hook, generic-lines-to-scan)
+	(generic-find-file-regexp, generic-ignore-files-regexp)
+	(default-generic-mode, generic-mode-find-file-hook)
+	(generic-mode-ini-file-find-file-hook): Move to generic-x.el.
+	* generic-x.el (generic-x): Docstring fix.  Put it in the data group.
+	(generic-use-find-file-hook, generic-lines-to-scan)
+	(generic-find-file-regexp, generic-ignore-files-regexp)
+	(default-generic-mode, generic-mode-find-file-hook)
+	(generic-mode-ini-file-find-file-hook): Move from generic.el.
+
 2005-04-10  Karl Fogel  <kfogel@red-bean.com>
 
 	* bookmark.el (bookmark-write-file): Catch errors writing file.
@@ -74,8 +428,8 @@
 
 2005-04-09  Richard M. Stallman  <rms@gnu.org>
 
-	* help.el (describe-key-briefly, describe-key): Replace
-	strings as event types with "(any string)".
+	* help.el (describe-key-briefly, describe-key):
+	Replace strings as event types with "(any string)".
 
 2005-04-09  Stefan Monnier  <monnier@iro.umontreal.ca>
 
@@ -188,8 +542,7 @@
 
 2005-04-08  Kim F. Storm  <storm@cua.dk>
 
-	* buff-menu.el (Buffer-menu-mode-map): Map follow-link to
-	mouse-face.
+	* buff-menu.el (Buffer-menu-mode-map): Map follow-link to mouse-face.
 
 	* mouse.el (mouse-on-link-p): Doc fix.
 
--- a/lisp/Makefile.in	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/Makefile.in	Mon Apr 18 13:40:23 2005 +0000
@@ -1,5 +1,5 @@
 # Maintenance productions for the Lisp directory
-# Copyright (C) 2000, 01, 03, 2004  Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
@@ -39,77 +39,6 @@
 lisptagsfiles2 = $(lisp)/[a-zA-Z]*/[a-zA-Z]*.el
 ETAGS = ../lib-src/etags
 
-# Files which should not be compiled.  If you change the name `DONTCOMPILE'
-# to something different, you'll have to change make-dist as well, and
-# modify the lists in $lisp and $shortlisp on src/Makefile.in.
-#
-# - emacs-lisp/cl-specs.el:  only contains `def-edebug-spec's so there's
-#   no point compiling it, although it doesn't hurt.
-
-DONTCOMPILE = \
-	$(lisp)/cus-load.el \
-	$(lisp)/emacs-lisp/cl-specs.el \
-	$(lisp)/eshell/esh-maint.el \
-	$(lisp)/eshell/esh-groups.el \
-	$(lisp)/finder-inf.el \
-	$(lisp)/forms-d2.el \
-	$(lisp)/forms-pass.el \
-	$(lisp)/generic-x.el \
-	$(lisp)/international/latin-1.el \
-	$(lisp)/international/latin-2.el \
-	$(lisp)/international/latin-3.el \
-	$(lisp)/international/latin-4.el \
-	$(lisp)/international/latin-5.el \
-	$(lisp)/international/latin-8.el \
-	$(lisp)/international/latin-9.el \
-	$(lisp)/international/mule-conf.el \
-	$(lisp)/language/czech.el \
-	$(lisp)/language/devanagari.el \
-	$(lisp)/language/malayalam.el \
-	$(lisp)/language/tamil.el \
-	$(lisp)/language/kannada.el \
-	$(lisp)/language/english.el \
-	$(lisp)/language/greek.el \
-	$(lisp)/language/hebrew.el \
-	$(lisp)/language/japanese.el \
-	$(lisp)/language/korean.el \
-	$(lisp)/language/lao.el \
-	$(lisp)/language/misc-lang.el \
-	$(lisp)/language/romanian.el \
-	$(lisp)/language/slovak.el \
-	$(lisp)/language/thai.el \
-	$(lisp)/language/utf-8-lang.el \
-	$(lisp)/language/georgian.el \
-	$(lisp)/loaddefs.el \
-	$(lisp)/ldefs-boot.el \
-	$(lisp)/loadup.el \
-	$(lisp)/mail/blessmail.el \
-	$(lisp)/patcomp.el \
-	$(lisp)/paths.el \
-	$(lisp)/play/bruce.el \
-	$(lisp)/subdirs.el \
-	$(lisp)/term/internal.el \
-	$(lisp)/term/AT386.el  \
-	$(lisp)/term/apollo.el \
-	$(lisp)/term/bobcat.el \
-	$(lisp)/term/iris-ansi.el \
-	$(lisp)/term/keyswap.el \
-	$(lisp)/term/linux.el \
-	$(lisp)/term/lk201.el \
-	$(lisp)/term/news.el \
-	$(lisp)/term/vt102.el \
-	$(lisp)/term/vt125.el \
-	$(lisp)/term/vt200.el \
-	$(lisp)/term/vt201.el \
-	$(lisp)/term/vt220.el \
-	$(lisp)/term/vt240.el \
-	$(lisp)/term/vt300.el \
-	$(lisp)/term/vt320.el \
-	$(lisp)/term/vt400.el \
-	$(lisp)/term/vt420.el \
-	$(lisp)/term/wyse50.el \
-	$(lisp)/version.el
-
 # Elisp files auto-generated.
 AUTOGENEL = loaddefs.el \
 	cus-load.el \
@@ -192,7 +121,7 @@
 # Update the AUTHORS file.
 
 update-authors:
-	$(emacs) -f batch-update-authors $(srcdir)/AUTHORS $(srcdir)
+	$(emacs) -l authors -f batch-update-authors $(srcdir)/AUTHORS $(srcdir)
 
 TAGS: $(lisptagsfiles1) $(lisptagsfiles2)
 	els=`echo $(lisptagsfiles1) $(lisptagsfiles2) | sed -e "s,$(lisp)/loaddefs[^ ]*,," -e "s,$(lisp)/ldefs-boot[^ ]*,,"`; \
@@ -207,31 +136,23 @@
 .el.elc: $(lisp)/subdirs.el
 	-$(emacs) -f batch-byte-compile $<
 
-$(DONTCOMPILE:.el=.elc):
-	-rm -f $@
-
-# Compile all Lisp files, except those from DONTCOMPILE,
-# but don't recompile those that are up to date.
+# Compile all Lisp files, but don't recompile those that are up to
+# date.  Some files don't actually get compiled because they set the
+# local variable no-byte-compile.
 
-# All .elc files are made writable
-# before compilation in case we checked out read-only (CVS option -r).
-# Files MUST be compiled one by one.  If we compile several files in a
-# row we can't make sure that the compilation environment is clean.
-# We also set the load-path of the Emacs used for compilation to the
-# current directory and its subdirectories, to make sure require's and
-# load's in the files being compiled find the right files.
-
-# NOTE about DONTCOMPILE: in the `echo <foo> | sort | uniq -u' we pass
-# $(DONTCOMPILE) twice.  This is in case one of the files in DONTCOMPILE
-# is absent.  -stef
+# All .elc files are made writable before compilation in case we
+# checked out read-only (CVS option -r).  Files MUST be compiled one by
+# one.  If we compile several files in a row we can't make sure that
+# the compilation environment is clean.  We also set the load-path of
+# the Emacs used for compilation to the current directory and its
+# subdirectories, to make sure require's and load's in the files being
+# compiled find the right files.
 
 compile: $(lisp)/subdirs.el doit
 	find $(lisp) -name "*.elc" -print | xargs chmod +w >/dev/null 2>&1; \
 	wd=$(lisp); $(setwins);	\
-	elpat=`echo $$wins | tr ' 	' '\012\012' | \
+	els=`echo $$wins | tr ' \011' '\012\012' | \
 		sed -e 's|\(.\)$$|\1/|' -e 's|^\./||' -e 's|$$|*.el|'`;	\
-	els=`echo $$elpat $(DONTCOMPILE) $(DONTCOMPILE) $(COMPILE_FIRST) | \
-		tr '	 ' '\012\012' | sort | uniq -u`; \
 	for el in $(COMPILE_FIRST) $$els; do \
 	  if test -f $$el; \
 	  then \
@@ -240,17 +161,17 @@
 	  fi \
 	done
 
-# Compile all Lisp files, except those from DONTCOMPILE.  This
-# is like `compile' but compiles files unconditionally.
+# Compile all Lisp files.  This is like `compile' but compiles files
+# unconditionally.  Some files don't actually get compiled because they
+# set the local variable no-byte-compile.
+
 compile-always: $(lisp)/subdirs.el doit
 	# `|| true' prevents old Bash versions from getting confused
 	# by an error.
 	find $(lisp) -name "*.elc" -print | xargs chmod +w >/dev/null 2>&1 || true; \
 	wd=$(lisp); $(setwins);	\
-	elpat=`echo $$wins | tr ' 	' '\012\012' | \
+	els=`echo $$wins | tr ' \011' '\012\012' | \
 		sed -e 's|\(.\)$$|\1/|' -e 's|^\./||' -e 's|$$|*.el|'`;	\
-	els=`echo $$elpat $(DONTCOMPILE) $(DONTCOMPILE) $(COMPILE_FIRST) | \
-		tr '	 ' '\012\012' | sort | uniq -u`; \
 	for el in $(COMPILE_FIRST) $$els; do \
 	  if test -f $$el; \
 	  then \
--- a/lisp/comint.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/comint.el	Mon Apr 18 13:40:23 2005 +0000
@@ -1701,7 +1701,10 @@
 	      ;; Interpret any carriage motion characters (newline, backspace)
 	      (comint-carriage-motion comint-last-output-start (point)))
 
+	    ;; Run these hooks with point where the user had it.
+	    (goto-char saved-point)
 	    (run-hook-with-args 'comint-output-filter-functions string)
+	    (set-marker saved-point (point))
 
 	    (goto-char (process-mark process)) ; in case a filter moved it
 
--- a/lisp/cus-edit.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/cus-edit.el	Mon Apr 18 13:40:23 2005 +0000
@@ -433,6 +433,10 @@
   "Input from the menus."
   :group 'environment)
 
+(defgroup dnd nil
+  "Handling data from drag and drop."
+  :group 'environment)
+
 (defgroup auto-save nil
   "Preventing accidential loss of data."
   :group 'files)
--- a/lisp/cus-theme.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/cus-theme.el	Mon Apr 18 13:40:23 2005 +0000
@@ -119,7 +119,7 @@
 		(princ " '(")
 		(prin1 symbol)
 		(princ " ")
-		(prin1 (symbol-value symbol))
+		(prin1 (custom-quote (symbol-value symbol)))
 		(princ ")")))
 	      vars)
       (if (bolp)
--- a/lisp/custom.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/custom.el	Mon Apr 18 13:40:23 2005 +0000
@@ -287,9 +287,18 @@
 
 SPEC should be an alist of the form ((DISPLAY ATTS)...).
 
-The first element of SPEC where the DISPLAY matches the frame
-is the one that takes effect in that frame.  The ATTRs in this
-element take effect; the other elements are ignored, on that frame.
+In the first element, DISPLAY can be :default.  The ATTS in that
+element then act as defaults for all the following elements.
+
+Aside from that, DISPLAY specifies conditions to match some or
+all frames.  For each frame, the first element of SPEC where the
+DISPLAY conditions are satisfied is the one that applies to that
+frame.  The ATTRs in this element take effect, and the following
+elements are ignored, on that frame.
+
+In the last element, DISPLAY can be t.  That element applies to a
+frame if none of the previous elements (except the :default if
+any) did.
 
 ATTS is a list of face attributes followed by their values:
   (ATTR VALUE ATTR VALUE...)
@@ -298,11 +307,12 @@
 `:slant', `:underline', `:overline', `:strike-through', `:box',
 `:foreground', `:background', `:stipple', `:inverse-video', and `:inherit'.
 
-DISPLAY can either be the symbol t, which will match all frames, or an
-alist of elements of the form \(REQ ITEM...).  For the DISPLAY to match a
-FRAME, each of these elements must be satisfied, meaning that the
-REQ property of the frame must match one of the corresponding ITEMs.
-These are the defined REQ values:
+DISPLAY can be `:default' (only in the first element), the symbol
+t (only in the last element) to match all frames, or an alist of
+conditions of the form \(REQ ITEM...).  For such an alist to
+match a frame, each of the conditions must be satisfied, meaning
+that the REQ property of the frame must match one of the
+corresponding ITEMs.  These are the defined REQ values:
 
 `type' (the value of `window-system')
   Under X, in addition to the values `window-system' can take,
--- a/lisp/dired.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/dired.el	Mon Apr 18 13:40:23 2005 +0000
@@ -1523,15 +1523,13 @@
   (setq dired-switches-alist nil)
   (dired-sort-other dired-actual-switches t)
   (run-mode-hooks 'dired-mode-hook)
-  (when (featurep 'x-dnd)
-    (make-variable-buffer-local 'x-dnd-test-function)
-    (make-variable-buffer-local 'x-dnd-protocol-alist)
-    (setq x-dnd-test-function 'dired-dnd-test-function)
-    (setq x-dnd-protocol-alist
+  (when (featurep 'dnd)
+    (make-variable-buffer-local 'dnd-protocol-alist)
+    (setq dnd-protocol-alist
 	  (append '(("^file:///" . dired-dnd-handle-local-file)
 		    ("^file://"  . dired-dnd-handle-file)
 		    ("^file:"    . dired-dnd-handle-local-file))
-		  x-dnd-protocol-alist))))
+		  dnd-protocol-alist))))
 
 ;; Idiosyncratic dired commands that don't deal with marks.
 
@@ -3136,18 +3134,6 @@
 		 (const :tag "Copy directories without asking" always))
   :group 'dired)
 
-(defun dired-dnd-test-function (window action types)
-  "The test function for drag and drop into dired buffers.
-WINDOW is where the mouse is when this function is called.  It may be a frame
-if the mouse is over the menu bar, scroll bar or tool bar.
-ACTION is the suggested action from the source, and TYPES are the
-types the drop data can have.  This function only accepts drops with
-types in `x-dnd-known-types'.  It returns the action suggested by the source."
-  (let ((type (x-dnd-choose-type types)))
-    (if type
-	(cons action type)
-      nil)))
-
 (defun dired-dnd-popup-notice ()
   (x-popup-dialog
    t
@@ -3176,7 +3162,7 @@
 URI is the file to handle, ACTION is one of copy, move, link or ask.
 Ask means pop up a menu for the user to select one of copy, move or link."
   (require 'dired-aux)
-  (let* ((from (x-dnd-get-local-file-name uri t))
+  (let* ((from (dnd-get-local-file-name uri t))
 	 (to (if from (concat (dired-current-directory)
 			   (file-name-nondirectory from))
 	       nil)))
@@ -3214,7 +3200,7 @@
 URI is the file to handle.  If the hostname in the URI isn't local, do nothing.
 ACTION is one of copy, move, link or ask.
 Ask means pop up a menu for the user to select one of copy, move or link."
-  (let ((local-file (x-dnd-get-local-file-uri uri)))
+  (let ((local-file (dnd-get-local-file-uri uri)))
     (if local-file (dired-dnd-handle-local-file local-file action)
       nil)))
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/dnd.el	Mon Apr 18 13:40:23 2005 +0000
@@ -0,0 +1,192 @@
+;;; dnd.el --- drag and drop support.
+
+;; Copyright (C) 2005
+;;  Free Software Foundation, Inc.
+
+;; Author: Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
+;; Maintainer: FSF
+;; Keywords: window, drag, drop
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; This file provides the generic handling of the drop part only.
+;; Different DND backends (X11, W32, etc.) that handle the platform
+;; specific DND parts call the functions here to do final delivery of
+;; a drop.
+
+;;; Code:
+
+;;; Customizable variables
+
+
+(defcustom dnd-protocol-alist
+  '(
+    ("^file:///" . dnd-open-local-file)	; XDND format.
+    ("^file://"  . dnd-open-file)	; URL with host
+    ("^file:"    . dnd-open-local-file)	; Old KDE, Motif, Sun
+    )
+
+  "The functions to call for different protocols when a drop is made.
+This variable is used by `dnd-handle-one-url' and `dnd-handle-file-name'.
+The list contains of (REGEXP . FUNCTION) pairs.
+The functions shall take two arguments, URL, which is the URL dropped and
+ACTION which is the action to be performed for the drop (move, copy, link,
+private or ask).
+If no match is found here, and the value of `browse-url-browser-function'
+is a pair of (REGEXP . FUNCTION), those regexps are tried for a match.
+If no match is found, the URL is inserted as text by calling `dnd-insert-text'.
+The function shall return the action done (move, copy, link or private)
+if some action was made, or nil if the URL is ignored."
+  :version "22.1"
+  :type 'alist
+  :group 'dnd)
+
+
+
+(defcustom dnd-open-file-other-window nil
+  "If non-nil, always use find-file-other-window to open dropped files."
+  :version "22.1"
+  :type 'boolean
+  :group 'dnd)
+
+
+;; Functions
+
+(defun dnd-handle-one-url (window action arg)
+  "Handle one dropped url by calling the appropriate handler.
+The handler is first located by looking at `dnd-protocol-alist'.
+If no match is found here, and the value of `browse-url-browser-function'
+is a pair of (REGEXP . FUNCTION), those regexps are tried for a match.
+If no match is found, just call `dnd-insert-text'.
+WINDOW is where the drop happend, ACTION is the action for the drop,
+ARG is the URL that has been dropped.
+Returns ACTION."
+  (require 'browse-url)
+  (let* ((uri (replace-regexp-in-string
+	       "%[A-Z0-9][A-Z0-9]"
+	       (lambda (arg)
+		 (format "%c" (string-to-number (substring arg 1) 16)))
+	       arg))
+	 ret)
+    (or
+     (catch 'done
+       (dolist (bf dnd-protocol-alist)
+	 (when (string-match (car bf) uri)
+	   (setq ret (funcall (cdr bf) uri action))
+	   (throw 'done t)))
+       nil)
+     (when (not (functionp browse-url-browser-function))
+       (catch 'done
+	 (dolist (bf browse-url-browser-function)
+	   (when (string-match (car bf) uri)
+	     (setq ret 'private)
+	     (funcall (cdr bf) uri action)
+	     (throw 'done t)))
+	 nil))
+     (progn
+       (dnd-insert-text window action uri)
+       (setq ret 'private)))
+    ret))
+
+
+(defun dnd-get-local-file-uri (uri)
+  "Return an uri converted to file:/// syntax if uri is a local file.
+Return nil if URI is not a local file."
+
+  ;; The hostname may be our hostname, in that case, convert to a local
+  ;; file.  Otherwise return nil.  TODO:  How about an IP-address as hostname?
+  (let ((hostname (when (string-match "^file://\\([^/]*\\)" uri)
+		      (downcase (match-string 1 uri))))
+	(system-name-no-dot
+	 (downcase (if (string-match "^[^\\.]+" system-name)
+		       (match-string 0 system-name)
+		     system-name))))
+    (when (and hostname
+	     (or (string-equal "localhost" hostname)
+		 (string-equal (downcase system-name) hostname)
+		 (string-equal system-name-no-dot hostname)))
+	(concat "file://" (substring uri (+ 7 (length hostname)))))))
+
+(defun dnd-get-local-file-name (uri &optional must-exist)
+  "Return file name converted from file:/// or file: syntax.
+URI is the uri for the file.  If MUST-EXIST is given and non-nil,
+only return non-nil if the file exists.
+Return nil if URI is not a local file."
+  (let ((f (cond ((string-match "^file:///" uri)	; XDND format.
+		  (substring uri (1- (match-end 0))))
+		 ((string-match "^file:" uri)		; Old KDE, Motif, Sun
+		  (substring uri (match-end 0))))))
+    (when (and f must-exist)
+      (let* ((decoded-f (decode-coding-string
+			 f
+			 (or file-name-coding-system
+			     default-file-name-coding-system)))
+	     (try-f (if (file-readable-p decoded-f) decoded-f f)))
+	(when (file-readable-p try-f) try-f)))))
+
+
+(defun dnd-open-local-file (uri action)
+  "Open a local file.
+The file is opened in the current window, or a new window if
+`dnd-open-file-other-window' is set.  URI is the url for the file,
+and must have the format file:file-name or file:///file-name.
+The last / in file:/// is part of the file name.  ACTION is ignored."
+
+  (let* ((f (dnd-get-local-file-name uri t)))
+    (if (and f (file-readable-p f))
+	(progn
+	  (if dnd-open-file-other-window
+	      (find-file-other-window f)
+	    (find-file f))
+	  'private)
+      (error "Can not read %s" uri))))
+
+(defun dnd-open-file (uri action)
+  "Open a local or remote file.
+The file is opened in the current window, or a new window if
+`dnd-open-file-other-window' is set.  URI is the url for the file,
+and must have the format file://hostname/file-name.  ACTION is ignored.
+The last / in file://hostname/ is part of the file name."
+
+  ;; The hostname may be our hostname, in that case, convert to a local
+  ;; file.  Otherwise return nil.
+  (let ((local-file (dnd-get-local-file-uri uri)))
+    (if local-file (dnd-open-local-file local-file action)
+      (error "Remote files not supported"))))
+
+
+(defun dnd-insert-text (window action text)
+  "Insert text at point or push to the kill ring if buffer is read only.
+TEXT is the text as a string, WINDOW is the window where the drop happened."
+  (if (or buffer-read-only
+	  (not (windowp window)))
+      (progn
+	(kill-new text)
+	(message
+	 (substitute-command-keys
+	  "The dropped text can be accessed with \\[yank]")))
+    (insert text))
+  action)
+
+
+(provide 'dnd)
+
+;; arch-tag: 0472f6a5-2e8f-4304-9e44-1a0877c771b7
+;;; dnd.el ends here
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/emacs-lisp/generic.el	Mon Apr 18 13:40:23 2005 +0000
@@ -0,0 +1,345 @@
+;;; generic.el --- defining simple major modes with comment and font-lock
+;;
+;; Copyright (C) 1997, 1999, 2004, 2005 Free Software Foundation, Inc.
+;;
+;; Author:  Peter Breton <pbreton@cs.umb.edu>
+;; Created: Fri Sep 27 1996
+;; Keywords: generic, comment, font-lock
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; INTRODUCTION:
+;;
+;; The macro `define-generic-mode' can be used to define small modes
+;; which provide basic comment and font-lock support.  These modes are
+;; intended for the many configuration files and such which are too
+;; small for a "real" mode, but still have a regular syntax, comment
+;; characters and the like.
+;;
+;; Each generic mode can define the following:
+;;
+;; * List of comment-characters.  The entries in this list should be
+;;   either a character, a one or two character string or a cons pair.
+;;   If the entry is a character or a string, it is added to the
+;;   mode's syntax table with `comment-start' syntax.  If the entry is
+;;   a cons pair, the elements of the pair are considered to be
+;;   `comment-start' and `comment-end' respectively.  (The latter
+;;   should be nil if you want comments to end at end of line.)
+;;   LIMITATIONS: Emacs does not support comment strings of more than
+;;   two characters in length.
+;;
+;; * List of keywords to font-lock.  Each keyword should be a string.
+;;   If you have additional keywords which should be highlighted in a
+;;   face different from `font-lock-keyword-face', you can use the
+;;   convenience function `generic-make-keywords-list' (which see),
+;;   and add the result to the following list:
+;;
+;; * Additional expressions to font-lock.  This should be a list of
+;;   expressions, each of which should be of the same form as those in
+;;   `font-lock-keywords'.
+;;
+;; * List of regular expressions to be placed in auto-mode-alist.
+;;
+;; * List of functions to call to do some additional setup
+;;
+;; This should pretty much cover basic functionality; if you need much
+;; more than this, or you find yourself writing extensive customizations,
+;; perhaps you should be writing a major mode instead!
+;;
+;; EXAMPLE:
+;;
+;; You can use `define-generic-mode' like this:
+;;
+;;   (define-generic-mode 'foo-generic-mode
+;;     (list ?%)
+;;     (list "keyword")
+;;     nil
+;;     (list "\\.FOO\\'")
+;;     (list 'foo-setup-function))
+;;
+;; to define a new generic-mode `foo-generic-mode', which has '%' as a
+;; comment character, and "keyword" as a keyword.  When files which
+;; end in '.FOO' are loaded, Emacs will go into foo-generic-mode and
+;; call foo-setup-function.  You can also use the function
+;; `foo-generic-mode' (which is interactive) to put a buffer into
+;; foo-generic-mode.
+;;
+;; GOTCHAS:
+;;
+;; Be careful that your font-lock definitions are correct.  Getting
+;; them wrong can cause Emacs to continually attempt to fontify! This
+;; problem is not specific to generic-mode.
+
+;; Credit for suggestions, brainstorming, help with debugging:
+;;   ACorreir@pervasive-sw.com (Alfred Correira)
+;; Extensive cleanup by:
+;;   Stefan Monnier (monnier+gnu/emacs@flint.cs.yale.edu)
+
+;;; Code:
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Internal Variables
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defvar generic-font-lock-keywords nil
+  "Keywords for `font-lock-defaults' in a generic mode.")
+(make-variable-buffer-local 'generic-font-lock-keywords)
+(defvaralias 'generic-font-lock-defaults 'generic-font-lock-keywords)
+(make-obsolete-variable 'generic-font-lock-defaults 'generic-font-lock-keywords "22.1")
+
+;;;###autoload
+(defvar generic-mode-list nil
+  "A list of mode names for `generic-mode'.
+Do not add entries to this list directly; use `define-generic-mode'
+instead (which see).")
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Functions
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;;###autoload
+(defmacro define-generic-mode (mode comment-list keyword-list
+				    font-lock-list auto-mode-list
+				    function-list &optional docstring
+				    &rest custom-keyword-args)
+  "Create a new generic mode MODE.
+
+MODE is the name of the command for the generic mode; it need not
+be quoted.  The optional DOCSTRING is the documentation for the
+mode command.  If you do not supply it, a default documentation
+string will be used instead.
+
+COMMENT-LIST is a list, whose entries are either a single
+character, a one or two character string or a cons pair.  If the
+entry is a character or a string, it is added to the mode's
+syntax table with `comment-start' syntax.  If the entry is a cons
+pair, the elements of the pair are considered to be
+`comment-start' and `comment-end' respectively.  (The latter
+should be nil if you want comments to end at end of line.)  Note
+that Emacs has limitations regarding comment characters.
+
+KEYWORD-LIST is a list of keywords to highlight with
+`font-lock-keyword-face'.  Each keyword should be a string.
+
+FONT-LOCK-LIST is a list of additional expressions to highlight.
+Each entry in the list should have the same form as an entry in
+`font-lock-keywords'.
+
+AUTO-MODE-LIST is a list of regular expressions to add to
+`auto-mode-alist'.  These regexps are added to `auto-mode-alist'
+as soon as `define-generic-mode' is called.
+
+FUNCTION-LIST is a list of functions to call to do some
+additional setup.
+
+The optional CUSTOM-KEYWORD-ARGS are pairs of keywords and
+values.  They will be passed to the generated `defcustom' form of
+the mode hook variable MODE-hook.  Defaults to MODE without the
+possible trailing \"-mode\".  (This default may not be a valid
+customization group defined with `defgroup'.  Make sure it is.)
+You can specify keyword arguments without specifying a docstring.
+
+See the file generic-x.el for some examples of `define-generic-mode'."
+  (declare (debug (sexp def-form def-form def-form form def-form
+			[&optional stringp] &rest [keywordp form]))
+	   (indent 1))
+
+  ;; Backward compatibility.
+  (when (eq (car-safe mode) 'quote)
+    (setq mode (eval mode)))
+
+  (when (and docstring (not (stringp docstring)))
+    ;; DOCSTRING is not a string so we assume that it's actually the
+    ;; first keyword of CUSTOM-KEYWORD-ARGS.
+    (push docstring custom-keyword-args)
+    (setq docstring nil))
+
+  (let* ((name (symbol-name mode))
+	 (pretty-name (capitalize (replace-regexp-in-string
+				   "-mode\\'" "" name)))
+	 (mode-hook (intern (concat name "-hook"))))
+
+    (unless (plist-get custom-keyword-args :group)
+      (setq custom-keyword-args
+	    (plist-put custom-keyword-args 
+		       :group `',(intern (replace-regexp-in-string
+					  "-mode\\'" "" name)))))
+
+    `(progn
+       ;; Add a new entry.
+       (add-to-list 'generic-mode-list ,name)
+
+       ;; Add it to auto-mode-alist
+       (dolist (re ,auto-mode-list)
+	 (add-to-list 'auto-mode-alist (cons re ',mode)))
+
+       (defcustom ,mode-hook nil
+	 ,(concat "Hook run when entering " pretty-name " mode.")
+	 :type 'hook
+	 ,@custom-keyword-args)
+
+       (defun ,mode ()
+	 ,(or docstring
+	      (concat pretty-name " mode.\n"
+		      "This a generic mode defined with `define-generic-mode'."))
+	 (interactive)
+	 (generic-mode-internal ',mode ,comment-list ,keyword-list
+				,font-lock-list ,function-list)))))
+
+;;;###autoload
+(defun generic-mode-internal (mode comment-list keyword-list
+				   font-lock-list function-list)
+  "Go into the generic mode MODE."
+  (let* ((name (symbol-name mode))
+	 (pretty-name (capitalize (replace-regexp-in-string
+				   "-mode\\'" "" name)))
+	 (mode-hook (intern (concat name "-hook"))))
+
+    (kill-all-local-variables)
+
+    (setq major-mode mode
+	  mode-name pretty-name)
+
+    (generic-mode-set-comments comment-list)
+
+    ;; Font-lock functionality.
+    ;; Font-lock-defaults is always set even if there are no keywords
+    ;; or font-lock expressions, so comments can be highlighted.
+    (setq generic-font-lock-keywords font-lock-list)
+    (when keyword-list
+      (push (concat "\\_<" (regexp-opt keyword-list t) "\\_>")
+	    generic-font-lock-keywords))
+    (setq font-lock-defaults '(generic-font-lock-keywords nil))
+
+    ;; Call a list of functions
+    (mapcar 'funcall function-list)
+
+    (run-mode-hooks mode-hook)))
+
+;;;###autoload
+(defun generic-mode (mode)
+  "Enter generic mode MODE.
+
+Generic modes provide basic comment and font-lock functionality
+for \"generic\" files.  (Files which are too small to warrant their
+own mode, but have comment characters, keywords, and the like.)
+
+To define a generic-mode, use the function `define-generic-mode'.
+Some generic modes are defined in `generic-x.el'."
+  (interactive
+   (list (completing-read "Generic mode: " generic-mode-list nil t)))
+  (funcall (intern mode)))
+
+;;; Comment Functionality
+(defun generic-mode-set-comments (comment-list)
+  "Set up comment functionality for generic mode."
+  (let ((st (make-syntax-table))
+	(chars nil)
+	(comstyles))
+    (make-local-variable 'comment-start)
+    (make-local-variable 'comment-start-skip)
+    (make-local-variable 'comment-end)
+
+    ;; Go through all the comments
+    (dolist (start comment-list)
+      (let (end (comstyle ""))
+	;; Normalize
+	(when (consp start)
+	  (setq end (cdr start))
+	  (setq start (car start)))
+	(when (char-valid-p start) (setq start (char-to-string start)))
+	(cond
+	 ((char-valid-p end)   (setq end (char-to-string end)))
+	 ((zerop (length end)) (setq end "\n")))
+
+	;; Setup the vars for `comment-region'
+	(if comment-start
+	    ;; We have already setup a comment-style, so use style b
+	    (progn
+	      (setq comstyle "b")
+	      (setq comment-start-skip
+		    (concat comment-start-skip "\\|" (regexp-quote start) "+\\s-*")))
+	  ;; First comment-style
+	  (setq comment-start start)
+	  (setq comment-end (if (string-equal end "\n") "" end))
+	  (setq comment-start-skip (concat (regexp-quote start) "+\\s-*")))
+
+       ;; Reuse comstyles if necessary
+       (setq comstyle
+             (or (cdr (assoc start comstyles))
+                 (cdr (assoc end comstyles))
+                 comstyle))
+       (push (cons start comstyle) comstyles)
+       (push (cons end comstyle) comstyles)
+
+	;; Setup the syntax table
+	(if (= (length start) 1)
+	    (modify-syntax-entry (string-to-char start)
+				 (concat "< " comstyle) st)
+	  (let ((c0 (elt start 0)) (c1 (elt start 1)))
+	    ;; Store the relevant info but don't update yet
+	    (push (cons c0 (concat (cdr (assoc c0 chars)) "1")) chars)
+	    (push (cons c1 (concat (cdr (assoc c1 chars))
+				   (concat "2" comstyle))) chars)))
+	(if (= (length end) 1)
+	    (modify-syntax-entry (string-to-char end)
+				 (concat ">" comstyle) st)
+	  (let ((c0 (elt end 0)) (c1 (elt end 1)))
+	    ;; Store the relevant info but don't update yet
+	    (push (cons c0 (concat (cdr (assoc c0 chars))
+				   (concat "3" comstyle))) chars)
+	    (push (cons c1 (concat (cdr (assoc c1 chars)) "4")) chars)))))
+
+    ;; Process the chars that were part of a 2-char comment marker
+    (dolist (cs (nreverse chars))
+      (modify-syntax-entry (car cs)
+			   (concat (char-to-string (char-syntax (car cs)))
+				   " " (cdr cs))
+			   st))
+    (set-syntax-table st)))
+
+(defun generic-bracket-support ()
+  "Imenu support for [KEYWORD] constructs found in INF, INI and Samba files."
+  (setq imenu-generic-expression
+	'((nil "^\\[\\(.*\\)\\]" 1))
+        imenu-case-fold-search t))
+
+;;;###autoload
+(defun generic-make-keywords-list (keyword-list face &optional prefix suffix)
+  "Return a `font-lock-keywords' construct that highlights KEYWORD-LIST.
+KEYWORD-LIST is a list of keyword strings that should be
+highlighted with face FACE.  This function calculates a regular
+expression that matches these keywords and concatenates it with
+PREFIX and SUFFIX.  Then it returns a construct based on this
+regular expression that can be used as an element of
+`font-lock-keywords'."
+  (unless (listp keyword-list)
+    (error "Keywords argument must be a list of strings"))
+  (list (concat prefix "\\_<"
+		;; Use an optimized regexp.
+		(regexp-opt keyword-list t)
+		"\\_>" suffix)
+	1
+	face))
+
+(provide 'generic)
+
+;; arch-tag: 239c1fc4-1303-48d9-9ac0-657d655669ea
+;;; generic.el ends here
--- a/lisp/emulation/cua-base.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/emulation/cua-base.el	Mon Apr 18 13:40:23 2005 +0000
@@ -384,11 +384,15 @@
   :type 'boolean
   :group 'cua)
 
-(defface cua-rectangle-face 'nil
+(defface cua-rectangle-face
+  '((default :inherit region)
+    (((class color)) :foreground "white" :background "maroon"))
   "*Font used by CUA for highlighting the rectangle."
   :group 'cua)
 
-(defface cua-rectangle-noselect-face 'nil
+(defface cua-rectangle-noselect-face
+  '((default :inherit region)
+    (((class color)) :foreground "white" :background "dimgray"))
   "*Font used by CUA for highlighting the non-selected rectangle lines."
   :group 'cua)
 
@@ -400,10 +404,10 @@
   :type 'boolean
   :group 'cua)
 
-(defface cua-global-mark-face '((((class color))
-				 :foreground "black"
-				 :background "yellow")
-				(t :bold t))
+(defface cua-global-mark-face
+  '((((min-colors 88)(class color)) :foreground "black" :background "yellow1")
+    (((class color)) :foreground "black" :background "yellow")
+    (t :bold t))
   "*Font used by CUA for highlighting the global mark."
   :group 'cua)
 
--- a/lisp/emulation/cua-rect.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/emulation/cua-rect.el	Mon Apr 18 13:40:23 2005 +0000
@@ -1402,16 +1402,6 @@
   (cua--M/H-key cua--rectangle-keymap key cmd))
 
 (defun cua--init-rectangles ()
-  (unless (face-background 'cua-rectangle-face)
-    (copy-face 'region 'cua-rectangle-face)
-    (set-face-background 'cua-rectangle-face "maroon")
-    (set-face-foreground 'cua-rectangle-face "white"))
-
-  (unless (face-background 'cua-rectangle-noselect-face)
-    (copy-face 'region 'cua-rectangle-noselect-face)
-    (set-face-background 'cua-rectangle-noselect-face "dimgray")
-    (set-face-foreground 'cua-rectangle-noselect-face "white"))
-
   (unless (eq cua-use-hyper-key 'only)
     (define-key cua--rectangle-keymap [(shift return)] 'cua-clear-rectangle-mark)
     (define-key cua--region-keymap    [(shift return)] 'cua-toggle-rectangle-mark))
--- a/lisp/faces.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/faces.el	Mon Apr 18 13:40:23 2005 +0000
@@ -2045,7 +2045,7 @@
 
 (defface secondary-selection
   '((((class color) (min-colors 88) (background light))
-     :background "yellow")
+     :background "yellow1")
     (((class color) (min-colors 88) (background dark))
      :background "SkyBlue4")
     (((class color) (min-colors 16) (background light))
@@ -2071,9 +2071,9 @@
 
 (defface trailing-whitespace
   '((((class color) (background light))
-     :background "red")
+     :background "red1")
     (((class color) (background dark))
-     :background "red")
+     :background "red1")
     (t :inverse-video t))
   "Basic face for highlighting trailing whitespace."
   :version "21.1"
--- a/lisp/files.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/files.el	Mon Apr 18 13:40:23 2005 +0000
@@ -1844,8 +1844,8 @@
      ("\\.properties\\(?:\\.[a-zA-Z0-9._-]+\\)?\\'" . conf-javaprop-mode)
      ;; *.cf, *.cfg, *.conf, *.config[.local|.de_DE.UTF8|...], */config
      ("[/.]c\\(?:on\\)?f\\(?:i?g\\)?\\(?:\\.[a-zA-Z0-9._-]+\\)?\\'" . conf-mode)
-     ("\\`/etc/\\(?:DIR_COLORS\\|ethers\\|.?fstab\\|.*hosts\\|lesskey\\|login\\.?de\\(?:fs\\|vperm\\)\\|magic\\|mtab\\|pam\\.d/.*\\|permissions\\|protocols\\|rpc\\|services\\)\\'" . conf-space-mode)
-     ("\\`/etc/\\(?:acpid?/.+\\|aliases\\|default/.+\\|group-?\\|hosts\\..+\\|inittab\\|ksysguarddrc\\|opera6rc\\|passwd-?\\|shadow-?\\)\\'" . conf-mode)
+     ("\\`/etc/\\(?:DIR_COLORS\\|ethers\\|.?fstab\\|.*hosts\\|lesskey\\|login\\.?de\\(?:fs\\|vperm\\)\\|magic\\|mtab\\|pam\\.d/.*\\|permissions\\(?:\\.d/.+\\)?\\|protocols\\|rpc\\|services\\)\\'" . conf-space-mode)
+     ("\\`/etc/\\(?:acpid?/.+\\|aliases\\(?:\\.d/.+\\)?\\|default/.+\\|group-?\\|hosts\\..+\\|inittab\\|ksysguarddrc\\|opera6rc\\|passwd-?\\|shadow-?\\|sysconfig/.+\\)\\'" . conf-mode)
      ;; either user's dot-files or under /etc or some such
      ("/\\.?\\(?:gnokiirc\\|kde.*rc\\|mime\\.types\\|wgetrc\\)\\'" . conf-mode)
      ;; alas not all ~/.*rc files are like this
--- a/lisp/filesets.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/filesets.el	Mon Apr 18 13:40:23 2005 +0000
@@ -1794,8 +1794,17 @@
 	 (name   (or name
 		     (completing-read
 		      (format "Add '%s' to fileset: " buffer)
-		      filesets-data nil t)))
-	 (entry  (assoc name filesets-data)))
+		      filesets-data nil)))
+         (entry  (or (assoc name filesets-data)
+                     (when (y-or-n-p
+                            (format "Fileset %s does not exist. Create it?"
+                                    name))
+                       (progn
+      (add-to-list 'filesets-data (list name '(:files)))
+      (message
+       "Fileset %s created.  Call `M-x filesets-save-config' to save."
+       name)
+      (car filesets-data))))))
     (if entry
 	(let* ((files  (filesets-entry-get-files entry))
 	       (this   (buffer-file-name buffer))
--- a/lisp/generic-x.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/generic-x.el	Mon Apr 18 13:40:23 2005 +0000
@@ -41,6 +41,16 @@
 ;; You can also send in new modes; if the file types a reasonably common,
 ;; we would like to install them.
 ;;
+;; DEFAULT GENERIC MODE:
+;;
+;; This file provides a hook which automatically puts a file into
+;; `default-generic-mode' if the first few lines of a file in
+;; fundamental mode start with a hash comment character.  To disable
+;; this functionality, set the variable `generic-use-find-file-hook'
+;; to nil BEFORE loading generic-x.  See the variables
+;; `generic-lines-to-scan' and `generic-find-file-regexp' for
+;; customization options.
+;;
 ;; PROBLEMS WHEN USED WITH FOLDING MODE:
 ;;
 ;; [The following relates to the obsolete selective-display technique.
@@ -95,11 +105,86 @@
 (require 'font-lock)
 
 (defgroup generic-x nil
-  "Extra modes for generic mode."
+  "A collection of generic modes."
   :prefix "generic-"
-  :group 'generic
+  :group 'data
   :version "20.3")
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Default-Generic mode
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defcustom generic-use-find-file-hook t
+  "*If non-nil, add a hook to enter `default-generic-mode' automatically.
+This is done if the first few lines of a file in fundamental mode
+start with a hash comment character."
+  :group 'generic-x
+  :type  'boolean)
+
+(defcustom generic-lines-to-scan 3
+  "*Number of lines that `generic-mode-find-file-hook' looks at.
+Relevant when deciding whether to enter Default-Generic mode automatically.
+This variable should be set to a small positive number."
+  :group 'generic-x
+  :type  'integer)
+
+(defcustom generic-find-file-regexp "^#"
+  "*Regular expression used by `generic-mode-find-file-hook'.
+Files in fundamental mode whose first few lines contain a match
+for this regexp, should be put into Default-Generic mode instead.
+The number of lines tested for the matches is specified by the
+value of the variable `generic-lines-to-scan', which see."
+  :group 'generic-x
+  :type  'regexp)
+
+(defcustom generic-ignore-files-regexp "[Tt][Aa][Gg][Ss]\\'"
+  "*Regular expression used by `generic-mode-find-file-hook'.
+Files whose names match this regular expression should not be put
+into Default-Generic mode, even if they have lines which match
+the regexp in `generic-find-file-regexp'.  If the value is nil,
+`generic-mode-find-file-hook' does not check the file names."
+  :group 'generic-x
+  :type  '(choice (const :tag "Don't check file names" nil) regexp))
+
+;; This generic mode is always defined
+(define-generic-mode default-generic-mode (list ?#) nil nil nil nil :group 'generic)
+
+;; A more general solution would allow us to enter generic-mode for
+;; *any* comment character, but would require us to synthesize a new
+;; generic-mode on the fly. I think this gives us most of what we
+;; want.
+(defun generic-mode-find-file-hook ()
+  "Hook function to enter Default-Generic mode automatically.
+
+Done if the first few lines of a file in Fundamental mode start
+with a match for the regexp in `generic-find-file-regexp', unless
+the file's name matches the regexp which is the value of the
+variable `generic-ignore-files-regexp'.
+
+This hook will be installed if the variable
+`generic-use-find-file-hook' is non-nil.  The variable
+`generic-lines-to-scan' determines the number of lines to look at."
+  (when (and (eq major-mode 'fundamental-mode)
+	     (or (null generic-ignore-files-regexp)
+		 (not (string-match
+		       generic-ignore-files-regexp
+		       (file-name-sans-versions buffer-file-name)))))
+    (save-excursion
+      (goto-char (point-min))
+      (when (re-search-forward generic-find-file-regexp
+			       (save-excursion
+				 (forward-line generic-lines-to-scan)
+				 (point)) t)
+	(goto-char (point-min))
+	(default-generic-mode)))))
+
+(and generic-use-find-file-hook
+    (add-hook 'find-file-hook 'generic-mode-find-file-hook))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Other Generic modes
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
 (defcustom generic-extras-enable-list nil
   "*List of generic modes to enable by default.
 Each entry in the list should be a symbol.  The variables
@@ -150,10 +235,6 @@
 		     etc-fstab-generic-mode)
 		   generic-extras-enable-list)))
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Generic-modes
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 ;;; Apache
 (when (memq 'apache-conf-generic-mode generic-extras-enable-list)
 
@@ -284,8 +365,21 @@
       (setq imenu-generic-expression
 	    '((nil "^\\[\\(.*\\)\\]" 1)
 	      ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 1))))))
-  "Generic mode for MS-Windows INI files."
-  :group 'generic-x))
+  "Generic mode for MS-Windows INI files.
+You can use `ini-generic-mode-find-file-hook' to enter this mode
+automatically for INI files whose names do not end in \".ini\"."
+  :group 'generic-x)
+
+(defun ini-generic-mode-find-file-hook ()
+  "Hook function to enter Ini-Generic mode automatically for INI files.
+Done if the first few lines of a file in Fundamental mode look
+like an INI file.  You can add this hook to `find-file-hook'."
+  (and (eq major-mode 'fundamental-mode)
+       (save-excursion
+	 (goto-char (point-min))
+	 (and (looking-at "^\\s-*\\[.*\\]")
+	      (ini-generic-mode)))))
+(defalias 'generic-mode-ini-file-find-file-hook 'ini-generic-mode-find-file-hook))
 
 ;;; Windows REG files
 ;;; Unfortunately, Windows 95 and Windows NT have different REG file syntax!
@@ -396,6 +490,7 @@
     (compile
      (concat (w32-shell-name) " -c " (buffer-file-name)))))
 
+(eval-when-compile (require 'comint))
 (defun bat-generic-mode-run-as-comint ()
   "Run the current BAT file in a comint buffer."
   (interactive)
@@ -785,7 +880,7 @@
      '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
        (1 font-lock-constant-face)
        (2 font-lock-variable-name-face nil t))))
-    '("\\.[rR][cC]$")
+    '("\\.[rR][cC]\\'")
     nil
     "Generic mode for MS-Windows Resource files."
     :group 'generic-x))
@@ -1406,7 +1501,7 @@
      (generic-make-keywords-list
       installshield-funarg-constants-list
       font-lock-variable-name-face "[^_]" "[^_]"))) ; is this face the best choice?
-  '("\\.[rR][uU][lL]$")
+  '("\\.[rR][uU][lL]\\'")
   '(generic-rul-mode-setup-function)
   "Generic mode for InstallShield RUL files."
   :group 'generic-x)
@@ -1584,8 +1679,8 @@
     "auto"
     "ignore")
   '(("^\\([/-A-Za-z0-9_]+\\)\\s-+\\([/-A-Za-z0-9_]+\\)"
-     (1 font-lock-type-face)
-     (2 font-lock-variable-name-face)))
+     (1 font-lock-type-face t)
+     (2 font-lock-variable-name-face t)))
   '("/etc/[v]*fstab\\'")
   (list
    (function
@@ -1667,7 +1762,7 @@
   ;; List of additional font-lock-expressions
   '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face)
     ("^\\([.A-Za-z0-9]+\\)"                 1 font-lock-variable-name-face))
-  ;; List of additional automode-alist expressions
+  ;; List of additional auto-mode-alist expressions
   nil
   ;; List of set up functions to call
   nil
@@ -1688,7 +1783,7 @@
   '("nameserver" "domain" "search" "sortlist" "options")
   ;; List of additional font-lock-expressions
   nil
-  ;; List of additional automode-alist expressions
+  ;; List of additional auto-mode-alist expressions
   '("/etc/resolv[e]?.conf\\'")
   ;; List of set up functions to call
   nil
--- a/lisp/generic.el	Mon Apr 18 13:17:40 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,455 +0,0 @@
-;;; generic.el --- defining simple major modes with comment and font-lock
-;;
-;; Copyright (C) 1997, 1999, 2004, 2005 Free Software Foundation, Inc.
-;;
-;; Author:  Peter Breton <pbreton@cs.umb.edu>
-;; Created: Fri Sep 27 1996
-;; Keywords: generic, comment, font-lock
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
-
-;; Purpose:
-
-;; Meta-mode to create simple major modes
-;; with basic comment and font-lock support
-
-;;; Commentary:
-
-;; INTRODUCTION:
-
-;; Generic-mode is a meta-mode which can be used to define small modes
-;; which provide basic comment and font-lock support.  These modes are
-;; intended for the many configuration files and such which are too
-;; small for a "real" mode, but still have a regular syntax, comment
-;; characters and the like.
-;;
-;; Each generic mode can define the following:
-;;
-;; * List of comment-characters.  The entries in this list should be
-;;   either a character, a one or two character string or a cons pair.
-;;   If the entry is a character or a string, it is added to the
-;;   mode's syntax table with `comment-start' syntax.  If the entry is
-;;   a cons pair, the elements of the pair are considered to be
-;;   `comment-start' and `comment-end' respectively.  (The latter
-;;   should be nil if you want comments to end at end of line.)
-;;   LIMITATIONS: Emacs does not support comment strings of more than
-;;   two characters in length.
-;;
-;; * List of keywords to font-lock.  Each keyword should be a string.
-;;   If you have additional keywords which should be highlighted in a
-;;   face different from `font-lock-keyword-face', you can use the
-;;   convenience function `generic-make-keywords-list' (which see),
-;;   and add the result to the following list:
-;;
-;; * Additional expressions to font-lock.  This should be a list of
-;;   expressions, each of which should be of the same form as those in
-;;   `font-lock-keywords'.
-;;
-;; * List of regular expressions to be placed in auto-mode-alist.
-;;
-;; * List of functions to call to do some additional setup
-;;
-;; This should pretty much cover basic functionality; if you need much
-;; more than this, or you find yourself writing extensive customizations,
-;; perhaps you should be writing a major mode instead!
-;;
-;; LOCAL VARIABLES:
-;;
-;; To put a file into generic mode using local variables, use a line
-;; like this in a Local Variables block:
-;;
-;;   mode: default-generic
-;;
-;; Do NOT use "mode: generic"!
-;; See also "AUTOMATICALLY ENTERING GENERIC MODE" below.
-;;
-;; DEFINING NEW GENERIC MODES:
-;;
-;; Use the `define-generic-mode' function to define new modes.
-;; For example:
-;;
-;;   (define-generic-mode 'foo-generic-mode
-;;     (list ?%)
-;;     (list "keyword")
-;;     nil
-;;     (list "\\.FOO\\'")
-;;     (list 'foo-setup-function))
-;;
-;; defines a new generic-mode `foo-generic-mode', which has '%' as a
-;; comment character, and "keyword" as a keyword.  When files which
-;; end in '.FOO' are loaded, Emacs will go into foo-generic-mode and
-;; call foo-setup-function.  You can also use the function
-;; `foo-generic-mode' (which is interactive) to put a buffer into
-;; foo-generic-mode.
-;;
-;; AUTOMATICALLY ENTERING GENERIC MODE:
-;;
-;; Generic-mode provides a hook which automatically puts a file into
-;; default-generic-mode if the first few lines of a file in
-;; fundamental mode start with a hash comment character.  To disable
-;; this functionality, set the variable `generic-use-find-file-hook'
-;; to nil BEFORE loading generic-mode.  See the variables
-;; `generic-lines-to-scan' and `generic-find-file-regexp' for
-;; customization options.
-;;
-;; GOTCHAS:
-;;
-;; Be careful that your font-lock definitions are correct.  Getting
-;; them wrong can cause Emacs to continually attempt to fontify! This
-;; problem is not specific to generic-mode.
-;;
-
-;; Credit for suggestions, brainstorming, help with debugging:
-;;   ACorreir@pervasive-sw.com (Alfred Correira)
-;; Extensive cleanup by:
-;;   Stefan Monnier (monnier+gnu/emacs@flint.cs.yale.edu)
-;;
-;;; Code:
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Internal Variables
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defvar generic-font-lock-keywords nil
-  "Keywords for `font-lock-defaults' in a generic mode.")
-(make-variable-buffer-local 'generic-font-lock-keywords)
-(defvaralias 'generic-font-lock-defaults 'generic-font-lock-keywords)
-(make-obsolete-variable 'generic-font-lock-defaults 'generic-font-lock-keywords "22.1")
-
-;;;###autoload
-(defvar generic-mode-list nil
-  "A list of mode names for `generic-mode'.
-Do not add entries to this list directly; use `define-generic-mode'
-instead (which see).")
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Customization Variables
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defgroup generic nil
-  "Define simple major modes with comment and font-lock support."
-  :prefix "generic-"
-  :group 'extensions)
-
-(defcustom generic-use-find-file-hook t
-  "*If non-nil, add a hook to enter `default-generic-mode' automatically.
-This is done if the first few lines of a file in fundamental mode
-start with a hash comment character."
-  :group 'generic
-  :type  'boolean)
-
-(defcustom generic-lines-to-scan 3
-  "*Number of lines that `generic-mode-find-file-hook' looks at.
-Relevant when deciding whether to enter Default-Generic mode automatically.
-This variable should be set to a small positive number."
-  :group 'generic
-  :type  'integer)
-
-(defcustom generic-find-file-regexp "^#"
-  "*Regular expression used by `generic-mode-find-file-hook'.
-Files in fundamental mode whose first few lines contain a match
-for this regexp, should be put into Default-Generic mode instead.
-The number of lines tested for the matches is specified by the
-value of the variable `generic-lines-to-scan', which see."
-  :group 'generic
-  :type  'regexp)
-
-(defcustom generic-ignore-files-regexp "[Tt][Aa][Gg][Ss]\\'"
-  "*Regular expression used by `generic-mode-find-file-hook'.
-Files whose names match this regular expression should not be put
-into Default-Generic mode, even if they have lines which match
-the regexp in `generic-find-file-regexp'.  If the value is nil,
-`generic-mode-find-file-hook' does not check the file names."
-  :group 'generic
-  :type  '(choice (const :tag "Don't check file names" nil) regexp))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Functions
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;;;###autoload
-(defmacro define-generic-mode (mode comment-list keyword-list
-				    font-lock-list auto-mode-list
-				    function-list &optional docstring
-				    &rest custom-keyword-args)
-  "Create a new generic mode MODE.
-
-MODE is the name of the command for the generic mode; it need not
-be quoted.  The optional DOCSTRING is the documentation for the
-mode command.  If you do not supply it, a default documentation
-string will be used instead.
-
-COMMENT-LIST is a list, whose entries are either a single
-character, a one or two character string or a cons pair.  If the
-entry is a character or a string, it is added to the mode's
-syntax table with `comment-start' syntax.  If the entry is a cons
-pair, the elements of the pair are considered to be
-`comment-start' and `comment-end' respectively.  (The latter
-should be nil if you want comments to end at end of line.)  Note
-that Emacs has limitations regarding comment characters.
-
-KEYWORD-LIST is a list of keywords to highlight with
-`font-lock-keyword-face'.  Each keyword should be a string.
-
-FONT-LOCK-LIST is a list of additional expressions to highlight.
-Each entry in the list should have the same form as an entry in
-`font-lock-keywords'.
-
-AUTO-MODE-LIST is a list of regular expressions to add to
-`auto-mode-alist'.  These regexps are added to `auto-mode-alist'
-as soon as `define-generic-mode' is called.
-
-FUNCTION-LIST is a list of functions to call to do some
-additional setup.
-
-The optional CUSTOM-KEYWORD-ARGS are pairs of keywords and
-values.  They will be passed to the generated `defcustom' form of
-the mode hook variable MODE-hook.  Defaults to MODE without the
-possible trailing \"-mode\".  (This default may not be a valid
-customization group defined with `defgroup'.  Make sure it is.)
-You can specify keyword arguments without specifying a docstring.
-
-See the file generic-x.el for some examples of `define-generic-mode'."
-  (declare (debug (sexp def-form def-form def-form form def-form
-			[&optional stringp] &rest [keywordp form]))
-	   (indent 1))
-
-  ;; Backward compatibility.
-  (when (eq (car-safe mode) 'quote)
-    (setq mode (eval mode)))
-
-  (when (and docstring (not (stringp docstring)))
-    ;; DOCSTRING is not a string so we assume that it's actually the
-    ;; first keyword of CUSTOM-KEYWORD-ARGS.
-    (push docstring custom-keyword-args)
-    (setq docstring nil))
-
-  (let* ((name (symbol-name mode))
-	 (pretty-name (capitalize (replace-regexp-in-string
-				   "-mode\\'" "" name)))
-	 (mode-hook (intern (concat name "-hook"))))
-
-    (unless (plist-get custom-keyword-args :group)
-      (setq custom-keyword-args
-	    (plist-put custom-keyword-args 
-		       :group `',(intern (replace-regexp-in-string
-					  "-mode\\'" "" name)))))
-
-    `(progn
-       ;; Add a new entry.
-       (add-to-list 'generic-mode-list ,name)
-
-       ;; Add it to auto-mode-alist
-       (dolist (re ,auto-mode-list)
-	 (add-to-list 'auto-mode-alist (cons re ',mode)))
-
-       (defcustom ,mode-hook nil
-	 ,(concat "Hook run when entering " pretty-name " mode.")
-	 :type 'hook
-	 ,@custom-keyword-args)
-
-       (defun ,mode ()
-	 ,(or docstring
-	      (concat pretty-name " mode.\n"
-		      "This a generic mode defined with `define-generic-mode'."))
-	 (interactive)
-	 (generic-mode-internal ',mode ,comment-list ,keyword-list
-				,font-lock-list ,function-list)))))
-
-;;;###autoload
-(defun generic-mode-internal (mode comment-list keyword-list
-				   font-lock-list function-list)
-  "Go into the generic mode MODE."
-  (let* ((name (symbol-name mode))
-	 (pretty-name (capitalize (replace-regexp-in-string
-				   "-mode\\'" "" name)))
-	 (mode-hook (intern (concat name "-hook"))))
-
-    (kill-all-local-variables)
-
-    (setq major-mode mode
-	  mode-name pretty-name)
-
-    (generic-mode-set-comments comment-list)
-
-    ;; Font-lock functionality.
-    ;; Font-lock-defaults is always set even if there are no keywords
-    ;; or font-lock expressions, so comments can be highlighted.
-    (setq generic-font-lock-keywords
-	  (append
-	   (when keyword-list
-	     (list (generic-make-keywords-list keyword-list
-					       font-lock-keyword-face)))
-	   font-lock-list))
-    (setq font-lock-defaults '(generic-font-lock-keywords nil))
-
-    ;; Call a list of functions
-    (mapcar 'funcall function-list)
-
-    (run-mode-hooks mode-hook)))
-
-;;;###autoload
-(defun generic-mode (mode)
-  "Enter generic mode MODE.
-
-Generic modes provide basic comment and font-lock functionality
-for \"generic\" files.  (Files which are too small to warrant their
-own mode, but have comment characters, keywords, and the like.)
-
-To define a generic-mode, use the function `define-generic-mode'.
-Some generic modes are defined in `generic-x.el'."
-  (interactive
-   (list (completing-read "Generic mode: " generic-mode-list nil t)))
-  (funcall (intern mode)))
-
-;;; Comment Functionality
-(defun generic-mode-set-comments (comment-list)
-  "Set up comment functionality for generic mode."
-  (let ((st (make-syntax-table))
-	(chars nil)
-	(comstyles))
-    (make-local-variable 'comment-start)
-    (make-local-variable 'comment-start-skip)
-    (make-local-variable 'comment-end)
-
-    ;; Go through all the comments
-    (dolist (start comment-list)
-      (let (end (comstyle ""))
-	;; Normalize
-	(when (consp start)
-	  (setq end (cdr start))
-	  (setq start (car start)))
-	(when (char-valid-p start) (setq start (char-to-string start)))
-	(cond
-	 ((char-valid-p end)   (setq end (char-to-string end)))
-	 ((zerop (length end)) (setq end "\n")))
-
-	;; Setup the vars for `comment-region'
-	(if comment-start
-	    ;; We have already setup a comment-style, so use style b
-	    (progn
-	      (setq comstyle "b")
-	      (setq comment-start-skip
-		    (concat comment-start-skip "\\|" (regexp-quote start) "+\\s-*")))
-	  ;; First comment-style
-	  (setq comment-start start)
-	  (setq comment-end (if (string-equal end "\n") "" end))
-	  (setq comment-start-skip (concat (regexp-quote start) "+\\s-*")))
-
-       ;; Reuse comstyles if necessary
-       (setq comstyle
-             (or (cdr (assoc start comstyles))
-                 (cdr (assoc end comstyles))
-                 comstyle))
-       (push (cons start comstyle) comstyles)
-       (push (cons end comstyle) comstyles)
-
-	;; Setup the syntax table
-	(if (= (length start) 1)
-	    (modify-syntax-entry (string-to-char start)
-				 (concat "< " comstyle) st)
-	  (let ((c0 (elt start 0)) (c1 (elt start 1)))
-	    ;; Store the relevant info but don't update yet
-	    (push (cons c0 (concat (cdr (assoc c0 chars)) "1")) chars)
-	    (push (cons c1 (concat (cdr (assoc c1 chars))
-				   (concat "2" comstyle))) chars)))
-	(if (= (length end) 1)
-	    (modify-syntax-entry (string-to-char end)
-				 (concat ">" comstyle) st)
-	  (let ((c0 (elt end 0)) (c1 (elt end 1)))
-	    ;; Store the relevant info but don't update yet
-	    (push (cons c0 (concat (cdr (assoc c0 chars))
-				   (concat "3" comstyle))) chars)
-	    (push (cons c1 (concat (cdr (assoc c1 chars)) "4")) chars)))))
-
-    ;; Process the chars that were part of a 2-char comment marker
-    (dolist (cs (nreverse chars))
-      (modify-syntax-entry (car cs)
-			   (concat (char-to-string (char-syntax (car cs)))
-				   " " (cdr cs))
-			   st))
-    (set-syntax-table st)))
-
-(defun generic-bracket-support ()
-  "Imenu support for [KEYWORD] constructs found in INF, INI and Samba files."
-  (setq imenu-generic-expression
-	'((nil "^\\[\\(.*\\)\\]" 1))
-        imenu-case-fold-search t))
-
-;; This generic mode is always defined
-(define-generic-mode default-generic-mode (list ?#) nil nil nil nil :group 'generic)
-
-;; A more general solution would allow us to enter generic-mode for
-;; *any* comment character, but would require us to synthesize a new
-;; generic-mode on the fly. I think this gives us most of what we
-;; want.
-(defun generic-mode-find-file-hook ()
-  "Hook function to enter Default-Generic mode automatically.
-
-Done if the first few lines of a file in Fundamental mode start
-with a match for the regexp in `generic-find-file-regexp', unless
-the file's name matches the regexp which is the value of the
-variable `generic-ignore-files-regexp'.
-
-This hook will be installed if the variable
-`generic-use-find-file-hook' is non-nil.  The variable
-`generic-lines-to-scan' determines the number of lines to look at."
-  (when (and (eq major-mode 'fundamental-mode)
-	     (or (null generic-ignore-files-regexp)
-		 (not (string-match
-		       generic-ignore-files-regexp
-		       (file-name-sans-versions buffer-file-name)))))
-    (save-excursion
-      (goto-char (point-min))
-      (when (re-search-forward generic-find-file-regexp
-			       (save-excursion
-				 (forward-line generic-lines-to-scan)
-				 (point)) t)
-	(goto-char (point-min))
-	(default-generic-mode)))))
-
-(defun generic-mode-ini-file-find-file-hook ()
-  "Hook function to enter Default-Generic mode automatically for INI files.
-Done if the first few lines of a file in Fundamental mode look like an
-INI file.  This hook is NOT installed by default."
-  (and (eq major-mode 'fundamental-mode)
-       (save-excursion
-	 (goto-char (point-min))
-	 (and (looking-at "^\\s-*\\[.*\\]")
-	      (ini-generic-mode)))))
-
-(and generic-use-find-file-hook
-    (add-hook 'find-file-hook 'generic-mode-find-file-hook))
-
-;;;###autoload
-(defun generic-make-keywords-list (keywords-list face &optional prefix suffix)
-  "Return a regular expression matching the specified KEYWORDS-LIST.
-The regexp is highlighted with FACE."
-  (unless (listp keywords-list)
-    (error "Keywords argument must be a list of strings"))
-  (list (concat prefix "\\_<"
-		;; Use an optimized regexp.
-		(regexp-opt keywords-list t)
-		"\\_>" suffix)
-	1
-	face))
-
-(provide 'generic)
-
-;; arch-tag: 239c1fc4-1303-48d9-9ac0-657d655669ea
-;;; generic.el ends here
--- a/lisp/gnus/ChangeLog	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/gnus/ChangeLog	Mon Apr 18 13:40:23 2005 +0000
@@ -1,8 +1,32 @@
+2005-04-13  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-art.el (gnus-mime-inline-part): Use mm-string-to-multibyte.
+	* qp.el (quoted-printable-encode-region): Use mm-string-to-multibyte.
+
+2005-04-13  Miles Bader  <miles@gnu.org>
+
+	* mm-util.el (mm-string-to-multibyte): Use Gnus trunk definition.
+
+2005-04-12  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* nnrss.el (nnrss-node-text): Replace CRLFs (which might be
+	contained in text because xml.el decodes entities) with LFs.
+
+2005-04-11  Lute Kamstra  <lute@gnu.org>
+
+	* message.el (message-make-date): Handle byte-compiler warnings
+	differently.
+	* nnimap.el (nnimap-date-days-ago): Ditto.
+
 2005-04-10  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* mm-util.el (mm-string-to-multibyte): New function.
 	(mm-detect-coding-region): Typo.
 
+2005-04-11  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* gnus-art.el (gnus-article-read-summary-keys): Fix misplaced parens.
+
 2005-04-06  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 	* mm-util.el (mm-coding-system-p): Don't return binary for the nil
@@ -526,9 +550,6 @@
 
 2004-11-26  Katsumi Yamaoka  <yamaoka@jpl.org>
 
-	* lpath.el: Remove bbdb-create-internal, bbdb-records,
-	spam-BBDB-register-routine and spam-enter-ham-BBDB.
-
 	* nnrss.el (nnrss-string-as-multibyte): Redefine it as a macro in
 	order to silence the byte compiler.
 
--- a/lisp/gnus/gnus-art.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/gnus/gnus-art.el	Mon Apr 18 13:40:23 2005 +0000
@@ -4358,21 +4358,16 @@
 		    (mm-read-coding-system "Charset: "))))
 	 (t
 	  (if (mm-handle-undisplayer handle)
-	      (mm-remove-part handle))
-	  (setq contents
-		(if (fboundp 'string-to-multibyte)
-		    (string-to-multibyte contents)
-		  (mapconcat
-		   (lambda (ch) (mm-string-as-multibyte (char-to-string ch)))
-		   contents "")))))
+	      (mm-remove-part handle))))
 	(forward-line 2)
-	(mm-insert-inline handle
-			  (if (and charset
-				   (setq charset (mm-charset-to-coding-system
-						  charset))
-				   (not (eq charset 'ascii)))
-			      (mm-decode-coding-string contents charset)
-			    contents))
+	(mm-insert-inline
+	 handle
+	 (if (and charset
+		  (setq charset (mm-charset-to-coding-system
+				 charset))
+		  (not (eq charset 'ascii)))
+	     (mm-decode-coding-string contents charset)
+	   (mm-string-to-multibyte contents)))
 	(goto-char b)))))
 
 (defun gnus-mime-view-part-as-charset (&optional handle arg)
@@ -5309,7 +5304,7 @@
 	      (when (eq win (selected-window))
 		(setq new-sum-point (point)
 		      new-sum-start (window-start win)
-		      new-sum-hscroll (window-hscroll win))
+		      new-sum-hscroll (window-hscroll win)))
 	      (when (eq in-buffer (current-buffer))
 		(setq selected (gnus-summary-select-article))
 		(set-buffer obuf)
@@ -5325,7 +5320,7 @@
 			   new-sum-point)
 		  (set-window-point win new-sum-point)
 		  (set-window-start win new-sum-start)
-		  (set-window-hscroll win new-sum-hscroll)))))
+		  (set-window-hscroll win new-sum-hscroll))))
 	  (set-window-configuration owin)
 	  (ding))))))
 
--- a/lisp/gnus/message.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/gnus/message.el	Mon Apr 18 13:40:23 2005 +0000
@@ -4564,12 +4564,11 @@
 	(when (re-search-forward ",+$" nil t)
 	  (replace-match "" t t))))))
 
+(eval-when-compile (require 'parse-time))
 (defun message-make-date (&optional now)
   "Make a valid data header.
 If NOW, use that time instead."
   (require 'parse-time)
-  (defvar parse-time-weekdays)
-  (defvar parse-time-months)
   (let* ((now (or now (current-time)))
 	 (zone (nth 8 (decode-time now)))
 	 (sign "+"))
--- a/lisp/gnus/mm-util.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/gnus/mm-util.el	Mon Apr 18 13:40:23 2005 +0000
@@ -91,7 +91,12 @@
      ;; (string-to-multibyte s)   ~= (decode-coding-string s 'binary)
      ;; (string-make-multibyte s) ~= (decode-coding-string s locale-coding-system)
      (string-as-multibyte . identity)
-     (string-to-multibyte . mm-string-as-multibyte)
+     (string-to-multibyte
+      . (lambda (string)
+	  "Return a multibyte string with the same individual chars as string."
+	  (mapconcat
+	   (lambda (ch) (mm-string-as-multibyte (char-to-string ch)))
+	   string "")))
      (multibyte-string-p . ignore)
      ;; It is not a MIME function, but some MIME functions use it.
      (make-temp-file . (lambda (prefix &optional dir-flag)
--- a/lisp/gnus/nnimap.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/gnus/nnimap.el	Mon Apr 18 13:40:23 2005 +0000
@@ -1386,10 +1386,10 @@
 	(list (- ms 1) (+ (expt 2 16) ls))
       (list ms ls))))
 
+(eval-when-compile (require 'parse-time))
 (defun nnimap-date-days-ago (daysago)
   "Return date, in format \"3-Aug-1998\", for DAYSAGO days ago."
   (require 'parse-time)
-  (defvar parse-time-months)
   (let* ((time (nnimap-time-substract (current-time) (days-to-time daysago)))
 	 (date (format-time-string
 		(format "%%d-%s-%%Y"
--- a/lisp/gnus/nnrss.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/gnus/nnrss.el	Mon Apr 18 13:40:23 2005 +0000
@@ -679,8 +679,11 @@
 	 (text (if (and node (listp node))
 		   (nnrss-node-just-text node)
 		 node))
-	 (cleaned-text (if text (gnus-replace-in-string
-				 text "^[\000-\037\177]+\\|^ +\\| +$" ""))))
+	 (cleaned-text (if text
+			   (gnus-replace-in-string
+			    (gnus-replace-in-string
+			     text "^[\000-\037\177]+\\|^ +\\| +$" "")
+			    "\r\n" "\n"))))
     (if (string-equal "" cleaned-text)
 	nil
       cleaned-text)))
--- a/lisp/gnus/qp.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/gnus/qp.el	Mon Apr 18 13:40:23 2005 +0000
@@ -100,15 +100,10 @@
 If `mm-use-ultra-safe-encoding' is set, fold lines unconditionally and
 encode lines starting with \"From\"."
   (interactive "r")
-  (save-excursion
-    (goto-char from)
-    (if (fboundp 'string-to-multibyte)	; Emacs 22
-	(if (re-search-forward (string-to-multibyte "[^\x0-\x7f\x80-\xff]")
-			       to t)
-	    ;; Fixme: This is somewhat misleading.
-	    (error "Multibyte character in QP encoding region"))
-      (if (re-search-forward (mm-string-as-multibyte "[^\0-\377]") to t)
-	  (error "Multibyte character in QP encoding region"))))
+  (goto-char from)
+  (if (re-search-forward (mm-string-to-multibyte "[^\x0-\x7f\x80-\xff]")
+			 to t)
+      (error "Multibyte character in QP encoding region"))
   (unless class
     ;; Avoid using 8bit characters. = is \075.
     ;; Equivalent to "^\000-\007\013\015-\037\200-\377="
--- a/lisp/help.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/help.el	Mon Apr 18 13:40:23 2005 +0000
@@ -590,7 +590,8 @@
 	;; Don't bother user with strings from (e.g.) the select-paste menu.
 	(if (stringp (aref key (1- (length key))))
 	    (aset key (1- (length key)) "(any string)"))
-	(if (stringp (aref untranslated (1- (length untranslated))))
+	(if (and (> (length untranslated) 0)
+		 (stringp (aref untranslated (1- (length untranslated)))))
 	    (aset untranslated (1- (length untranslated))
 		  "(any string)"))
 	;; Now describe the key, perhaps as changed.
@@ -603,7 +604,6 @@
 			 key-desc
 			 (if (symbolp defn) defn (prin1-to-string defn)))))))))
 
-
 (defun describe-key (key &optional untranslated up-event)
   "Display documentation of the function invoked by KEY.
 KEY should be a key sequence--when calling from a program,
--- a/lisp/international/code-pages.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/international/code-pages.el	Mon Apr 18 13:40:23 2005 +0000
@@ -189,7 +189,7 @@
 	      ;; For Quail translation.  Fixme: this should really be
 	      ;; a separate table that only translates the coding
 	      ;; system's safe-chars.
-	      (cons 'translation-table-for-input ,ucs-mule-to-mule-unicode)))
+	      (cons 'translation-table-for-input 'ucs-mule-to-mule-unicode)))
        (push (list ',name
 		   nil			; charset list
 		   ',decoder
@@ -4475,7 +4475,7 @@
  pt154
  [?р√ ?р▓ ?с╝ ?р⌠ ?Б─· ?Б─╕ ?р╤ ?р╝ ?р╡ ?р╞ ?р═ ?с╒ ?р╒ ?р  ?р╨ ?р╦ ?р≈ ?Б─≤ ?Б─≥ ?Б─° ?Б─² ?Б─╒ ?Б─⌠
   ?Б─■ ?рЁ ?р╥ ?р║ ?сё ?рё ?р⌡ ?р╩ ?р╧ ?б═ ?п▌ ?я· ?п┬ ?с╗ ?р≤ ?р╟ ?б╖ ?п│ ?б╘ ?с≤ ?\б╚ ?б╛ ?с╞
-  ?б╝ ?р° ?б╟ ?р╠ ?п├ ?я√ ?р≥ ?с╘ ?б╤ ?б╥ ?я▒ ?Б└√ ?с≥ ?б╩ ?я≤ ?р╙ ?р╚ ?р² ?п░ ?п▒ ?п▓ ?п⌠ ?п■
+  ?б╝ ?р° ?б╟ ?р╠ ?п├ ?я√ ?р≥ ?с╘ ?б╤ ?б╥ ?я▒ ?Б└√ ?с≥ ?\б╩ ?я≤ ?р╙ ?р╚ ?р² ?п░ ?п▒ ?п▓ ?п⌠ ?п■
   ?п∙ ?п√ ?п≈ ?п≤ ?п≥ ?п  ?п⌡ ?п° ?п² ?п· ?п÷ ?п═ ?п║ ?п╒ ?пё ?п╓ ?п╔ ?п╕ ?п╖ ?п╗ ?п╘ ?п╙ ?п╚
   ?п╛ ?п╜ ?п╝ ?п╞ ?п╟ ?п╠ ?п╡ ?пЁ ?п╢ ?п╣ ?п╤ ?п╥ ?п╦ ?п╧ ?п╨ ?п╩ ?п╪ ?п╫ ?п╬ ?п© ?я─ ?я│ ?я┌
   ?я┐ ?я└ ?я┘ ?я├ ?я┤ ?я┬ ?я┴ ?я┼ ?я▀ ?я▄ ?я█ ?я▌ ?я▐])
--- a/lisp/international/mule-cmds.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/international/mule-cmds.el	Mon Apr 18 13:40:23 2005 +0000
@@ -2395,6 +2395,15 @@
 		    (= 0 (length locale))) ; nil or empty string
 	  (setq locale (getenv (pop vars))))))
 
+    (unless (or locale (not (fboundp 'mac-get-preference)))
+      (setq locale (mac-get-preference "AppleLocale"))
+      (unless locale
+	(let ((languages (mac-get-preference "AppleLanguages")))
+	  (unless (= (length languages) 0) ; nil or empty vector
+	    (setq locale (aref languages 0))))))
+    (unless (or locale (not (boundp 'mac-system-locale)))
+      (setq locale mac-system-locale))
+
     (when locale
 
       ;; Translate "swedish" into "sv_SE.ISO8859-1", and so on,
@@ -2425,7 +2434,8 @@
 		 (when locale
 		   (if (string-match "\\.\\([^@]+\\)" locale)
 		       (locale-charset-to-coding-system
-			(match-string 1 locale)))))))
+			(match-string 1 locale))))
+		 (and (eq system-type 'macos) mac-system-coding-system))))
 
 	(if (consp language-name)
 	    ;; locale-language-names specify both lang-env and coding.
--- a/lisp/international/ucs-tables.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/international/ucs-tables.el	Mon Apr 18 13:40:23 2005 +0000
@@ -1,6 +1,6 @@
 ;;; ucs-tables.el --- translation to, from and via Unicode  -*- coding: iso-2022-7bit -*-
 
-;; Copyright (C) 2001, 2002  Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2002, 2005  Free Software Foundation, Inc.
 
 ;; Author: Dave Love <fx@gnu.org>
 ;; Keywords: i18n
@@ -2496,8 +2496,10 @@
 ;; normal-mode and minibuffer-setup-hook.
 (defun ucs-set-table-for-input (&optional buffer)
   "Set up an appropriate `translation-table-for-input' for BUFFER.
-BUFFER defaults to the current buffer."
+BUFFER defaults to the current buffer.
+This function is automatically called directly at the end of `get-buffer-create'."
   (when (and unify-8859-on-encoding-mode
+             (not unify-8859-on-decoding-mode)
 	     (char-table-p translation-table-for-input))
     (let ((cs (and buffer-file-coding-system
 		   (coding-system-base buffer-file-coding-system)))
@@ -2535,5 +2537,5 @@
 
 (provide 'ucs-tables)
 
-;;; arch-tag: b497e22b-7fe1-486a-9352-e2d7f7d76a76
+;; arch-tag: b497e22b-7fe1-486a-9352-e2d7f7d76a76
 ;;; ucs-tables.el ends here
--- a/lisp/jka-compr.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/jka-compr.el	Mon Apr 18 13:40:23 2005 +0000
@@ -198,12 +198,16 @@
 			 (choice :tag "Compress Message"
 				 (string :format "%v")
 				 (const :tag "No Message" nil))
-			 (string :tag "Compress Program")
+			 (choice :tag "Compress Program"
+				 (string)
+				 (const :tag "None" nil))
 			 (repeat :tag "Compress Arguments" string)
 			 (choice :tag "Uncompress Message"
 				 (string :format "%v")
 				 (const :tag "No Message" nil))
-			 (string :tag "Uncompress Program")
+			 (choice :tag "Uncompress Program"
+				 (string)
+				 (const :tag "None" nil))
 			 (repeat :tag "Uncompress Arguments" string)
 			 (boolean :tag "Append")
 			 (boolean :tag "Strip Extension")
--- a/lisp/loadhist.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/loadhist.el	Mon Apr 18 13:40:23 2005 +0000
@@ -194,29 +194,27 @@
 	(dolist (elt (cdr unload-hook-features-list))
 	  (if (symbolp elt)
 	      (elp-restore-function elt))))
-    (mapc
-     (lambda (x)
-       (cond ((stringp x) nil)
-             ((consp x)
-              ;; Remove any feature names that this file provided.
-              (if (eq (car x) 'provide)
-                  (setq features (delq (cdr x) features)))
-              (when (eq (car x) 'defvar)
-		;; Kill local values as much as possible.
-		(dolist (buf (buffer-list))
-		  (with-current-buffer buf
-		    (kill-local-variable (cdr x))))
-		;; Get rid of the default binding if we can.
-		(unless (local-variable-if-set-p (cdr x))
-		  (makunbound (cdr x)))))
-	     (t
-	      (when (fboundp x)
-		(if (fboundp 'ad-unadvise)
-		    (ad-unadvise x))
-		(fmakunbound x)
-		(let ((aload (get x 'autoload)))
-		  (if aload (fset x (cons 'autoload aload))))))))
-     (cdr unload-hook-features-list))
+    (dolist (x (cdr unload-hook-features-list))
+      (when (consp x)
+	;; Remove any feature names that this file provided.
+	(if (eq (car x) 'provide)
+	    (setq features (delq (cdr x) features)))
+	(when (eq (car x) 'defvar)
+	  ;; Kill local values as much as possible.
+	  (dolist (buf (buffer-list))
+	    (with-current-buffer buf
+	      (kill-local-variable (cdr x))))
+	  ;; Get rid of the default binding if we can.
+	  (unless (local-variable-if-set-p (cdr x))
+	    (makunbound (cdr x))))
+	(when (eq (car x) 'defun)
+	  (let ((fun (cdr x)))
+	    (when (fboundp fun)
+	      (if (fboundp 'ad-unadvise)
+		  (ad-unadvise fun))
+	      (fmakunbound fun)
+	      (let ((aload (get fun 'autoload)))
+		(if aload (fset fun (cons 'autoload aload)))))))))
     ;; Delete the load-history element for this file.
     (let ((elt (assoc file load-history)))
       (setq load-history (delq elt load-history)))))
--- a/lisp/loadup.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/loadup.el	Mon Apr 18 13:40:23 2005 +0000
@@ -203,6 +203,7 @@
 
 (load "vc-hooks")
 (load "ediff-hook")
+(if (fboundp 'x-show-tip) (load "tooltip"))
 (message "%s" (garbage-collect))
 
 ;If you want additional libraries to be preloaded and their
--- a/lisp/mail/rmail.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/mail/rmail.el	Mon Apr 18 13:40:23 2005 +0000
@@ -246,7 +246,7 @@
 
 ;;;###autoload
 (defcustom rmail-ignored-headers
-  (concat "^via:\\|^mail-from:\\|^origin:\\|^references:"
+  (concat "^via:\\|^mail-from:\\|^origin:\\|^references:\\|^sender:"
 	  "\\|^status:\\|^received:\\|^x400-originator:\\|^x400-recipients:"
 	  "\\|^x400-received:\\|^x400-mts-identifier:\\|^x400-content-type:"
 	  "\\|^\\(resent-\\|\\)message-id:\\|^summary-line:\\|^resent-date:"
@@ -254,14 +254,17 @@
 	  "\\|^x-mailer:\\|^delivered-to:\\|^lines:\\|^mime-version:"
 	  "\\|^content-transfer-encoding:\\|^x-coding-system:"
 	  "\\|^return-path:\\|^errors-to:\\|^return-receipt-to:"
-	  "\\|^x-sign:\\|^x-beenthere:\\|^x-mailman-version:"
+	  "\\|^x-sign:\\|^x-beenthere:\\|^x-mailman-version:\\|^x-mailman-copy:"
 	  "\\|^precedence:\\|^list-help:\\|^list-post:\\|^list-subscribe:"
 	  "\\|^list-id:\\|^list-unsubscribe:\\|^list-archive:"
 	  "\\|^content-type:\\|^content-length:"
 	  "\\|^x-attribution:\\|^x-disclaimer:\\|^x-trace:"
 	  "\\|^x-complaints-to:\\|^nntp-posting-date:\\|^user-agent"
 	  "\\|^importance:\\|^envelope-to:\\|^delivery-date"
-	  "\\|^x.*-priority:\\|^x-mimeole:")
+	  "\\|^x.*-priority:\\|^x-mimeole:\\|^x-archive:"
+	  "\\|^resent-face:\\|^resent-x.*:\\|^resent-organization\\|^resent-openpgp"
+	  "\\|^openpgp:\\|^x-request-pgp:\\|^x-original.*:"
+	  "\\|^x-virus-scanned:\\|^x-spam-[^s].*:")
   "*Regexp to match header fields that Rmail should normally hide.
 This variable is used for reformatting the message header,
 which normally happens once for each message,
@@ -653,6 +656,7 @@
 	      . font-lock-function-name-face)
 	    '("^Reply-To:.*$" . font-lock-function-name-face)
 	    '("^Subject:" . font-lock-comment-face)
+	    '("^X-Spam-Status:" . font-lock-keyword-face)
 	    '("^\\(To\\|Apparently-To\\|Cc\\|Newsgroups\\):"
 	      . font-lock-keyword-face)
 	    ;; Use MATCH-ANCHORED to effectively anchor the regexp left side.
@@ -662,8 +666,7 @@
 			"\\(" cite-chars "[ \t]*\\)\\)+"
 			"\\(.*\\)")
 	       (beginning-of-line) (end-of-line)
-	       (2 font-lock-constant-face nil t)
-	       (4 font-lock-comment-face nil t)))
+	       (3 font-lock-comment-face nil t)))
 	    '("^\\(X-[a-z0-9-]+\\|In-reply-to\\|Date\\):.*\\(\n[ \t]+.*\\)*$"
 	      . font-lock-string-face))))
   "Additional expressions to highlight in Rmail mode.")
--- a/lisp/mail/sendmail.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/mail/sendmail.el	Mon Apr 18 13:40:23 2005 +0000
@@ -366,7 +366,9 @@
       (list '("^\\(To\\|Newsgroups\\):" . font-lock-function-name-face)
 	    '("^\\(B?CC\\|Reply-to\\|Mail-\\(reply\\|followup\\)-to\\):" . font-lock-keyword-face)
 	    '("^\\(Subject:\\)[ \t]*\\(.+\\)?"
-	      (1 font-lock-comment-face) (2 font-lock-type-face nil t))
+	      (1 font-lock-comment-face)
+;;	      (2 font-lock-type-face nil t)
+	      )
 	    ;; Use EVAL to delay in case `mail-header-separator' gets changed.
 	    '(eval .
 	      (let ((separator (if (zerop (length mail-header-separator))
@@ -380,8 +382,7 @@
 			"\\(" cite-chars "[ \t]*\\)\\)+"
 			"\\(.*\\)")
 	       (beginning-of-line) (end-of-line)
-	       (2 font-lock-constant-face nil t)
-	       (4 font-lock-comment-face nil t)))
+	       (3 font-lock-comment-face nil t)))
 	    '("^\\(X-[A-Za-z0-9-]+\\|In-reply-to\\):.*\\(\n[ \t]+.*\\)*$"
 	      . font-lock-string-face))))
   "Additional expressions to highlight in Mail mode.")
--- a/lisp/makefile.w32-in	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/makefile.w32-in	Mon Apr 18 13:40:23 2005 +0000
@@ -1,5 +1,5 @@
 #  -*- Makefile -*- for GNU Emacs on the Microsoft W32 API.
-#  Copyright (c) 2000,2001,2004 Free Software Foundation, Inc.
+#  Copyright (c) 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
 #
 #  This file is part of GNU Emacs.
 #
@@ -46,77 +46,6 @@
 lisptagsfiles2 = $(lisp)/*/*.el
 ETAGS = "../lib-src/$(BLD)/etags"
 
-# Files which should not be compiled.  If you change the name `DONTCOMPILE'
-# to something different, you'll have to change make-dist as well, and
-# modify the lists in $lisp and $shortlisp on src/Makefile.in.
-#
-# - emacs-lisp/cl-specs.el:  only contains `def-edebug-spec's so there's
-#   no point compiling it, although it doesn't hurt.
-
-DONTCOMPILE = \
-	$(lisp)/cus-load.el \
-	$(lisp)/emacs-lisp/cl-specs.el \
-	$(lisp)/eshell/esh-maint.el \
-	$(lisp)/eshell/esh-groups.el \
-	$(lisp)/finder-inf.el \
-	$(lisp)/forms-d2.el \
-	$(lisp)/forms-pass.el \
-	$(lisp)/generic-x.el \
-	$(lisp)/international/latin-1.el \
-	$(lisp)/international/latin-2.el \
-	$(lisp)/international/latin-3.el \
-	$(lisp)/international/latin-4.el \
-	$(lisp)/international/latin-5.el \
-	$(lisp)/international/latin-8.el \
-	$(lisp)/international/latin-9.el \
-	$(lisp)/international/mule-conf.el \
-	$(lisp)/language/czech.el \
-	$(lisp)/language/devanagari.el \
-	$(lisp)/language/kannada.el \
-	$(lisp)/language/malayalam.el \
-	$(lisp)/language/tamil.el \
-	$(lisp)/language/english.el \
-	$(lisp)/language/greek.el \
-	$(lisp)/language/hebrew.el \
-	$(lisp)/language/japanese.el \
-	$(lisp)/language/korean.el \
-	$(lisp)/language/lao.el \
-	$(lisp)/language/misc-lang.el \
-	$(lisp)/language/romanian.el \
-	$(lisp)/language/slovak.el \
-	$(lisp)/language/thai.el \
-	$(lisp)/language/utf-8-lang.el \
-	$(lisp)/language/georgian.el \
-	$(lisp)/loaddefs.el \
-	$(lisp)/ldefs-boot.el \
-	$(lisp)/loadup.el \
-	$(lisp)/mail/blessmail.el \
-	$(lisp)/patcomp.el \
-	$(lisp)/paths.el \
-	$(lisp)/play/bruce.el \
-	$(lisp)/subdirs.el \
-	$(lisp)/term/internal.el \
-	$(lisp)/term/AT386.el  \
-	$(lisp)/term/apollo.el \
-	$(lisp)/term/bobcat.el \
-	$(lisp)/term/iris-ansi.el \
-	$(lisp)/term/keyswap.el \
-	$(lisp)/term/linux.el \
-	$(lisp)/term/lk201.el \
-	$(lisp)/term/news.el \
-	$(lisp)/term/vt102.el \
-	$(lisp)/term/vt125.el \
-	$(lisp)/term/vt200.el \
-	$(lisp)/term/vt201.el \
-	$(lisp)/term/vt220.el \
-	$(lisp)/term/vt240.el \
-	$(lisp)/term/vt300.el \
-	$(lisp)/term/vt320.el \
-	$(lisp)/term/vt400.el \
-	$(lisp)/term/vt420.el \
-	$(lisp)/term/wyse50.el \
-	$(lisp)/version.el
-
 # Files to compile before others during a bootstrap.  This is done to
 # speed up the bootstrap process.  The CC files are compiled first
 # because CC mode tweaks the compilation process, and requiring
@@ -251,7 +180,7 @@
 # Update the AUTHORS file.
 
 update-authors:
-	$(emacs) -f batch-update-authors $(srcdir)/AUTHORS $(srcdir)
+	$(emacs) -l authors -f batch-update-authors $(srcdir)/AUTHORS $(srcdir)
 
 TAGS: $(lisptagsfiles1) $(lisptagsfiles2)
 	$(ETAGS) $(lisptagsfiles1) $(lisptagsfiles2)
@@ -264,19 +193,17 @@
 .el.elc:
 	-$(emacs) -f batch-byte-compile $<
 
-$(DONTCOMPILE:.el=.elc):
-	-$(DEL) $@
-
-# Compile all Lisp files, except those from DONTCOMPILE,
-# but don't recompile those that are up to date.
+# Compile all Lisp files, but don't recompile those that are up to
+# date.  Some files don't actually get compiled because they set the
+# local variable no-byte-compile.
 
-# All .elc files are made writable
-# before compilation in case we checked out read-only (CVS option -r).
-# Files MUST be compiled one by one.  If we compile several files in a
-# row we can't make sure that the compilation environment is clean.
-# We also set the load-path of the Emacs used for compilation to the
-# current directory and its subdirectories, to make sure require's and
-# load's in the files being compiled find the right files.
+# All .elc files are made writable before compilation in case we
+# checked out read-only (CVS option -r).  Files MUST be compiled one by
+# one.  If we compile several files in a row we can't make sure that
+# the compilation environment is clean.  We also set the load-path of
+# the Emacs used for compilation to the current directory and its
+# subdirectories, to make sure require's and load's in the files being
+# compiled find the right files.
 
 # Need separate version for sh and native cmd.exe
 compile: subdirs.el compile-$(SHELLTYPE) doit
@@ -304,8 +231,10 @@
 	  done; \
 	done
 
-# Compile all Lisp files, except those from DONTCOMPILE.  This
-# is like `compile' but compiles files unconditionally.
+# Compile all Lisp files.  This is like `compile' but compiles files
+# unconditionally.  Some files don't actually get compiled because they
+# set the local variable no-byte-compile.
+
 compile-always: subdirs.el compile-always-$(SHELLTYPE) doit
 
 compile-always-CMD:
--- a/lisp/progmodes/f90.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/progmodes/f90.el	Mon Apr 18 13:40:23 2005 +0000
@@ -1055,10 +1055,10 @@
       (f90-change-keywords f90-auto-keyword-case
                            (line-beginning-position) (line-end-position))))
 
-(defun f90-electric-insert ()
+(defun f90-electric-insert (&optional arg)
   "Change keyword case and auto-fill line as operators are inserted."
-  (interactive)
-  (self-insert-command 1)
+  (interactive "*p")
+  (self-insert-command arg)
   (if auto-fill-function (f90-do-auto-fill) ; also updates line
     (f90-update-line)))
 
--- a/lisp/progmodes/gdb-ui.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/progmodes/gdb-ui.el	Mon Apr 18 13:40:23 2005 +0000
@@ -79,7 +79,7 @@
 (defvar gdb-overlay-arrow-position nil)
 (defvar gdb-server-prefix nil)
 (defvar gdb-flush-pending-output nil)
-(defvar gdb-location-list nil "List of directories for source files.")
+(defvar gdb-location-list nil "Alist of breakpoint numbers and full filenames.")
 (defvar gdb-find-file-unhook nil)
 
 (defvar gdb-buffer-type nil
@@ -258,6 +258,7 @@
     'gdb-mouse-set-clear-breakpoint)
   (define-key gud-minor-mode-map [left-margin mouse-3]
     'gdb-mouse-toggle-breakpoint)
+;  Currently only works in margin.
 ;  (define-key gud-minor-mode-map [left-fringe mouse-3]
 ;    'gdb-mouse-toggle-breakpoint)
 
@@ -606,6 +607,21 @@
 	  (gdb-get-target-string)
 	  "*"))
 
+(defun gdb-display-inferior-io-buffer ()
+  "Display IO of inferior in a separate window."
+  (interactive)
+  (if gdb-use-inferior-io-buffer
+      (gdb-display-buffer
+       (gdb-get-create-buffer 'gdb-inferior-io))))
+
+(defun gdb-frame-inferior-io-buffer ()
+  "Display IO of inferior in a new frame."
+  (interactive)
+  (if gdb-use-inferior-io-buffer
+      (let ((special-display-regexps (append special-display-regexps '(".*")))
+	    (special-display-frame-alist gdb-frame-parameters))
+	(display-buffer (gdb-get-create-buffer 'gdb-inferior-io)))))
+
 (defvar gdb-inferior-io-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map "\C-c\C-c" 'gdb-inferior-io-interrupt)
@@ -1372,9 +1388,9 @@
 	      (file  (match-string 2))
 	      (line  (match-string 3)))
 	  (save-selected-window
-	    (let* ((buf (find-file-noselect (if (file-exists-p file)
-						file
-					      (cdr (assoc bptno gdb-location-list)))))
+	    (let* ((buf (find-file-noselect
+			 (if (file-exists-p file) file
+			   (cdr (assoc bptno gdb-location-list)))))
 		   (window (display-buffer buf)))
 	      (with-current-buffer buf
 		(goto-line (string-to-number line))
@@ -1810,26 +1826,26 @@
 	   "Read address: "
 	   (propertize gdb-memory-address
 		       'face font-lock-warning-face
-		       'help-echo (purecopy "mouse-1: Set memory address")
-		       'local-map (purecopy (gdb-make-header-line-mouse-map
-					     'mouse-1
-					     #'gdb-memory-set-address)))
+		       'help-echo "mouse-1: Set memory address"
+		       'local-map (gdb-make-header-line-mouse-map
+				   'mouse-1
+				   #'gdb-memory-set-address))
 	   "  Repeat Count: "
 	   (propertize (number-to-string gdb-memory-repeat-count)
 		       'face font-lock-warning-face
-		       'help-echo (purecopy "mouse-1: Set repeat count")
-		       'local-map (purecopy (gdb-make-header-line-mouse-map
-					     'mouse-1
-					     #'gdb-memory-set-repeat-count)))
+		       'help-echo "mouse-1: Set repeat count"
+		       'local-map (gdb-make-header-line-mouse-map
+				   'mouse-1
+				   #'gdb-memory-set-repeat-count))
 	   "  Display Format: "
 	   (propertize gdb-memory-format
 		       'face font-lock-warning-face
-		       'help-echo (purecopy "mouse-3: Select display format")
+		       'help-echo "mouse-3: Select display format"
 		       'local-map gdb-memory-format-keymap)
 	   "  Unit Size: "
 	   (propertize gdb-memory-unit
 		       'face font-lock-warning-face
-		       'help-echo (purecopy "mouse-3: Select unit size")
+		       'help-echo "mouse-3: Select unit size"
 		       'local-map gdb-memory-unit-keymap))))
   (run-mode-hooks 'gdb-memory-mode-hook)
   'gdb-invalidate-memory)
@@ -1936,11 +1952,12 @@
   (let ((answer (get-buffer-window buf 0))
 	(must-split nil))
     (if answer
-	(display-buffer buf)		;Raise the frame if necessary.
+	(display-buffer buf nil 0)	;Raise the frame if necessary.
       ;; The buffer is not yet displayed.
       (pop-to-buffer gud-comint-buffer)	;Select the right frame.
       (let ((window (get-lru-window)))
-	(if window
+	(if (and window
+	    (not (eq window (get-buffer-window gud-comint-buffer))))
 	    (progn
 	      (set-window-buffer window buf)
 	      (setq answer window))
@@ -1965,6 +1982,9 @@
   (define-key menu [memory] '("Memory" . gdb-display-memory-buffer))
   (define-key menu [assembler] '("Machine" . gdb-display-assembler-buffer))
   (define-key menu [registers] '("Registers" . gdb-display-registers-buffer))
+  (define-key menu [inferior]
+    '(menu-item "Inferior IO" gdb-display-inferior-io-buffer
+		:enable gdb-use-inferior-io-buffer))
   (define-key menu [locals] '("Locals" . gdb-display-locals-buffer))
   (define-key menu [frames] '("Stack" . gdb-display-stack-buffer))
   (define-key menu [breakpoints] '("Breakpoints" . gdb-display-breakpoints-buffer)))
@@ -1977,6 +1997,9 @@
   (define-key menu [memory] '("Memory" . gdb-frame-memory-buffer))
   (define-key menu [assembler] '("Machine" . gdb-frame-assembler-buffer))
   (define-key menu [registers] '("Registers" . gdb-frame-registers-buffer))
+  (define-key menu [inferior]
+    '(menu-item "Inferior IO" gdb-frame-inferior-io-buffer
+		:enable gdb-use-inferior-io-buffer))
   (define-key menu [locals] '("Locals" . gdb-frame-locals-buffer))
   (define-key menu [frames] '("Stack" . gdb-frame-stack-buffer))
   (define-key menu [breakpoints] '("Breakpoints" . gdb-frame-breakpoints-buffer)))
@@ -1985,11 +2008,21 @@
   (define-key gud-menu-map [ui]
     `(menu-item "GDB-UI" ,menu :visible (eq gud-minor-mode 'gdba)))
   (define-key menu [gdb-restore-windows]
-    '("Restore Window Layout" . gdb-restore-windows))
+  '(menu-item "Restore Window Layout" gdb-restore-windows
+	      :help "Restore standard layout for debug session."))
   (define-key menu [gdb-many-windows]
-    (menu-bar-make-toggle gdb-many-windows gdb-many-windows
-     "Display Other Windows" "Many windows %s"
-     "Toggle display of locals, stack and breakpoint information")))
+  '(menu-item "Display Other Windows" gdb-many-windows
+	      :help "Toggle display of locals, stack and breakpoint information"
+	      :button (:toggle . gdb-many-windows)))
+  (define-key menu [gdb-use-inferior-io]
+    (menu-bar-make-toggle toggle-gdb-use-inferior-io-buffer
+			  gdb-use-inferior-io-buffer
+     "Separate inferior IO" "Use separate IO %s"
+     "Toggle separate IO for inferior.")))
+
+(defadvice toggle-gdb-use-inferior-io-buffer (after gdb-kill-io-buffer activate)
+  (unless gdb-use-inferior-io-buffer
+    (kill-buffer (gdb-inferior-io-name))))
 
 (defun gdb-frame-gdb-buffer ()
   "Display GUD buffer in a new frame."
@@ -2038,7 +2071,8 @@
   (when gdb-use-inferior-io-buffer
     (split-window-horizontally)
     (other-window 1)
-    (gdb-set-window-buffer (gdb-inferior-io-name)))
+    (gdb-set-window-buffer
+     (gdb-get-create-buffer 'gdb-inferior-io)))
   (other-window 1)
   (gdb-set-window-buffer (gdb-stack-buffer-name))
   (split-window-horizontally)
@@ -2337,7 +2371,6 @@
   (setq mode-name "Machine")
   (setq gdb-overlay-arrow-position nil)
   (add-to-list 'overlay-arrow-variable-list 'gdb-overlay-arrow-position)
-  (put 'gdb-overlay-arrow-position 'overlay-arrow-string "=>")
   (setq fringes-outside-margins t)
   (setq buffer-read-only t)
   (use-local-map gdb-assembler-mode-map)
--- a/lisp/progmodes/gud.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/progmodes/gud.el	Mon Apr 18 13:40:23 2005 +0000
@@ -89,16 +89,27 @@
 
 (defvar gud-running nil
   "Non-nil if debuggee is running.
-Used to grey out relevant toolbar icons.")
-
+Used to grey out relevant togolbar icons.")
+
+;; Use existing Info buffer, if possible.
 (defun gud-goto-info ()
   "Go to relevant Emacs info node."
   (interactive)
-  (select-frame (make-frame))
-  (require 'info)
-  (if (memq gud-minor-mode '(gdbmi gdba))
-      (Info-goto-node "(emacs)GDB Graphical Interface")
-    (Info-goto-node "(emacs)Debuggers")))
+  (let ((same-window-regexps same-window-regexps)
+	(display-buffer-reuse-frames t))
+    (catch 'info-found
+      (walk-windows
+       '(lambda (window)
+	  (if (eq (window-buffer window) (get-buffer "*info*"))
+	      (progn
+		(setq same-window-regexps nil)
+		(throw 'info-found nil))))
+       nil 0)
+      (require 'info)
+      (select-frame (make-frame)))
+    (if (memq gud-minor-mode '(gdbmi gdba))
+	(Info-goto-node "(emacs)GDB Graphical Interface")
+      (Info-goto-node "(emacs)Debuggers"))))
 
 (easy-mmode-defmap gud-menu-map
   '(([help]     "Info" . gud-goto-info)
@@ -1417,7 +1428,7 @@
 
     output))
 
-(defcustom gud-pdb-command-name "pydb"
+(defcustom gud-pdb-command-name "pdb"
   "File name for executing the Python debugger.
 This should be an executable on your path, or an absolute file name."
   :type 'string
@@ -2518,7 +2529,6 @@
 
 (defvar gud-minor-mode-type nil)
 (defvar gud-overlay-arrow-position nil)
-(put 'gud-overlay-arrow-position 'overlay-arrow-string "=>")
 (add-to-list 'overlay-arrow-variable-list 'gud-overlay-arrow-position)
 
 (defun gud-sentinel (proc msg)
@@ -2614,7 +2624,6 @@
 	      (widen)
 	      (goto-line line)
 	      (setq pos (point))
-	      (setq overlay-arrow-string "=>")
 	      (or gud-overlay-arrow-position
 		  (setq gud-overlay-arrow-position (make-marker)))
 	      (set-marker gud-overlay-arrow-position (point) (current-buffer)))
--- a/lisp/progmodes/sh-script.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/progmodes/sh-script.el	Mon Apr 18 13:40:23 2005 +0000
@@ -555,14 +555,24 @@
 
 
 
-(defvar sh-here-document-word "EOF"
+(defcustom sh-here-document-word "EOF"
   "Word to delimit here documents.
-If the first character of this string is \"-\", this character will
-be removed from the string when it is used to close the here document.
-This convention is used by the Bash shell, for example, to indicate
-that leading tabs inside the here document should be ignored.
-Note that Emacs currently has no support for indenting inside here
-documents - you must insert literal tabs by hand.")
+If the first character of this string is \"-\", this is taken as
+part of the redirection operator, rather than part of the
+word (that is, \"<<-\" instead of \"<<\").  This is a feature
+used by some shells (for example Bash) to indicate that leading
+tabs inside the here document should be ignored.  In this case,
+Emacs indents the initial body and end of the here document with
+tabs, to the same level as the start (note that apart from this
+there is no support for indentation of here documents).  This
+will only work correctly if `sh-basic-offset' is a multiple of
+`tab-width'.
+
+Any quote characters or leading whitespace in the word are
+removed when closing the here document."
+  :type 'string
+  :group 'sh-script)
+
 
 (defvar sh-test
   '((sh "[  ]" . 3)
@@ -3247,7 +3257,7 @@
    (let ((sh-add-buffer (current-buffer)))
      (list (completing-read "Variable: " 'sh-add-completer)
 	   (prefix-numeric-value current-prefix-arg))))
-  (insert (sh-feature '((bash . "$[ ")
+  (insert (sh-feature '((bash . "$(( ")
 			(ksh88 . "$(( ")
 			(posix . "$(( ")
 			(rc . "`{expr $")
@@ -3256,7 +3266,7 @@
 	  (sh-remember-variable var)
 	  (if (< delta 0) " - " " + ")
 	  (number-to-string (abs delta))
-	  (sh-feature '((bash . " ]")
+	  (sh-feature '((bash . " ))")
 			(ksh88 . " ))")
 			(posix . " ))")
 			(rc . "}")
@@ -3482,7 +3492,8 @@
       "esac" >
       \n "done"
       > \n
-      "shift " (sh-add "OPTIND" -1) \n))
+      "shift " (sh-add "OPTIND" -1) \n
+      "OPTIND=1" \n))
 
 
 
@@ -3500,7 +3511,6 @@
 	     (match-string 1))))))
 
 
-
 (defun sh-maybe-here-document (arg)
   "Insert self.  Without prefix, following unquoted `<' inserts here document.
 The document is bounded by `sh-here-document-word'."
@@ -3511,18 +3521,21 @@
       (save-excursion
 	(backward-char 2)
 	(sh-quoted-p))
-      (progn
+      (let ((tabs (if (string-match "\\`-" sh-here-document-word)
+                      (make-string (/ (current-indentation) tab-width) ?\t)
+                    ""))
+            (delim (replace-regexp-in-string "['\"]" ""
+                                            sh-here-document-word)))
 	(insert sh-here-document-word)
 	(or (eolp) (looking-at "[ \t]") (insert ? ))
 	(end-of-line 1)
 	(while
 	    (sh-quoted-p)
 	  (end-of-line 2))
-	(newline)
+	(insert ?\n tabs)
 	(save-excursion
-          (insert ?\n (substring
-                       sh-here-document-word
-                       (if (string-match "^-" sh-here-document-word) 1 0)))))))
+          (insert ?\n tabs (replace-regexp-in-string
+                            "\\`-?[ \t]*" "" delim))))))
 
 
 ;; various other commands
@@ -3574,7 +3587,7 @@
 
 This function does not modify the last line of the region if the region ends
 right at the start of the following line; it does not modify blank lines
-at the start of the region.  So you can put the region around an entire 
+at the start of the region.  So you can put the region around an entire
 shell command and conveniently use this command."
   (interactive "r\nP")
   (save-excursion
--- a/lisp/repeat.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/repeat.el	Mon Apr 18 13:40:23 2005 +0000
@@ -284,7 +284,9 @@
 	      ;; does not alter it.
 	      (let ((real-last-command real-last-command))
 		(execute-kbd-macro real-last-command))
-	    (call-interactively real-last-command)))))
+            (run-hooks 'pre-command-hook)
+	    (call-interactively real-last-command)
+            (run-hooks 'post-command-hook)))))
     (when repeat-repeat-char
       ;; A simple recursion here gets into trouble with max-lisp-eval-depth
       ;; on long sequences of repetitions of a command like `forward-word'
--- a/lisp/simple.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/simple.el	Mon Apr 18 13:40:23 2005 +0000
@@ -1279,7 +1279,9 @@
 (defalias 'advertised-undo 'undo)
 
 (defconst undo-equiv-table (make-hash-table :test 'eq :weakness t)
-  "Table mapping redo records to the corresponding undo one.")
+  "Table mapping redo records to the corresponding undo one.
+A redo record for undo-in-region maps to t.
+A redo record for ordinary undo maps to the following (earlier) undo.")
 
 (defvar undo-in-region nil
   "Non-nil if `pending-undo-list' is not just a tail of `buffer-undo-list'.")
@@ -1339,7 +1341,7 @@
 	  (message (if undo-in-region
 		       (if equiv "Redo in region!" "Undo in region!")
 		     (if equiv "Redo!" "Undo!"))))
-      (when (and equiv undo-no-redo)
+      (when (and (consp equiv) undo-no-redo)
 	;; The equiv entry might point to another redo record if we have done
 	;; undo-redo-undo-redo-... so skip to the very last equiv.
 	(while (let ((next (gethash equiv undo-equiv-table)))
@@ -1350,10 +1352,13 @@
 	 (prefix-numeric-value arg)
        1))
     ;; Record the fact that the just-generated undo records come from an
-    ;; undo operation, so we can skip them later on.
+    ;; undo operation--that is, they are redo records.
+    ;; In the ordinary case (not within a region), map the redo
+    ;; record to the following undos.
     ;; I don't know how to do that in the undo-in-region case.
-    (unless undo-in-region
-      (puthash buffer-undo-list pending-undo-list undo-equiv-table))
+    (puthash buffer-undo-list
+	     (if undo-in-region t pending-undo-list)
+	     undo-equiv-table)
     ;; Don't specify a position in the undo record for the undo command.
     ;; Instead, undoing this should move point to where the change is.
     (let ((tail buffer-undo-list)
@@ -2547,7 +2552,7 @@
 ;; This is actually used in subr.el but defcustom does not work there.
 (defcustom yank-excluded-properties
   '(read-only invisible intangible field mouse-face help-echo local-map keymap
-    yank-handler)
+    yank-handler follow-link)
   "*Text properties to discard when yanking.
 The value should be a list of text properties to discard or t,
 which means to discard all text properties."
--- a/lisp/startup.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/startup.el	Mon Apr 18 13:40:23 2005 +0000
@@ -719,10 +719,19 @@
     (and command-line-args
          (setcdr command-line-args args)))
 
-  ;; Under X Windows, this creates the X frame and deletes the terminal frame.
+  ;; Under X Window, this creates the X frame and deletes the terminal frame.
   (when (fboundp 'frame-initialize)
     (frame-initialize))
 
+  ;; Turn off blinking cursor if so specified in X resources.  This is here
+  ;; only because all other settings of no-blinking-cursor are here.
+  (unless (or noninteractive
+	      emacs-basic-display
+	      (and (memq window-system '(x w32 mac))
+		   (not (member (x-get-resource "cursorBlink" "CursorBlink")
+				'("off" "false")))))
+    (setq no-blinking-cursor t))
+
   ;; If frame was created with a menu bar, set menu-bar-mode on.
   (unless (or noninteractive
 	      emacs-basic-display
@@ -742,6 +751,9 @@
   (custom-reevaluate-setting 'blink-cursor-mode)
   (custom-reevaluate-setting 'normal-erase-is-backspace)
 
+  ;; If you change the code below, you need to also change the
+  ;; corresponding code in the tooltip-mode defcustom.  The two need
+  ;; to be equivalent under all conditions, or Custom will get confused.
   (unless (or noninteractive
 	      emacs-basic-display
               (not (display-graphic-p))
@@ -1067,15 +1079,15 @@
   :group 'initialization)
 
 
-(defcustom fancy-splash-delay 10
+(defcustom fancy-splash-delay 7
   "*Delay in seconds between splash screens."
   :group 'fancy-splash-screen
   :type 'integer)
 
 
-(defcustom fancy-splash-max-time 60
+(defcustom fancy-splash-max-time 30
   "*Show splash screens for at most this number of seconds.
-Values less than 60 seconds are ignored."
+Values less than twice `fancy-splash-delay' are ignored."
   :group 'fancy-splash-screen
   :type 'integer)
 
@@ -1253,7 +1265,7 @@
 		    mode-line-format (propertize "---- %b %-"
 						 'face '(:weight bold))
 		    fancy-splash-stop-time (+ (float-time)
-					      (max 60 fancy-splash-max-time))
+					      fancy-splash-max-time)
 		    timer (run-with-timer 0 fancy-splash-delay
 					  #'fancy-splash-screens-1
 					  splash-buffer))
--- a/lisp/term.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/term.el	Mon Apr 18 13:40:23 2005 +0000
@@ -684,14 +684,13 @@
 (defvar term-ansi-at-save-user nil)
 (defvar term-ansi-at-save-pwd nil)
 (defvar term-ansi-at-save-anon nil)
-(defvar term-ansi-current-bold 0)
+(defvar term-ansi-current-bold nil)
 (defvar term-ansi-current-color 0)
-(defvar term-ansi-face-already-done 0)
+(defvar term-ansi-face-already-done nil)
 (defvar term-ansi-current-bg-color 0)
-(defvar term-ansi-current-underline 0)
-(defvar term-ansi-current-highlight 0)
-(defvar term-ansi-current-reverse 0)
-(defvar term-ansi-current-invisible 0)
+(defvar term-ansi-current-underline nil)
+(defvar term-ansi-current-reverse nil)
+(defvar term-ansi-current-invisible nil)
 
 ;;; Four should be enough, if you want more, just add. -mm
 (defvar term-terminal-more-parameters 0)
@@ -732,8 +731,7 @@
      [ "Enable paging" term-pager-toggle (not term-pager-count)]
      [ "Disable paging" term-pager-toggle term-pager-count])))
 
-(if term-mode-map
-    nil
+(unless term-mode-map
   (setq term-mode-map (make-sparse-keymap))
   (define-key term-mode-map "\ep" 'term-previous-input)
   (define-key term-mode-map "\en" 'term-next-input)
@@ -1062,7 +1060,6 @@
   (make-local-variable 'term-ansi-face-already-done)
   (make-local-variable 'term-ansi-current-bg-color)
   (make-local-variable 'term-ansi-current-underline)
-  (make-local-variable 'term-ansi-current-highlight)
   (make-local-variable 'term-ansi-current-reverse)
   (make-local-variable 'term-ansi-current-invisible)
 
@@ -2509,14 +2506,14 @@
 (defun term-horizontal-column ()
   (- (term-current-column) (term-start-line-column)))
 
-;; Calls either vertical-motion or buffer-vertical-motion
+;; Calls either vertical-motion or term-buffer-vertical-motion
 (defmacro term-vertical-motion (count)
   (list 'funcall 'term-vertical-motion count))
 
 ;; An emulation of vertical-motion that is independent of having a window.
 ;; Instead, it uses the term-width variable as the logical window width.
 
-(defun buffer-vertical-motion (count)
+(defun term-buffer-vertical-motion (count)
   (cond ((= count 0)
 	 (move-to-column (* term-width (/ (current-column) term-width)))
 	 0)
@@ -2701,7 +2698,7 @@
 	      (setq term-vertical-motion (symbol-function 'vertical-motion))
 	      (term-check-size proc))
 	  (setq term-vertical-motion
-		(symbol-function 'buffer-vertical-motion)))
+		(symbol-function 'term-buffer-vertical-motion)))
 
 	(setq save-marker (copy-marker (process-mark proc)))
 
@@ -3041,12 +3038,12 @@
   (setq term-current-column 1)
   (setq term-insert-mode nil)
   (setq term-current-face nil)
-  (setq term-ansi-current-underline 0)
-  (setq term-ansi-current-bold 0)
-  (setq term-ansi-current-reverse 0)
+  (setq term-ansi-current-underline nil)
+  (setq term-ansi-current-bold nil)
+  (setq term-ansi-current-reverse nil)
   (setq term-ansi-current-color 0)
-  (setq term-ansi-current-invisible 0)
-  (setq term-ansi-face-already-done 0)
+  (setq term-ansi-current-invisible nil)
+  (setq term-ansi-face-already-done nil)
   (setq term-ansi-current-bg-color 0))
 
 ;;; New function to deal with ansi colorized output, as you can see you can
@@ -3057,32 +3054,32 @@
 
 ;;; Bold  (terminfo: bold)
    ((eq parameter 1)
-    (setq term-ansi-current-bold 1))
+    (setq term-ansi-current-bold t))
 
 ;;; Underline
    ((eq parameter 4)
-    (setq term-ansi-current-underline 1))
+    (setq term-ansi-current-underline t))
 
 ;;; Blink (unsupported by Emacs), will be translated to bold.
 ;;; This may change in the future though.
    ((eq parameter 5)
-    (setq term-ansi-current-bold 1))
+    (setq term-ansi-current-bold t))
 
 ;;; Reverse
    ((eq parameter 7)
-    (setq term-ansi-current-reverse 1))
+    (setq term-ansi-current-reverse t))
 
 ;;; Invisible
    ((eq parameter 8)
-    (setq term-ansi-current-invisible 1))
+    (setq term-ansi-current-invisible t))
 
 ;;; Reset underline (i.e. terminfo rmul)
    ((eq parameter 24)
-    (setq term-ansi-current-underline 0))
+    (setq term-ansi-current-underline nil))
 
 ;;; Reset reverse (i.e. terminfo rmso)
    ((eq parameter 27)
-    (setq term-ansi-current-reverse 0))
+    (setq term-ansi-current-reverse nil))
 
 ;;; Foreground
    ((and (>= parameter 30) (<= parameter 37))
@@ -3103,12 +3100,12 @@
 ;;; 0 (Reset) or unknown (reset anyway)
    (t
     (setq term-current-face nil)
-    (setq term-ansi-current-underline 0)
-    (setq term-ansi-current-bold 0)
-    (setq term-ansi-current-reverse 0)
+    (setq term-ansi-current-underline nil)
+    (setq term-ansi-current-bold nil)
+    (setq term-ansi-current-reverse nil)
     (setq term-ansi-current-color 0)
-    (setq term-ansi-current-invisible 0)
-    (setq term-ansi-face-already-done 1)
+    (setq term-ansi-current-invisible nil)
+    (setq term-ansi-face-already-done t)
     (setq term-ansi-current-bg-color 0)))
 
 ;	(message "Debug: U-%d R-%d B-%d I-%d D-%d F-%d B-%d"
@@ -3121,9 +3118,9 @@
 ;		   term-ansi-current-bg-color)
 
 
-  (if (= term-ansi-face-already-done 0)
-      (if (= term-ansi-current-reverse 1)
-	  (if (= term-ansi-current-invisible 1)
+  (unless term-ansi-face-already-done
+      (if term-ansi-current-reverse
+	  (if term-ansi-current-invisible
 	      (setq term-current-face
 		    (if (= term-ansi-current-color 0)
 			(list :background
@@ -3145,13 +3142,13 @@
 			(if (= term-ansi-current-bg-color 0)
 			    (face-background 'default)
 			(elt ansi-term-color-vector term-ansi-current-bg-color))))
-	    (if (= term-ansi-current-bold 1)
+	    (when term-ansi-current-bold
 		(setq term-current-face
 		      (append '(:weight bold) term-current-face)))
-	    (if (= term-ansi-current-underline 1)
+	    (when term-ansi-current-underline
 		(setq term-current-face
 		      (append '(:underline t) term-current-face))))
-	(if (= term-ansi-current-invisible 1)
+	(if term-ansi-current-invisible
 	    (setq term-current-face
 		  (if (= term-ansi-current-bg-color 0)
 		      (list :background
@@ -3169,15 +3166,15 @@
 		      (elt ansi-term-color-vector term-ansi-current-color)
 		      :background
 		      (elt ansi-term-color-vector term-ansi-current-bg-color)))
-	  (if (= term-ansi-current-bold 1)
+	  (when term-ansi-current-bold
 	      (setq term-current-face
 		    (append '(:weight bold) term-current-face)))
-	  (if (= term-ansi-current-underline 1)
+	  (when term-ansi-current-underline
 	      (setq term-current-face
 		    (append '(:underline t) term-current-face))))))
 
 ;;;	(message "Debug %S" term-current-face)
-  (setq term-ansi-face-already-done 0))
+  (setq term-ansi-face-already-done nil))
 
 
 ;;; Handle a character assuming (eq terminal-state 2) -
--- a/lisp/term/mac-win.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/term/mac-win.el	Mon Apr 18 13:40:23 2005 +0000
@@ -77,7 +77,7 @@
 ;;(require 'select)
 (require 'menu-bar)
 (require 'fontset)
-(require 'x-dnd)
+(require 'dnd)
 
 (defvar x-invocation-args)
 
@@ -1085,13 +1085,38 @@
 (put 'escape 'ascii-character ?\e)
 
 
-;;;; Keysyms
+;;;; Script codes and coding systems
+(defconst mac-script-code-coding-systems
+  '((0 . mac-roman)			; smRoman
+    (1 . japanese-shift-jis)		; smJapanese
+    (2 . chinese-big5)			; smTradChinese
+    (3 . korean-iso-8bit)		; smKorean
+    (7 . mac-cyrillic)			; smCyrillic
+    (25 . chinese-iso-8bit)		; smSimpChinese
+    (29 . mac-centraleurroman)		; smCentralEuroRoman
+    )
+  "Alist of Mac script codes vs Emacs coding systems.")
 
-;; Define constant values to be set to mac-keyboard-text-encoding
-(defconst kTextEncodingMacRoman 0)
-(defconst kTextEncodingISOLatin1 513 "0x201")
-(defconst kTextEncodingISOLatin2 514 "0x202")
+(defconst mac-system-coding-system
+  (let ((base (or (cdr (assq mac-system-script-code
+			     mac-script-code-coding-systems))
+		  'mac-roman)))
+    (if (eq system-type 'darwin)
+	base
+      (coding-system-change-eol-conversion base 'mac)))
+  "Coding system derived from the system script code.")
+
+;;;; Keyboard layout/language change events
+(defun mac-handle-language-change (event)
+  (interactive "e")
+  (let ((coding-system
+	 (cdr (assq (car (cadr event)) mac-script-code-coding-systems))))
+    (set-keyboard-coding-system (or coding-system 'mac-roman))
+    ;; MacJapanese maps reverse solidus to ?\x80.
+    (if (eq coding-system 'japanese-shift-jis)
+	(define-key key-translation-map [?\x80] "\\"))))
 
+(define-key special-event-map [language-change] 'mac-handle-language-change)
 
 ;;;; Selections and cut buffers
 
@@ -1139,21 +1164,14 @@
 
 (setq frame-creation-function 'x-create-frame-with-faces)
 
-(define-ccl-program ccl-encode-mac-roman-font
-  `(0
-    (if (r0 != ,(charset-id 'ascii))
-	(if (r0 <= ?\x8f)
-	    (translate-character mac-roman-encoder r0 r1)
-	  ((r1 <<= 7)
-	   (r1 |= r2)
-	   (translate-character mac-roman-encoder r0 r1)))))
-  "CCL program for Mac Roman font")
-
-(let
-    ((encoding-vector (make-vector 256 nil))
-     (i 0)
-     (vec	;; mac-centraleurroman (128..255) -> UCS mapping
-      [	#x00C4	;; 128:LATIN CAPITAL LETTER A WITH DIAERESIS
+(cp-make-coding-system
+ mac-centraleurroman
+ (apply
+  'vector
+  (mapcar
+   (lambda (c) (decode-char 'ucs c))
+   ;; mac-centraleurroman (128..255) -> UCS mapping
+   [	#x00C4	;; 128:LATIN CAPITAL LETTER A WITH DIAERESIS
 	#x0100	;; 129:LATIN CAPITAL LETTER A WITH MACRON
 	#x0101	;; 130:LATIN SMALL LETTER A WITH MACRON
 	#x00C9	;; 131:LATIN CAPITAL LETTER E WITH ACUTE
@@ -1281,26 +1299,18 @@
 	#x017C	;; 253:LATIN SMALL LETTER Z WITH DOT ABOVE
 	#x0122	;; 254:LATIN CAPITAL LETTER G WITH CEDILLA
 	#x02C7	;; 255:CARON
-	])
-     translation-table)
-  (while (< i 128)
-    (aset encoding-vector i i)
-    (setq i (1+ i)))
-  (while (< i 256)
-    (aset encoding-vector i
-	  (decode-char 'ucs (aref vec (- i 128))))
-    (setq i (1+ i)))
-  (setq translation-table
-	(make-translation-table-from-vector encoding-vector))
-;;  (define-translation-table 'mac-centraleurroman-decoder translation-table)
-  (define-translation-table 'mac-centraleurroman-encoder
-    (char-table-extra-slot translation-table 0)))
+	]))
+ "Mac Central European Roman Encoding (MIME:x-mac-centraleurroman).")
+(coding-system-put 'mac-centraleurroman 'mime-charset 'x-mac-centraleurroman)
 
-(let
-    ((encoding-vector (make-vector 256 nil))
-     (i 0)
-     (vec	;; mac-cyrillic (128..255) -> UCS mapping
-      [	#x0410	;; 128:CYRILLIC CAPITAL LETTER A
+(cp-make-coding-system
+ mac-cyrillic
+ (apply
+  'vector
+  (mapcar
+   (lambda (c) (decode-char 'ucs c))
+   ;; mac-cyrillic (128..255) -> UCS mapping
+   [	#x0410	;; 128:CYRILLIC CAPITAL LETTER A
 	#x0411	;; 129:CYRILLIC CAPITAL LETTER BE
 	#x0412	;; 130:CYRILLIC CAPITAL LETTER VE
 	#x0413	;; 131:CYRILLIC CAPITAL LETTER GHE
@@ -1428,27 +1438,16 @@
 	#x044D	;; 253:CYRILLIC SMALL LETTER E
 	#x044E	;; 254:CYRILLIC SMALL LETTER YU
 	#x20AC	;; 255:EURO SIGN
-	])
-     translation-table)
-  (while (< i 128)
-    (aset encoding-vector i i)
-    (setq i (1+ i)))
-  (while (< i 256)
-    (aset encoding-vector i
-	  (decode-char 'ucs (aref vec (- i 128))))
-    (setq i (1+ i)))
-  (setq translation-table
-	(make-translation-table-from-vector encoding-vector))
-;;  (define-translation-table 'mac-cyrillic-decoder translation-table)
-  (define-translation-table 'mac-cyrillic-encoder
-    (char-table-extra-slot translation-table 0)))
+	]))
+ "Mac Cyrillic Encoding (MIME:x-mac-cyrillic).")
+(coding-system-put 'mac-cyrillic 'mime-charset 'x-mac-cyrillic)
 
 (defvar mac-font-encoder-list
   '(("mac-roman" mac-roman-encoder
      ccl-encode-mac-roman-font "%s")
-    ("mac-centraleurroman" mac-centraleurroman-encoder
+    ("mac-centraleurroman" encode-mac-centraleurroman
      ccl-encode-mac-centraleurroman-font "%s ce")
-    ("mac-cyrillic" mac-cyrillic-encoder
+    ("mac-cyrillic" encode-mac-cyrillic
      ccl-encode-mac-cyrillic-font "%s cy")))
 
 (let ((encoder-list
@@ -1468,24 +1467,34 @@
 	    (if mac-encoded
 		(aset table c mac-encoded))))))))
 
+(define-ccl-program ccl-encode-mac-roman-font
+  `(0
+    (if (r0 != ,(charset-id 'ascii))
+	(if (r0 <= ?\x8f)
+	    (translate-character mac-roman-encoder r0 r1)
+	  ((r1 <<= 7)
+	   (r1 |= r2)
+	   (translate-character mac-roman-encoder r0 r1)))))
+  "CCL program for Mac Roman font")
+
 (define-ccl-program ccl-encode-mac-centraleurroman-font
   `(0
     (if (r0 != ,(charset-id 'ascii))
 	(if (r0 <= ?\x8f)
-	    (translate-character mac-centraleurroman-encoder r0 r1)
+	    (translate-character encode-mac-centraleurroman r0 r1)
 	  ((r1 <<= 7)
 	   (r1 |= r2)
-	   (translate-character mac-centraleurroman-encoder r0 r1)))))
+	   (translate-character encode-mac-centraleurroman r0 r1)))))
   "CCL program for Mac Central European Roman font")
 
 (define-ccl-program ccl-encode-mac-cyrillic-font
   `(0
     (if (r0 != ,(charset-id 'ascii))
 	(if (r0 <= ?\x8f)
-	    (translate-character mac-cyrillic-encoder r0 r1)
+	    (translate-character encode-mac-cyrillic r0 r1)
 	  ((r1 <<= 7)
 	   (r1 |= r2)
-	   (translate-character mac-cyrillic-encoder r0 r1)))))
+	   (translate-character encode-mac-cyrillic r0 r1)))))
   "CCL program for Mac Cyrillic font")
 
 
@@ -1648,8 +1657,8 @@
 		      (if (and (> start 0) (> end 0))
 			  (progn (set-mark start)
 				 (goto-char end)))))
-		(x-dnd-handle-one-url window 'private
-				      (concat "file:" file-name))))
+		(dnd-handle-one-url window 'private
+				    (concat "file:" file-name))))
 	    (car (cdr (cdr event)))))
   (raise-frame))
 
@@ -1739,14 +1748,11 @@
   ;; started (see run_mac_command in sysdep.c).
   (setq shell-file-name "sh")
 
-  ;; To display filenames in Chinese or Japanese, replace mac-roman with
-  ;; big5 or sjis
-  (setq file-name-coding-system 'mac-roman))
-
-;; X Window emulation in macterm.c is not complete enough to start a
-;; frame without a minibuffer properly.  Call this to tell ediff
-;; library to use a single frame.
-; (ediff-toggle-multiframe)
+  ;; Some system variables are encoded with the system script code.
+  (dolist (v '(system-name
+	       emacs-build-system	; Mac OS 9 version cannot dump
+	       user-login-name user-real-login-name user-full-name))
+    (set v (decode-coding-string (symbol-value v) mac-system-coding-system))))
 
 ;; If Emacs is started from the Finder, change the default directory
 ;; to the user's home directory.
@@ -1763,7 +1769,5 @@
 ;; or bold bitmap versions will not display these variants correctly.
 (setq scalable-fonts-allowed t)
 
-;; (prefer-coding-system 'mac-roman)
-
 ;; arch-tag: 71dfcd14-cde8-4d66-b05c-85ec94fb23a6
 ;;; mac-win.el ends here
--- a/lisp/term/w32-win.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/term/w32-win.el	Mon Apr 18 13:40:23 2005 +0000
@@ -76,7 +76,7 @@
 (require 'faces)
 (require 'select)
 (require 'menu-bar)
-(require 'x-dnd)
+(require 'dnd)
 (require 'code-pages)
 
 ;; Conditional on new-fontset so bootstrapping works on non-GUI compiles
@@ -109,8 +109,8 @@
       (if (and (> x 0) (> y 0))
 	  (set-frame-selected-window nil window))
       (mapcar (lambda (file-name) 
-		(x-dnd-handle-one-url window 'private 
-				      (concat "file:" file-name)))
+		(dnd-handle-one-url window 'private 
+				    (concat "file:" file-name)))
 		(car (cdr (cdr event)))))
   (raise-frame)))
 
--- a/lisp/term/xterm.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/term/xterm.el	Mon Apr 18 13:40:23 2005 +0000
@@ -53,15 +53,85 @@
   (define-key map "\e[24~" [f12])
   (define-key map "\e[29~" [print])
 
+  (define-key map "\e[11;2~" [S-f1])
+  (define-key map "\e[12;2~" [S-f2])
+  (define-key map "\e[13;2~" [S-f3])
+  (define-key map "\e[14;2~" [S-f4])
+  (define-key map "\e[15;2~" [S-f5])
+  (define-key map "\e[17;2~" [S-f6])
+  (define-key map "\e[18;2~" [S-f7])
+  (define-key map "\e[19;2~" [S-f8])
+  (define-key map "\e[20;2~" [S-f9])
+  (define-key map "\e[21;2~" [S-f10])
+  (define-key map "\e[23;2~" [S-f11])
+  (define-key map "\e[24;2~" [S-f12])
+
+  (define-key map "\e[11;5~" [C-f1])
+  (define-key map "\e[12;5~" [C-f2])
+  (define-key map "\e[13;5~" [C-f3])
+  (define-key map "\e[14;5~" [C-f4])
+  (define-key map "\e[15;5~" [C-f5])
+  (define-key map "\e[17;5~" [C-f6])
+  (define-key map "\e[18;5~" [C-f7])
+  (define-key map "\e[19;5~" [C-f8])
+  (define-key map "\e[20;5~" [C-f9])
+  (define-key map "\e[21;5~" [C-f10])
+  (define-key map "\e[23;5~" [C-f11])
+  (define-key map "\e[24;5~" [C-f12])
+
+  (define-key map "\e[11;6~" [C-S-f1])
+  (define-key map "\e[12;6~" [C-S-f2])
+  (define-key map "\e[13;6~" [C-S-f3])
+  (define-key map "\e[14;6~" [C-S-f4])
+  (define-key map "\e[15;6~" [C-S-f5])
+  (define-key map "\e[17;6~" [C-S-f6])
+  (define-key map "\e[18;6~" [C-S-f7])
+  (define-key map "\e[19;6~" [C-S-f8])
+  (define-key map "\e[20;6~" [C-S-f9])
+  (define-key map "\e[21;6~" [C-S-f10])
+  (define-key map "\e[23;6~" [C-S-f11])
+  (define-key map "\e[24;6~" [C-S-f12])
+
+  (define-key map "\e[11;3~" [A-f1])
+  (define-key map "\e[12;3~" [A-f2])
+  (define-key map "\e[13;3~" [A-f3])
+  (define-key map "\e[14;3~" [A-f4])
+  (define-key map "\e[15;3~" [A-f5])
+  (define-key map "\e[17;3~" [A-f6])
+  (define-key map "\e[18;3~" [A-f7])
+  (define-key map "\e[19;3~" [A-f8])
+  (define-key map "\e[20;3~" [A-f9])
+  (define-key map "\e[21;3~" [A-f10])
+  (define-key map "\e[23;3~" [A-f11])
+  (define-key map "\e[24;3~" [A-f12])
+
   (define-key map "\e[1;2A" [S-up])
   (define-key map "\e[1;2B" [S-down])
   (define-key map "\e[1;2C" [S-right])
   (define-key map "\e[1;2D" [S-left])
+  (define-key map "\e[1;2F" [S-end])
+  (define-key map "\e[1;2H" [S-home])
 
   (define-key map "\e[1;5A" [C-up])
   (define-key map "\e[1;5B" [C-down])
   (define-key map "\e[1;5C" [C-right])
   (define-key map "\e[1;5D" [C-left])
+  (define-key map "\e[1;5F" [C-end])
+  (define-key map "\e[1;5H" [C-home])
+
+  (define-key map "\e[1;6A" [C-S-up])
+  (define-key map "\e[1;6B" [C-S-down])
+  (define-key map "\e[1;6C" [C-S-right])
+  (define-key map "\e[1;6D" [C-S-left])
+  (define-key map "\e[1;6F" [C-S-end])
+  (define-key map "\e[1;6H" [C-S-home])
+
+  (define-key map "\e[1;3A" [A-up])
+  (define-key map "\e[1;3B" [A-down])
+  (define-key map "\e[1;3C" [A-right])
+  (define-key map "\e[1;3D" [A-left])
+  (define-key map "\e[1;3F" [A-end])
+  (define-key map "\e[1;3H" [A-home])
 
   (define-key map "\e[2;2~" [S-insert])
   (define-key map "\e[3;2~" [S-delete])
@@ -73,6 +143,16 @@
   (define-key map "\e[5;5~" [C-prior])
   (define-key map "\e[6;5~" [C-next])
 
+  (define-key map "\e[2;6~" [C-S-insert])
+  (define-key map "\e[3;6~" [C-S-delete])
+  (define-key map "\e[5;6~" [C-S-prior])
+  (define-key map "\e[6;6~" [C-S-next])
+
+  (define-key map "\e[2;3~" [A-insert])
+  (define-key map "\e[3;3~" [A-delete])
+  (define-key map "\e[5;3~" [A-prior])
+  (define-key map "\e[6;3~" [A-next])
+
   (define-key map "\eOA" [up])
   (define-key map "\eOB" [down])
   (define-key map "\eOC" [right])
--- a/lisp/textmodes/org.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/textmodes/org.el	Mon Apr 18 13:40:23 2005 +0000
@@ -5,7 +5,7 @@
 ;; Author: Carsten Dominik <dominik at science dot uva dot nl>
 ;; Keywords: outlines, hypermedia, calendar
 ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/
-;; Version: 3.05
+;; Version: 3.06
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -74,11 +74,18 @@
 ;; Documentation
 ;; -------------
 ;; The documentation of Org-mode can be found in the TeXInfo file.
-;; This distribution also contains a PDF version of it.  At the homepage
-;; of Org-mode, you can read online the same text online as HTML.
+;; The distribution also contains a PDF version of it.  At the homepage
+;; of Org-mode, you can read the same text online as HTML.
 ;;
 ;; Changes:
 ;; -------
+;; Version 3.06
+;;    - M-S-RET inserts a new TODO heading.
+;;    - New startup option `content'.
+;;    - Better visual response when TODO items in agenda change status.
+;;    - Window positioning after visibility state changes optimized and made
+;;      configurable.  See `org-cycle-hook' and `org-occur-hook'.
+;;
 ;; Version 3.05
 ;;    - Agenda entries from the diary are linked to the diary file, so
 ;;      adding and editing diary entries can be done directly from the agenda.
@@ -101,7 +108,7 @@
 ;;    - Effect of C-u and C-u C-u in org-timeline swapped.
 ;;    - Timeline now always contains today, and `.' jumps to it.
 ;;    - Table editor:
-;;      - cut and paste of regtangular regions in tables
+;;      - cut and paste of rectangular regions in tables
 ;;      - command to convert org-mode table to table.el table and back
 ;;      - command to treat several cells like a paragraph and fill it
 ;;      - command to convert a buffer region to a table
@@ -121,96 +128,6 @@
 ;;    - When reading a date, the calendar can be manipulated with keys.
 ;;    - Link support for RMAIL and Wanderlust (from planner.el, untested)
 ;;    - Minor bug fixes and documentation improvements.
-;;
-;; Version 3.00
-;;    - Multifile Agenda shows current entries from many different files.
-;;    - TeXInfo documentation (thanks to Christian Egli for the conversion).
-;;    - Additional applications for TODO keywords, see documentation.
-;;      Different files may have different TODO keywords etc.
-;;    - Priorities for TODO items.
-;;    - The browser mode used by `org-remember-handler' is improved.
-;;    - Images get inlined in HTML export (thanks to Carsten Wimmer).
-;;    - File links can contain line numbers, like file:/usr/etc/config:255
-;;    - Minor bug fixes.
-;;
-;; Version 2.10
-;;    - TODO entries can have additional states besides TODO and DONE.
-;;      See new variable `org-todo-keywords'.
-;;    - TODO keywords can be interpreted as categories.  See variable
-;;      `org-todo-interpretation'.
-;;    - M-TAB completion on TODO keywords, TeX symbols, and normal words.
-;;    - All keywords (like TODO, DEADLINE etc) are configurable.
-;;    - Cursor positioning optimized after pro/demotion and TODO cycling.
-;;    - Emphasizing in HTML works now for *bold*, /italic/ and _underline_.
-;;    - New commands to kill, copy and yank entire subtrees.  Yanking
-;;      modifies the level of the tree before insertion.
-;;    - New command `org-goto' (C-c C-j) to quickly move to other locations
-;;      in the buffer without affecting outline visibility.
-;;    - Hooks for John Wiegley's remember.el.
-;;    - `org-read-date' pops up calendar for date selection with the mouse.
-;;      See variable `org-popup-calendar-for-date-prompt'.  
-;;
-;; Version 2.6
-;;    - TODO items can be SCHEDULED to a certain date.
-;;    - Expired DEADLINEs are ignored if in an entry marked DONE.
-;;    - From the diary or time-sorted view (C-c C-r), C-c C-t can be used to
-;;      change the TODO state of an item remotely.
-;;    - Horizontal computations in table editor. See `org-table-eval-formula'.
-;;    - Fixed bug with summing tables (command `org-table-sum', `C-c +').
-;;    - Calendar window follows the timestamp when a timestamp is changed.
-;;      New variable `org-calendar-follow-timestamp-change'.
-;;    - Time-sorted view (`org-diary-view', C-c C-r) now uses the prefix
-;;      argument to force inclusion of unscheduled TODO items.
-;;    - New variable `org-confirm-shell-links' to turn of safety query.
-;;    - New variable `org-open-non-existing-files'.
-;;
-;; Version 2.4
-;;    - A time-sorted view on all time stamps can be created with C-c C-r.
-;;    - Timestamps and Deadlines can be shown in the Emacs diary.
-;;    - Date ranges introduced.
-;;    - Time-string formats are no longer configurable.
-;;    - Vertical lines in tables can be made invisible with `C-c |'.
-;;    - New "link" type to execute shell commands, like "shell:ls *.org"
-;;    - Upon export, "myfile.org" becomes "myfile.html" or "myfile.txt",
-;;      instead of "myfile.org.html" or "myfile.org.txt".
-;;    - When the cursor is in the white space at the beginning of a line,
-;;      TAB removes the whitespace before indenting again.
-;;
-;; Version 2.0
-;;    - Windows (NT/2000) support.
-;;    - Works with both Emacs and XEmacs.
-;;    - Fully automatic table editor.
-;;    - New link types into Gnus, VM and BBDB.
-;;    - Other link system changes
-;;      - Time stamps are treated as links to the calendar.
-;;      - Easy creation of links with global command `org-store-link'.
-;;      - Insertion of links with `C-c C-l' works differently now.
-;;      - Space characters allowed as part of a link.
-;;      - Options in `org-file-apps' extended.  The command may now be
-;;        symbol 'emacs', or a lisp form.
-;;    Please re-read the manual section about links.
-;;    - Timestamp changes
-;;      - `org-deadline' now prompts for a date.
-;;      - A line can now contain several timestamps.  Updating of a
-;;        timestamp only happens if the cursor is at the timestamp.
-;;      - Changed the time-stamp-format to ISO, to make sure it will
-;;        always work (non-English month names had caused problems
-;;        with `parse-time-string'.).  Changing the time stamp format
-;;        is not recommended.
-;;    - Picture mode enhancements have been removed from org.el
-;;
-;; Version 1.4
-;;    - Some option name changes, not backward compatible.
-;;    - ASCII exporter upgrade: Table of contents.
-;;    - HTML exporter upgrade: fixed-width regions, better
-;;      sub/superscripts, many TeX symbols supported.
-;;    - Calendar support.
-;;
-;; Version 1.3
-;;    - HTML exporter upgrade, in particular table of contents
-;;
-;; Version 1.0
-;;    - Initial release
 
 ;;; Code:
 
@@ -221,7 +138,7 @@
 
 ;;; Customization variables
 
-(defvar org-version "3.05"
+(defvar org-version "3.06"
   "The version number of the file org.el.")
 (defun org-version ()
   (interactive)
@@ -255,9 +172,12 @@
 
    #+STARTUP: fold
    #+STARTUP: nofold
-"
+   #+STARTUP: content"
   :group 'org-startup
-  :type 'boolean)
+  :type '(choice
+          (const :tag "nofold: show all" nil)
+          (const :tag "fold: overview" t)
+          (const :tag "content: all headlines" content)))
 
 (defcustom org-startup-truncated t
   "Non-nil means, entering Org-mode will set `truncate-lines'.
@@ -281,10 +201,11 @@
 
 (defcustom org-insert-mode-line-in-empty-file nil
   "Non-nil means insert the first line setting Org-mode in empty files.
-When the function `org-mode' is called interactively in an empty, this
+When the function `org-mode' is called interactively in an empty file, this
 normally means that the file name does not automatically trigger Org-mode.
 To ensure that the file will always be in Org-mode in the future, a
-line enforcing Org-mode can be inserted into the buffer."
+line enforcing Org-mode will be inserted into the buffer, if this option
+has been set."
   :group 'org-startup
   :type 'boolean)
 
@@ -409,9 +330,9 @@
 (defvar org-todo-line-regexp nil
   "Matches a headline and puts TODO state into group 2 if present.")
 (make-variable-buffer-local 'org-todo-line-regexp)
-(defvar orb-nl-done-regexp nil
+(defvar org-nl-done-regexp nil
   "Matches newline followed by a headline with the DONE keyword.")
-(make-variable-buffer-local 'orb-nl-done-regexp)
+(make-variable-buffer-local 'org-nl-done-regexp)
 (defvar org-looking-at-done-regexp nil
   "Matches the DONE keyword a point.")
 (make-variable-buffer-local 'org-looking-at-done-regexp)
@@ -446,7 +367,9 @@
             (setq key (match-string 1) value (match-string 2))
             (cond 
              ((equal key "CATEGORY")
-              (setq cat (intern (car (org-split-string value splitre)))))
+              (if (string-match "[ \t]+$" value)
+                  (setq value (replace-match "" t t value)))
+              (setq cat (intern value)))
              ((equal key "SEQ_TODO")
               (setq int 'sequence
                     kwds (append kwds (org-split-string value splitre))))
@@ -460,6 +383,7 @@
               (let ((opts (org-split-string value splitre))
                     (set '(("fold" org-startup-folded t)
                            ("nofold" org-startup-folded nil)
+                           ("content" org-startup-folded 'content)
                            ("dlcheck" org-startup-with-deadline-check t)
                            ("nodlcheck" org-startup-with-deadline-check nil)))
                     l var val)
@@ -490,7 +414,7 @@
           (concat "^\\(\\*+\\)[ \t]*\\("
                   (mapconcat 'regexp-quote org-todo-keywords "\\|")
                   "\\)? *\\(.*\\)")
-          orb-nl-done-regexp
+          org-nl-done-regexp
           (concat "[\r\n]\\*+[ \t]+" org-done-string "\\>")
           org-looking-at-done-regexp (concat "^" org-done-string "\\>")
           org-deadline-regexp (concat "\\<" org-deadline-string)
@@ -555,7 +479,7 @@
   :type 'boolean)
 
 (defcustom org-fit-agenda-window t
-  "Non-nil means, change windo size of agenda to fit content."
+  "Non-nil means, change window size of agenda to fit content."
   :group 'org-agenda
   :type 'boolean)
 
@@ -582,7 +506,7 @@
   :type 'number)
 
 (defcustom org-agenda-include-all-todo t
-  "Non-nil means, the multifile agenda will always contain all TODO entries.
+  "Non-nil means, the agenda will always contain all TODO entries.
 When nil, date-less entries will only be shown if `org-agenda' is called
 with a prefix argument.
 When non-nil, the TODO entries will be listed at the top of the agenda, before
@@ -596,6 +520,13 @@
   :group 'org-agenda
   :type 'boolean)
 
+(defcustom org-calendar-to-agenda-key [?c]
+  "The key to be installed in `calendar-mode-map' for switching to the agenda.
+The command `org-calendar-goto-agenda' will be bound to this key.  The
+default is the character `c' because then`c' can be used to switch back and
+force between agenda and calendar."
+  :group 'org-agenda
+  :type 'sexp)
 
 (defcustom org-agenda-sorting-strategy '(time-up category-keep priority-down)
   "Sorting structure for the agenda items of a single day.
@@ -657,6 +588,23 @@
   :tag "Org Structure"
   :group 'org)
 
+(defcustom org-cycle-hook '(org-optimize-window-after-visibility-change)
+  "Hook that is run after `org-cycle' has changed the buffer visibility.
+The function(s) in this hook must accept a single argument which indicates
+the new state that was set by the most recent `org-cycle' command. The
+argument is a symbol.  After a global state change, it can have the values
+`overview', `content', or `all'.  After a local state change, it can have
+the values `folded', `children', or `subtree'."
+  :group 'org-structure
+  :type 'hook)
+
+(defcustom org-occur-hook '(org-first-headline-recenter)
+  "Hook that is run after `org-occur' has constructed a sparse tree.
+This can be used to recenter the window to show as much of the structure
+as possible."
+  :group 'org-structure
+  :type 'hook)
+
 (defcustom org-adapt-indentation t
   "Non-nil means, adapt indentation when promoting and demoting.
 When this is set and the *entire* text in an entry is indented, the
@@ -692,7 +640,6 @@
   :type 'boolean)
 
 
-
 (defgroup org-link nil
   "Options concerning links in Org-mode."
   :tag "Org Link"
@@ -913,12 +860,12 @@
   happens only if changes to a field might have  changed the column width.
 Optimization requires replacing the functions `self-insert-command',
 `delete-char', and `backward-delete-char' in Org-mode buffers, with a
-slight (in fact: unnoticable) speed impact for normal typing.  Org-mode is
+slight (in fact: unnoticeable) speed impact for normal typing.  Org-mode is
 very good at guessing when a re-align will be necessary, but you can always
 force one with `C-c C-c'.
 
-If you would like to use the optimized version in Org-mode, but the un-optimized
-version in OrgTbl-mode, see the variable `orgtbl-optimized'.
+If you would like to use the optimized version in Org-mode, but the
+un-optimized version in OrgTbl-mode, see the variable `orgtbl-optimized'.
 
 This variable can be used to turn on and off the table editor during a session,
 but in order to toggle optimization, a restart is required."
@@ -931,7 +878,7 @@
 (defcustom org-table-default-size "5x2"
   "The default size for newly created tables, Columns x Rows."
   :group 'org-table
-  :type 'string)
+   :type 'string)
 
 (defcustom org-table-automatic-realign t
   "Non-nil means, automatically re-align table when pressing TAB or RETURN.
@@ -1116,7 +1063,7 @@
 
 (defcustom org-export-with-fixed-width t
   "Non-nil means, lines starting with \":\" will be in fixed width font.
-This can be used to have preformatted text, fragments of code etc.  For
+This can be used to have pre-formatted text, fragments of code etc.  For
 example
   : ;; Some Lisp examples
   : (while (defc cnt)
@@ -1151,7 +1098,7 @@
   :type 'string)
 
 (defcustom org-export-with-emphasize t
-  "Non-nil means, interprete *word*, /word/, and _word_ as emphasized text.
+  "Non-nil means, interpret *word*, /word/, and _word_ as emphasized text.
 If the export target supports emphasizing text, the word will be
 typeset in bold, italic, or underlined, respectively.  Works only for
 single words, but you can say: I *really* *mean* *this*.
@@ -1169,7 +1116,7 @@
 
 ;; FIXME: Should () parens be removed as well in sub/superscripts?
 (defcustom org-export-with-sub-superscripts t
-  "Non-nil means, interprete \"_\" and \"^\" for export.
+  "Non-nil means, interpret \"_\" and \"^\" for export.
 When this option is turned on, you can use TeX-like syntax for sub- and
 superscripts.  Several characters after \"_\" or \"^\" will be
 considered as a single item - so grouping with {} is normally not
@@ -1191,7 +1138,7 @@
   :type 'boolean)
 
 (defcustom org-export-with-TeX-macros t
-  "Non-nil means, interprete simple TeX-like macros when exporting.
+  "Non-nil means, interpret simple TeX-like macros when exporting.
 For example, HTML export converts \\alpha to &alpha; and \\AA to &Aring;.
 No only real TeX macros will work here, but the standard HTML entities
 for math can be used as macro names as well.  For a list of supported
@@ -1301,9 +1248,10 @@
 (defface org-warning-face ;; font-lock-warning-face
   '((((type tty) (class color)) (:foreground "red"))
     (((class color) (background light)) (:foreground "Red" :bold t))
-    (((class color) (background dark)) (:foreground "Pink" :bold t))
+    (((class color) (background dark)) (:foreground "Red1" :bold t))
+;    (((class color) (background dark)) (:foreground "Pink" :bold t))
     (t (:inverse-video t :bold t)))
-  "Face for deadlines and TODO keyords."
+  "Face for deadlines and TODO keywords."
   :group 'org-faces)
 
 (defcustom org-fontify-done-headline nil
@@ -1483,14 +1431,20 @@
   ;; Hook, and startup actions
   (if (or arg
           (and org-insert-mode-line-in-empty-file
+               (interactive-p)
                (= (point-min) (point-max))))
       (save-excursion
         (goto-char (point-min))
         (insert "    -*- mode: org -*-\n\n")))
   (run-hooks 'org-mode-hook)
-  (if org-startup-with-deadline-check
-      (call-interactively 'org-check-deadlines)
-    (if org-startup-folded (org-cycle t))))
+  (unless (boundp 'org-inhibit-startup)
+    (if org-startup-with-deadline-check
+        (call-interactively 'org-check-deadlines)
+      (cond
+       ((eq org-startup-folded t)
+        (org-cycle))
+       ((eq org-startup-folded 'contents)
+        (org-cycle) (org-cycle))))))
 
 ;;; Font-Lock stuff
 
@@ -1534,7 +1488,7 @@
         t)))
 
 (defun org-activate-dates (limit)
-  "Run through the buffer and add overlays to links."
+  "Run through the buffer and add overlays to dates."
   (if (re-search-forward org-tsr-regexp limit t)
       (progn
         (add-text-properties (match-beginning 0) (match-end 0)
@@ -1553,7 +1507,8 @@
          (list
           '(org-activate-links (0 'org-link-face))
           '(org-activate-dates (0 'org-link-face))
-          (list (concat "^\\*+[ \t]*" org-not-done-regexp) '(1 'org-warning-face t))
+          (list (concat "^\\*+[ \t]*" org-not-done-regexp)
+                '(1 'org-warning-face t))
           (list (concat "\\[#[A-Z]\\]") '(0 'org-warning-face t))
           (list (concat "\\<" org-deadline-string) '(0 'org-warning-face t))
           (list (concat "\\<" org-scheduled-string) '(0 'org-warning-face t))
@@ -1673,20 +1628,23 @@
 	    (show-branches)
 	    (if (bobp) (throw 'exit nil))))
 	(message "CONTENTS...done"))
-      (setq org-cycle-global-status 'contents))
+      (setq org-cycle-global-status 'contents)
+      (run-hook-with-args 'org-cycle-hook 'contents))
 
      ((and (eq last-command this-command)
 	   (eq org-cycle-global-status 'contents))
       ;; We just showed the table of contents - now show everything
       (show-all)
       (message "SHOW ALL")
-      (setq org-cycle-global-status 'all))
+      (setq org-cycle-global-status 'all)
+      (run-hook-with-args 'org-cycle-hook 'all))
 
      (t
       ;; Default action: go to overview
       (hide-sublevels 1)
       (message "OVERVIEW")
-      (setq org-cycle-global-status 'overview))))
+      (setq org-cycle-global-status 'overview)
+      (run-hook-with-args 'org-cycle-hook 'overview))))
 
    ((integerp arg)
     ;; Show-subtree, ARG levels up from here.
@@ -1721,18 +1679,21 @@
 	(show-entry)
 	(show-children)
 	(message "CHILDREN")
-	(setq org-cycle-subtree-status 'children))
+	(setq org-cycle-subtree-status 'children)
+        (run-hook-with-args 'org-cycle-hook 'children))
        ((and (eq last-command this-command)
 	     (eq org-cycle-subtree-status 'children))
 	;; We just showed the children, now show everything.
 	(show-subtree)
 	(message "SUBTREE")
-	(setq org-cycle-subtree-status 'subtree))
+	(setq org-cycle-subtree-status 'subtree)
+        (run-hook-with-args 'org-cycle-hook 'subtree))
        (t
 	;; Default action: hide the subtree.
 	(hide-subtree)
 	(message "FOLDED")
-	(setq org-cycle-subtree-status 'folded)))))
+	(setq org-cycle-subtree-status 'folded)
+        (run-hook-with-args 'org-cycle-hook 'folded)))))
 
    ;; TAB emulation
    (buffer-read-only (org-back-to-heading))
@@ -1752,6 +1713,30 @@
         (org-back-to-heading)
         (org-cycle)))))
 
+(defun org-optimize-window-after-visibility-change (state)
+  "Adjust the window after a change in outline visibility.
+This function is the default value of the hook `org-cycle-hook'."
+  (cond
+   ((eq state 'overview) (org-first-headline-recenter 1))
+   ((eq state 'content)  nil)
+   ((eq state 'all)      nil)
+   ((eq state 'folded)   nil)
+   ((eq state 'children) (or (org-subtree-end-visible-p) (recenter 1)))
+   ((eq state 'subtree)  (or (org-subtree-end-visible-p) (recenter 1)))))
+
+(defun org-subtree-end-visible-p ()
+  "Is the end of the current subtree visible?"
+  (pos-visible-in-window-p
+   (save-excursion (outline-end-of-subtree) (point))))
+
+(defun org-first-headline-recenter (&optional N)
+  "Move cursor to the first headline and recenter the headline.
+Optional argument N means, put the headline into the Nth line of the window."
+  (goto-char (point-min))
+  (re-search-forward (concat "^" outline-regexp))
+  (beginning-of-line)
+  (recenter (prefix-numeric-value N)))
+
 (defvar org-goto-window-configuration nil)
 (defvar org-goto-marker nil)
 (defvar org-goto-map (make-sparse-keymap))
@@ -1788,8 +1773,8 @@
 
 When you want to go to a different location in a document, the fastest way
 is often to fold the entire buffer and then dive into the tree.  This
-method has the disadvantage, than the previous location will be folded, and
-that can be unwanted.
+method has the disadvantage, that the previous location will be folded,
+which may not be what you want.
 
 This command works around this by showing a copy of the current buffer in
 overview mode.  You can dive into the tree in that copy, to find the
@@ -1883,9 +1868,9 @@
 ;;; Promotion, Demotion, Inserting new headlines
 
 (defvar org-ignore-region nil
-  "To temporary disable the active region.")
-
-(defun org-insert-heading (arg)
+  "To temporarily disable the active region.")
+
+(defun org-insert-heading (&optional arg)
   "Insert a new heading with same depth at point."
   (interactive "P")
   (let* ((head (save-excursion
@@ -1902,6 +1887,22 @@
       (insert " "))
     (run-hooks 'org-insert-heading-hook)))
 
+(defun org-insert-todo-heading (arg)
+  "Insert a new heading with the same level and TODO state as current heading.
+If the heading has no TODO state, or if the state is DONE, use the first
+state (TODO by default).  Also with prefix arg, force first state."
+  (interactive "P")
+  (org-insert-heading)
+  (save-excursion
+    (org-back-to-heading)
+    (outline-previous-heading)
+    (looking-at org-todo-line-regexp))
+  (if (or arg
+          (not (match-beginning 2))
+          (equal (match-string 2) org-done-string))
+      (insert (car org-todo-keywords) " ")
+    (insert (match-string 2) " ")))
+
 (defun org-promote-subtree (&optional arg)
   "Promote the entire subtree.
 See also `org-promote'."
@@ -2062,7 +2063,7 @@
 ring.  We need it to check if the kill was created by `org-copy-subtree'.")
 
 (defvar org-subtree-clip-folded nil
-  "Was the last copied suptree folded?
+  "Was the last copied subtree folded?
 This is used to fold the tree back after pasting.")
 
 (defun org-cut-subtree (&optional arg)
@@ -2074,7 +2075,7 @@
 (defun org-copy-subtree (&optional arg cut)
   "Cut the current subtree into the clipboard.
 This is a short-hand for marking the subtree and then copying it.
-If CUT is non nil, actually cur the subtree."
+If CUT is non nil, actually cut the subtree."
   (interactive "p")
   (let (beg end folded)
     (org-back-to-heading)
@@ -2129,7 +2130,7 @@
                               ^re_ (buffer-substring (point-at-bol) (point)))
                              (- (match-end 0) (match-beginning 0)))
                             (t nil)))
-         (prevous-level (save-excursion
+         (previous-level (save-excursion
                           (outline-previous-visible-heading 1)
                           (if (looking-at re)
                               (- (match-end 0) (match-beginning 0))
@@ -2139,7 +2140,7 @@
                        (if (looking-at re)
                            (- (match-end 0) (match-beginning 0))
                          1)))
-         (new-level (or force-level (max prevous-level next-level)))
+         (new-level (or force-level (max previous-level next-level)))
          (shift (if (or (= old-level -1)
                         (= new-level -1)
                         (= old-level new-level))
@@ -2181,7 +2182,7 @@
   "Check if the current kill is an outline subtree, or a set of trees.
 Returns nil if kill does not start with a headline, or if the first
 headline level is not the largest headline level in the tree.
-So this will actually acceept several entries of equal levels as well,
+So this will actually accept several entries of equal levels as well,
 which is OK for `org-paste-subtree'.
 If optional TXT is given, check this string instead of the current kill."
   (let* ((kill (or txt (current-kill 0) ""))
@@ -2203,9 +2204,9 @@
   "Perform completion on word at point.
 At the beginning of a headline, this completes TODO keywords as given in
 `org-todo-keywords'.
-If the current word is preceeded by a backslash, completes the TeX symbols
+If the current word is preceded by a backslash, completes the TeX symbols
 that are supported for HTML support.
-If the current word is preceeded by \"#+\", completes special words for
+If the current word is preceded by \"#+\", completes special words for
 setting file options.
 At all other locations, this simply calls `ispell-complete-word'."
   (interactive "P")
@@ -2280,6 +2281,11 @@
             (goto-char (match-end 0))
             (insert " " org-comment-string))))))
 
+(defvar org-last-todo-state-is-todo nil
+  "This is non-nil when the last TODO state change led to a TODO state.
+If the last change removed the TODO tag or switched to DONE, then
+this is nil.")
+
 (defun org-todo (&optional arg)
   "Change the TODO state of an item.
 The state of an item is given by a keyword at the start of the heading,
@@ -2326,6 +2332,8 @@
                   (t nil)))
            (next (if state (concat " " state " ") " ")))
       (replace-match next t t)
+      (setq org-last-todo-state-is-todo
+            (not (equal state org-done-string)))
       (run-hooks 'org-after-todo-state-change-hook)))
   ;; Fixup cursor location if close to the keyword
   (if (and (outline-on-heading-p)
@@ -2390,6 +2398,7 @@
                   (funcall callback))
           (setq cnt (1+ cnt))
           (org-show-hierarchy-above))))
+    (run-hooks 'org-occur-hook)
     (if (interactive-p)
         (message "%d match(es) for regexp %s" cnt regexp))
     cnt))
@@ -2414,6 +2423,8 @@
 (defvar org-priority-regexp ".*?\\(\\[#\\([A-Z]\\)\\] ?\\)"
   "Regular expression matching the priority indicator.")
 
+(defvar org-remove-priority-next-time nil)
+
 (defun org-priority-up ()
   "Increase the priority of the current item."
   (interactive)
@@ -2440,7 +2451,10 @@
        ((eq action 'set)
         (message (format "Priority A-%c, SPC to remove: " org-lowest-priority))
         (setq new (read-char-exclusive))
-        (if (equal new ?\ ) (setq remove t)))
+        (cond ((equal new ?\ ) (setq remove t))
+              ((or (< (upcase new) ?A) (> (upcase new) org-lowest-priority))
+               (error "Priority must be between `%c' and `%c'"
+                      ?A org-lowest-priority))))
        ((eq action 'up)
         (setq new (1- current)))
        ((eq action 'down)
@@ -2452,13 +2466,15 @@
           (if remove
               (replace-match "" t t nil 1)
             (replace-match news t t nil 2))
-        (looking-at org-todo-line-regexp)
-        (if (match-end 2)
-            (progn
-              (goto-char (match-end 2))
-              (insert " [#" news "]"))
-          (goto-char (match-beginning 3))
-          (insert "[#" news "] "))))
+        (if remove
+            (error "No priority cookie found in line")
+          (looking-at org-todo-line-regexp)
+          (if (match-end 2)
+              (progn
+                (goto-char (match-end 2))
+                (insert " [#" news "]"))
+            (goto-char (match-beginning 3))
+            (insert "[#" news "] ")))))
     (if remove
         (message "Priority removed")
       (message "Priority of current item set to %s" news))))
@@ -2663,9 +2679,9 @@
 (defun org-check-deadlines (ndays)
   "Check if there are any deadlines due or past due.
 A deadline is considered due if it happens within `org-deadline-warning-days'
-days from todays date.  If the deadline appears in an entry marked DONE,
+days from today's date.  If the deadline appears in an entry marked DONE,
 it is not shown.  The prefix arg NDAYS can be used to test that many
-days.  If the prefix are is a raw C-u prefix, all deadlines are shown."
+days.  If the prefix is a raw C-u prefix, all deadlines are shown."
   (interactive "P")
   (let* ((org-warn-days
           (cond
@@ -2720,22 +2736,21 @@
           d (floor (/ diff ds))  diff (mod diff ds)
           h (floor (/ diff hs))  diff (mod diff hs)
           m (floor (/ diff 60)))
-    (if to-buffer
-        (progn
-          (goto-char match-end)
-          (when (and (org-at-table-p) (looking-at " *|"))
-            (setq align t)
-            (goto-char (match-end 0)))
-          (if (looking-at
-               "\\( *-? *[0-9]+y\\)?\\( *[0-9]+d\\)? *[0-9][0-9]:[0-9][0-9]")
-              (replace-match ""))
-          (if negative (insert " -"))
-          (if (> y 0) (insert " " (format fy y d h m))
-            (if (> d 0) (insert " " (format fd d h m))
-              (insert " " (format fh h m))))
-          (if align (org-table-align))
-          (message "Time difference inserted"))
-      (message (org-make-tdiff-string y d h m)))))
+    (if (not to-buffer)
+        (message (org-make-tdiff-string y d h m))
+      (when (org-at-table-p)
+        (goto-char match-end)
+        (setq align t)
+        (and (looking-at " *|") (goto-char (match-end 0))))
+      (if (looking-at
+           "\\( *-? *[0-9]+y\\)?\\( *[0-9]+d\\)? *[0-9][0-9]:[0-9][0-9]")
+          (replace-match ""))
+      (if negative (insert " -"))
+      (if (> y 0) (insert " " (format fy y d h m))
+        (if (> d 0) (insert " " (format fd d h m))
+          (insert " " (format fh h m))))
+      (if align (org-table-align))
+      (message "Time difference inserted"))))
 
 (defun org-make-tdiff-string (y d h m)
   (let ((fmt "")
@@ -2789,7 +2804,7 @@
   (org-timestamp-change (prefix-numeric-value arg) 'day))
 
 (defun org-timestamp-down-day (&optional arg)
-  "Increase the date in the time stamp by one day.
+  "Decrease the date in the time stamp by one day.
 With prefix ARG, change that many days."
   (interactive "p")
   (org-timestamp-change (- (prefix-numeric-value arg)) 'day))
@@ -2800,7 +2815,7 @@
        (>= (match-end n) pos)))
 
 (defun org-at-timestamp-p ()
-  "Determine if the the cursor is in or at a timestamp."
+  "Determine if the cursor is  or at a timestamp."
   (interactive)
   (let* ((tsr org-ts-regexp2)
          (pos (point))
@@ -2939,7 +2954,7 @@
    '("Agenda") "Agenda Files"
    (append
     (list 
-     ["Edit file list" (customize-variable 'org-agenda-files) t]
+     ["Edit File List" (customize-variable 'org-agenda-files) t]
      "--")
    (mapcar 'org-file-menu-entry org-agenda-files)))
   (org-agenda-set-mode-name)
@@ -2957,7 +2972,7 @@
 (define-key org-agenda-mode-map [(shift right)] 'org-agenda-date-later)
 (define-key org-agenda-mode-map [(shift left)] 'org-agenda-date-earlier)
 
-(define-key org-agenda-mode-map ">" 'org-agenda-date-today)
+(define-key org-agenda-mode-map ">" 'org-agenda-date-prompt)
 (let ((l '(1 2 3 4 5 6 7 8 9 0)))
   (while l (define-key org-agenda-mode-map
              (int-to-string (pop l)) 'digit-argument)))
@@ -2968,10 +2983,17 @@
 (define-key org-agenda-mode-map "q" 'org-agenda-quit)
 (define-key org-agenda-mode-map "x" 'org-agenda-exit)
 (define-key org-agenda-mode-map "P" 'org-agenda-show-priority)
-(define-key org-agenda-mode-map "p" 'org-agenda-priority)
+(define-key org-agenda-mode-map "n" 'next-line)
+(define-key org-agenda-mode-map "p" 'previous-line)
+(define-key org-agenda-mode-map "\C-n" 'org-agenda-next-date-line)
+(define-key org-agenda-mode-map "\C-p" 'org-agenda-previous-date-line)
 (define-key org-agenda-mode-map "," 'org-agenda-priority)
+(define-key org-agenda-mode-map "\C-c," 'org-agenda-priority)
 (define-key org-agenda-mode-map "i" 'org-agenda-diary-entry)
 (define-key org-agenda-mode-map "c" 'org-agenda-goto-calendar)
+(eval-after-load "calendar"
+  '(define-key calendar-mode-map org-calendar-to-agenda-key
+     'org-calendar-goto-agenda))
 (define-key org-agenda-mode-map "C" 'org-agenda-convert-date)
 (define-key org-agenda-mode-map "m" 'org-agenda-phases-of-moon)
 (define-key org-agenda-mode-map "M" 'org-agenda-phases-of-moon)
@@ -2981,6 +3003,8 @@
 (define-key org-agenda-mode-map "H" 'org-agenda-holidays)
 (define-key org-agenda-mode-map "+" 'org-agenda-priority-up)
 (define-key org-agenda-mode-map "-" 'org-agenda-priority-down)
+(define-key org-agenda-mode-map [(shift up)] 'org-agenda-priority-up)
+(define-key org-agenda-mode-map [(shift down)] 'org-agenda-priority-down)
 (define-key org-agenda-mode-map [(right)] 'org-agenda-later)
 (define-key org-agenda-mode-map [(left)] 'org-agenda-earlier)
 
@@ -3007,7 +3031,7 @@
      ["Reschedule +1 day" org-agenda-date-later t]
      ["Reschedule -1 day" org-agenda-date-earlier t]
      "--"
-     ["Reschedule to today" org-agenda-date-today t])
+     ["Reschedule to ..." org-agenda-date-prompt t])
     ("Priority"
      ["Set Priority" org-agenda-priority t]
      ["Increase Priority" org-agenda-priority-up t]
@@ -3024,8 +3048,8 @@
      :style toggle :selected org-agenda-include-diary :active t]
     "--"
     ["New Diary Entry" org-agenda-diary-entry t]
-    ("Calendar commands"
-     ["Goto calendar" org-agenda-goto-calendar t]
+    ("Calendar Commands"
+     ["Goto Calendar" org-agenda-goto-calendar t]
      ["Phases of the Moon" org-agenda-phases-of-moon t]
      ["Sunrise/Sunset" org-agenda-sunrise-sunset t]
      ["Holidays" org-agenda-holidays t]
@@ -3040,11 +3064,11 @@
 (defvar org-agenda-last-marker-time (time-to-seconds (current-time))
   "Creation time of the last agenda marker.")
 
-(defun org-agenda-new-marker (pos)
+(defun org-agenda-new-marker (&optional pos)
   "Return a new agenda marker.
 Org-mode keeps a list of these markers and resets them when they are
 no longer in use."
-  (let ((m (copy-marker pos)))
+  (let ((m (copy-marker (or pos (point)))))
     (setq org-agenda-last-marker-time (time-to-seconds (current-time)))
     (push m org-agenda-markers)
     m))
@@ -3089,7 +3113,7 @@
 (defun org-timeline (&optional include-all)
   "Show a time-sorted view of the entries in the current org file.
 Only entries with a time stamp of today or later will be listed.  With
-one C-u prefix argument, also past entries will be listed.
+one C-u prefix argument, past entries will also be listed.
 With two C-u prefixes, all unfinished TODO items will also be shown,
 under the current date.
 If the buffer contains an active region, only check the region for
@@ -3237,7 +3261,6 @@
           (setq rtnall (append rtnall rtn))))
       (if org-agenda-include-diary
           (progn
-            (require 'calendar)
             (require 'diary-lib)
             (setq rtn (org-get-entries-from-diary date))
             (setq rtnall (append rtnall rtn))))
@@ -3293,8 +3316,8 @@
 
 (defun org-agenda-exit (arg)
   "Exit agenda by removing the window or the buffer.
-Also kill all Org-mode buffers which have be loaded by `org-agenda'.
-Org-mode buffers visitied directly by the user will no be touched."
+Also kill all Org-mode buffers which have been loaded by `org-agenda'.
+Org-mode buffers visited directly by the user will not be touched."
   (interactive "P")
   (org-release-buffers org-agenda-new-buffers)
   (setq org-agenda-new-buffers nil)
@@ -3356,6 +3379,24 @@
   (message "Switched to %s view"
            (if (equal org-agenda-ndays 1) "day" "week")))
 
+(defun org-agenda-next-date-line (&optional arg)
+  "Jump to the next line indicating a date in agenda buffer."
+  (interactive "p")
+  (beginning-of-line 1)
+  (if (looking-at "^\\S-") (forward-char 1))
+  (if (not (re-search-forward "^\\S-" nil t arg))
+      (progn
+        (backward-char 1)
+        (error "No next date after this line in this buffer.")))
+  (goto-char (match-beginning 0)))
+
+(defun org-agenda-previous-date-line (&optional arg)
+  "Jump to the next line indicating a date in agenda buffer."
+  (interactive "p")
+  (beginning-of-line 1)
+  (if (not (re-search-backward "^\\S-" nil t arg))
+      (error "No previous date before this line in this buffer.")))
+
 (defun org-agenda-follow-mode ()
   "Toggle follow mode in an agenda buffer."
   (interactive)
@@ -3374,7 +3415,7 @@
            (if org-agenda-include-diary "on" "off")))
 
 (defun org-agenda-set-mode-name ()
-  "Set the mode name to indicate all the small mode seetings."
+  "Set the mode name to indicate all the small mode settings."
   (setq mode-name
         (concat "Org-Agenda"
                 (if (equal org-agenda-ndays 1) " Day"    "")
@@ -3384,6 +3425,7 @@
   (force-mode-line-update))
 
 (defun org-agenda-post-command-hook ()
+  (and (eolp) (not (bolp)) (backward-char 1))
   (if (and org-agenda-follow-mode
            (get-text-property (point) 'org-marker))
       (org-agenda-show)))
@@ -3454,7 +3496,7 @@
       (replace-match "")))
 
 ;; Advise the add-to-diary-list function to allow org to jump to
-;; diary entires. Wrapped into eval-after-load to avoid loading
+;; diary entries. Wrapped into eval-after-load to avoid loading
 ;; advice unnecessarily
 (eval-after-load "diary-lib"
   '(defadvice add-to-diary-list (before org-mark-diary-entry activate)
@@ -3477,7 +3519,11 @@
 (defun org-diary-default-entry ()
   "Add a dummy entry to the diary.
 Needed to avoid empty dates which mess up holiday display."
-  (add-to-diary-list original-date "Org-mode dummy" "" nil))
+  ;; Catch the error if dealing with the new add-to-diary-alist
+  (condition-case nil
+      (add-to-diary-list original-date "Org-mode dummy" "")
+    (error
+     (add-to-diary-list original-date  "Org-mode dummy" "" nil))))
 
 (defun org-add-file (&optional file)
   "Add current file to the list of files in variable `org-agenda-files'.
@@ -3561,7 +3607,7 @@
 ;;;###autoload
 (defun org-diary (&rest args)
   "Returns diary information from org-files.
-This function can be used in an \"sexp\" diary entry in the Emacs calendar.
+This function can be used in a \"sexp\" diary entry in the Emacs calendar.
 It accesses org files and extracts information from those files to be
 listed in the diary.  The function accepts arguments specifying what
 items should be listed.  The following arguments are allowed:
@@ -3581,7 +3627,7 @@
 
    :todo         List all TODO items from the org-file.  This may be a
                  long list - so this is not turned on by default.
-                 Like deadlines, these entires only show up in the
+                 Like deadlines, these entries only show up in the
                  diary for *today*, not at any other date.
 
 The call in the diary file should look like this:
@@ -3670,10 +3716,10 @@
   "Is the current entry marked DONE?"
   (save-excursion
     (and (re-search-backward "[\r\n]\\*" nil t)
-         (looking-at orb-nl-done-regexp))))
+         (looking-at org-nl-done-regexp))))
 
 (defun org-at-date-range-p ()
-  "It the cursor inside a date range?"
+  "Is the cursor inside a date range?"
   (interactive)
   (save-excursion
     (catch 'exit
@@ -3693,6 +3739,7 @@
 (defun org-agenda-get-todos ()
   "Return the TODO information for agenda display."
   (let* ((props (list 'face nil
+                      'done-face 'org-done-face
                       'mouse-face 'highlight
                       'keymap org-agenda-keymap
                       'help-echo
@@ -3705,7 +3752,7 @@
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
       (goto-char (match-beginning 1))
-      (setq marker (org-agenda-new-marker (point))
+      (setq marker (org-agenda-new-marker (point-at-bol))
             txt (org-format-agenda-item "" (match-string 1))
             priority 
             (+ (org-get-priority txt)
@@ -3715,7 +3762,8 @@
                              (member (match-string 2) org-todo-keywords)))
                        1)))
       (add-text-properties
-       0 (length txt) (append (list 'org-marker marker 'priority priority)
+       0 (length txt) (append (list 'org-marker marker 'org-hd-marker marker
+                                    'priority priority)
                               props)
        txt)
       (push txt ee)
@@ -3740,23 +3788,25 @@
                     (apply 'encode-time  ; DATE bound by calendar
                            (list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
                    0 11)))
-         marker deadlinep scheduledp tmp priority
+         marker hdmarker deadlinep scheduledp donep tmp priority
          ee txt)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
       (if (not (save-match-data (org-at-date-range-p)))
           (progn
-            (setq marker (org-agenda-new-marker (point))
+            (setq marker (org-agenda-new-marker (match-beginning 0))
                   tmp (buffer-substring (max (point-min)
                                              (- (match-beginning 0)
                                                 org-ds-keyword-length))
                                         (match-beginning 0))
                   deadlinep (string-match org-deadline-regexp tmp)
-                  scheduledp (string-match org-scheduled-regexp tmp))
+                  scheduledp (string-match org-scheduled-regexp tmp)
+                  donep (org-entry-is-done-p))
             (save-excursion
               (if (re-search-backward "\\(^\\|\r\\)\\*+" nil t)
                   (progn
                     (goto-char (match-end 1))
+                    (setq hdmarker (org-agenda-new-marker))
                     (looking-at "\\*+[ \t]*\\([^\r\n]+\\)")
                     (setq txt (org-format-agenda-item
                                (format "%s%s"
@@ -3766,18 +3816,24 @@
                 (setq txt org-agenda-no-heading-message))
               (setq priority (org-get-priority txt))
               (add-text-properties
-               0 (length txt) (append (list 'org-marker marker) props)
+               0 (length txt) (append (list 'org-marker marker
+                                            'org-hd-marker hdmarker) props)
                txt)
               (if deadlinep
                   (add-text-properties
                    0 (length txt)
-                   (list 'face 'org-warning-face
+                   (list 'face 
+                         (if donep 'org-done-face 'org-warning-face)
+                         'undone-face 'org-warning-face
+                         'done-face 'org-done-face
                          'priority (+ 100 priority))
                    txt)
                 (if scheduledp
                     (add-text-properties
                      0 (length txt)
                      (list 'face 'org-scheduled-today-face
+                           'undone-face 'org-scheduled-today-face
+                           'done-face 'org-done-face
                            priority (+ 99 priority))
                      txt)
                   (add-text-properties
@@ -3790,8 +3846,7 @@
 (defun org-agenda-get-deadlines ()
   "Return the deadline information for agenda display."
   (let* ((wdays org-deadline-warning-days)
-         (props (list 'face nil
-                      'mouse-face 'highlight
+         (props (list 'mouse-face 'highlight
                       'keymap org-agenda-keymap
                       'help-echo
                       (format "mouse-2 or RET jump to org file %s"
@@ -3799,13 +3854,13 @@
          (regexp org-deadline-time-regexp)
          (todayp (equal date (calendar-current-date))) ; DATE bound by calendar
          (d1 (calendar-absolute-from-gregorian date))  ; DATE bound by calendar
-         d2 diff pos
-         ee txt head)
+         d2 diff pos pos1
+         ee txt head hdmarker)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
-      (setq d2 (time-to-days
+      (setq pos (1- (match-beginning 1))
+            d2 (time-to-days
                 (org-time-string-to-time (match-string 1)))
-            pos (point)
             diff (- d2 d1))
       ;; When to show a deadline in the calendar:
       ;; If the expiration is within wdays warning time.
@@ -3815,6 +3870,7 @@
             (if (re-search-backward "\\(^\\|\r\\)\\*+[ \t]*" nil t)
                 (progn
                   (goto-char (match-end 0))
+                  (setq pos1 (match-end 1))
                   (setq head (buffer-substring-no-properties
                               (point)
                               (progn (skip-chars-forward "^\r\n")
@@ -3829,10 +3885,16 @@
                0 (length txt) 
                (append 
                 (list 'org-marker (org-agenda-new-marker pos)
+                      'org-hd-marker (org-agenda-new-marker pos1)
                       'priority (+ (- 10 diff) (org-get-priority txt))
                       'face (cond ((<= diff 0) 'org-warning-face)
-                                  ((<= diff 5) 'font-lock-function-name-face)
-                                  (t nil)))
+                                  ((<= diff 5) 'org-scheduled-previously-face)
+                                  (t nil))
+                      'undone-face (cond
+                                    ((<= diff 0) 'org-warning-face)
+                                    ((<= diff 5) 'org-scheduled-previously-face)
+                                    (t nil))
+                      'done-face 'org-done-face)
                 props)
                txt)
               (push txt ee)))))
@@ -3841,6 +3903,8 @@
 (defun org-agenda-get-scheduled ()
   "Return the scheduled information for agenda display."
   (let* ((props (list 'face 'org-scheduled-previously-face
+                      'undone-face 'org-scheduled-previously-face
+                      'done-face 'org-done-face
                       'mouse-face 'highlight
                       'keymap org-agenda-keymap
                       'help-echo
@@ -3849,13 +3913,13 @@
          (regexp org-scheduled-time-regexp)
          (todayp (equal date (calendar-current-date))) ; DATE bound by calendar
          (d1 (calendar-absolute-from-gregorian date))  ; DATE bound by calendar
-         d2 diff marker pos
+         d2 diff marker hdmarker pos pos1
          ee txt head)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
-      (setq d2 (time-to-days
+      (setq pos (1- (match-beginning 1))
+            d2 (time-to-days
                 (org-time-string-to-time (match-string 1)))
-            pos (point)
             diff (- d2 d1))
       ;; When to show a scheduled item in the calendar:
       ;; If it is on or past the date.
@@ -3864,6 +3928,7 @@
             (if (re-search-backward "\\(^\\|\r\\)\\*+[ \t]*" nil t)
                 (progn
                   (goto-char (match-end 0))
+                  (setq pos1 (match-end 1))
                   (setq head (buffer-substring-no-properties
                               (point)
                               (progn (skip-chars-forward "^\r\n") (point))))
@@ -3873,10 +3938,10 @@
                                (format "Sched.%2dx: " (- 1 diff)) head))))
               (setq txt org-agenda-no-heading-message))
             (when txt
-              (setq marker (org-agenda-new-marker pos))
               (add-text-properties
                0 (length txt)
-               (append (list 'org-marker marker
+               (append (list 'org-marker (org-agenda-new-marker pos)
+                             'org-hd-marker (org-agenda-new-marker pos1)
                              'priority (+ (- 5 diff) (org-get-priority txt)))
                        props) txt)
               (push txt ee)))))
@@ -3892,7 +3957,7 @@
                               (abbreviate-file-name (buffer-file-name)))))
          (regexp org-tr-regexp)
          (d0 (calendar-absolute-from-gregorian date))
-         marker ee txt d1 d2 s1 s2)
+         marker hdmarker ee txt d1 d2 s1 s2)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
       (setq s1 (match-string 1)
@@ -3906,6 +3971,7 @@
             (setq marker (org-agenda-new-marker (point)))
             (if (re-search-backward "\\(^\\|\r\\)\\*+" nil t)
                 (progn
+                  (setq hdmarker (org-agenda-new-marker (match-end 1)))
                   (goto-char (match-end 1))
                   (looking-at "\\*+[ \t]*\\([^\r\n]+\\)")
                   (setq txt (org-format-agenda-item 
@@ -3915,6 +3981,7 @@
               (setq txt org-agenda-no-heading-message))
             (add-text-properties
              0 (length txt) (append (list 'org-marker marker
+                                          'org-hd-marker hdmarker
                                           'priority (org-get-priority txt))
                                     props)
              txt)
@@ -3926,7 +3993,7 @@
 
 (defun org-format-agenda-item (prefix txt)
   "Format TXT to be inserted into the agenda buffer.
-In particular, this indents the lins and adds a category."
+In particular, this indents the line and adds a category."
   (let ((cat (or org-category
                  (file-name-sans-extension
                   (file-name-nondirectory (buffer-file-name)))))
@@ -4040,7 +4107,7 @@
              (org-flag-heading nil))))))  ; show the next heading
 
 (defun org-agenda-goto-mouse (ev)
-  "Go to the Org-mode file which contains the deadline at the mouse click."
+  "Go to the Org-mode file which contains the item at the mouse click."
   (interactive "e")
   (mouse-set-point ev)
   (org-agenda-goto))
@@ -4061,7 +4128,7 @@
     (select-window win)))
 
 (defun org-agenda-show-mouse (ev)
-  "Display the Org-mode file which contains the deadline at the mouse click."
+  "Display the Org-mode file which contains the item at the mouse click."
   (interactive "e")
   (mouse-set-point ev)
   (org-agenda-show))
@@ -4074,17 +4141,22 @@
 (defun org-agenda-error ()
   (error "Command not allowed in this line."))
 
+(defvar org-last-heading-marker (make-marker)
+  "Marker pointing to the headline that last changed its TODO state
+by a remote command from the agenda.")
+
 (defun org-agenda-todo ()
-  "Cycle TODO state of line at point, also in Org-mode file."
+  "Cycle TODO state of line at point, also in Org-mode file.
+This changes the line at point, all other lines in the agenda referring to
+the same tree node, and the headline of the tree node in the Org-mode file."
   (interactive)
   (org-agenda-check-no-diary)
-  (let* ((props (text-properties-at (point)))
-         (col (current-column))
+  (let* ((col (current-column))
          (marker (or (get-text-property (point) 'org-marker)
                      (org-agenda-error)))
-         (pl (get-text-property (point-at-bol) 'prefix-length))
          (buffer (marker-buffer marker))
          (pos (marker-position marker))
+         (hdmarker (get-text-property (point) 'org-hd-marker))
          (buffer-read-only nil)
          newhead)
     (save-excursion
@@ -4096,16 +4168,46 @@
         (and (outline-next-heading)
              (org-flag-heading nil)))   ; show the next heading
       (org-todo)
-      (setq newhead (org-get-heading)))
+      (forward-char 1)
+      (setq newhead (org-get-heading))
+      (save-excursion
+        (org-back-to-heading)
+        (move-marker org-last-heading-marker (point))))
     (beginning-of-line 1)
-    (move-to-column pl)
-    (if (looking-at ".*")
-        (progn
-          (replace-match newhead t t)
-          (move-to-column col)
-          (add-text-properties (point-at-bol) (point-at-eol) props)
-          (beginning-of-line 1))
-      (error "Line update did not work"))))
+    (save-excursion
+      (org-agenda-change-all-lines newhead hdmarker 'fixface))
+    (move-to-column col)))
+
+(defun org-agenda-change-all-lines (newhead hdmarker &optional fixface)
+  "Change all lines in the agenda buffer which match hdmarker.
+The new content of the line will be NEWHEAD.  HDMARKER is checked with
+`equal' against all `org-hd-marker' text properties in the file."
+  (let* (props m pl undone-face done-face)
+    (save-excursion
+      (goto-char (point-max))
+      (beginning-of-line 1)
+      (while (not (bobp))
+        (when (and (setq m (get-text-property (point) 'org-hd-marker))
+                   (equal m hdmarker))
+          (setq props (text-properties-at (point))
+                pl (get-text-property (point) 'prefix-length)
+                undone-face (get-text-property (point) 'undone-face)
+                done-face (get-text-property (point) 'done-face))
+          (move-to-column pl)
+          (if (looking-at ".*")
+              (progn
+                (replace-match newhead t t)
+                (beginning-of-line 1)
+                (add-text-properties (point-at-bol) (point-at-eol) props)
+                (if fixface
+                    (add-text-properties 
+                     (point-at-bol) (point-at-eol)
+                     (list 'face
+                           (if org-last-todo-state-is-todo
+                               undone-face done-face))))
+                (beginning-of-line 1))
+            (error "Line update did not work")))
+        (beginning-of-line 0)))))
 
 (defun org-agenda-priority-up ()
   "Increase the priority of line at point, also in Org-mode file."
@@ -4118,7 +4220,9 @@
   (org-agenda-priority 'down))
 
 (defun org-agenda-priority (&optional force-direction)
-  "Set the priority of line at point, also in Org-mode file."
+  "Set the priority of line at point, also in Org-mode file.
+This changes the line at point, all other lines in the agenda referring to
+the same tree node, and the headline of the tree node in the Org-mode file."
   (interactive)
   (org-agenda-check-no-diary)
   (let* ((props (text-properties-at (point)))
@@ -4128,6 +4232,7 @@
          (pl (get-text-property (point-at-bol) 'prefix-length))
          (buffer (marker-buffer marker))
          (pos (marker-position marker))
+         (hdmarker (get-text-property (point) 'org-hd-marker))
          (buffer-read-only nil)
          newhead)
     (save-excursion
@@ -4140,15 +4245,8 @@
              (org-flag-heading nil)))   ; show the next heading
       (funcall 'org-priority force-direction)
       (setq newhead (org-get-heading)))
-    (beginning-of-line 1)
-    (move-to-column pl)
-    (if (looking-at ".*")
-        (progn
-          (replace-match (concat newhead) t t)
-          (move-to-column col)
-          (add-text-properties (point-at-bol) (point-at-eol) props)
-          (beginning-of-line 1))
-      (error "Line update did not work"))))
+    (org-agenda-change-all-lines newhead hdmarker)
+    (beginning-of-line 1)))
 
 (defun org-agenda-date-later (arg &optional what)
   "Change the date of this item to one day later."
@@ -4172,8 +4270,8 @@
   (interactive "p")
   (org-agenda-date-later (- arg) what))
 
-(defun org-agenda-date-today (arg)
-  "Change the date of this item to today."
+(defun org-agenda-date-prompt (arg)
+  "Change the date of this item.  Date is prompted for, with default today."
   (interactive "p")
   (org-agenda-check-no-diary)
   (let* ((marker (or (get-text-property (point) 'org-marker)
@@ -4222,7 +4320,7 @@
                  (or (not (equal ?b char))
                      (get-text-property mark 'day)))
       (error "Don't know which date to use for diary entry"))
-    ;; We implememnt this by hacking the `calendar-cursor-to-date' function
+    ;; We implement this by hacking the `calendar-cursor-to-date' function
     ;; and the `calendar-mark-ring' variable.  Saves a lot of code.
     (let ((calendar-mark-ring
            (list (calendar-gregorian-from-absolute
@@ -4262,12 +4360,12 @@
         (fset 'calendar-cursor-to-date oldf))))
 
 (defun org-agenda-phases-of-moon ()
-  "Display the phases of the moon for 3 month around cursor date."
+  "Display the phases of the moon for the 3 months around the cursor date."
   (interactive)
   (org-agenda-execute-calendar-command 'calendar-phases-of-moon))
 
 (defun org-agenda-holidays ()
-  "Display the holidays for 3 month around cursor date."
+  "Display the holidays for the 3 months around the cursor date."
   (interactive)
   (org-agenda-execute-calendar-command 'list-calendar-holidays))
 
@@ -4275,11 +4373,12 @@
   "Display sunrise and sunset for the cursor date.
 Latitude and longitude can be specified with the variables
 `calendar-latitude' and `calendar-longitude'.  When called with prefix
-argument, location will be prompted for."
+argument, latitude and longitude will be prompted for."
   (interactive "P")
   (let ((calendar-longitude (if arg nil calendar-longitude))
         (calendar-latitude  (if arg nil calendar-latitude))
-        (calendar-location-name nil))
+        (calendar-location-name
+         (if arg "the given coordinates" calendar-location-name)))
     (org-agenda-execute-calendar-command 'calendar-sunrise-sunset)))
 
 (defun org-agenda-goto-calendar ()
@@ -4291,6 +4390,13 @@
     (calendar)
     (calendar-goto-date date)))
 
+(defun org-calendar-goto-agenda ()
+  "Compute the Org-mode agenda for the calendar date displayed at the cursor.
+This is a command that has to be installed in `calendar-mode-map'."
+  (interactive)
+  (org-agenda nil (calendar-absolute-from-gregorian
+                   (calendar-cursor-to-date))))
+
 (defun org-agenda-convert-date ()
   (interactive)
   (let ((day (get-text-property (point) 'day))
@@ -4298,25 +4404,21 @@
     (unless day
       (error "Don't know which date to convert"))
     (setq date (calendar-gregorian-from-absolute day))
-    (require 'cal-julian)
-    (require 'cal-hebrew)
-    (require 'cal-islam)
-    (require 'cal-french)
-    (require 'cal-mayan)
-    (require 'cal-coptic)
-    (require 'cal-persia)
-    (require 'cal-china)
     (setq s (concat 
              "Gregorian:  " (calendar-date-string date) "\n"
+             "ISO:        " (calendar-iso-date-string date) "\n"
+             "Day of Yr:  " (calendar-day-of-year-string date) "\n"
              "Julian:     " (calendar-julian-date-string date) "\n"
-             "Astronomic: " (calendar-astro-date-string date) " (at noon UTC)\n"
-             "Hebrew:     " (calendar-hebrew-date-string date) "\n"
-             "Islamic:    " (calendar-islamic-date-string date) "\n"
+             "Astronomic: " (calendar-astro-date-string date)
+             " (Julian date number at noon UTC)\n"
+             "Hebrew:     " (calendar-hebrew-date-string date) " (until sunset)\n"
+             "Islamic:    " (calendar-islamic-date-string date) " (until sunset)\n"
              "French:     " (calendar-french-date-string date) "\n"
-             "Maya:       " (calendar-mayan-date-string date) "\n"
+             "Mayan:      " (calendar-mayan-date-string date) "\n"
              "Coptic:     " (calendar-coptic-date-string date) "\n"
+             "Ethiopic:   " (calendar-ethiopic-date-string date) "\n"
              "Persian:    " (calendar-persian-date-string date) "\n"
-             "Chineese:   " (calendar-chinese-date-string date) "\n"))
+             "Chinese:    " (calendar-chinese-date-string date) "\n"))
     (with-output-to-temp-buffer "*Dates*"
       (princ s))
     (fit-window-to-buffer (get-buffer-window "*Dates*"))))
@@ -5100,11 +5202,11 @@
   "Marker at the end of the table last aligned.
 Used to check if cursor still is in that table, to minimize realignment.")
 (defvar org-table-last-alignment nil
-  "List of flags for flushright alignment, from the last re-algnment.
+  "List of flags for flushright alignment, from the last re-alignment.
 This is being used to correctly align a single field after TAB or RET.")
 ;; FIXME:  The following is currently not used.
 (defvar org-table-last-column-widths nil
-  "List of max width of ffields in each column.
+  "List of max width of fields in each column.
 This is being used to correctly align a single field after TAB or RET.")
 
 
@@ -5327,7 +5429,7 @@
   "Copy a field down in the current column.
 If the field at the cursor is empty, copy into it the content of the nearest
 non-empty field above.  With argument N, use the Nth non-empty field.
-If the current fields is not empty, it is copied down to the next row, and
+If the current field is not empty, it is copied down to the next row, and
 the cursor is moved with it.  Therefore, repeating this command causes the
 column to be filled row-by-row.  
 If the variable `org-table-copy-increment' is non-nil and the field is an
@@ -5430,7 +5532,7 @@
                            (progn (end-of-line 1)
                                   (skip-chars-backward "^|")
                                   (insert " |")
-                                  (bachward-char 2) t)))))
+                                  (backward-char 2) t)))))
       (when (and force (not (looking-at ".*|")))
         (save-excursion (end-of-line 1) (insert "|")))
       (if on-delim
@@ -5533,7 +5635,7 @@
          "Please position cursor in a data line for column operations")))))
 
 (defun org-table-delete-column (&optional arg)
-  "Insert a new column into the table."
+  "Delete a column into the table."
   (interactive "P")
   (if (not (org-at-table-p))
       (error "Not at a table"))
@@ -5603,7 +5705,7 @@
   (interactive)
   (org-table-move-row nil))
 (defun org-table-move-row-up ()
-  "Move table row down."
+  "Move table row up."
   (interactive)
   (org-table-move-row 'up))
 
@@ -5696,7 +5798,7 @@
 
 (defun org-table-copy-region (&optional cut)
   "Copy rectangular region in table to clipboard.
-A special clibbooard is used which can only be accessed
+A special clipboard is used which can only be accessed
 with `org-table-paste-rectangle'"
   (interactive "P")
   (unless (org-region-active-p) (error "No active region"))
@@ -5731,7 +5833,7 @@
     (if cut (org-table-align))))
   
 (defun org-table-paste-rectangle (&optional arg)
-  "Paste a rectangluar region into a table.
+  "Paste a rectangular region into a table.
 The upper right corner ends up in the current field.  All involved fields
 will be overwritten.  If the rectangle does not fit into the present table,
 the table is enlarged as needed.  The process ignores horizontal separator
@@ -5835,7 +5937,7 @@
             nlines)
         (org-table-cut-region)
         (if (> (length (car org-table-clip)) 1)
-            (error "Region must be limited to single columm"))
+            (error "Region must be limited to single column"))
         (setq nlines (if arg
                          (if (< arg 1)
                              (+ (length org-table-clip) arg)
@@ -5873,11 +5975,11 @@
   (if (string-match "[ \t]+$" s) (setq s (replace-match "" t t s))))
 
 (defun org-wrap (string &optional width lines)
-  "Wrap string to either a number of lines, or a with in characters.
+  "Wrap string to either a number of lines, or a width in characters.
 If WIDTH is non-nil, the string is wrapped to that width, however many lines
-that costs.  If there is a work longer than WIDTH, the text is actually
+that costs.  If there is a word longer than WIDTH, the text is actually
 wrapped to the length of that word.
-IF WIDTH is nil and LINES is non-nil, the string is forced into at mot that
+IF WIDTH is nil and LINES is non-nil, the string is forced into at most that
 many lines, whatever width that takes.
 The return value is a list of lines, without newlines at the end."
   (let* ((words (org-split-string string "[ \t\n]+"))
@@ -5961,7 +6063,7 @@
 (defun org-table-toggle-vline-visibility (&optional arg)
   "Toggle the visibility of table vertical lines.
 The effect is immediate and on all tables in the file.
-With prefix ARG, make lines invisible when ARG if positive, make lines
+With prefix ARG, make lines invisible when ARG is positive, make lines
 visible when ARG is not positive"
   (interactive "P")
   (let ((action (cond
@@ -5983,7 +6085,7 @@
     (redraw-frame (selected-frame))))
 
 (defun org-table-map-tables (function)
-  "Apply FUNCTION to the start of all tables in the  buffer."
+  "Apply FUNCTION to the start of all tables in the buffer."
   (save-excursion
     (save-restriction
       (widen)
@@ -6005,7 +6107,7 @@
 region and point is located in a table column, sum all numbers in that
 column.
 
-If at least on number looks like a time HH:MM or HH:MM:SS, all other
+If at least one number looks like a time HH:MM or HH:MM:SS, all other
 numbers are assumed to be times as well (in decimal hours) and the
 numbers are added as such."
   (interactive)
@@ -6115,9 +6217,9 @@
 
 A few examples for formulae:
   $1+$2               Sum of first and second field
-  $1+$2;%f.2          Same, and format result to two digits after dec.point
+  $1+$2;%.2f          Same, and format result to two digits after dec.point
   exp($2)+exp($1)     Math functions can be used
-  $;%f.1              Reformat current cell to 1 digit after dec.point
+  $;%.1f              Reformat current cell to 1 digit after dec.point
   ($3-32)*5/9         degrees F -> C conversion
 
 When called with a raw C-u prefix, the formula is applied to the current
@@ -6210,7 +6312,7 @@
 
 (defvar orgtbl-mode nil
   "Variable controlling orgtbl-mode, a minor mode enabling the org-mode
-table editor iin arbitrary modes.")
+table editor in arbitrary modes.")
 (make-variable-buffer-local 'orgtbl-mode)
 
 (defvar orgtbl-mode-map (make-sparse-keymap)
@@ -6399,36 +6501,36 @@
 (easy-menu-define orgtbl-mode-menu orgtbl-mode-map "OrgTbl menu"
   '("Tbl"
     ["Align" org-ctrl-c-ctrl-c :active (org-at-table-p) :keys "C-c C-c"]
-    ["Next field" org-cycle :active (org-at-table-p) :keys "TAB"]
+    ["Next Field" org-cycle :active (org-at-table-p) :keys "TAB"]
     ["Previous Field" org-shifttab :active (org-at-table-p) :keys "S-TAB"]
-    ["Next row" org-return :active (org-at-table-p) :keys "RET"]
+    ["Next Row" org-return :active (org-at-table-p) :keys "RET"]
     "--"
-    ["Blank field" org-table-blank-field :active (org-at-table-p) :keys "C-c SPC"]
-    ["Copy field from above"
+    ["Blank Field" org-table-blank-field :active (org-at-table-p) :keys "C-c SPC"]
+    ["Copy Field from Above"
      org-table-copy-down :active (org-at-table-p) :keys "S-RET"]
     "--"
     ("Column"
-     ["Move column left" org-metaleft :active (org-at-table-p) :keys "M-<left>"]
-     ["Move column right" org-metaright :active (org-at-table-p) :keys "M-<right>"]
-     ["Delete column" org-shiftmetaleft :active (org-at-table-p) :keys "M-S-<left>"]
-     ["Insert column" org-shiftmetaright :active (org-at-table-p) :keys "M-S-<right>"])
+     ["Move Column Left" org-metaleft :active (org-at-table-p) :keys "M-<left>"]
+     ["Move Column Right" org-metaright :active (org-at-table-p) :keys "M-<right>"]
+     ["Delete Column" org-shiftmetaleft :active (org-at-table-p) :keys "M-S-<left>"]
+     ["Insert Column" org-shiftmetaright :active (org-at-table-p) :keys "M-S-<right>"])
     ("Row"
-     ["Move row up" org-metaup :active (org-at-table-p) :keys "M-<up>"]
-     ["Move row down" org-metadown :active (org-at-table-p) :keys "M-<down>"]
-     ["Delete row" org-shiftmetaup :active (org-at-table-p) :keys "M-S-<up>"]
-     ["Insert row" org-shiftmetadown :active (org-at-table-p) :keys "M-S-<down>"]
+     ["Move Row Up" org-metaup :active (org-at-table-p) :keys "M-<up>"]
+     ["Move Row Down" org-metadown :active (org-at-table-p) :keys "M-<down>"]
+     ["Delete Row" org-shiftmetaup :active (org-at-table-p) :keys "M-S-<up>"]
+     ["Insert Row" org-shiftmetadown :active (org-at-table-p) :keys "M-S-<down>"]
      "--"
-     ["Insert hline" org-table-insert-hline :active (org-at-table-p) :keys "C-c -"])
+     ["Insert Hline" org-table-insert-hline :active (org-at-table-p) :keys "C-c -"])
     ("Rectangle"
-     ["Copy rectangle" org-copy-special :active (org-at-table-p) :keys "C-c M-w"]
-     ["Cut rectangle" org-cut-special :active (org-at-table-p) :keys "C-c C-w"]
-     ["Paste rectangle" org-paste-special :active (org-at-table-p) :keys "C-c C-y"]
-     ["Fill rectangle" org-table-wrap-region :active (org-at-table-p) :keys "C-c C-q"])
+     ["Copy Rectangle" org-copy-special :active (org-at-table-p) :keys "C-c M-w"]
+     ["Cut Rectangle" org-cut-special :active (org-at-table-p) :keys "C-c C-w"]
+     ["Paste Rectangle" org-paste-special :active (org-at-table-p) :keys "C-c C-y"]
+     ["Fill Rectangle" org-table-wrap-region :active (org-at-table-p) :keys "C-c C-q"])
     "--"
-    ["Which column?" org-table-current-column :active (org-at-table-p) :keys "C-c ?"]
-    ["Sum column/rectangle" org-table-sum 
+    ["Which Column?" org-table-current-column :active (org-at-table-p) :keys "C-c ?"]
+    ["Sum Column/Rectangle" org-table-sum 
      :active (or (org-at-table-p) (org-region-active-p)) :keys "C-c +"]
-    ["Eval formula" org-table-eval-formula :active (org-at-table-p) :keys "C-c ="]
+    ["Eval Formula" org-table-eval-formula :active (org-at-table-p) :keys "C-c ="]
     ))
 
 ;;; Exporting
@@ -6436,7 +6538,7 @@
 (defconst org-level-max 20)
 
 (defun org-export-find-first-heading-line (list)
-  "Remove all lines from LIST which are before  the first headline."
+  "Remove all lines from LIST which are before the first headline."
   (let ((orig-list list)
         (re (concat "^" outline-regexp)))
     (while (and list
@@ -6897,7 +6999,7 @@
               (if todo (throw 'exit t))))))))
 
 ;; FIXME: Try to handle <b> and <i> as faces via text properties.
-;; FIXME: Can I implement *bold*,/italic/ and _underline_ for AXCII export?
+;; FIXME: Can I implement *bold*,/italic/ and _underline_ for ASCII export?
 (defun org-html-expand-for-ascii (line)
   "Handle quoted HTML for ASCII export."
   (if org-export-html-expand
@@ -6930,7 +7032,7 @@
 
 (defun org-export-copy-visible (&optional arg)
   "Copy the visible part of the buffer to another buffer, for printing.
-Also removes the first line of the buffer it is specifies a mode,
+Also removes the first line of the buffer if it specifies a mode,
 and all options lines."
   (interactive "P")
   (let* ((filename (concat (file-name-sans-extension (buffer-file-name))
@@ -7013,7 +7115,8 @@
    (if (equal org-todo-interpretation 'type)
        (mapconcat 'identity org-todo-keywords " ")
      "Me Jason Marie DONE")
-   (if org-startup-folded "fold" "nofold")
+   (cdr (assoc org-startup-folded
+               '((nil . "nofold")(t . "fold")(content . "content"))))
    (if org-startup-with-deadline-check "dlcheck" "nodlcheck")
    ))
 
@@ -7029,7 +7132,7 @@
 (defun org-toggle-fixed-width-section (arg)
   "Toggle the fixed-width indicator at the beginning of lines in the region.
 If there is no active region, only acts on the current line.
-If the first non-white  character in the first line of the region is a
+If the first non-white character in the first line of the region is a
 vertical bar \"|\", then the command removes the bar from all lines in
 the region.  If the first character is not a bar, the command adds a
 bar to all lines, in the column given by the beginning of the region.
@@ -7736,8 +7839,8 @@
 (define-key org-mode-map "\C-c\C-x\C-a"   'org-export-as-ascii)
 (define-key org-mode-map "\C-c\C-xv"      'org-export-copy-visible)
 (define-key org-mode-map "\C-c\C-x\C-v"   'org-export-copy-visible)
-(define-key org-mode-map "\C-c\C-xo"      'org-export-as-opml)
-(define-key org-mode-map "\C-c\C-x\C-o"   'org-export-as-opml)
+;(define-key org-mode-map "\C-c\C-xo"      'org-export-as-opml)
+;(define-key org-mode-map "\C-c\C-x\C-o"   'org-export-as-opml)
 (define-key org-mode-map "\C-c\C-xt"      'org-insert-export-options-template)
 (define-key org-mode-map "\C-c:"          'org-toggle-fixed-width-section)
 (define-key org-mode-map "\C-c\C-xh"      'org-export-as-html)
@@ -7941,6 +8044,8 @@
       (table-recognize-table))
      ((org-at-table-p)
       (org-table-align))
+     ((save-excursion (beginning-of-line 1) (looking-at "#\\+[A-Z]+"))
+      (let (org-inhibit-startup) (org-mode)))
      ((org-region-active-p)
       (org-table-convert-region (region-beginning) (region-end) arg))
      ((and (region-beginning) (region-end))
@@ -7996,8 +8101,8 @@
      "--"
      ["Jump" org-goto t])
     ("Edit Structure"
-     ["Move subtree up" org-shiftmetaup (not (org-at-table-p))]
-     ["Move subtree down" org-shiftmetadown (not (org-at-table-p))]
+     ["Move Subtree Up" org-shiftmetaup (not (org-at-table-p))]
+     ["Move Subtree Down" org-shiftmetadown (not (org-at-table-p))]
      "--"
      ["Copy Subtree"  org-copy-special (not (org-at-table-p))]
      ["Cut Subtree"  org-cut-special (not (org-at-table-p))]
@@ -8008,20 +8113,20 @@
      ["Demote Heading"  org-metaright (not (org-at-table-p))]
      ["Demote Subtree"  org-shiftmetaright (not (org-at-table-p))])
     "--"
-    ("TODO lists"
+    ("TODO Lists"
      ["TODO/DONE/-" org-todo t]
      ["Show TODO Tree" org-show-todo-tree t]
      "--"
-     ["Set priority" org-priority t]
-     ["Priority up" org-shiftup t]
-     ["Priority down" org-shiftdown t])
+     ["Set Priority" org-priority t]
+     ["Priority Up" org-shiftup t]
+     ["Priority Down" org-shiftdown t])
     ("Dates and Scheduling"
      ["Timestamp" org-time-stamp t]
      ("Change Date"
-      ["1 day later" org-timestamp-up-day t]
-      ["1 day earlier" org-timestamp-down-day t]
-      ["1 ... later" org-shiftup t]
-      ["1 ... earlier" org-shiftdown t])
+      ["1 Day Later" org-timestamp-up-day t]
+      ["1 Day Earlier" org-timestamp-down-day t]
+      ["1 ... Later" org-shiftup t]
+      ["1 ... Earlier" org-shiftdown t])
      ["Compute Time Range" org-evaluate-time-range t]
      ["Schedule Item" org-schedule t]
      ["Deadline" org-deadline t]
@@ -8030,71 +8135,70 @@
      ["Date from Calendar" org-date-from-calendar t])
     "--"
     ("Timeline/Agenda"
-     ["Show TODO Tree this file"  org-show-todo-tree t]
-     ["Check Deadlines this file" org-check-deadlines t]
-     ["Timeline current file" org-timeline t]
+     ["Show TODO Tree this File"  org-show-todo-tree t]
+     ["Check Deadlines this File" org-check-deadlines t]
+     ["Timeline Current File" org-timeline t]
      "--"
-     ["Adenda (multifile)" org-agenda t])
+     ["Agenda" org-agenda t])
     ("File List for Agenda")
     "--"
     ("Hyperlinks"
-     ["Store Link (global)" org-store-link t]
+     ["Store Link (Global)" org-store-link t]
      ["Insert Link" org-insert-link t]
      ["Follow Link" org-open-at-point t])
-    ;; ["BBDB" org-bbdb-name t]
     "--"
     ("Table"
      ["Align" org-ctrl-c-ctrl-c (org-at-table-p)]
-     ["Next field" org-cycle (org-at-table-p)]
+     ["Next Field" org-cycle (org-at-table-p)]
      ["Previous Field" org-shifttab (org-at-table-p)]
-     ["Next row" org-return (org-at-table-p)]
+     ["Next Row" org-return (org-at-table-p)]
      "--"
-     ["Blank field" org-table-blank-field (org-at-table-p)]
-     ["Copy field from above" org-table-copy-down (org-at-table-p)]
+     ["Blank Field" org-table-blank-field (org-at-table-p)]
+     ["Copy Field from Above" org-table-copy-down (org-at-table-p)]
      "--"
      ("Column"
-      ["Move column left" org-metaleft (org-at-table-p)]
-      ["Move column right" org-metaright (org-at-table-p)]
-      ["Delete column" org-shiftmetaleft (org-at-table-p)]
-      ["Insert column" org-shiftmetaright (org-at-table-p)])
+      ["Move Column Left" org-metaleft (org-at-table-p)]
+      ["Move Column Right" org-metaright (org-at-table-p)]
+      ["Delete Column" org-shiftmetaleft (org-at-table-p)]
+      ["Insert Column" org-shiftmetaright (org-at-table-p)])
      ("Row"
-      ["Move row up" org-metaup (org-at-table-p)]
-      ["Move row down" org-metadown (org-at-table-p)]
-      ["Delete row" org-shiftmetaup (org-at-table-p)]
-      ["Insert row" org-shiftmetadown (org-at-table-p)]
+      ["Move Row Up" org-metaup (org-at-table-p)]
+      ["Move Row Down" org-metadown (org-at-table-p)]
+      ["Delete Row" org-shiftmetaup (org-at-table-p)]
+      ["Insert Row" org-shiftmetadown (org-at-table-p)]
       "--"
-      ["Insert hline" org-table-insert-hline (org-at-table-p)])
+      ["Insert Hline" org-table-insert-hline (org-at-table-p)])
      ("Rectangle"
-      ["Copy rectangle" org-copy-special (org-at-table-p)]
-      ["Cut rectangle" org-cut-special (org-at-table-p)]
-      ["Paste rectangle" org-paste-special (org-at-table-p)]
-      ["Fill rectangle" org-table-wrap-region (org-at-table-p)])
+      ["Copy Rectangle" org-copy-special (org-at-table-p)]
+      ["Cut Rectangle" org-cut-special (org-at-table-p)]
+      ["Paste Rectangle" org-paste-special (org-at-table-p)]
+      ["Fill Rectangle" org-table-wrap-region (org-at-table-p)])
      "--"
-     ["Which column?" org-table-current-column (org-at-table-p)]
-     ["Sum column/rectangle" org-table-sum 
+     ["Which Column?" org-table-current-column (org-at-table-p)]
+     ["Sum Column/Rectangle" org-table-sum 
       (or (org-at-table-p) (org-region-active-p))]
-     ["Eval formula" org-table-eval-formula (org-at-table-p)]
+     ["Eval Formula" org-table-eval-formula (org-at-table-p)]
      "--"
      ["Invisible Vlines" org-table-toggle-vline-visibility
       :style toggle :selected (org-in-invisibility-spec-p '(org-table))]
      "--"
      ["Create" org-table-create (and (not (org-at-table-p))
                                      org-enable-table-editor)]
-     ["Convert region" org-ctrl-c-ctrl-c (not (org-at-table-p 'any))]
-     ["Import from file" org-table-import (not (org-at-table-p))]
-     ["Export to file" org-table-export (org-at-table-p)]
+     ["Convert Region" org-ctrl-c-ctrl-c (not (org-at-table-p 'any))]
+     ["Import from File" org-table-import (not (org-at-table-p))]
+     ["Export to File" org-table-export (org-at-table-p)]
      "--"
-     ["Create/convert from/to table.el" org-table-create-with-table.el t])
+     ["Create/Convert from/to table.el" org-table-create-with-table.el t])
     "--"
     ("Export"
      ["ASCII" org-export-as-ascii t]
-     ["Extract visible text" org-export-copy-visible t]
+     ["Extract Visible Text" org-export-copy-visible t]
      ["HTML"  org-export-as-html t]
-     ["HTML, and open" org-export-as-html-and-open t]
-     ["OPML" org-export-as-opml nil]
+     ["HTML and Open" org-export-as-html-and-open t]
+;     ["OPML" org-export-as-opml nil]
      "--"
-     ["Option template" org-insert-export-options-template t]
-     ["Toggle fixed width" org-toggle-fixed-width-section t])
+     ["Option Template" org-insert-export-options-template t]
+     ["Toggle Fixed Width" org-toggle-fixed-width-section t])
     "--"
     ("Documentation"
      ["Show Version" org-version t]
@@ -8106,7 +8210,6 @@
       (fboundp 'customize-menu-create)])
     ))
 
-
 (defun org-info (&optional node)
   "Read documentation for Org-mode in the info system.
 With optional NODE, go directly to that node."
@@ -8114,15 +8217,14 @@
   (require 'info)
   (Info-goto-node (format "(org)%s" (or node ""))))
 
-
 (defun org-install-agenda-files-menu ()
   (easy-menu-change 
    '("Org") "File List for Agenda"
    (append
     (list 
-     ["Edit file list" (customize-variable 'org-agenda-files) t]
-     ["Add current file to list" org-add-file t]
-     ["Remove current file from list" org-remove-file t]
+     ["Edit File List" (customize-variable 'org-agenda-files) t]
+     ["Add Current File to List" org-add-file t]
+     ["Remove Current File from List" org-remove-file t]
      "--")
     (mapcar 'org-file-menu-entry org-agenda-files))))
 
@@ -8301,7 +8403,7 @@
 This function considers both visible and invisible heading lines.
 With argument, move up ARG levels."
   (if org-noutline-p
-      (outline-up-heading-all arg)
+      (outline-up-heading arg t)
     (org-back-to-heading t)
     (looking-at outline-regexp)
     (if (<= (- (match-end 0) (match-beginning 0)) arg)
@@ -8381,5 +8483,3 @@
 
 ;;; org.el ends here
 
-
-
--- a/lisp/tooltip.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/tooltip.el	Mon Apr 18 13:40:23 2005 +0000
@@ -139,10 +139,8 @@
   :tag "GUD buffers predicate"
   :group 'tooltip)
 
-(defcustom tooltip-use-echo-area nil
-  "Use the echo area instead of tooltip frames.
-This is only relevant GUD display, since otherwise it is equivalent to
-turning off Tooltip mode."
+(defcustom tooltip-gud-echo-area nil
+  "Use the echo area instead of frames for GUD tooltips."
   :type 'boolean
   :tag "Use echo area"
   :group 'tooltip)
@@ -187,6 +185,12 @@
   "Toggle Tooltip display.
 With ARG, turn tooltip mode on if and only if ARG is positive."
   :global t
+  ;; If you change the :init-value below, you also need to change the
+  ;; corresponding code in startup.el.
+  :init-value (not (or noninteractive
+		       emacs-quick-startup
+		       (not (display-graphic-p))
+		       (not (fboundp 'x-show-tip))))
   :group 'tooltip
   (unless (or (null tooltip-mode) (fboundp 'x-show-tip))
     (error "Sorry, tooltips are not yet available on this system"))
@@ -285,17 +289,19 @@
       (push (cons key value) alist))
     alist))
 
-(defun tooltip-show (text)
+(defun tooltip-show (text gud-tip)
   "Show a tooltip window displaying TEXT.
 
-Text larger than `x-max-tooltip-size' (which see) is clipped.
+Text larger than `x-max-tooltip-size' is clipped.
 
 If the alist in `tooltip-frame-parameters' includes `left' and `top'
 parameters, they determine the x and y position where the tooltip
 is displayed.  Otherwise, the tooltip pops at offsets specified by
 `tooltip-x-offset' and `tooltip-y-offset' from the current mouse
-position."
-  (if tooltip-use-echo-area
+position.
+
+GUD-TIP is t if the tooltip is from a GUD session and nil otherwise."
+  (if (and gud-tip tooltip-gud-echo-area)
       (message "%s" text)
     (condition-case error
 	(let ((params (copy-sequence tooltip-frame-parameters))
@@ -411,7 +417,7 @@
 (defun tooltip-gud-process-output (process output)
   "Process debugger output and show it in a tooltip window."
   (set-process-filter process tooltip-gud-original-filter)
-  (tooltip-show (tooltip-strip-prompt process output)))
+  (tooltip-show (tooltip-strip-prompt process output) t))
 
 (defun tooltip-gud-print-command (expr)
   "Return a suitable command to print the expression EXPR.
@@ -457,8 +463,8 @@
   (tooltip-show
    (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer)
      (let ((string (buffer-string)))
-       ;; remove newline for tooltip-use-echo-area
-       (substring string 0 (- (length string) 1))))))
+       ;; remove newline for tooltip-gud-echo-area
+       (substring string 0 (- (length string) 1)))) t))
 
 
 ;;; Tooltip help.
@@ -491,7 +497,7 @@
 the timer with ID `tooltip-timeout-id' fires.
 Value is non-nil if this function handled the tip."
   (when (stringp tooltip-help-message)
-    (tooltip-show tooltip-help-message)
+    (tooltip-show tooltip-help-message nil)
     t))
 
 (provide 'tooltip)
--- a/lisp/wdired.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/wdired.el	Mon Apr 18 13:40:23 2005 +0000
@@ -31,8 +31,8 @@
 ;;
 ;; Have you ever wished to use C-x r t (string-rectangle), M-%
 ;; (query-replace), M-c (capitalize-word), etc. to change the name of
-;; the files in a "dired" buffer? Now you can do this. All the power
-;; of emacs commands are available to renaming files!
+;; the files in a "dired" buffer? Now you can do this.  All the power
+;; of Emacs commands are available to renaming files!
 ;; 
 ;; This package provides a function that makes the filenames of a a
 ;; dired buffer editable, by changing the buffer mode (which inhibits
@@ -40,7 +40,7 @@
 ;; one or more files and directories, and when you press C-c C-c, the
 ;; renaming takes effect and you are back to dired mode.
 ;;
-;; Another things you can do with wdired:
+;; Another things you can do with WDired:
 ;;
 ;; - To move files to another directory (by typing their path,
 ;;   absolute or relative, as a part of the new filename).
@@ -49,21 +49,16 @@
 ;;
 ;; - To change the permission bits of the filenames (in systems with a
 ;;   working unix-alike `dired-chmod-program'). See and customize the
-;;   variable `wdired-allow-to-change-permissions'. To change a single
+;;   variable `wdired-allow-to-change-permissions'.  To change a single
 ;;   char (toggling between its two more usual values) you can press
-;;   the space bar over it or left-click the mouse. To set any char to
+;;   the space bar over it or left-click the mouse.  To set any char to
 ;;   an specific value (this includes the SUID, SGID and STI bits) you
-;;   can use the key labeled as the letter you want. Please note that
+;;   can use the key labeled as the letter you want.  Please note that
 ;;   permissions of the links cannot be changed in that way, because
 ;;   the change would affect to their targets, and this would not be
 ;;   WYSIWYG :-).
 ;;
 ;; - To mark files for deletion, by deleting their whole filename.
-;;
-;; I do not have a URL to hang wdired, but you can use the one below
-;; to find the latest version:
-;;
-;; http://groups.google.com/groups?as_ugroup=gnu.emacs.sources&as_q=wdired
 
 ;;; Installation:
 
@@ -75,21 +70,19 @@
 ;; (require 'wdired)
 ;; (define-key dired-mode-map "r" 'wdired-change-to-wdired-mode)
 ;;
-;; This is recommended way for faster emacs startup time and lower
-;; memory consumption, but remind to add these lines before dired.el
-;; gets loaded (i.e., near the beginning of your .emacs file):
+;; This is the recommended way for faster Emacs startup time and lower
+;; memory consumption:
 ;;
 ;; (autoload 'wdired-change-to-wdired-mode "wdired")
-;; (add-hook 'dired-load-hook
+;; (eval-after-load "dired"
 ;;           '(lambda ()
 ;;              (define-key dired-mode-map "r" 'wdired-change-to-wdired-mode)
 ;;              (define-key dired-mode-map
 ;;                [menu-bar immediate wdired-change-to-wdired-mode]
 ;;                '("Edit File Names" . wdired-change-to-wdired-mode))))
 ;;
-;;
-;; Type "M-x customize-group RET wdired" if you want make changes to
-;; the default behavior.
+;; Type "M-x customize-group RET wdired" if you want to make changes
+;; to the default behavior.
 
 ;;; Usage:
 
@@ -103,60 +96,12 @@
 
 ;;; Change Log:
 
-;; From 1.9 to 1.91
-;;
-;; - Fixed a bug (introduced in 1.9) so now files can be marked for
-;;   deletion again, by deleting their whole filename.
-
-;; From 1.8 to 1.9
-;;
-;; - Another alternative way of editing permissions allowed, see
-;;   `wdired-allow-to-change-permissions' for details.
-;;
-;; - Now wdired doesn't rely on regexp so much. As a consequence of
-;;   this, you can add newlines to filenames and symlinks targets
-;;   (although this is not very usual, IMHO). Please note that dired
-;;   (at least in Emacs 21.1 and previous) does not work very well
-;;   with filenames with newlines in them, so RET is deactivated in
-;;   wdired mode. But you can activate it if you want.
-;;
-;; - Now `upcase-word' `capitalize-word' and `downcase-word' are not
-;;   advised to work better with wdired mode, but the keys bound to
-;;   them use wdired versions of those commands.
-;;
-;; - Now "undo" actions are not inherited from wdired mode when
-;;   changing to dired mode.
-;;
-;; - Code and documentation cleanups.
-;;
-;; - Fixed a bug that was making wdired to fail on users with
-;;   `dired-backup-overwrite' set to t.
-;;
-;; - C-c C-[ now abort changes.
-
-;; From 1.7 to 1.8
-;;
-;; - Now permission (access-control) bits of the files can be changed.
-;;   Please see the commentary section and the custom variable
-;;   `wdired-allow-to-change-permissions' for details.
-;;
-;; - Added another possible value for the variable
-;;   `wdired-always-move-to-filename-beginning', useful to change
-;;   permission bits of several files without the cursor jumping to
-;;   filenames when changing lines.
-
-;; From 0.1 to 1.7
-
-;; - I've moved the list of changes to another file, because it was
-;;   huge. Ask me for it or search older versions in google.
-
-;;; TODO:
-
-;; - Make it to work in XEmacs. Any volunteer?
+;; Google is your friend (previous versions with complete changelogs
+;; were posted to gnu.emacs.sources)
 
 ;;; Code:
 
-(defvar dired-backup-overwrite) ; Only in emacs 20.x this is a custom var
+(defvar dired-backup-overwrite) ; Only in Emacs 20.x this is a custom var
 (eval-when-compile
   (set (make-local-variable 'byte-compile-dynamic) t))
 
@@ -170,22 +115,22 @@
   :group 'dired)
 
 (defcustom wdired-use-interactive-rename nil
-  "*If t, confirmation is required before actually rename the files.
-Confirmation is required also for overwriting files.  If nil, no
-confirmation is required for change the file names, and the variable
-`wdired-is-ok-overwrite' is used to see if it is ok to overwrite files
-without asking."
+  "*If non-nil, WDired requires confirmation before actually renaming files.
+If nil, WDired doesn't require confirmation to change the file names,
+and the variable `wdired-confirm-overwrite' controls whether it is ok
+to overwrite files without asking."
   :type 'boolean
   :group 'wdired)
 
-(defcustom wdired-is-ok-overwrite nil
-  "*If non-nil the renames can overwrite files without asking. 
-This variable is used only if `wdired-use-interactive-rename' is nil."
+(defcustom wdired-confirm-overwrite t
+  "*If nil the renames can overwrite files without asking. 
+This variable has no effect at all if `wdired-use-interactive-rename'
+is not nil."
   :type 'boolean
   :group 'wdired)
 
-(defcustom wdired-always-move-to-filename-beginning nil
-  "*If t the \"up\" and \"down\" movement is done as in dired mode.
+(defcustom wdired-use-dired-vertical-movement nil
+  "*If t, the \"up\" and \"down\" movement works as in Dired mode.
 That is, always move the point to the beginning of the filename at line.
 
 If `sometimes, only move to the beginning of filename if the point is
@@ -199,20 +144,20 @@
   :group 'wdired)
 
 (defcustom wdired-allow-to-redirect-links t
-  "*If non-nil, the target of the symbolic links can be changed also.
+  "*If non-nil, the target of the symbolic links are editable.
 In systems without symbolic links support, this variable has no effect
 at all."
   :type 'boolean
   :group 'wdired)
 
 (defcustom wdired-allow-to-change-permissions nil
-  "*If non-nil, the permissions bits of the files can be changed also.
+  "*If non-nil, the permissions bits of the files are editable.
 
 If t, to change a single bit, put the cursor over it and press the
 space bar, or left click over it.  You can also hit the letter you want
 to set: if this value is allowed, the character in the buffer will be
 changed.  Anyway, the point is advanced one position, so, for example,
-you can keep the \"x\" key pressed to give execution permissions to
+you can keep the <x> key pressed to give execution permissions to
 everybody to that file.
 
 If `advanced, the bits are freely editable.  You can use
@@ -220,7 +165,7 @@
 newlines), but if you want your changes to be useful, you better put a
 intelligible value.
 
-Anyway, the real change of the permissions is done with the external
+Anyway, the real change of the permissions is done by the external
 program `dired-chmod-program', which must exist."
   :type '(choice (const :tag "Not allowed" nil)
                  (const :tag "Toggle/set bits" t)
@@ -233,9 +178,9 @@
     (define-key map "\C-c\C-c" 'wdired-finish-edit)
     (define-key map "\C-c\C-k" 'wdired-abort-changes)
     (define-key map "\C-c\C-[" 'wdired-abort-changes)
-    (define-key map "\C-m"     'wdired-newline)
-    (define-key map "\C-j"     'wdired-newline)
-    (define-key map "\C-o"     'wdired-newline)
+    (define-key map "\C-m"     'ignore)
+    (define-key map "\C-j"     'ignore)
+    (define-key map "\C-o"     'ignore)
     (define-key map [up]       'wdired-previous-line)
     (define-key map "\C-p"     'wdired-previous-line)
     (define-key map [down]     'wdired-next-line)
@@ -261,7 +206,7 @@
     map))
 
 (defvar wdired-mode-hook nil
-  "Hook run when changing to wdired mode.")
+  "Hooks run when changing to WDired mode.")
 
 ;; Local variables (put here to avoid compilation gripes)
 (defvar wdired-col-perm) ;; Column where the permission bits start
@@ -271,15 +216,15 @@
 (defun wdired-mode ()
   "\\<wdired-mode-map>File Names Editing mode.
 
-Press \\[wdired-finish-edit] to make the changes to take effect and
-exit.  To abort the edit, use \\[wdired-abort-changes].
+Press \\[wdired-finish-edit] to make the changes to take effect
+and exit.  To abort the edit, use \\[wdired-abort-changes].
 
-In this mode you can edit the names of the files, the target of the
-links and the permission bits of the files.  You can `customize-group'
-wdired.
+In this mode you can edit the names of the files, the target of
+the links and the permission bits of the files.  You can use
+\\[customize-group] RET wdired to customize WDired behavior.
 
-Editing things out of the filenames, or adding or deleting lines is
-not allowed, because the rest of the buffer is read-only."
+The only editable texts in a WDired buffer are filenames,
+symbolic link targets, and filenames permission."
   (interactive)
   (error "This mode can be enabled only by `wdired-change-to-wdired-mode'"))
 (put 'wdired-mode 'mode-class 'special)
@@ -288,8 +233,10 @@
 ;;;###autoload
 (defun wdired-change-to-wdired-mode ()
   "Put a dired buffer in a mode in which filenames are editable.
-In this mode the names of the files can be changed, and after
-typing C-c C-c the files and directories in disk are renamed.
+\\<wdired-mode-map>
+This mode allows the user to change the names of the files, and after
+typing \\[wdired-finish-edit] Emacs renames the files and directories
+in disk.
 
 See `wdired-mode'."
   (interactive)
@@ -302,7 +249,7 @@
   (dired-unadvertise default-directory)
   (add-hook 'kill-buffer-hook 'wdired-check-kill-buffer nil t)
   (setq major-mode 'wdired-mode)
-  (setq mode-name "Edit filenames")
+  (setq mode-name "Editable Dired")
   (setq revert-buffer-function 'wdired-revert)
   ;; I temp disable undo for performance: since I'm going to clear the
   ;; undo list, it can save more than a 9% of time with big
@@ -359,7 +306,7 @@
 (defun wdired-get-filename (&optional no-dir old)
   "Return the filename at line.
 Similar to `dired-get-filename' but it doesn't rely on regexps.  It
-relies on wdired buffer's properties.  Optional arg NO-DIR with value
+relies on WDired buffer's properties.  Optional arg NO-DIR with value
 non-nil means don't include directory.  Optional arg OLD with value
 non-nil means return old filename."
   ;; FIXME: Use dired-get-filename's new properties.
@@ -411,7 +358,7 @@
   "Actually rename files based on your editing in the Dired buffer."
   (interactive)
   (wdired-change-to-dired-mode)
-  (let ((overwrite (or wdired-is-ok-overwrite 1))
+  (let ((overwrite (or (not wdired-confirm-overwrite) 1))
 	(changes nil)
 	(files-deleted nil)
 	(errors 0)
@@ -510,12 +457,13 @@
 	(forward-line)))))
 
 (defun wdired-customize ()
-  "Customize wdired options."
+  "Customize WDired options."
   (interactive)
   (customize-apropos "wdired" 'groups))
 
 (defun wdired-revert (&optional arg noconfirm)
-  "Discard changes in the buffer and update the changes in the disk."
+  "Discard changes in the buffer and update it based on changes on disk.
+Optional arguments are ignored."
   (wdired-change-to-dired-mode)
   (revert-buffer)
   (wdired-change-to-wdired-mode))
@@ -529,12 +477,12 @@
 
 (defun wdired-next-line (arg)
   "Move down lines then position at filename or the current column.
-See `wdired-always-move-to-filename-beginning'.  Optional prefix ARG
+See `wdired-use-dired-vertical-movement'.  Optional prefix ARG
 says how many lines to move; default is one line."
   (interactive "p")
   (next-line arg)
-  (if (or (eq wdired-always-move-to-filename-beginning t)
-	  (and wdired-always-move-to-filename-beginning
+  (if (or (eq wdired-use-dired-vertical-movement t)
+	  (and wdired-use-dired-vertical-movement
 	       (< (current-column)
 		  (save-excursion (dired-move-to-filename)
 				  (current-column)))))
@@ -542,22 +490,17 @@
 
 (defun wdired-previous-line (arg)
   "Move up lines then position at filename or the current column.
-See `wdired-always-move-to-filename-beginning'.  Optional prefix ARG
+See `wdired-use-dired-vertical-movement'.  Optional prefix ARG
 says how many lines to move; default is one line."
   (interactive "p")
   (previous-line arg)
-  (if (or (eq wdired-always-move-to-filename-beginning t)
-	  (and wdired-always-move-to-filename-beginning
+  (if (or (eq wdired-use-dired-vertical-movement t)
+	  (and wdired-use-dired-vertical-movement
 	       (< (current-column)
 		  (save-excursion (dired-move-to-filename)
 				  (current-column)))))
       (dired-move-to-filename)))
 
-;; dired doesn't works well with newlines, so ...
-(defun wdired-newline ()
-  "Do nothing."
-  (interactive))
-
 ;; Put the needed properties to allow the user to change links' targets
 (defun wdired-preprocess-symlinks ()
   (let ((inhibit-read-only t))
@@ -634,19 +577,19 @@
 	       (setq arg 0))))))))
 
 (defun wdired-downcase-word (arg)
-  "Wdired version of `downcase-word'.
+  "WDired version of `downcase-word'.
 Like original function but it skips read-only words."
   (interactive "p")
   (wdired-xcase-word 'downcase-word arg))
 
 (defun wdired-upcase-word (arg)
-  "Wdired version of `upcase-word'.
+  "WDired version of `upcase-word'.
 Like original function but it skips read-only words."
   (interactive "p")
   (wdired-xcase-word 'upcase-word arg))
 
 (defun wdired-capitalize-word (arg)
-  "Wdired version of `capitalize-word'.
+  "WDired version of `capitalize-word'.
 Like original function but it skips read-only words."
   (interactive "p")
   (wdired-xcase-word 'capitalize-word arg))
--- a/lisp/whitespace.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/whitespace.el	Mon Apr 18 13:40:23 2005 +0000
@@ -86,7 +86,7 @@
 
 ;;; Code:
 
-(defvar whitespace-version "3.4" "Version of the whitespace library.")
+(defvar whitespace-version "3.5" "Version of the whitespace library.")
 
 (defvar whitespace-all-buffer-files nil
   "An associated list of buffers and files checked for whitespace cleanliness.
@@ -599,7 +599,7 @@
       (setq pmax (point))
       (if (equal pmin pmax)
 	  (progn
-	    (whitespace-highlight-the-space pmin pmax)
+	    (whitespace-highlight-the-space pmin (1+ pmax))
 	    t)
 	nil))))
 
@@ -637,7 +637,7 @@
 	    (setq pmax (point))
 	    (if (equal pmin pmax)
 		(progn
-		  (whitespace-highlight-the-space pmin pmax)
+		  (whitespace-highlight-the-space (- pmin 1) pmax)
 		  t)
 	      nil))
 	nil))))
@@ -733,12 +733,11 @@
   "Highlight the current line, unhighlighting a previously jumped to line."
   (if whitespace-display-spaces-in-color
       (let ((ol (whitespace-make-overlay b e)))
-	(whitespace-unhighlight-the-space)
 	(push ol whitespace-highlighted-space)
 	(whitespace-overlay-put ol 'face 'whitespace-highlight-face))))
 ;;  (add-hook 'pre-command-hook 'whitespace-unhighlight-the-space))
 
-(defun whitespace-unhighlight-the-space ()
+(defun whitespace-unhighlight-the-space()
   "Unhighlight the currently highlight line."
   (if (and whitespace-display-spaces-in-color whitespace-highlighted-space)
       (progn
--- a/lisp/x-dnd.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/x-dnd.el	Mon Apr 18 13:40:23 2005 +0000
@@ -31,9 +31,9 @@
 
 ;;; Code:
 
-;;; Customizable variables
+(require 'dnd)
 
-
+;;; Customizable variables
 (defcustom x-dnd-test-function 'x-dnd-default-test-function
   "The function drag and drop uses to determine if to accept or reject a drop.
 The function takes three arguments, WINDOW ACTION and TYPES.
@@ -51,28 +51,6 @@
   :type 'symbol
   :group 'x)
 
-(defcustom x-dnd-protocol-alist
-  '(
-    ("^file:///" . x-dnd-open-local-file)	; XDND format.
-    ("^file://"  . x-dnd-open-file)		; URL with host
-    ("^file:"    . x-dnd-open-local-file)	; Old KDE, Motif, Sun
-    )
-
-  "The functions to call for different protocols when a drop is made.
-This variable is used by `x-dnd-handle-uri-list', `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).
-If no match is found here, and the value of `browse-url-browser-function'
-is a pair of (REGEXP . FUNCTION), those regexps are tried for a match.
-Insertion of text is not handeled by these functions, see `x-dnd-types-alist'
-for that.
-The function shall return the action done (move, copy, link or private)
-if some action was made, or nil if the URL is ignored."
-  :version "22.1"
-  :type 'alist
-  :group 'x)
 
 
 (defcustom x-dnd-types-alist
@@ -85,10 +63,10 @@
     ("text/plain;charset=UTF-8" . x-dnd-insert-utf8-text)
     ("text/plain;charset=utf-8" . x-dnd-insert-utf8-text)
     ("text/unicode" . x-dnd-insert-utf16-text)
-    ("text/plain" . x-dnd-insert-text)
+    ("text/plain" . dnd-insert-text)
     ("COMPOUND_TEXT" . x-dnd-insert-ctext)
-    ("STRING" . x-dnd-insert-text)
-    ("TEXT"   . x-dnd-insert-text)
+    ("STRING" . dnd-insert-text)
+    ("TEXT"   . dnd-insert-text)
     )
   "Which function to call to handle a drop of that type.
 If the type for the drop is not present, or the function is nil,
@@ -102,12 +80,6 @@
   :type 'alist
   :group 'x)
 
-(defcustom x-dnd-open-file-other-window nil
-  "If non-nil, always use find-file-other-window to open dropped files."
-  :version "22.1"
-  :type 'boolean
-  :group 'x)
-
 (defcustom x-dnd-known-types
   '("text/uri-list"
     "text/x-moz-url"
@@ -236,109 +208,6 @@
     (setcdr (x-dnd-get-state-cons-for-frame window) current-state)))
 
 
-(defun x-dnd-handle-one-url (window action arg)
-  "Handle one dropped url by calling the appropriate handler.
-The handler is first localted by looking at `x-dnd-protocol-alist'.
-If no match is found here, and the value of `browse-url-browser-function'
-is a pair of (REGEXP . FUNCTION), those regexps are tried for a match.
-If no match is found, just call `x-dnd-insert-text'.
-WINDOW is where the drop happend, ACTION is the action for the drop,
-ARG is the URL that has been dropped.
-Returns ACTION."
-  (require 'browse-url)
-  (let* ((uri (replace-regexp-in-string
-	       "%[A-Z0-9][A-Z0-9]"
-	       (lambda (arg)
-		 (format "%c" (string-to-number (substring arg 1) 16)))
-	       arg))
-	 ret)
-    (or
-     (catch 'done
-       (dolist (bf x-dnd-protocol-alist)
-	 (when (string-match (car bf) uri)
-	   (setq ret (funcall (cdr bf) uri action))
-	   (throw 'done t)))
-       nil)
-     (when (not (functionp browse-url-browser-function))
-       (catch 'done
-	 (dolist (bf browse-url-browser-function)
-	   (when (string-match (car bf) uri)
-	     (setq ret 'private)
-	     (funcall (cdr bf) uri action)
-	     (throw 'done t)))
-	 nil))
-     (progn
-       (x-dnd-insert-text window action uri)
-       (setq ret 'private)))
-    ret))
-
-
-(defun x-dnd-get-local-file-uri (uri)
-  "Return an uri converted to file:/// syntax if uri is a local file.
-Return nil if URI is not a local file."
-
-  ;; The hostname may be our hostname, in that case, convert to a local
-  ;; file.  Otherwise return nil.  TODO:  How about an IP-address as hostname?
-  (let ((hostname (when (string-match "^file://\\([^/]*\\)" uri)
-		      (downcase (match-string 1 uri))))
-	(system-name-no-dot
-	 (downcase (if (string-match "^[^\\.]+" system-name)
-		       (match-string 0 system-name)
-		     system-name))))
-    (when (and hostname
-	     (or (string-equal "localhost" hostname)
-		 (string-equal (downcase system-name) hostname)
-		 (string-equal system-name-no-dot hostname)))
-	(concat "file://" (substring uri (+ 7 (length hostname)))))))
-
-(defun x-dnd-get-local-file-name (uri &optional must-exist)
-  "Return file name converted from file:/// or file: syntax.
-URI is the uri for the file.  If MUST-EXIST is given and non-nil,
-only return non-nil if the file exists.
-Return nil if URI is not a local file."
-  (let ((f (cond ((string-match "^file:///" uri)	; XDND format.
-		  (substring uri (1- (match-end 0))))
-		 ((string-match "^file:" uri)		; Old KDE, Motif, Sun
-		  (substring uri (match-end 0))))))
-    (when (and f must-exist)
-      (let* ((decoded-f (decode-coding-string
-			 f
-			 (or file-name-coding-system
-			     default-file-name-coding-system)))
-	     (try-f (if (file-readable-p decoded-f) decoded-f f)))
-	(when (file-readable-p try-f) try-f)))))
-
-
-(defun x-dnd-open-local-file (uri action)
-  "Open a local file.
-The file is opened in the current window, or a new window if
-`x-dnd-open-file-other-window' is set.  URI is the url for the file,
-and must have the format file:file-name or file:///file-name.
-The last / in file:/// is part of the file name.  ACTION is ignored."
-
-  (let* ((f (x-dnd-get-local-file-name uri t)))
-    (if (and f (file-readable-p f))
-	(progn
-	  (if x-dnd-open-file-other-window
-	      (find-file-other-window f)
-	    (find-file f))
-	  'private)
-      (error "Can not read %s" uri))))
-
-(defun x-dnd-open-file (uri action)
-  "Open a local or remote file.
-The file is opened in the current window, or a new window if
-`x-dnd-open-file-other-window' is set.  URI is the url for the file,
-and must have the format file://hostname/file-name.  ACTION is ignored.
-The last / in file://hostname/ is part of the file name."
-
-  ;; The hostname may be our hostname, in that case, convert to a local
-  ;; file.  Otherwise return nil.
-  (let ((local-file (x-dnd-get-local-file-uri uri)))
-    (if local-file (x-dnd-open-local-file local-file action)
-      (error "Remote files not supported"))))
-
-
 (defun x-dnd-handle-moz-url (window action data)
   "Handle one item of type text/x-moz-url.
 WINDOW is the window where the drop happened.  ACTION is ignored.
@@ -360,49 +229,36 @@
 (defun x-dnd-insert-utf8-text (window action text)
   "Decode the UTF-8 text and insert it at point.
 TEXT is the text as a string, WINDOW is the window where the drop happened."
-  (x-dnd-insert-text window action (decode-coding-string text 'utf-8)))
+  (dnd-insert-text window action (decode-coding-string text 'utf-8)))
 
 (defun x-dnd-insert-utf16-text (window action text)
   "Decode the UTF-16 text and insert it at point.
 TEXT is the text as a string, WINDOW is the window where the drop happened."
   ;; See comment in x-dnd-handle-moz-url about coding.
   (let ((coding (if (eq (byteorder) ?B) 'utf-16be 'utf-16le)))
-    (x-dnd-insert-text window action (decode-coding-string text coding))))
+    (dnd-insert-text window action (decode-coding-string text coding))))
 
 (defun x-dnd-insert-ctext (window action text)
   "Decode the compound text and insert it at point.
 TEXT is the text as a string, WINDOW is the window where the drop happened."
-  (x-dnd-insert-text window action
-		     (decode-coding-string text
-					   'compound-text-with-extensions)))
-
-(defun x-dnd-insert-text (window action text)
-  "Insert text at point or push to the kill ring if buffer is read only.
-TEXT is the text as a string, WINDOW is the window where the drop happened."
-  (if (or buffer-read-only
-	  (not (windowp window)))
-      (progn
-	(kill-new text)
-	(message
-	 (substitute-command-keys
-	  "The dropped text can be accessed with \\[yank]")))
-    (insert text))
-  action)
+  (dnd-insert-text window action
+		   (decode-coding-string text
+					 'compound-text-with-extensions)))
 
 (defun x-dnd-handle-uri-list (window action string)
-  "Split an uri-list into separate URIs and call `x-dnd-handle-one-url'.
+  "Split an uri-list into separate URIs and call `dnd-handle-one-url'.
 WINDOW is the window where the drop happened.
 STRING is the uri-list as a string.  The URIs are separated by \r\n."
   (let ((uri-list (split-string string "[\0\r\n]" t))
 	retval)
     (dolist (bf uri-list)
       ;; If one URL is handeled, treat as if the whole drop succeeded.
-      (let ((did-action (x-dnd-handle-one-url window action bf)))
+      (let ((did-action (dnd-handle-one-url window action bf)))
 	(when did-action (setq retval did-action))))
     retval))
 
 (defun x-dnd-handle-file-name (window action string)
-  "Prepend file:// to file names and call `x-dnd-handle-one-url'.
+  "Prepend file:// to file names and call `dnd-handle-one-url'.
 WINDOW is the window where the drop happened.
 STRING is the file names as a string, separated by nulls."
   (let ((uri-list (split-string string "[\0\r\n]" t))
@@ -410,7 +266,7 @@
     (dolist (bf uri-list)
       ;; If one URL is handeled, treat as if the whole drop succeeded.
       (let* ((file-uri (concat "file://" bf))
-	     (did-action (x-dnd-handle-one-url window action file-uri)))
+	     (did-action (dnd-handle-one-url window action file-uri)))
 	(when did-action (setq retval did-action))))
     retval))
 
@@ -456,10 +312,10 @@
       (if (and (windowp w) (window-live-p w))
 	  ;; If dropping in a window, open files in that window rather
 	  ;; than in a new widow.
-	  (let ((x-dnd-open-file-other-window nil))
+	  (let ((dnd-open-file-other-window nil))
 	    (goto-char (posn-point (event-start event)))
 	    (funcall handler window action data))
-	(let ((x-dnd-open-file-other-window t))  ;; Dropping on non-window.
+	(let ((dnd-open-file-other-window t))  ;; Dropping on non-window.
 	  (select-frame frame)
 	  (funcall handler window action data))))))
 
@@ -881,7 +737,6 @@
 
 ;;;
 
-
 (provide 'x-dnd)
 
 ;;; arch-tag: b621fb7e-50da-4323-850b-5fc71ae64621
--- a/lisp/xt-mouse.el	Mon Apr 18 13:17:40 2005 +0000
+++ b/lisp/xt-mouse.el	Mon Apr 18 13:40:23 2005 +0000
@@ -156,10 +156,12 @@
 With prefix arg, turn XTerm mouse mode on iff arg is positive.
 
 Turn it on to use Emacs mouse commands, and off to use xterm mouse commands.
-This works in terminal emulators compatible with xterm.  Only single clicks
-are supported.  When turned on, the normal xterm mouse functionality is still
-available by holding down the SHIFT key while pressing the mouse button."
-  nil " Mouse" nil :global t :group 'mouse
+This works in terminal emulators compatible with xterm.  It only
+works for simple uses of the mouse.  Basically, only non-modified
+single clicks are supported.  When turned on, the normal xterm
+mouse functionality for such clicks is still available by holding
+down the SHIFT key while pressing the mouse button."
+  :global t :group 'mouse
   (if xterm-mouse-mode
       ;; Turn it on
       (unless window-system
--- a/lispref/ChangeLog	Mon Apr 18 13:17:40 2005 +0000
+++ b/lispref/ChangeLog	Mon Apr 18 13:40:23 2005 +0000
@@ -1,3 +1,11 @@
+2005-04-17  Richard M. Stallman  <rms@gnu.org>
+
+	* buffers.texi (Indirect Buffers): Clarify.
+
+	* positions.texi (Positions): Clarify converting marker to integer.
+
+	* strings.texi (String Basics): Mention string-match; clarify.
+
 2005-04-08  Lute Kamstra  <lute@gnu.org>
 
 	* modes.texi (Search-based Fontification): Fix cross references.
--- a/lispref/buffers.texi	Mon Apr 18 13:17:40 2005 +0000
+++ b/lispref/buffers.texi	Mon Apr 18 13:40:23 2005 +0000
@@ -1067,11 +1067,11 @@
 themselves.
 
   In all other respects, the indirect buffer and its base buffer are
-completely separate.  They have different names, different values of
-point, different narrowing, different markers and overlays (though
+completely separate.  They have different names, independent values of
+point, independent narrowing, independent markers and overlays (though
 inserting or deleting text in either buffer relocates the markers and
-overlays for both), different major modes, and different buffer-local
-variables.
+overlays for both), independent major modes, and independent
+buffer-local variable bindings.
 
   An indirect buffer cannot visit a file, but its base buffer can.  If
 you try to save the indirect buffer, that actually saves the base
--- a/lispref/positions.texi	Mon Apr 18 13:17:40 2005 +0000
+++ b/lispref/positions.texi	Mon Apr 18 13:40:23 2005 +0000
@@ -15,14 +15,17 @@
 often speak of the character ``at'' a position, meaning the character
 after that position.
 
-  Positions are usually represented as integers starting from 1, but can
-also be represented as @dfn{markers}---special objects that relocate
-automatically when text is inserted or deleted so they stay with the
-surrounding characters.  Functions that expect an argument to be a
-position (an integer), but accept a marker as a substitute, normally
-ignore the marker buffer.  Of course, markers used this way usually
-point to a position in the buffer that the function operates on, but
-that is entirely the programmer's responsibility.  @xref{Markers}.
+  Positions are usually represented as integers starting from 1, but
+can also be represented as @dfn{markers}---special objects that
+relocate automatically when text is inserted or deleted so they stay
+with the surrounding characters.  Functions that expect an argument to
+be a position (an integer), but accept a marker as a substitute,
+normally ignore which buffer the marker points into; they convert the
+marker to an integer, and use that integer, exactly as if you had
+passed the integer as the argument, even if the marker points to the
+``wrong'' buffer.  A marker that points nowhere cannot convert to an
+integer; using it instead of an integer causes an error.
+@xref{Markers}.
 
   See also the ``field'' feature (@pxref{Fields}), which provides
 functions that are used by many cursor-motion commands.
--- a/lispref/strings.texi	Mon Apr 18 13:17:40 2005 +0000
+++ b/lispref/strings.texi	Mon Apr 18 13:40:23 2005 +0000
@@ -74,10 +74,11 @@
 and other modifiers for keyboard input characters.
 
   Strings are useful for holding regular expressions.  You can also
-match regular expressions against strings (@pxref{Regexp Search}).  The
-functions @code{match-string} (@pxref{Simple Match Data}) and
-@code{replace-match} (@pxref{Replacing Match}) are useful for
-decomposing and modifying strings based on regular expression matching.
+match regular expressions against strings with @code{string-match}
+(@pxref{Regexp Search}).  The functions @code{match-string}
+(@pxref{Simple Match Data}) and @code{replace-match} (@pxref{Replacing
+Match}) are useful for decomposing and modifying strings after
+matching regular expressions against them.
 
   Like a buffer, a string can contain text properties for the characters
 in it, as well as the characters themselves.  @xref{Text Properties}.
--- a/mac/ChangeLog	Mon Apr 18 13:17:40 2005 +0000
+++ b/mac/ChangeLog	Mon Apr 18 13:40:23 2005 +0000
@@ -1,3 +1,8 @@
+2005-04-14  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* makefile.MPW (NonCarbonLibs): Add LocalesLib.  Delete
+	TextEncodingConverter.
+
 2005-04-06  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
 	* Emacs.app/Contents/Resources/English.lproj/InfoPlist.strings
--- a/mac/makefile.MPW	Mon Apr 18 13:17:40 2005 +0000
+++ b/mac/makefile.MPW	Mon Apr 18 13:40:23 2005 +0000
@@ -146,7 +146,7 @@
 	"{SharedLibraries}StdCLib" ╤
 	"{SharedLibraries}MathLib" ╤
 	"{SharedLibraries}AppleScriptLib" ╤
-	"{SharedLibraries}TextEncodingConverter" ╤
+	"{SharedLibraries}LocalesLib" ╤
 	"{SharedLibraries}AppearanceLib" ╤
 	"{SharedLibraries}QuickTimeLib" ╤
 	"{PPCLibraries}StdCRuntime.o" ╤
--- a/make-dist	Mon Apr 18 13:17:40 2005 +0000
+++ b/make-dist	Mon Apr 18 13:40:23 2005 +0000
@@ -6,7 +6,8 @@
 #### be distributed.  This means that if you add a file with an odd name,
 #### you should make sure that this script will include it.
 
-# Copyright (C) 1995, 1997, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
+# Copyright (C) 1995, 1997, 1998, 2000, 2001, 2002, 2005 
+#   Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
@@ -183,9 +184,9 @@
 if [ $check = yes ];
 then
   ### Check for .elc files with no corresponding .el file.
-  ls -1 lisp/[a-z]*.el lisp/[a-z]*/[a-z]*.el \
+  ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
 	leim/[a-z]*/[a-z]*.el | sed 's/\.el$/.elc/' > /tmp/el
-  ls -1 lisp/[a-z]*.elc lisp/[a-z]*/[a-z]*.elc \
+  ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
 	leim/[a-z]*/[a-z]*.elc > /tmp/elc
   bogosities="`comm -13 /tmp/el /tmp/elc`"
   if [ "${bogosities}" != "" ]; then
@@ -195,21 +196,17 @@
   rm -f /tmp/el /tmp/elc
 
   ### Check for .el files with no corresponding .elc file.
-  (cd lisp; ls -1 [a-z]*.el [a-z]*/[a-z]*.el ; \
-   cd ../leim; ls -1 [a-z]*/[a-z]*.el) > /tmp/el
-  (cd lisp; ls -1 [a-z]*.elc [a-z]*/[a-z]*.elc; \
-   cd ../leim; ls -1 [a-z]*/[a-z]*.elc) | sed 's/\.elc$/.el/' > /tmp/elc
+  ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
+	leim/[a-z]*/[a-z]*.el > /tmp/el
+  ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
+	leim/[a-z]*/[a-z]*.elc | sed 's/\.elc$/.el/' > /tmp/elc
   losers="`comm -23 /tmp/el /tmp/elc`"
   bogosities=
   for file in $losers; do
-    file1=`echo $file | sed -e "s|.*/||"`
-    if ! sed -n -e "/^DONTCOMPILE/,/[^\\]\$/p" lisp/Makefile.in |
-	 grep -q "[ 	]$file1\($\| \)"; then
+    if ! grep -q "no-byte-compile: t" $file; then
       case $file in
 	site-init.el | site-load.el | site-start.el | default.el)
 	  ;;
-	term/*)
-	  ;;
 	*)
 	  bogosities="$file $bogosities"
 	  ;;
@@ -347,11 +344,12 @@
  done
  ## simula.el doesn't keep abbreviations in simula.defns any more.
  ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
- ln ChangeLog Makefile.in makefile.nt ChangeLog.? ../${tempdir}/lisp
- ln makefile.w32-in ../${tempdir}/lisp
+ ln ChangeLog ChangeLog.*[0-9] ../${tempdir}/lisp
+ ln Makefile.in makefile.w32-in ../${tempdir}/lisp
  test -f README && ln README ../${tempdir}/lisp
  (cd ../${tempdir}/lisp
   rm -f TAGS =*
+  rm -f ldefs-boot.el
   rm -f site-init site-init.el site-init.elc
   rm -f site-load site-load.el site-load.elc
   rm -f site-start site-start.el site-start.elc
@@ -387,7 +385,7 @@
 
    if [ -f $file/ChangeLog ]; then
      ln $file/ChangeLog ../${tempdir}/lisp/$file
-     for f in $file/ChangeLog.[0-9]; do
+     for f in $file/ChangeLog.*[0-9]; do
        if [ -f $f ]; then
 	 ln $f ../${tempdir}/lisp/$file
        fi
@@ -407,6 +405,8 @@
  ln ja-dic/*.el ja-dic/*.elc ../${tempdir}/leim/ja-dic
  ln Makefile.in ../${tempdir}/leim/Makefile.in
  ln leim-ext.el ../${tempdir}/leim/leim-ext.el
+ ## Lisp files that start with a capital are generated from TIT
+ ## dictionaries so we don't distribute them.
  ln quail/[a-z]*.el quail/[a-z]*.elc ../${tempdir}/leim/quail
  rm -f ../${tempdir}/leim/quail/quick-b5.*
  rm -f ../${tempdir}/leim/quail/quick-cns.*
--- a/man/ChangeLog	Mon Apr 18 13:17:40 2005 +0000
+++ b/man/ChangeLog	Mon Apr 18 13:40:23 2005 +0000
@@ -1,3 +1,42 @@
+2005-04-17  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* frames.texi (XTerm Mouse): Xterm Mouse mode is no longer enabled
+	by default in terminals compatible with xterm.  Mention that
+	xterm-mouse-mode is a minor mode and put in pxref to Minor Modes
+	node.
+
+2005-04-15  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.texi: Update to version 3.06.
+
+2005-04-13  Lute Kamstra  <lute@gnu.org>
+
+	* cc-mode.texi: Prevent creating an unnecessary empty cc-mode.ss file.
+
+2005-04-12  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* frames.texi (XTerm Mouse): Xterm Mouse mode is now enabled by
+	default.
+
+2005-04-12  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* xresources.texi (Table of Resources): Add cursorBlink.
+
+2005-04-11  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* rmail.texi (Rmail Summary Edit): Explain numeric arguments to
+	`d', `C-d' and `u'.
+
+2005-04-11  Richard M. Stallman  <rms@gnu.org>
+
+	* cmdargs.texi (Initial Options): -Q is now --quick, and does less.
+	(Misc X): Add -D, --basic-display.
+
+	* maintaining.texi (Change Log): Correct the description of
+	the example.
+
+	* major.texi (Choosing Modes): Document magic-mode-alist.
+
 2005-04-10  Thien-Thi Nguyen  <ttn@gnu.org>
 
 	* cl.texi (Porting Common Lisp): Fix typo.
@@ -53,6 +92,10 @@
 
 	* calendar.texi (Diary): Mention shell utility `calendar'.
 
+2005-04-01  Richard M. Stallman  <rms@gnu.org>
+
+	* cmdargs.texi (Misc X): Explain horizontal scroll bars don't exist.
+
 2005-04-01  Jay Belanger  <belanger@truman.edu>
 
 	* calc.texi (Troubleshooting Commands): Remove comment about
@@ -878,7 +921,7 @@
 
 2005-01-15  Sergey Poznyakoff  <gray@Mirddin.farlep.net>
 
- 	* man/rmail.texi (Movemail): Explain differences
+	* rmail.texi (Movemail): Explain differences
 	between standard and mailutils versions of movemail.
 	Describe command line and configuration options introduced
 	with the latter.
--- a/man/cc-mode.texi	Mon Apr 18 13:17:40 2005 +0000
+++ b/man/cc-mode.texi	Mon Apr 18 13:40:23 2005 +0000
@@ -55,7 +55,9 @@
 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
 @comment Define an index for syntactic symbols.
+@ifnottex
 @defindex ss
+@end ifnottex
 
 @comment Combine key, syntactic symbol and concept indices into one.
 @syncodeindex ss cp
--- a/man/cmdargs.texi	Mon Apr 18 13:17:40 2005 +0000
+++ b/man/cmdargs.texi	Mon Apr 18 13:40:23 2005 +0000
@@ -268,12 +268,10 @@
 
 @item -Q
 @opindex -Q
-@itemx --bare-bones
-@opindex --bare-bones
-Start emacs with minimum customizations and window decorations.
-This is like using @samp{-q} and @samp{--no-site-file}, but in
-addition it also disables the menu-bar, the tool-bar, the scroll-bars,
-tool tips, the blinking cursor, and the fancy startup screen.
+@itemx --quick
+@opindex --quick
+Start emacs with minimum customizations.  This is like using @samp{-q}
+and @samp{--no-site-file}, but also disables the startup screen.
 
 @item --no-splash
 @opindex --no-splash
@@ -1222,6 +1220,14 @@
 @opindex --no-blinking-cursor
 @cindex blinking cursor disable, command-line argument
 Disable the blinking cursor on graphical terminals.
+
+@item -D
+@opindex -D
+@itemx --basic-display
+@opindex --basic-display
+Disable the menu-bar, the tool-bar, the scroll-bars, and tool tips,
+and turn off the blinking cursor.  This can be useful for making a
+test case that simplifies debugging of display problems.
 @end table
 
   The @samp{--xrm} option (@pxref{Resources}) specifies additional
--- a/man/custom.texi	Mon Apr 18 13:17:40 2005 +0000
+++ b/man/custom.texi	Mon Apr 18 13:40:23 2005 +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,2002,2004
+@c Copyright (C) 1985,86,87,93,94,95,97,2000,2001,2002,2004,2005
 @c  Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Customization, Quitting, Amusements, Top
@@ -2313,8 +2313,44 @@
 @example
 (put 'narrow-to-region 'disabled nil)
 @end example
+
+@item
+Adjusting the configuration to various contexts.
+
+In most of the cases, people want their Emacs to behave the same on
+all their machines, so their configuration should be the same, no
+matter whether it's GNU/Linux or not, under X11 or on a tty, with one
+version of  Emacs or another, ...
+
+What can happen, tho, is that depending on the circumstance some
+features may or may not be available.  In that case just prepend each
+such customization with a little test that ensures that the feature
+can be used.  The best tests are usually checking that the feature is
+available, rather than checking what kind of environment is
+being used.
+
+@example
+(if (fboundp 'blinking-cursor-mode)
+    (blinking-cursor-mode 0))
+@end example
+
+@example
+(if (boundp 'coding-category-utf-8)
+  (set-coding-priority '(coding-category-utf-8)))
+@end example
+
+@example
+(require 'cl)                   ; To define `ignore-errors'.
+(ignore-errors (set-face-background 'region "grey75"))
+@end example
+
+Note also that a @code{setq} on a variable which does not exist is
+generally harmless, so those usually do not need to be made
+conditional on any kind of test.
+
 @end itemize
 
+
 @node Terminal Init
 @subsection Terminal-specific Initialization
 
--- a/man/frames.texi	Mon Apr 18 13:17:40 2005 +0000
+++ b/man/frames.texi	Mon Apr 18 13:40:23 2005 +0000
@@ -1055,10 +1055,14 @@
 
 Some terminal emulators under X support mouse clicks in the terminal
 window.  In a terminal emulator which is compatible with @code{xterm},
-you can use @kbd{M-x xterm-mouse-mode} to enable simple use of the
-mouse---only single clicks are supported.  The normal @code{xterm} mouse
-functionality is still available by holding down the @kbd{SHIFT} key
-when you press the mouse button.
+you can use @kbd{M-x xterm-mouse-mode} to give Emacs control over
+simple use of the mouse---basically, only non-modified single clicks
+are supported.  The normal @code{xterm} mouse functionality for such
+clicks is still available by holding down the @kbd{SHIFT} key when you
+press the mouse button.
+
+  Xterm Mouse mode is a global minor mode (@pxref{Minor Modes}).
+Repeating the command turns the mode off again.
 
 @ignore
    arch-tag: 7dcf3a31-a43b-45d4-a900-445b10d77e49
--- a/man/maintaining.texi	Mon Apr 18 13:17:40 2005 +0000
+++ b/man/maintaining.texi	Mon Apr 18 13:40:23 2005 +0000
@@ -58,7 +58,7 @@
 line in the change log starts with a space or a tab.  The bulk of the
 entry consists of @dfn{items}, each of which starts with a line starting
 with whitespace and a star.  Here are two entries, both dated in May
-1993, each with two items:
+1993, with two items and one item respectively.
 
 @iftex
 @medbreak
@@ -79,10 +79,10 @@
 @end smallexample
 
   One entry can describe several changes; each change should have its
-own item.  Normally there should be a blank line between items.  When
-items are related (parts of the same change, in different places), group
-them by leaving no blank line between them.  The second entry above
-contains two items grouped in this way.
+own item, or its own line in an item.  Normally there should be a
+blank line between items.  When items are related (parts of the same
+change, in different places), group them by leaving no blank line
+between them.
 
   @kbd{C-x 4 a} visits the change log file and creates a new entry
 unless the most recent entry is for today's date and your name.  It
@@ -92,8 +92,8 @@
 
 @vindex add-log-keep-changes-together
   When the variable @code{add-log-keep-changes-together} is
-non-@code{nil}, @kbd{C-x 4 a} adds to any existing entry for the file
-rather than starting a new entry.
+non-@code{nil}, @kbd{C-x 4 a} adds to any existing item for the file
+rather than starting a new item.
 
 @vindex change-log-version-info-enabled
 @vindex change-log-version-number-regexp-list
--- a/man/major.texi	Mon Apr 18 13:17:40 2005 +0000
+++ b/man/major.texi	Mon Apr 18 13:40:23 2005 +0000
@@ -98,6 +98,21 @@
 @var{mode-function}, Emacs discards the suffix that matched
 @var{regexp} and searches the list again for another match.
 
+@vindex magic-mode-alist
+  Sometimes the major mode is determined from the way the file's text
+begins.  The variable @code{magic-mode-alist} controls this.  Its value
+is a list of elements of this form:
+
+@example
+(@var{regexp} . @var{mode-function})
+@end example
+
+@noindent
+This looks like an element of @code{auto-mode-alist}, but it doesn't work
+the same: this @var{regexp} is matched against the text at the start
+of the buffer, not against the file name.  @code{magic-mode-alist}
+takes priority over @code{auto-mode-alist}.
+
   You can specify the major mode to use for editing a certain file by
 special text in the first nonblank line of the file.  The
 mode name should appear in this line both preceded and followed by
--- a/man/org.texi	Mon Apr 18 13:17:40 2005 +0000
+++ b/man/org.texi	Mon Apr 18 13:40:23 2005 +0000
@@ -3,7 +3,7 @@
 @setfilename ../info/org
 @settitle Org Mode Manual
 
-@set VERSION 3.05
+@set VERSION 3.06
 @set DATE April 2005
 
 @dircategory Emacs
@@ -92,7 +92,7 @@
 Introduction
 
 * Summary::                     Brief summary of what Org-mode does
-* Installation::                How to install Org-mode
+* Installation and Activation::  How to install Org-mode
 
 Document Structure
 
@@ -106,8 +106,8 @@
 TODO items
 
 * TODO basics::                 Marking and displaying TODO entries
+* TODO extensions::             Workflow and assignments
 * Priorities::                  Some things are more important than others
-* TODO extensions::             Workflow and assignments
 
 Extended use of TODO keywords
 
@@ -133,8 +133,8 @@
 
 Timeline and Agenda
 
-* Timeline (single file)::      Time-sorted view for single file
-* Agenda (multiple files)::     Your weekly planner
+* Timeline::                    Time-sorted view for single file
+* Agenda::                      Your weekly planner
 * Agenda commands::             Remote editing of org trees
 * Calendar/Diary integration::  Integrating Anniversaries and more
 
@@ -168,10 +168,10 @@
 
 @menu
 * Summary::                     Brief summary of what Org-mode does
-* Installation::                How to install Org-mode
+* Installation and Activation::  How to install Org-mode
 @end menu
 
-@node Summary, Installation, Introduction, Introduction
+@node Summary, Installation and Activation, Introduction, Introduction
 @section Summary
 @cindex summary
 
@@ -214,8 +214,8 @@
 
 @page
 
-@node Installation,  , Summary, Introduction
-@section Installation
+@node Installation and Activation,  , Summary, Introduction
+@section Installation and Activation
 @cindex installation
 @cindex autoload
 @cindex global keybindings
@@ -236,12 +236,15 @@
 and @command{org-agenda} - please choose suitable keys yourself.
 
 @lisp
+;; These lines only if org-mode is not part of the X/Emacs distribution.
 (autoload 'org-mode "org" "Org mode" t)
 (autoload 'org-diary "org" "Diary entries from Org mode")
 (autoload 'org-agenda "org" "Multi-file agenda from Org mode" t)
 (autoload 'org-store-link "org" "Store a link to the current location" t)
 (autoload 'orgtbl-mode "org" "Org tables as a minor mode" t)
 (autoload 'turn-on-orgtbl "org" "Org tables as a minor mode")
+
+;; The following lines are always needed.  Choose your own keys.
 (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
 (define-key global-map "\C-cl" 'org-store-link)
 (define-key global-map "\C-ca" 'org-agenda)
@@ -257,7 +260,8 @@
 @end example
 
 @noindent which will select Org-mode for this buffer no matter what
-the file's name is.
+the file's name is.  See also the variable
+@code{org-insert-mode-line-in-empty-file'}. 
 
 @node Document Structure, TODO items, Introduction, Top
 @chapter Document Structure
@@ -361,9 +365,9 @@
 @example
 #+STARTUP: fold
 #+STARTUP: nofold
+#+STARTUP: content
 @end example
 
-
 @node Motion, Structure editing, Visibility cycling, Document Structure
 @section Motion
 @cindex motion, between headlines
@@ -411,6 +415,9 @@
 @kindex M-@key{RET}
 @item M-@key{RET}
 Insert new heading with same level as current
+@kindex M-S-@key{RET}
+@item M-S-@key{RET}
+Insert new TODO entry with same level as current heading.
 @kindex M-@key{left}
 @item M-@key{left}
 Promote current heading by one level
@@ -437,7 +444,7 @@
 Copy subtree to kill ring.
 @kindex C-c C-h C-y
 @item C-c C-h C-y
-Yank subtree from kill ring.  This does modify the level of subtree to
+Yank subtree from kill ring.  This does modify the level of the subtree to
 make sure the tree fits in nicely at the yank position.  The yank
 level can also be specified with a prefix arg, or by yanking after a
 headline marker like @samp{****}.
@@ -513,11 +520,11 @@
 
 @menu
 * TODO basics::                 Marking and displaying TODO entries
+* TODO extensions::             Workflow and assignments
 * Priorities::                  Some things are more important than others
-* TODO extensions::             Workflow and assignments
 @end menu
 
-@node TODO basics, Priorities, TODO items, TODO items
+@node TODO basics, TODO extensions, TODO items, TODO items
 @section Basic TODO functionality
 
 Any headline can become a TODO item by starting it with the word TODO,
@@ -538,49 +545,20 @@
 ,-> (unmarked) -> TODO -> DONE --.
 '--------------------------------'
 @end example
+The same rotation can also be done ``remotely'' from the timeline and
+agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
 @kindex C-c C-v
 @cindex sparse tree, for TODO
 @item C-c C-v
 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds
 the entire buffer, but shows all TODO items and the headings hierarchy
 above them.  With prefix arg, show also the DONE entries.
+@item C-u C-c a
+A @kbd{C-u} argument to the @code{org-agenda command} (@pxref{Agenda})
+collects all unfinished TODO items into a single place.
 @end table
 
-@node Priorities, TODO extensions, TODO basics, TODO items
-@section Priorities
-@cindex priorities
-
-If you use Org-mode extensively to organize your work, you may end up
-with a number of TODO entries so large that you'd like to prioritize
-them.  You can do this by placing a @emph{priority cookie} into the
-headline, like this
-
-@example
-*** TODO [#A] Write letter to Sam Fortune
-@end example
-
-@noindent
-With its standard setup, Org-mode supports priorities @samp{A},
-@samp{B}, and @samp{C}.  @samp{A} is the highest priority.  An entry
-without a cookie is treated as priority @samp{B}.  Priorities make a
-difference only in the multi-file agenda (@pxref{Agenda (multiple files)}).
-
-@table @kbd
-@kindex @kbd{C-c ,}
-@item @kbd{C-c ,}
-Set the priority of the current item.  The command prompts for a
-priority character @samp{A}, @samp{B} or @samp{C}.  When you press
-@key{SPC} instead, the priority cookie is removed from the headline.
-@kindex S-@key{up}
-@kindex S-@key{down}
-@item S-@key{up}
-@itemx S-@key{down}
-Increase/decrease priority of current item.  Note that these keys are
-also used to modify time stamps (@pxref{Creating timestamps}).
-@end table
-
-
-@node TODO extensions,  , Priorities, TODO items
+@node TODO extensions, Priorities, TODO basics, TODO items
 @section Extended use of TODO keywords
 @cindex extended TODO keywords
 
@@ -624,9 +602,11 @@
 @cindex types as TODO keywords
 
 The second possibility is to use TODO keywords to indicate different
-types of action items.  For example, when you work with several people
-on a single project, you might want to assign action items to
-persons. 
+types of action items.  For example, you might want to indicate that
+items are for ``work'' or ``home''.  Or, when you work with several
+people on a single project, you might want to assign action items
+directly to persons, by using their names as TODO keywords.  This
+would be set up like this:
 
 @lisp
 (setq org-todo-keywords '("Fred" "Sara" "Lucy" "Mike" "DONE")
@@ -634,12 +614,15 @@
 @end lisp
 
 In this case, different keywords do not indicate a sequence, but
-rather different types.  This changes the behavior of the command
-@kbd{C-c C-t} slightly.  When used several times in succession, it
-will still cycle through all names.  But when when you return to the
-item after some time and execute @kbd{C-c C-t} again, it will switch
-from each name directly to DONE.  Use prefix arguments or completion
-to quickly select a specific name.
+rather different types.  So it is normally not useful to change from
+one type to another.  Therefore, in this case the the behavior of the
+command @kbd{C-c C-t} is changed slightly@footnote{This is also true
+for the @kbd{t} command in the timeline and agenda buffers}.  When
+used several times in succession, it will still cycle through all
+names.  But when when you return to the item after some time and
+execute @kbd{C-c C-t} again, it will switch from each name directly to
+DONE.  Use prefix arguments or completion to quickly select a specific
+name.
 
 @node Per file keywords,  , TODO types, TODO extensions
 @subsection Setting up TODO keywords for individual files
@@ -647,11 +630,12 @@
 @cindex per file keywords
 
 It can be very useful to use different aspects of the TODO mechanism
-in different files.  For this you need to add special lines to the
-file which set the keywords and interpretation for that file only.
-For example, to set one of the two examples discussed above, you
-need one of the following lines, starting in column zero anywhere in
-the file:
+in different files, which is not possible with the global settings
+described above.  For file-local settings, you need to add special
+lines to the file which set the keywords and interpretation for that
+file only.  For example, to set one of the two examples discussed
+above, you need one of the following lines, starting in column zero
+anywhere in the file:
 
 @example
 #+SEQ_TODO: TODO FEEDBACK VERIFY DONE
@@ -664,11 +648,15 @@
 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
 
 @cindex DONE, final TODO keyword
-Remember that the last keyword must always mean that the
-item is DONE (you may use a different word, though).  After changing
-these lines, use @kbd{M-x normal-mode} to make the changes known to
-Org-mode.  Also note that in each file, only one of the two aspects
-of TODO keywords can be used.
+Remember that the last keyword must always mean that the item is DONE
+(you may use a different word, though).  Also note that in each file,
+only one of the two aspects of TODO keywords can be used.  After
+changing one of these lines, use @kbd{C-c C-c} with the cursor still
+in the line to make the changes known to Org-mode@footnote{Org-mode
+parses these lines only when Org-mode is activated after visiting a
+file.  @kbd{C-c C-c} with the cursor in a line starting with @samp{#-}
+is simply restarting Org-mode, making sure that these changes will be
+respected.}. 
 
 If you want to use very many keywords, for example when working with a
 large group of people, you may split the names over several lines:
@@ -680,6 +668,43 @@
 #+TYP_TODO: DONE
 @end example
 
+@node Priorities,  , TODO extensions, TODO items
+@section Priorities
+@cindex priorities
+
+If you use Org-mode extensively to organize your work, you may end up
+with a number of TODO entries so large that you'd like to prioritize
+them.  This can be done by placing a @emph{priority cookie} into the
+headline, like this
+
+@example
+*** TODO [#A] Write letter to Sam Fortune
+@end example
+
+@noindent
+With its standard setup, Org-mode supports priorities @samp{A},
+@samp{B}, and @samp{C}.  @samp{A} is the highest priority.  An entry
+without a cookie is treated as priority @samp{B}.  Priorities make a
+difference only in the agenda (@pxref{Agenda}).
+
+@table @kbd
+@kindex @kbd{C-c ,}
+@item @kbd{C-c ,}
+Set the priority of the current item.  The command prompts for a
+priority character @samp{A}, @samp{B} or @samp{C}.  When you press
+@key{SPC} instead, the priority cookie is removed from the headline.
+The priorities can also be changed ``remotely'' from the timeline and
+agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
+
+@kindex S-@key{up}
+@kindex S-@key{down}
+@item S-@key{up}
+@itemx S-@key{down}
+Increase/decrease priority of current item.  Note that these keys are
+also used to modify time stamps (@pxref{Creating timestamps}).
+@end table
+
+
 @node Tables, Hyperlinks, TODO items, Top
 @chapter Tables
 @cindex tables
@@ -995,7 +1020,7 @@
 current article/entry.  For W3 and W3M buffer, the link goes to the
 current URL.  For any other files, the link will just point to the file.
 The key binding @kbd{C-c l} is only a suggestion - see
-@ref{Installation}.
+@ref{Installation and Activation}.
 
 @kindex C-c C-l
 @item C-c C-l
@@ -1048,7 +1073,6 @@
 following customization will tell @emph{Remember} to use org files as
 target, and to create annotations compatible with Org-mode links.
 
-
 @c FIXME: The autoload will not be necessary when Org-mode is part of Emacs
 @example
 (autoload 'org-remember-annotation "org")
@@ -1113,7 +1137,7 @@
 special format, either @samp{<2003-09-16 Tue>} or @samp{<2003-09-16
 Tue 09:39>}.  A time stamp can appear anywhere in the headline or body
 of an org-tree entry.  Its presence allows to show entries on specific
-dates in the agenda (@pxref{Agenda (multiple files)}).  We distinguish:
+dates in the agenda (@pxref{Agenda}).  We distinguish:
 
 @table @var
 @cindex timestamp
@@ -1192,7 +1216,7 @@
 @kindex C-c C-o
 @item C-c C-o
 Access the agenda for the date given by the time stamp at point
-(@pxref{Agenda (multiple files)}).
+(@pxref{Agenda}).
 
 @kindex C-c C-d
 @item C-c C-d
@@ -1303,13 +1327,13 @@
 appointments.
 
 @menu
-* Timeline (single file)::      Time-sorted view for single file
-* Agenda (multiple files)::     Your weekly planner
+* Timeline::                    Time-sorted view for single file
+* Agenda::                      Your weekly planner
 * Agenda commands::             Remote editing of org trees
 * Calendar/Diary integration::  Integrating Anniversaries and more
 @end menu
 
-@node Timeline (single file), Agenda (multiple files), Timeline and Agenda, Timeline and Agenda
+@node Timeline, Agenda, Timeline and Agenda, Timeline and Agenda
 @section Timeline for a single file
 @cindex single file summary
 @cindex agenda, for single file
@@ -1335,9 +1359,9 @@
 commands available in the Agenda buffer are listed in @ref{Agenda
 commands}.
 
-@node Agenda (multiple files), Agenda commands, Timeline (single file), Timeline and Agenda
-@section Agenda from multiple files
-@cindex agenda, from multiple files
+@node Agenda, Agenda commands, Timeline, Timeline and Agenda
+@section Agenda
+@cindex agenda
 
 An agenda can be compiled from one or more org files.  The main
 purpose of this command is to act like a planner, in order to show you
@@ -1374,7 +1398,7 @@
 unfinished TODO items (also those without a date) are also listed at
 the beginning of the buffer, before the first date.@*
 The key binding @kbd{C-c a} is only a suggestion - see
-@ref{Installation}.
+@ref{Installation and Activation}.
 @end table
 
 The commands available in the Agenda buffer are listed in
@@ -1384,24 +1408,18 @@
 
 @cindex category
 In the agenda buffer, each entry is preceded by a @emph{category},
-which is derived from the file name.  You can also set the category of
-a file through file variables, for example by making the first line of
-the file look like this:
-
-@cindex file variables
-@example
-Planet Finder -*- mode: org; org-category: Cheops -*-
-@end example
-@noindent
-Or, like with TODO keywords (@pxref{Per file keywords}), you can
-insert a special line anywhere in the file:
-
+which is derived from the file name.  The category can also be set
+with a special line anywhere in the buffer, looking like this:
 @example
 #+CATEGORY: Cheops
 @end example
 @noindent
-The display looks best if the category is no longer than 10 characters.
+After changing this line, press @kbd{C-c C-c} with the cursor still in
+the line, to make the changes know to org-mode.  Otherwise, the change
+will only be active the next time you visit this file with Emacs.
 
+The display in the agenda buffer looks best if the category is no
+longer than 10 characters.
 
 @subsection Sorting of agenda items
 @cindex sorting, of agenda items
@@ -1427,7 +1445,7 @@
 Sorting can be customized using the variable
 @code{org-agenda-sorting-strategy}.
 
-@node Agenda commands, Calendar/Diary integration, Agenda (multiple files), Timeline and Agenda
+@node Agenda commands, Calendar/Diary integration, Agenda, Timeline and Agenda
 @section Commands in the agenda buffer
 
 Entries in the agenda buffer are linked back to the org file or diary
@@ -1443,6 +1461,13 @@
 exceptions are marked.
 
 @table @kbd
+@tsubheading{Motion}
+@kindex n
+@item n
+Next line (same as @key{up}).
+@kindex p
+@item p
+Previous line (same as @key{down}).
 @tsubheading{View/GoTo org file}
 @kindex mouse-3
 @kindex @key{SPC}
@@ -1470,7 +1495,6 @@
 the agenda buffer, the other window always shows the corresponding
 location in the org file.
 
-
 @tsubheading{Change display}
 @kindex o
 @item o
@@ -1515,8 +1539,8 @@
 Change the TODO state of the item, both in the agenda and in the
 original org file.
 
-@kindex p
-@item p
+@kindex ,
+@item ,
 Set the priority for the current item.  Org-mode prompts for the
 priority character. If you reply with @key{SPC}, the priority cookie
 is removed from the entry.
@@ -1526,13 +1550,17 @@
 Display weighted priority of current item.
 
 @kindex +
+@kindex S-@key{up}
 @item +
+@item S-@key{up}
 Increase the priority of the current item.  The priority is changed in
 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
 key for this.
 
 @kindex -
+@kindex S-@key{down}
 @item -
+@item S-@key{down}
 Decrease the priority of the current item.
 
 @kindex S-@key{right}
@@ -1568,10 +1596,9 @@
 @item c
 Open the Emacs calendar and move to the date at the agenda cursor.
 
-@kindex C
-@item C
-Convert the date at cursor into many other cultural and historic
-calendars.
+@item c
+When in the calendar, compute and show the Org-mode agenda for the
+date at the cursor.
 
 @kindex M
 @item M
@@ -1579,8 +1606,13 @@
 
 @kindex S
 @item S
-Show sunrise and sunset times.  The location must be set with calendar
-variables, see documentation of the Emacs calendar.
+Show sunrise and sunset times.  The geographical location must be set
+with calendar variables, see documentation of the Emacs calendar.
+
+@kindex C
+@item C
+Convert the date at cursor into many other cultural and historic
+calendars.
 
 @kindex H
 @item H
@@ -1643,7 +1675,8 @@
 command to insert new entries for the current date works in the agenda
 buffer, as well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to
 display Sunrise/Sunset times, show lunar phases and to convert to
-other calendars, respectively.
+other calendars, respectively.  @kbd{c} can be used to switch back and
+forth between calendar and agenda.
 
 @node Agenda to diary,  , Diary to agenda, Calendar/Diary integration
 @subsection Including the agenda into the diary
@@ -1651,8 +1684,8 @@
 If you prefer to use the Emacs diary as your main instrument and if
 you wish to include the Org-mode agenda into it, the following steps
 are necessary: Autoload the function @command{org-diary} as shown
-above under @ref{Installation}.  You also need to use @emph{fancy
-diary display} by setting in @file{.emacs}:
+above under @ref{Installation and Activation}.  You also need to use
+@emph{fancy diary display} by setting in @file{.emacs}:
 
 @lisp
 (add-hook 'diary-display-hook 'fancy-diary-display)
@@ -2038,11 +2071,6 @@
 Org mode cooperates with table.el, see @ref{table.el}.
 @end table
 
-@c EmacsWiki
-@c organizer-mode
-@c todo-mode
-@c records mode
-
 @page  @c FIXME
 
 @node Acknowledgments, Bugs, Interaction, Miscellaneous
@@ -2068,9 +2096,9 @@
 Christian Egli converted the documentation into TeXInfo format.  He
 also showed me his plans for a multifile summary for Org-mode. Some of
 his ideas have found their way into the agenda.
-@item 
-Philip Rooke created the Org-mode reference card and did some
-beta-testing.
+@item
+Philip Rooke created the Org-mode reference card.  He also helped with
+beta testing and contributed a number of very useful ideas.
 @item
 Linking to VM/BBDB/GNUS was inspired by Tom Shannon's
 @file{organizer-mode.el}.
@@ -2102,8 +2130,8 @@
 Under XEmacs, if Org-mode entries are included into the diary, it is
 not possible to jump back from the diary to the org file.  Apparently,
 the text properties are lost when the fancy-diary-display is used.
-However, from Org-mode's agenda (created with @kbd{C-c C-r} or
-@kbd{M-x org-agenda}), things do work correctly.
+However, from Org-mode's timeline and agenda buffers (created with
+@kbd{C-c C-r} and @kbd{C-c a}), things do work correctly.
 @item 
 Linux should also have a default viewer application, using mailcap.
 Maybe we can use GNUS or VM mime code?  Or dired's guessing commands?
@@ -2126,7 +2154,6 @@
 
 @bye
 
-
 @ignore
    arch-tag: 7893d1fe-cc57-4d13-b5e5-f494a1bcc7ac
 @end ignore
--- a/man/rmail.texi	Mon Apr 18 13:17:40 2005 +0000
+++ b/man/rmail.texi	Mon Apr 18 13:40:23 2005 +0000
@@ -891,10 +891,13 @@
 
   Almost all Rmail commands work in the summary buffer as well as in the
 Rmail buffer.  Thus, @kbd{d} in the summary buffer deletes the current
-message, @kbd{u} undeletes, and @kbd{x} expunges.  @kbd{o} and @kbd{C-o}
-output the current message to a file; @kbd{r} starts a reply to it.  You
-can scroll the current message while remaining in the summary buffer
-using @key{SPC} and @key{DEL}.
+message, @kbd{u} undeletes, and @kbd{x} expunges.  (However, in the
+summary buffer, a numeric argument to @kbd{d}, @kbd{C-d} and @kbd{u}
+serves as a repeat count.  A negative argument reverses the meaning of
+@kbd{d} and @kbd{C-d}.)  @kbd{o} and @kbd{C-o} output the current
+message to a file; @kbd{r} starts a reply to it.  You can scroll the
+current message while remaining in the summary buffer using @key{SPC}
+and @key{DEL}.
 
   The Rmail commands to move between messages also work in the summary
 buffer, but with a twist: they move through the set of messages included
--- a/man/xresources.texi	Mon Apr 18 13:17:40 2005 +0000
+++ b/man/xresources.texi	Mon Apr 18 13:40:23 2005 +0000
@@ -175,6 +175,10 @@
 @item @code{cursorColor} (class @code{Foreground})
 Color name for text cursor (point).
 
+@item @code{cursorBlink} (class @code{CursorBlink})
+Specifies whether to make the cursor blink. The default is @samp{on}.  Use
+@samp{off} or @samp{false} to turn cursor blinking off.
+
 @item @code{font} (class @code{Font})
 Font name for text (or fontset name, @pxref{Fontsets}).
 
--- a/src/ChangeLog	Mon Apr 18 13:17:40 2005 +0000
+++ b/src/ChangeLog	Mon Apr 18 13:40:23 2005 +0000
@@ -1,3 +1,102 @@
+2005-04-16  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* term.c (struct keys): Add support for shifted keys.
+
+2005-04-16  Richard M. Stallman  <rms@gnu.org>
+
+	* xdisp.c (with_echo_area_buffer): Delete WHICH < 0 case.
+	(set_message): Call with_echo_area_buffer with WHICH = 0.
+	(set_message_1): Erase the echo area buffer first thing.
+	(echo_area_display): Don't clear echo_message_buffer.
+
+2005-04-16  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* Makefile.in (mac.o): Depend on charset.h and coding.h.
+
+	* mac.c: Include charset.h and coding.h.
+	[TARGET_API_MAC_CARBON] (Qutf_8): Remove extern.
+	[TARGET_API_MAC_CARBON] (cfstring_create_with_string): New
+	function.
+	[TARGET_API_MAC_CARBON] (Fmac_get_preference): Use it.
+
+	* macfns.c [TARGET_API_MAC_CARBON] (Fx_file_dialog): Likewise.
+
+	* image.c [MAC_OSX] (image_load_quartz2d): Likewise.
+
+	* macterm.c (x_autoselect_window_p): Remove variable.
+	(last_window): New variable.
+	(XTreassert_line_highlight, x_change_line_highlight): Remove
+	declarations.
+	(mac_focus_changed, x_detect_focus_change): New functions and
+	declarations.
+	(XTextExtents16, front_emacs_window): Remove function.
+	(mac_focus_frame): New function.
+	(XTmouse_position, do_menu_choice, do_zoom_window, XTread_socket)
+	(mac_check_for_quit_char): Use it instead of front_emacs_window.
+	(x_scroll_bar_report_motion): Obtain window from control owner.
+	(x_make_frame_invisible): Set window manager size hint.
+	(do_mouse_moved): Remove function.
+	(XTread_socket): Move its contents here.  Generate select-window
+	event on mouse movement if needed.  Use x_detect_focus_change on
+	activate/deactivate events.  Don't deiconify frame or invalidate
+	window rectangle when dnd items are dropped.  Don't
+	activate/deactivate root control.
+	(frame_highlight, frame_unhighlight): Activate/deactivate root
+	control here.
+	(syms_of_macterm): Delete DEFVAR_BOOL for x_autoselect_window_p.
+
+	* macterm.h (cfstring_create_with_string) [TARGET_API_MAC_CARBON]:
+	New extern.
+
+2005-04-15  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* Makefile.in: Define new macro TOOLTIP_SUPPORT.
+	(lisp): Use it.
+	(SOME_MACHINE_LISP): Add tooltip.
+
+2005-04-14  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* mac.c [!TARGET_API_MAC_CARBON]: Include MacLocales.h.  Don't
+	include TextEncodingConverter.h.
+	(mac_system_script_code, Vmac_system_locale): New variables.
+	(syms_of_mac): Defvar them.
+	(mac_get_system_locale): New function.
+
+	* macfns.c (x_set_name, x_set_title) [!TARGET_API_MAC_CARBON]: Use
+	ENCODE_SYSTEM to encode title bar string.
+	(x_create_tip_frame): Apply 2005-03-18 change for xfns.c.
+	(Fx_file_dialog) [TARGET_API_MAC_CARBON && !MAC_OSX]: Use
+	CFStringGetSystemEncoding to get system default string encoding.
+
+	* macterm.c [!TARGET_API_MAC_CARBON]: Don't include
+	TextEncodingConverter.h.
+
+2005-04-13  Steven Tamm  <steventamm@mac.com>
+
+	* macterm.c (syms_of_macterm): Remove redundant definition of
+	mac-pass-control-to-system.
+
+2005-04-12  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* window.c (Fset_window_configuration): Be careful when you choose
+	among several possible points for the new_current_buffer.
+
+2005-04-12  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* keyboard.c (poll_for_input) [SYNC_INPUT]: Don't call
+	poll_for_input_1.  Set interrupt_input_pending to 1 instead.
+	(Qlanguage_change) [MAC_OS]: New variable.
+	(syms_of_keyboard) [MAC_OS]: Intern and staticpro it.
+	(kbd_buffer_get_event) [MAC_OS]: Make event for LANGUAGE_CHANGE_EVENT.
+
+	* macterm.c (mac_keyboard_text_encoding)
+	(current_mac_keyboard_text_encoding): Remove variables.
+	(XTread_socket): Store language-change event if keyboard script	change
+	is detected.  Don't convert input to `mac_keyboard_text_encoding'.
+	(syms_of_macterm): Delete DEFVAR_INT for mac-keyboard-text-encoding.
+
+	* termhooks.h (enum event_kind) [MAC_OS]: Add LANGUAGE_CHANGE_EVENT.
+
 2005-04-10  Richard M. Stallman  <rms@gnu.org>
 
 	* emacs.c (standard_args): Rename --bare-bones to --quick.
@@ -48,8 +147,8 @@
 	* mac.c (cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
 	(Fmac_get_preference): Doc fix.
 
-	* macfns.c (Fx_create_frame, x_create_tip_frame): Add
-	"fontset-mac" to fallback font/fontsets.
+	* macfns.c (Fx_create_frame, x_create_tip_frame):
+	Add "fontset-mac" to fallback font/fontsets.
 
 2005-04-04  Kim F. Storm  <storm@cua.dk>
 
@@ -80,8 +179,8 @@
 	Vascii_downcase_table.
 	(fast_string_match_ignore_case): Likewise.
 	(search_buffer): Fix checking of boyer-moore usability.
-	(boyer_moore): Calculate translate_prev_byte1/2/3 in advance.  No
-	need of tranlating characters in PAT.  Fix calculation of
+	(boyer_moore): Calculate translate_prev_byte1/2/3 in advance.
+	No need of tranlating characters in PAT.  Fix calculation of
 	simple_translate.
 
 2005-03-31  Stefan Monnier  <monnier@iro.umontreal.ca>
@@ -885,9 +984,9 @@
 
 2005-02-02  Steven Tamm  <steventamm@mac.com>
 
-	* macfns.c (unwind_create_frame): Fixing compile error due to
+	* macfns.c (unwind_create_frame): Fix compile error due to
 	xassert being uncondition, but predicate is.
-	* dispnew.c (update_window): Fixing compile error due to
+	* dispnew.c (update_window): Fix compile error due to
 	xassert being uncondition, but predicate is.
 
 2005-02-02  Miles Bader  <miles@gnu.org>
@@ -1031,6 +1130,7 @@
 
 	* s/darwin.h: Removed PTY_ITERATION from here.
 	(DARWIN): Define.
+
 	* process.c (init_process): Default process-connection-type to
 	nil on darwin 6 or less, t if it is 7 or higher.  This way the
 	broken pty behavior is still allowed on darwin 6 for interactive
@@ -3536,8 +3636,8 @@
 2004-08-26  Steven Tamm  <steventamm@mac.com>
 
 	* fileio.c (Fread_file_name): Call x_file_dialog on carbon on
-	tool-bar/menu click
-	* macfns.c (Fx_file_dialog): Implemented using NavServices
+	tool-bar/menu click.
+	* macfns.c (Fx_file_dialog): Implement using NavServices.
 
 2004-08-24  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
@@ -5024,7 +5124,7 @@
 
 2004-04-26  Steven Tamm  <tamm@Steven-Tamms-Computer.local>
 
-	* lread.c (init_lread): Fixing typo HAVE_CARBON test logic
+	* lread.c (init_lread): Fix typo in HAVE_CARBON test logic.
 
 2004-04-26  Miles Bader  <miles@gnu.org>
 
@@ -5479,10 +5579,10 @@
 
 2004-03-11  Steven Tamm <steventamm@mac.com>
 
-	* image.c [MAC_OSX]: Include sys/stat.h
+	* image.c [MAC_OSX]: Include sys/stat.h.
 
 	* macfns.c (syms_of_macfns): Remove definitions of things now
-	defined in image.c
+	defined in image.c.
 
 2004-03-11  Kim F. Storm  <storm@cua.dk>
 
@@ -6192,7 +6292,7 @@
 	* macterm.c (Vmac_emulate_three_button_mouse): New variable for
 	controlling emulation of a three button mouse with option and
 	command keys.
-	(Qreverse, mac_get_enumlated_btn): Handle the emulation
+	(Qreverse, mac_get_enumlated_btn): Handle the emulation.
 	(mac_event_to_emacs_modifiers, XTread_socket): Ditto.
 
 2004-02-15  Kim F. Storm  <storm@cua.dk>
@@ -11132,7 +11232,7 @@
 
 2003-01-20  Steven Tamm  <steventamm@mac.com>
 
-	* macterm.c (XTread_socket): Checks for valid, visible window
+	* macterm.c (XTread_socket): Check for valid, visible window
 	before sending a scroll-wheel event.
 
 2003-01-20  Richard M. Stallman  <rms@gnu.org>
@@ -11491,7 +11591,7 @@
 
 2002-12-28  Steven Tamm  <steventamm@mac.com>
 
-	* Makefile.in (macosx-bundle): Fixes to Mac OS X/Carbon port to
+	* Makefile.in (macosx-bundle): Fix Mac OS X/Carbon port to
 	allow building in a different directory than source.  Uses some
 	GNU Make extensions, but there is no other make on Mac OS X.
 
@@ -11534,7 +11634,7 @@
 
 	* macterm.c (XTread_socket): Call KeyTranslate for control and
 	meta to deal correctly shifted non-alpha characters, like C-S-5
-	being treated like C-%.  Does not look for shift key to deal
+	being treated like C-%.  Do not look for shift key to deal
 	with masking off control-key with mac-reverse-ctrl-meta.
 
 2002-12-21  Richard M. Stallman  <rms@gnu.org>
--- a/src/Makefile.in	Mon Apr 18 13:17:40 2005 +0000
+++ b/src/Makefile.in	Mon Apr 18 13:40:23 2005 +0000
@@ -686,6 +686,12 @@
 #define WINNT_SUPPORT
 #endif
 
+#ifdef HAVE_WINDOW_SYSTEM
+#define TOOLTIP_SUPPORT ${lispsource}tooltip.elc
+#else
+#define TOOLTIP_SUPPORT
+#endif
+
 /* List of Lisp files loaded into the dumped Emacs.  It's arranged
    like this because it's easier to generate it semi-mechanically from
    loadup.el this way.
@@ -780,6 +786,7 @@
 	${lispsource}emacs-lisp/timer.elc \
 	${lispsource}vc-hooks.elc \
 	${lispsource}ediff-hook.elc \
+	TOOLTIP_SUPPORT \
 	VMS_SUPPORT \
 	MSDOS_SUPPORT \
 	WINNT_SUPPORT \
@@ -887,6 +894,7 @@
   ${dotdot}/lisp/ls-lisp.elc ${dotdot}/lisp/dos-fns.elc \
   ${dotdot}/lisp/w32-fns.elc ${dotdot}/lisp/dos-w32.elc \
   ${dotdot}/lisp/disp-table.elc ${dotdot}/lisp/dos-vars.elc \
+  ${dotdot}/lisp/tooltip.elc \
   ${dotdot}/lisp/international/ccl.elc \
   ${dotdot}/lisp/international/codepage.elc \
   ${dotdot}/lisp/mouse.elc ${dotdot}/lisp/international/fontset.elc \
@@ -1233,7 +1241,8 @@
   fontset.o indent.o insdel.o keyboard.o macros.o minibuf.o msdos.o process.o \
   scroll.o sysdep.o term.o widget.o window.o xdisp.o xfaces.o xfns.o xmenu.o \
   xterm.o xselect.o sound.o: macgui.h
-mac.o: mac.c process.h sysselect.h blockinput.h atimer.h systime.h $(config_h)
+mac.o: mac.c process.h sysselect.h blockinput.h atimer.h systime.h charset.h \
+  coding.h $(config_h)
 macfns.o: macfns.c charset.h macterm.h macgui.h frame.h window.h buffer.h \
   dispextern.h macgui.h fontset.h $(INTERVAL_SRC) keyboard.h blockinput.h \
   atimer.h systime.h epaths.h termhooks.h coding.h systime.h $(config_h)
--- a/src/image.c	Mon Apr 18 13:17:40 2005 +0000
+++ b/src/image.c	Mon Apr 18 13:40:23 2005 +0000
@@ -2423,7 +2423,7 @@
 	  UNGCPRO;
 	  return 0;
 	}
-      path = cfstring_create_with_utf8_cstring (SDATA (file));
+      path = cfstring_create_with_string (file);
       url = CFURLCreateWithFileSystemPath (NULL, path,
 					   kCFURLPOSIXPathStyle, 0);
       CFRelease (path);
--- a/src/keyboard.c	Mon Apr 18 13:17:40 2005 +0000
+++ b/src/keyboard.c	Mon Apr 18 13:40:23 2005 +0000
@@ -521,7 +521,7 @@
 /* Symbols to denote kinds of events.  */
 Lisp_Object Qfunction_key;
 Lisp_Object Qmouse_click;
-#ifdef WINDOWSNT
+#if defined (WINDOWSNT) || defined (MAC_OS)
 Lisp_Object Qlanguage_change;
 #endif
 Lisp_Object Qdrag_n_drop;
@@ -2100,7 +2100,11 @@
      struct atimer *timer;
 {
   if (poll_suppress_count == 0)
+#ifdef SYNC_INPUT
+    interrupt_input_pending = 1;
+#else
     poll_for_input_1 ();
+#endif
 }
 
 #endif /* POLL_FOR_INPUT */
@@ -4026,11 +4030,16 @@
 	    x_activate_menubar (XFRAME (event->frame_or_window));
 	}
 #endif
-#ifdef WINDOWSNT
+#if defined (WINDOWSNT) || defined (MAC_OS)
       else if (event->kind == LANGUAGE_CHANGE_EVENT)
 	{
+#ifdef MAC_OS
+	  /* Make an event (language-change (KEY_SCRIPT)).  */
+	  obj = Fcons (make_number (event->code), Qnil);
+#else
 	  /* Make an event (language-change (FRAME CHARSET LCID)).  */
 	  obj = Fcons (event->frame_or_window, Qnil);
+#endif
 	  obj = Fcons (Qlanguage_change, Fcons (obj, Qnil));
 	  kbd_fetch_ptr = event + 1;
 	}
@@ -10976,7 +10985,7 @@
   staticpro (&Qfunction_key);
   Qmouse_click = intern ("mouse-click");
   staticpro (&Qmouse_click);
-#ifdef WINDOWSNT
+#if defined (WINDOWSNT) || defined (MAC_OS)
   Qlanguage_change = intern ("language-change");
   staticpro (&Qlanguage_change);
 #endif
--- a/src/mac.c	Mon Apr 18 13:17:40 2005 +0000
+++ b/src/mac.c	Mon Apr 18 13:40:23 2005 +0000
@@ -31,6 +31,8 @@
 #include "sysselect.h"
 #include "systime.h"
 #include "blockinput.h"
+#include "charset.h"
+#include "coding.h"
 
 #include "macterm.h"
 
@@ -49,6 +51,7 @@
 #include <Events.h>
 #include <Processes.h>
 #include <EPPC.h>
+#include <MacLocales.h>
 #endif	/* not HAVE_CARBON */
 
 #include <utime.h>
@@ -67,6 +70,12 @@
 
 Lisp_Object QCLIPBOARD;
 
+/* The system script code. */
+static int mac_system_script_code;
+
+/* The system locale identifier string.  */
+static Lisp_Object Vmac_system_locale;
+
 /* An instance of the AppleScript component.  */
 static ComponentInstance as_scripting_component;
 /* The single script context used for all script executions.  */
@@ -258,7 +267,6 @@
 #if TARGET_API_MAC_CARBON
 static Lisp_Object Qstring, Qnumber, Qboolean, Qdate, Qdata;
 static Lisp_Object Qarray, Qdictionary;
-extern Lisp_Object Qutf_8;
 #define DECODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 0)
 
 struct cfdict_context
@@ -267,7 +275,7 @@
   int with_tag, hash_bound;
 };
 
-/* C string to CFString. */
+/* C string to CFString.  */
 
 CFStringRef
 cfstring_create_with_utf8_cstring (c_str)
@@ -284,6 +292,37 @@
 }
 
 
+/* Lisp string to CFString.  */
+
+CFStringRef
+cfstring_create_with_string (s)
+     Lisp_Object s;
+{
+  CFStringRef string = NULL;
+
+  if (STRING_MULTIBYTE (s))
+    {
+      char *p, *end = SDATA (s) + SBYTES (s);
+
+      for (p = SDATA (s); p < end; p++)
+	if (!isascii (*p))
+	  {
+	    s = ENCODE_UTF_8 (s);
+	    break;
+	  }
+      string = CFStringCreateWithBytes (NULL, SDATA (s), SBYTES (s),
+					kCFStringEncodingUTF8, false);
+    }
+
+  if (string == NULL)
+    /* Failed to interpret as UTF 8.  Fall back on Mac Roman.  */
+    string = CFStringCreateWithBytes (NULL, SDATA (s), SBYTES (s),
+				      kCFStringEncodingMacRoman, false);
+
+  return string;
+}
+
+
 /* From CFData to a lisp string.  Always returns a unibyte string.  */
 
 Lisp_Object
@@ -3704,11 +3743,11 @@
   app_id = kCFPreferencesCurrentApplication;
   if (!NILP (application))
     {
-      app_id = cfstring_create_with_utf8_cstring (SDATA (application));
+      app_id = cfstring_create_with_string (application);
       if (app_id == NULL)
 	goto out;
     }
-  key_str = cfstring_create_with_utf8_cstring (SDATA (XCAR (key)));
+  key_str = cfstring_create_with_string (XCAR (key));
   if (key_str == NULL)
     goto out;
   app_plist = CFPreferencesCopyAppValue (key_str, app_id);
@@ -3721,7 +3760,7 @@
     {
       if (CFGetTypeID (plist) != CFDictionaryGetTypeID ())
 	break;
-      key_str = cfstring_create_with_utf8_cstring (SDATA (XCAR (key)));
+      key_str = cfstring_create_with_string (XCAR (key));
       if (key_str == NULL)
 	goto out;
       plist = CFDictionaryGetValue (plist, key_str);
@@ -4167,6 +4206,29 @@
 }
 #endif /* MAC_OSX */
 
+
+static Lisp_Object
+mac_get_system_locale ()
+{
+  OSErr err;
+  LangCode lang;
+  RegionCode region;
+  LocaleRef locale;
+  Str255 str;
+
+  lang = GetScriptVariable (smSystemScript, smScriptLang);
+  region = GetScriptManagerVariable (smRegionCode);
+  err = LocaleRefFromLangOrRegionCode (lang, region, &locale);
+  if (err == noErr)
+    err = LocaleRefGetPartString (locale, kLocaleAllPartsMask,
+				  sizeof (str), str);
+  if (err == noErr)
+    return build_string (str);
+  else
+    return Qnil;
+}
+
+
 void
 syms_of_mac ()
 {
@@ -4197,6 +4259,16 @@
   defsubr (&Sdo_applescript);
   defsubr (&Smac_file_name_to_posix);
   defsubr (&Sposix_file_name_to_mac);
+
+  DEFVAR_INT ("mac-system-script-code", &mac_system_script_code,
+    doc: /* The system script code.  */);
+  mac_system_script_code = (ScriptCode) GetScriptManagerVariable (smSysScript);
+
+  DEFVAR_LISP ("mac-system-locale", &Vmac_system_locale,
+    doc: /* The system locale identifier string.
+This is not a POSIX locale ID, but an ICU locale ID.  So encoding
+information is not included.  */);
+  Vmac_system_locale = mac_get_system_locale ();
 }
 
 /* arch-tag: 29d30c1f-0c6b-4f88-8a6d-0558d7f9dbff
--- a/src/macfns.c	Mon Apr 18 13:17:40 2005 +0000
+++ b/src/macfns.c	Mon Apr 18 13:40:23 2005 +0000
@@ -1895,7 +1895,7 @@
 #if TARGET_API_MAC_CARBON
 	name = ENCODE_UTF_8 (name);
 #else
-        return;
+	name = ENCODE_SYSTEM (name);
 #endif
 
       BLOCK_INPUT;
@@ -1977,7 +1977,7 @@
 #if TARGET_API_MAC_CARBON
 	name = ENCODE_UTF_8 (name);
 #else
-        return;
+	name = ENCODE_SYSTEM (name);
 #endif
 
       BLOCK_INPUT;
@@ -3637,9 +3637,6 @@
 
   check_mac ();
 
-  /* Use this general default value to start with until we know if
-     this frame has a specified name.  */
-  Vx_resource_name = Vinvocation_name;
 
 #ifdef MULTI_KBOARD
   kb = dpyinfo->kboard;
@@ -3653,7 +3650,6 @@
       && !EQ (name, Qunbound)
       && !NILP (name))
     error ("Invalid frame name--not a string or nil");
-  Vx_resource_name = name;
 
   frame = Qnil;
   GCPRO3 (parms, name, frame);
@@ -4252,8 +4248,7 @@
     options.optionFlags |= kNavSelectAllReadableItem;
     if (!NILP(prompt))
       {
-	message =
-	  cfstring_create_with_utf8_cstring (SDATA (ENCODE_UTF_8 (prompt)));
+	message = cfstring_create_with_string (prompt);
 	options.message = message;
       }
     /* Don't set the application, let it use default.
@@ -4362,7 +4357,12 @@
 		  filename[len++] = '/';
 		CFStringGetCString(reply.saveFileName, filename+len, 
 				   sizeof (filename) - len,
-				   kCFStringEncodingUTF8);
+#if MAC_OSX
+				   kCFStringEncodingUTF8
+#else
+				   CFStringGetSystemEncoding ()
+#endif
+				   );
 	      }
 	    file = DECODE_FILE (make_unibyte_string (filename,
 						     strlen (filename)));
--- a/src/macterm.c	Mon Apr 18 13:17:40 2005 +0000
+++ b/src/macterm.c	Mon Apr 18 13:40:23 2005 +0000
@@ -95,6 +95,7 @@
 			: controlKey)
 #define macAltKey      (NILP (Vmac_command_key_is_meta) ? cmdKey : optionKey)
 
+#define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
 
 
 /* Non-nil means Emacs uses toolkit scroll bars.  */
@@ -110,9 +111,8 @@
 
 static int any_help_event_p;
 
-/* Non-zero means autoselect window with the mouse cursor.  */
-
-int x_autoselect_window_p;
+/* Last window where we saw the mouse.  Used by mouse-autoselect-window.  */
+static Lisp_Object last_window;
 
 /* Non-zero means make use of UNDERLINE_POSITION font properties.  */
 
@@ -273,14 +273,16 @@
 static int x_compute_min_glyph_bounds P_ ((struct frame *));
 static void x_update_end P_ ((struct frame *));
 static void XTframe_up_to_date P_ ((struct frame *));
-static void XTreassert_line_highlight P_ ((int, int));
-static void x_change_line_highlight P_ ((int, int, int, int));
 static void XTset_terminal_modes P_ ((void));
 static void XTreset_terminal_modes P_ ((void));
 static void x_clear_frame P_ ((void));
 static void frame_highlight P_ ((struct frame *));
 static void frame_unhighlight P_ ((struct frame *));
 static void x_new_focus_frame P_ ((struct x_display_info *, struct frame *));
+static void mac_focus_changed P_ ((int, struct mac_display_info *,
+				   struct frame *, struct input_event *));
+static void x_detect_focus_change P_ ((struct mac_display_info *,
+				       EventRecord *, struct input_event *));
 static void XTframe_rehighlight P_ ((struct frame *));
 static void x_frame_rehighlight P_ ((struct x_display_info *));
 static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
@@ -1198,15 +1200,6 @@
 }
 
 
-static void
-XTextExtents16 (XFontStruct *font, XChar2b *text, int nchars,
-                     int *direction,int *font_ascent,
-                     int *font_descent, XCharStruct *cs)
-{
-  /* MAC_TODO: Use GetTextMetrics to do this and inline it below. */
-}
-
-
 /* x_sync is a no-op on Mac.  */
 void
 x_sync (f)
@@ -3494,6 +3487,14 @@
 frame_highlight (f)
      struct frame *f;
 {
+  OSErr err;
+  ControlRef root_control;
+
+  BLOCK_INPUT;
+  err = GetRootControl (FRAME_MAC_WINDOW (f), &root_control);
+  if (err == noErr)
+    ActivateControl (root_control);
+  UNBLOCK_INPUT;
   x_update_cursor (f, 1);
 }
 
@@ -3501,6 +3502,14 @@
 frame_unhighlight (f)
      struct frame *f;
 {
+  OSErr err;
+  ControlRef root_control;
+
+  BLOCK_INPUT;
+  err = GetRootControl (FRAME_MAC_WINDOW (f), &root_control);
+  if (err == noErr)
+    DeactivateControl (root_control);
+  UNBLOCK_INPUT;
   x_update_cursor (f, 1);
 }
 
@@ -3543,6 +3552,68 @@
   x_frame_rehighlight (dpyinfo);
 }
 
+/* Handle FocusIn and FocusOut state changes for FRAME.
+   If FRAME has focus and there exists more than one frame, puts
+   a FOCUS_IN_EVENT into *BUFP.  */
+
+static void
+mac_focus_changed (type, dpyinfo, frame, bufp)
+     int type;
+     struct mac_display_info *dpyinfo;
+     struct frame *frame;
+     struct input_event *bufp;
+{
+  if (type == activeFlag)
+    {
+      if (dpyinfo->x_focus_event_frame != frame)
+        {
+          x_new_focus_frame (dpyinfo, frame);
+          dpyinfo->x_focus_event_frame = frame;
+
+          /* Don't stop displaying the initial startup message
+             for a switch-frame event we don't need.  */
+          if (GC_NILP (Vterminal_frame)
+              && GC_CONSP (Vframe_list)
+              && !GC_NILP (XCDR (Vframe_list)))
+            {
+              bufp->kind = FOCUS_IN_EVENT;
+              XSETFRAME (bufp->frame_or_window, frame);
+            }
+        }
+    }
+  else
+    {
+      if (dpyinfo->x_focus_event_frame == frame)
+        {
+          dpyinfo->x_focus_event_frame = 0;
+          x_new_focus_frame (dpyinfo, 0);
+        }
+    }
+}
+
+/* The focus may have changed.  Figure out if it is a real focus change,
+   by checking both FocusIn/Out and Enter/LeaveNotify events.
+
+   Returns FOCUS_IN_EVENT event in *BUFP. */
+
+static void
+x_detect_focus_change (dpyinfo, event, bufp)
+     struct mac_display_info *dpyinfo;
+     EventRecord *event;
+     struct input_event *bufp;
+{
+  struct frame *frame;
+
+  frame = mac_window_to_frame ((WindowPtr) event->message);
+  if (! frame)
+    return;
+
+  /* On Mac, this is only called from focus events, so no switch needed.  */
+  mac_focus_changed ((event->modifiers & activeFlag),
+		     dpyinfo, frame, bufp);
+}
+
+
 /* Handle an event saying the mouse has moved out of an Emacs frame.  */
 
 void
@@ -3980,25 +4051,19 @@
 }
 
 
-static WindowPtr
-front_emacs_window ()
-{
-#if TARGET_API_MAC_CARBON
-  WindowPtr wp = GetFrontWindowOfClass (kDocumentWindowClass, true);
-
-  while (wp && !is_emacs_window (wp))
-    wp = GetNextWindowOfClass (wp, kDocumentWindowClass, true);
-#else
-  WindowPtr wp = FrontWindow ();
-
-  while (wp && (wp == tip_window || !is_emacs_window (wp)))
-    wp = GetNextWindow (wp);
-#endif
-
-  return wp;
-}
-
-#define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
+static struct frame *
+mac_focus_frame (dpyinfo)
+     struct mac_display_info *dpyinfo;
+{
+  if (dpyinfo->x_focus_frame)
+    return dpyinfo->x_focus_frame;
+  else
+    /* Mac version may get events, such as a menu bar click, even when
+       all the frames are invisible.  In this case, we regard the
+       event came to the selected frame.  */
+    return SELECTED_FRAME ();
+}
+
 
 /* Return the current position of the mouse.
    *fp should be a frame which indicates which display to ask about.
@@ -4031,13 +4096,10 @@
 {
   Point mouse_pos;
   int ignore1, ignore2;
-  WindowPtr wp = front_emacs_window ();
-  struct frame *f;
+  struct frame *f = mac_focus_frame (FRAME_MAC_DISPLAY_INFO (*fp));
+  WindowPtr wp = FRAME_MAC_WINDOW (f);
   Lisp_Object frame, tail;
 
-  if (is_emacs_window(wp))
-    f = mac_window_to_frame (wp);
-
   BLOCK_INPUT;
 
   if (! NILP (last_mouse_scroll_bar) && insist == 0)
@@ -4604,7 +4666,12 @@
      unsigned long *time;
 {
   struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
-  WindowPtr wp = front_emacs_window ();
+  ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar);
+#if TARGET_API_MAC_CARBON
+  WindowPtr wp = GetControlOwner (ch);
+#else
+  WindowPtr wp = (*ch)->contrlOwner;
+#endif
   Point mouse_pos;
   struct frame *f = mac_window_to_frame (wp);
   int win_y, top_range;
@@ -5050,7 +5117,7 @@
     return Qnil;
 
   /* Since x_new_font doesn't update any fontset information, do it now.  */
-  FRAME_FONTSET(f) = fontset;
+  FRAME_FONTSET (f) = fontset;
 
   return build_string (fontsetname);
 }
@@ -5498,6 +5565,13 @@
 
   BLOCK_INPUT;
 
+  /* Before unmapping the window, update the WM_SIZE_HINTS property to claim
+     that the current position of the window is user-specified, rather than
+     program-specified, so that when the window is mapped again, it will be
+     placed at the same location, without forcing the user to position it
+     by hand again (they have already done that once for this window.)  */
+  x_wm_set_size_hint (f, (long) 0, 1);
+
   HideWindow (FRAME_MAC_WINDOW (f));
 
   /* We can't distinguish this from iconification
@@ -7070,7 +7144,6 @@
 #include <Dialogs.h>
 #include <Script.h>
 #include <Types.h>
-#include <TextEncodingConverter.h>
 #include <Resources.h>
 
 #if __MWERKS__
@@ -7146,11 +7219,6 @@
 Lisp_Object Vmac_pass_control_to_system;
 #endif
 
-/* convert input from Mac keyboard (assumed to be in Mac Roman coding)
-   to this text encoding */
-int mac_keyboard_text_encoding;
-int current_mac_keyboard_text_encoding = kTextEncodingMacRoman;
-
 /* Set in term/mac-win.el to indicate that event loop can now generate
    drag and drop events.  */
 Lisp_Object Qmac_ready_for_drag_n_drop;
@@ -7460,21 +7528,6 @@
 {
   /* Window-activate events will do the job. */
 #if 0
-  WindowPtr wp;
-  struct frame *f;
-
-  wp = front_emacs_window ();
-  if (wp)
-    {
-      f = mac_window_to_frame (wp);
-
-      if (f)
-	{
-	  x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f);
-	  activate_scroll_bars (f);
-	}
-    }
-
   app_is_suspended = false;
   app_sleep_time = WNE_SLEEP_AT_RESUME;
 #endif
@@ -7485,21 +7538,6 @@
 {
   /* Window-deactivate events will do the job. */
 #if 0
-  WindowPtr wp;
-  struct frame *f;
-
-  wp = front_emacs_window ();
-  if (wp)
-    {
-      f = mac_window_to_frame (wp);
-
-      if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)
-	{
-	  x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0);
-	  deactivate_scroll_bars (f);
-	}
-    }
-
   app_is_suspended = true;
   app_sleep_time = WNE_SLEEP_AT_SUSPEND;
 #endif
@@ -7507,40 +7545,6 @@
 
 
 static void
-do_mouse_moved (mouse_pos, f)
-     Point mouse_pos;
-     FRAME_PTR *f;
-{
-  WindowPtr wp = front_emacs_window ();
-  struct x_display_info *dpyinfo;
-
-  if (wp)
-    {
-      *f = mac_window_to_frame (wp);
-      dpyinfo = FRAME_MAC_DISPLAY_INFO (*f);
-
-      if (dpyinfo->mouse_face_hidden)
-	{
-	  dpyinfo->mouse_face_hidden = 0;
-	  clear_mouse_face (dpyinfo);
-	}
-
-      SetPortWindowPort (wp);
-
-      GlobalToLocal (&mouse_pos);
-
-      if (dpyinfo->grabbed && tracked_scroll_bar)
-	x_scroll_bar_note_movement (tracked_scroll_bar,
-				    mouse_pos.v
-				    - XINT (tracked_scroll_bar->top),
-				    TickCount() * (1000 / 60));
-      else
-	note_mouse_movement (*f, &mouse_pos);
-    }
-}
-
-
-static void
 do_apple_menu (SInt16 menu_item)
 {
 #if !TARGET_API_MAC_CARBON
@@ -7576,7 +7580,7 @@
 
     default:
       {
-        struct frame *f = mac_window_to_frame (front_emacs_window ());
+        struct frame *f = mac_focus_frame (&one_mac_display_info);
         MenuHandle menu = GetMenuHandle (menu_id);
         if (menu)
           {
@@ -7654,13 +7658,14 @@
   Point top_left;
   int w_title_height, columns, rows, width, height;
   struct frame *f = mac_window_to_frame (w);
+  struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
 
 #if TARGET_API_MAC_CARBON
   {
     Point standard_size;
 
     standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
-    standard_size.v = FRAME_MAC_DISPLAY_INFO (f)->height;
+    standard_size.v = dpyinfo->height;
 
     if (IsWindowInStandardState (w, &standard_size, &zoom_rect))
       zoom_in_or_out = inZoomIn;
@@ -7716,7 +7721,7 @@
 	= zoom_rect;
     }
 
-  ZoomWindow (w, zoom_in_or_out, w == front_emacs_window ());
+  ZoomWindow (w, zoom_in_or_out, f == mac_focus_frame (dpyinfo));
 
   SetPort (save_port);
 #endif /* not TARGET_API_MAC_CARBON */
@@ -8582,10 +8587,13 @@
 	      {
 		SInt32 delta;
 		Point point;
-		WindowPtr window_ptr = front_emacs_window ();
-
-		if (!IsValidWindowPtr (window_ptr))
+		struct frame *f = mac_focus_frame (dpyinfo);
+		WindowPtr window_ptr;
+
+		if (!f)
 		  {
+		    /* Beep if wheel move occurs when all the frames
+		       are invisible.  */
 		    SysBeep(1);
 		    break;
 		  }
@@ -8601,6 +8609,7 @@
 		inev.modifiers = (mac_event_to_emacs_modifiers (eventRef)
 				  | ((delta < 0) ? down_modifier
 				     : up_modifier));
+		window_ptr = FRAME_MAC_WINDOW (f);
 		SetPortWindowPort (window_ptr);
 		GlobalToLocal (&point);
 		XSETINT (inev.x, point.h);
@@ -8659,14 +8668,14 @@
 	    switch (part_code)
 	      {
 	      case inMenuBar:
-		f = mac_window_to_frame (front_emacs_window ());
+		f = mac_focus_frame (dpyinfo);
 		saved_menu_event_location = er.where;
 		inev.kind = MENU_BAR_ACTIVATE_EVENT;
 		XSETFRAME (inev.frame_or_window, f);
 		break;
 
 	      case inContent:
-		if (window_ptr != front_emacs_window ())
+		if (window_ptr != FRAME_MAC_WINDOW (mac_focus_frame (dpyinfo)))
 		  SelectWindow (window_ptr);
 		else
 		  {
@@ -8857,7 +8866,61 @@
 	      help_echo_string = help_echo_object = help_echo_window = Qnil;
 	      help_echo_pos = -1;
 
-	      do_mouse_moved (er.where, &f);
+	      if (dpyinfo->grabbed && last_mouse_frame
+		  && FRAME_LIVE_P (last_mouse_frame))
+		f = last_mouse_frame;
+	      else
+		f = dpyinfo->x_focus_frame;
+
+	      if (dpyinfo->mouse_face_hidden)
+		{
+		  dpyinfo->mouse_face_hidden = 0;
+		  clear_mouse_face (dpyinfo);
+		}
+
+	      if (f)
+		{
+		  WindowPtr wp = FRAME_MAC_WINDOW (f);
+		  Point mouse_pos = er.where;
+
+		  SetPortWindowPort (wp);
+
+		  GlobalToLocal (&mouse_pos);
+
+		  if (dpyinfo->grabbed && tracked_scroll_bar)
+		    x_scroll_bar_note_movement (tracked_scroll_bar,
+						mouse_pos.v
+						- XINT (tracked_scroll_bar->top),
+						TickCount() * (1000 / 60));
+		  else
+		    {
+		      /* Generate SELECT_WINDOW_EVENTs when needed.  */
+		      if (mouse_autoselect_window)
+			{
+			  Lisp_Object window;
+
+			  window = window_from_coordinates (f,
+							    mouse_pos.h,
+							    mouse_pos.v,
+							    0, 0, 0, 0);
+
+			  /* Window will be selected only when it is
+			     not selected now and last mouse movement
+			     event was not in it.  Minibuffer window
+			     will be selected iff it is active.  */
+			  if (WINDOWP (window)
+			      && !EQ (window, last_window)
+			      && !EQ (window, selected_window))
+			    {
+			      inev.kind = SELECT_WINDOW_EVENT;
+			      inev.frame_or_window = window;
+			    }
+
+			  last_window=window;
+			}
+		      note_mouse_movement (f, &mouse_pos);
+		    }
+		}
 
 	      /* If the contents of the global variable
 		 help_echo_string has changed, generate a
@@ -8871,7 +8934,6 @@
 	case activateEvt:
 	  {
 	    WindowPtr window_ptr = (WindowPtr) er.message;
-	    ControlRef root_control;
 
 #if USE_CARBON_EVENTS
 	    if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
@@ -8887,16 +8949,12 @@
 	    if (!is_emacs_window (window_ptr))
 	      break;
 
-	    f = mac_window_to_frame (window_ptr);
-	    GetRootControl (window_ptr, &root_control);
-
 	    if ((er.modifiers & activeFlag) != 0)
 	      {
 		/* A window has been activated */
 		Point mouse_loc = er.where;
 
-		x_new_focus_frame (dpyinfo, f);
-		ActivateControl (root_control);
+		x_detect_focus_change (dpyinfo, &er, &inev);
 
 		SetPortWindowPort (window_ptr);
 		GlobalToLocal (&mouse_loc);
@@ -8910,13 +8968,9 @@
 		/* A window has been deactivated */
 		dpyinfo->grabbed = 0;
 
-		if (f == dpyinfo->x_focus_frame)
-		  {
-		    x_new_focus_frame (dpyinfo, 0);
-		    DeactivateControl (root_control);
-		  }
-
-
+		x_detect_focus_change (dpyinfo, &er, &inev);
+
+		f = mac_window_to_frame (window_ptr);
 		if (f == dpyinfo->mouse_face_mouse_frame)
 		  {
 		    /* If we move outside the frame, then we're
@@ -8957,13 +9011,31 @@
 		break;
 #endif
 
-#if TARGET_API_MAC_CARBON
-	    if (!IsValidWindowPtr (front_emacs_window ()))
+	    if (dpyinfo->x_focus_frame == NULL)
 	      {
+		/* Beep if keyboard input occurs when all the frames
+		   are invisible.  */
 		SysBeep (1);
 		break;
 	      }
-#endif
+
+	    {
+	      static SInt16 last_key_script = -1;
+	      SInt16 current_key_script = GetScriptManagerVariable (smKeyScript);
+
+	      if (last_key_script != current_key_script)
+		{
+		  struct input_event event;
+
+		  EVENT_INIT (event);
+		  event.kind = LANGUAGE_CHANGE_EVENT;
+		  event.arg = Qnil;
+		  event.code = current_key_script;
+		  kbd_buffer_store_event (&event);
+		  count++;
+		}
+	      last_key_script = current_key_script;
+	    }
 
 	    ObscureCursor ();
 
@@ -8998,95 +9070,32 @@
 		    unsigned long some_state = 0;
 		    inev.code = KeyTranslate (kchr_ptr, new_keycode,
 					      &some_state) & 0xff;
-		  } else if (!NILP(Vmac_option_modifier) && (er.modifiers & optionKey))
-            {
-                /* When using the option key as an emacs modifier, convert
-                   the pressed key code back to one without the Mac option
-                   modifier applied. */
-                int new_modifiers = er.modifiers & ~optionKey;
-                int new_keycode = keycode | new_modifiers;
-                Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
-                unsigned long some_state = 0;
-                inev.code = KeyTranslate (kchr_ptr, new_keycode,
-                                          &some_state) & 0xff;
-            }
+		  }
+		else if (!NILP (Vmac_option_modifier)
+			 && (er.modifiers & optionKey))
+		  {
+		    /* When using the option key as an emacs modifier,
+		       convert the pressed key code back to one
+		       without the Mac option modifier applied. */
+		    int new_modifiers = er.modifiers & ~optionKey;
+		    int new_keycode = keycode | new_modifiers;
+		    Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
+		    unsigned long some_state = 0;
+		    inev.code = KeyTranslate (kchr_ptr, new_keycode,
+					      &some_state) & 0xff;
+		  }
 		else
 		  inev.code = er.message & charCodeMask;
 		inev.kind = ASCII_KEYSTROKE_EVENT;
 	      }
 	  }
 
-	  /* If variable mac-convert-keyboard-input-to-latin-1 is
-	     non-nil, convert non-ASCII characters typed at the Mac
-	     keyboard (presumed to be in the Mac Roman encoding) to
-	     iso-latin-1 encoding before they are passed to Emacs.
-	     This enables the Mac keyboard to be used to enter
-	     non-ASCII iso-latin-1 characters directly.  */
-	  if (mac_keyboard_text_encoding != kTextEncodingMacRoman
-	      && inev.kind == ASCII_KEYSTROKE_EVENT && inev.code >= 128)
-	    {
-	      static TECObjectRef converter = NULL;
-	      OSStatus the_err = noErr;
-	      OSStatus convert_status = noErr;
-
-	      if (converter ==  NULL)
-		{
-		  the_err = TECCreateConverter (&converter,
-						kTextEncodingMacRoman,
-						mac_keyboard_text_encoding);
-		  current_mac_keyboard_text_encoding
-		    = mac_keyboard_text_encoding;
-		}
-	      else if (mac_keyboard_text_encoding
-		       != current_mac_keyboard_text_encoding)
-		{
-		  /* Free the converter for the current encoding
-		     before creating a new one.  */
-		  TECDisposeConverter (converter);
-		  the_err = TECCreateConverter (&converter,
-						kTextEncodingMacRoman,
-						mac_keyboard_text_encoding);
-		  current_mac_keyboard_text_encoding
-		    = mac_keyboard_text_encoding;
-		}
-
-	      if (the_err == noErr)
-		{
-		  unsigned char ch = inev.code;
-		  ByteCount actual_input_length, actual_output_length;
-		  unsigned char outbuf[32];
-
-		  convert_status = TECConvertText (converter, &ch, 1,
-						   &actual_input_length,
-						   outbuf, 1,
-						   &actual_output_length);
-		  if (convert_status == noErr
-		      && actual_input_length == 1
-		      && actual_output_length == 1)
-		    inev.code = *outbuf;
-
-		  /* Reset internal states of the converter object.
-		     If it fails, create another one. */
-		  convert_status = TECFlushText (converter, outbuf,
-						 sizeof (outbuf),
-						 &actual_output_length);
-		  if (convert_status != noErr)
-		    {
-		      TECDisposeConverter (converter);
-		      TECCreateConverter (&converter,
-					  kTextEncodingMacRoman,
-					  mac_keyboard_text_encoding);
-		    }
-		}
-	    }
-
 #if USE_CARBON_EVENTS
 	  inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
 #else
 	  inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
 #endif
-	  XSETFRAME (inev.frame_or_window,
-		     mac_window_to_frame (front_emacs_window ()));
+	  XSETFRAME (inev.frame_or_window, mac_focus_frame (dpyinfo));
 	  inev.timestamp = er.when * (1000 / 60);  /* ticks to milliseconds */
 	  break;
 
@@ -9099,22 +9108,10 @@
 	     constuct_drag_n_drop in w32term.c.  */
 	  if (!NILP (drag_and_drop_file_list))
 	    {
-	      struct frame *f = NULL;
+	      struct frame *f = mac_focus_frame (dpyinfo);
 	      WindowPtr wp;
 	      Lisp_Object frame;
 
-	      wp = front_emacs_window ();
-
-	      if (!wp)
-		{
-		  struct frame *f = XFRAME (XCAR (Vframe_list));
-		  CollapseWindow (FRAME_MAC_WINDOW (f), false);
-		  wp = front_emacs_window ();
-		}
-
-	      if (wp)
-		f = mac_window_to_frame (wp);
-
 	      inev.kind = DRAG_N_DROP_EVENT;
 	      inev.code = 0;
 	      inev.timestamp = er.when * (1000 / 60);
@@ -9131,10 +9128,12 @@
 	      XSETFRAME (frame, f);
 	      inev.frame_or_window = Fcons (frame, drag_and_drop_file_list);
 
+#if 0
 	      /* Regardless of whether Emacs was suspended or in the
 		 foreground, ask it to redraw its entire screen.
 		 Otherwise parts of the screen can be left in an
 		 inconsistent state.  */
+	      wp = FRAME_MAC_WINDOW (f);
 	      if (wp)
 #if TARGET_API_MAC_CARBON
 		{
@@ -9146,6 +9145,7 @@
 #else /* not TARGET_API_MAC_CARBON */
                 InvalRect (&(wp->portRect));
 #endif /* not TARGET_API_MAC_CARBON */
+#endif
 	    }
 	default:
 	  break;
@@ -9625,7 +9625,7 @@
       e.arg = Qnil;
       e.modifiers = NULL;
       e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60);
-      XSETFRAME (e.frame_or_window, mac_window_to_frame (front_emacs_window ()));
+      XSETFRAME (e.frame_or_window, mac_focus_frame (&one_mac_display_info));
       /* Remove event from queue to prevent looping. */
       RemoveEventFromQueue (GetMainEventQueue (), event);
       ReleaseEvent (event);
@@ -9819,10 +9819,6 @@
   Qeuc_kr = intern ("euc-kr");
   staticpro (&Qeuc_kr);
 
-  DEFVAR_BOOL ("x-autoselect-window", &x_autoselect_window_p,
-    doc: /* *Non-nil means autoselect window with mouse pointer.  */);
-  x_autoselect_window_p = 0;
-
   DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
 	       doc: /* If not nil, Emacs uses toolkit scroll bars.  */);
   Vx_toolkit_scroll_bars = Qt;
@@ -9882,10 +9878,6 @@
 Toolbox for processing before Emacs sees it.  */);
   Vmac_pass_control_to_system = Qt;
 
-  DEFVAR_LISP ("mac-pass-control-to-system", &Vmac_pass_control_to_system,
-   doc: /* If non-nil, the Mac \"Control\" key is passed on to the Mac
-Toolbox for processing before Emacs sees it.  */);
-  Vmac_pass_control_to_system = Qt;
 #endif
 
   DEFVAR_LISP ("mac-allow-anti-aliasing", &Vmac_use_core_graphics,
@@ -9893,21 +9885,6 @@
 The text will be rendered using Core Graphics text rendering which
 may anti-alias the text.  */);
   Vmac_use_core_graphics = Qnil;
-
-  DEFVAR_INT ("mac-keyboard-text-encoding", &mac_keyboard_text_encoding,
-    doc: /* One of the Text Encoding Base constant values defined in the
-Basic Text Constants section of Inside Macintosh - Text Encoding
-Conversion Manager.  Its value determines the encoding characters
-typed at the Mac keyboard (presumed to be in the MacRoman encoding)
-will convert into.  E.g., if it is set to kTextEncodingMacRoman (0),
-its default value, no conversion takes place.  If it is set to
-kTextEncodingISOLatin1 (0x201) or kTextEncodingISOLatin2 (0x202),
-characters typed on Mac keyboard are first converted into the
-ISO Latin-1 or ISO Latin-2 encoding, respectively before being
-passed to Emacs.  Together with Emacs's set-keyboard-coding-system
-command, this enables the Mac keyboard to be used to enter non-ASCII
-characters directly.  */);
-  mac_keyboard_text_encoding = kTextEncodingMacRoman;
 }
 
 /* arch-tag: f2259165-4454-4c04-a029-a133c8af7b5b
--- a/src/macterm.h	Mon Apr 18 13:17:40 2005 +0000
+++ b/src/macterm.h	Mon Apr 18 13:40:23 2005 +0000
@@ -195,14 +195,14 @@
   int bitmaps_last;
 
   /* The frame (if any) which has the window that has keyboard focus.
-     Zero if none.  This is examined by Ffocus_frame in w32fns.c.  Note
+     Zero if none.  This is examined by Ffocus_frame in macfns.c.  Note
      that a mere EnterNotify event can set this; if you need to know the
      last frame specified in a FocusIn or FocusOut event, use
-     w32_focus_event_frame.  */
+     x_focus_event_frame.  */
   struct frame *x_focus_frame;
 
   /* The last frame mentioned in a FocusIn or FocusOut event.  This is
-     separate from w32_focus_frame, because whether or not LeaveNotify
+     separate from x_focus_frame, because whether or not LeaveNotify
      events cause us to lose focus depends on whether or not we have
      received a FocusIn event for it.  */
   struct frame *x_focus_event_frame;
@@ -210,7 +210,7 @@
   /* The frame which currently has the visual highlight, and should get
      keyboard input (other sorts of input have the frame encoded in the
      event).  It points to the focus frame's selected window's
-     frame.  It differs from w32_focus_frame when we're using a global
+     frame.  It differs from x_focus_frame when we're using a global
      minibuffer.  */
   struct frame *x_highlight_frame;
 
@@ -418,7 +418,7 @@
 
 #define FRAME_SIZE_HINTS(f) ((f)->output_data.mac->size_hints)
 
-/* This gives the w32_display_info structure for the display F is on.  */
+/* This gives the mac_display_info structure for the display F is on.  */
 #define FRAME_MAC_DISPLAY_INFO(f) (&one_mac_display_info)
 #define FRAME_X_DISPLAY_INFO(f) (&one_mac_display_info)
 
@@ -624,6 +624,7 @@
 extern void mac_clear_font_name_table P_ ((void));
 #if TARGET_API_MAC_CARBON
 extern CFStringRef cfstring_create_with_utf8_cstring P_ ((const char *));
+extern CFStringRef cfstring_create_with_string P_ ((Lisp_Object));
 extern Lisp_Object cfdata_to_lisp P_ ((CFDataRef));
 extern Lisp_Object cfstring_to_lisp P_ ((CFStringRef));
 extern Lisp_Object cfnumber_to_lisp P_ ((CFNumberRef));
--- a/src/term.c	Mon Apr 18 13:17:40 2005 +0000
+++ b/src/term.c	Mon Apr 18 13:40:23 2005 +0000
@@ -1289,7 +1289,26 @@
   {"k6", "f6"},
   {"k7", "f7"},
   {"k8", "f8"},
-  {"k9", "f9"}
+  {"k9", "f9"},
+
+  {"&0", "S-cancel"},    /*shifted cancel key*/
+  {"&9", "S-begin"},     /*shifted begin key*/
+  {"*0", "S-find"},      /*shifted find key*/
+  {"*1", "S-execute"},   /*shifted execute? actually shifted command key*/
+  {"*4", "S-delete"},    /*shifted delete-character key*/
+  {"*7", "S-end"},       /*shifted end key*/
+  {"*8", "S-clearline"}, /*shifted clear-to end-of-line key*/
+  {"#1", "S-help"},      /*shifted help key*/
+  {"#2", "S-home"},      /*shifted home key*/
+  {"#3", "S-insert"},    /*shifted insert-character key*/
+  {"#4", "S-left"},      /*shifted left-arrow key*/
+  {"%d", "S-menu"},      /*shifted menu? actually shifted options key*/
+  {"%c", "S-next"},      /*shifted next key*/
+  {"%e", "S-prior"},     /*shifted previous key*/
+  {"%f", "S-print"},     /*shifted print key*/
+  {"%g", "S-redo"},      /*shifted redo key*/
+  {"%i", "S-right"},     /*shifted right-arrow key*/
+  {"!3", "S-undo"}       /*shifted undo key*/
   };
 
 static char **term_get_fkeys_arg;
--- a/src/termhooks.h	Mon Apr 18 13:17:40 2005 +0000
+++ b/src/termhooks.h	Mon Apr 18 13:40:23 2005 +0000
@@ -103,10 +103,11 @@
 				   the wheel event occurred in.
 				   .timestamp gives a timestamp (in
 				   milliseconds) for the event.  */
-#ifdef WINDOWSNT
-  LANGUAGE_CHANGE_EVENT,	/* A LANGUAGE_CHANGE_EVENT is generated
-				   on WINDOWSNT when the keyboard layout
-				   or input language is changed by the
+#if defined (WINDOWSNT) || defined (MAC_OS)
+  LANGUAGE_CHANGE_EVENT,	/* A LANGUAGE_CHANGE_EVENT is
+				   generated on WINDOWSNT or Mac OS
+				   when the keyboard layout or input
+				   language is changed by the
 				   user.  */
 #endif
   SCROLL_BAR_CLICK_EVENT,	/* .code gives the number of the mouse button
--- a/src/window.c	Mon Apr 18 13:17:40 2005 +0000
+++ b/src/window.c	Mon Apr 18 13:40:23 2005 +0000
@@ -1,7 +1,7 @@
 /* Window creation, deletion and examination for GNU Emacs.
    Does not include redisplay.
-   Copyright (C) 1985,86,87, 1993,94,95,96,97,98, 2000,01,02,03,04
-   Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
+     2001, 2002, 2003, 2004, 2005  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -5596,7 +5596,20 @@
       if (XBUFFER (new_current_buffer) == current_buffer)
 	old_point = PT;
       else
-	old_point = BUF_PT (XBUFFER (new_current_buffer));
+	/* BUF_PT (XBUFFER (new_current_buffer)) gives us the position of
+	   point in new_current_buffer as of the last time this buffer was
+	   used.  This can be non-deterministic since it can be changed by
+	   things like jit-lock by mere temporary selection of some random
+	   window that happens to show this buffer.
+	   So if possible we want this arbitrary choice of "which point" to
+	   be the one from the to-be-selected-window so as to prevent this
+	   window's cursor from being copied from another window.  */
+	if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer)
+	    /* If current_window = selected_window, its point is in BUF_PT.  */
+	    && !EQ (selected_window, data->current_window))
+	  old_point = XMARKER (XWINDOW (data->current_window)->pointm)->charpos;
+	else
+	  old_point = BUF_PT (XBUFFER (new_current_buffer));
     }
 
   frame = XWINDOW (SAVED_WINDOW_N (saved_windows, 0)->window)->frame;
--- a/src/xdisp.c	Mon Apr 18 13:17:40 2005 +0000
+++ b/src/xdisp.c	Mon Apr 18 13:40:23 2005 +0000
@@ -567,12 +567,21 @@
 
 static Lisp_Object Vmessages_buffer_name;
 
-/* Current, index 0, and last displayed echo area message.  Either
-   buffers from echo_buffers, or nil to indicate no message.  */
+/* Index 0 is the buffer that holds the current (desired) echo area message,
+   or nil if none is desired right now.
+
+   Index 1 is the buffer that holds the previously displayed echo area message,
+   or nil to indicate no message.  This is normally what's on the screen now.
+
+   These two can point to the same buffer.  That happens when the last
+   message output by the user (or made by echoing) has been displayed.  */
 
 Lisp_Object echo_area_buffer[2];
 
-/* The buffers referenced from echo_area_buffer.  */
+/* Permanent pointers to the two buffers that are used for echo area
+   purposes.  Once the two buffers are made, and their pointers are
+   placed here, these two slots remain unchanged unless those buffers
+   need to be created afresh.  */
 
 static Lisp_Object echo_buffer[2];
 
@@ -7213,10 +7222,6 @@
    WHICH > 0 means use echo_area_buffer[1].  If that is nil, choose a
    suitable buffer from echo_buffer[] and clear it.
 
-   If WHICH < 0, set echo_area_buffer[1] to echo_area_buffer[0], so
-   that the current message becomes the last displayed one, make
-   choose a suitable buffer for echo_area_buffer[0], and clear it.
-
    Value is what FN returns.  */
 
 static int
@@ -7241,17 +7246,6 @@
     this_one = 0, the_other = 1;
   else if (which > 0)
     this_one = 1, the_other = 0;
-  else
-    {
-      this_one = 0, the_other = 1;
-      clear_buffer_p = 1;
-
-      /* We need a fresh one in case the current echo buffer equals
-	 the one containing the last displayed echo area message.  */
-      if (!NILP (echo_area_buffer[this_one])
-	  && EQ (echo_area_buffer[this_one], echo_area_buffer[the_other]))
-	echo_area_buffer[this_one] = Qnil;
-    }
 
   /* Choose a suitable buffer from echo_buffer[] is we don't
      have one.  */
@@ -7871,7 +7865,7 @@
     = ((s && multibyte_p)
        || (STRINGP (string) && STRING_MULTIBYTE (string)));
 
-  with_echo_area_buffer (0, -1, set_message_1,
+  with_echo_area_buffer (0, 0, set_message_1,
 			 (EMACS_INT) s, string, nbytes, multibyte_p);
   message_buf_print = 0;
   help_echo_showing_p = 0;
@@ -7903,6 +7897,7 @@
 
   /* Insert new message at BEG.  */
   TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
+  Ferase_buffer ();
 
   if (STRINGP (string))
     {
@@ -8118,10 +8113,8 @@
   else if (!EQ (mini_window, selected_window))
     windows_or_buffers_changed++;
 
-  /* Last displayed message is now the current message.  */
+  /* The current message is now also the last one displayed.  */
   echo_area_buffer[1] = echo_area_buffer[0];
-  /* Inform read_char that we're not echoing.  */
-  echo_message_buffer = Qnil;
 
   /* Prevent redisplay optimization in redisplay_internal by resetting
      this_line_start_pos.  This is done because the mini-buffer now