changeset 90147:e1fbb019c538

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-39 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 258-271) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 66) - Update from CVS
author Miles Bader <miles@gnu.org>
date Thu, 21 Apr 2005 05:59:53 +0000
parents a4445dd2a017 (current diff) 0d3be807b1ab (diff)
children c1d383777d46
files ChangeLog admin/ChangeLog admin/FOR-RELEASE admin/admin.el admin/make-tarball.txt admin/nt/makedist.bat configure configure.in etc/NEWS etc/TODO etc/TUTORIAL.ru etc/TUTORIAL.th lisp/ChangeLog lisp/bindings.el lisp/comint.el lisp/cus-theme.el lisp/desktop.el lisp/emulation/cua-base.el lisp/files.el lisp/filesets.el lisp/gnus/ChangeLog lisp/gnus/qp.el lisp/international/mule-cmds.el lisp/international/mule-conf.el lisp/isearch.el lisp/jka-compr.el lisp/loadhist.el lisp/loadup.el lisp/mail/rmail.el lisp/mail/sendmail.el lisp/menu-bar.el lisp/paren.el lisp/progmodes/gud.el lisp/progmodes/inf-lisp.el lisp/repeat.el lisp/simple.el lisp/startup.el lisp/subr.el lisp/term/mac-win.el lisp/textmodes/org.el lisp/tooltip.el lisp/vc.el lisp/xt-mouse.el lispref/ChangeLog lispref/buffers.texi lispref/customize.texi lispref/modes.texi lispref/positions.texi lispref/streams.texi lispref/strings.texi lispref/symbols.texi lispref/syntax.texi mac/ChangeLog mac/makefile.MPW make-dist man/ChangeLog man/building.texi man/custom.texi man/frames.texi man/misc.texi src/ChangeLog src/Makefile.in src/config.in src/dired.c src/dispextern.h src/dispnew.c src/editfns.c src/fileio.c src/filelock.c src/fns.c src/fringe.c src/image.c src/lisp.h src/lread.c src/mac.c src/macfns.c src/macgui.h src/macterm.c src/macterm.h src/sysdep.c src/term.c src/window.c src/window.h src/xdisp.c src/xfaces.c src/xmenu.c src/xrdb.c
diffstat 91 files changed, 2611 insertions(+), 1709 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Apr 21 05:57:27 2005 +0000
+++ b/ChangeLog	Thu Apr 21 05:59:53 2005 +0000
@@ -1,3 +1,14 @@
+2005-04-20  Thien-Thi Nguyen  <ttn@gnu.org>
+
+	* configure.in: Check for <pwd.h>.
+	* configure: Regenerate.
+
+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
--- a/admin/ChangeLog	Thu Apr 21 05:57:27 2005 +0000
+++ b/admin/ChangeLog	Thu Apr 21 05:59:53 2005 +0000
@@ -1,3 +1,13 @@
+2005-04-19  Lute Kamstra  <lute@gnu.org>
+
+	* make-tarball.txt: Don't commit lisp/loaddefs.el.
+
+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	Thu Apr 21 05:57:27 2005 +0000
+++ b/admin/FOR-RELEASE	Thu Apr 21 05:59:53 2005 +0000
@@ -82,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.
@@ -274,11 +238,11 @@
 etc/TUTORIAL.pl
 etc/TUTORIAL.pt_BR       Marcelo Toledo
 etc/TUTORIAL.ro
-etc/TUTORIAL.ru
+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	Thu Apr 21 05:57:27 2005 +0000
+++ b/admin/admin.el	Thu Apr 21 05:59:53 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/make-tarball.txt	Thu Apr 21 05:57:27 2005 +0000
+++ b/admin/make-tarball.txt	Thu Apr 21 05:59:53 2005 +0000
@@ -21,10 +21,11 @@
 
 5.   rm configure; make bootstrap
 
-6.  Commit configure, README, AUTHORS, lisp/loaddefs.el,
-    lisp/cus-load.el, lisp/finder-inf.el, lisp/version.el,
-    man/emacs.texi.  For a release, also commit the ChangeLog files in
-    all directories.
+6.  Commit configure, README, AUTHORS, lisp/cus-load.el,
+    lisp/finder-inf.el, lisp/version.el, man/emacs.texi.
+    Copy lisp/loaddefs.el to lisp/ldefs-boot.el and commit
+    lisp/ldefs-boot.el.  For a release, also commit the ChangeLog
+    files in all directories.
 
 7.   make-dist --snapshot.  Check the contents of the new tar with
      admin/diff-tar-files against an older tar file.  Some old pretest
@@ -34,12 +35,12 @@
 8.   xdelta delta emacs-OLD.tar.gz emacs-NEW.tar.gz emacs-OLD-NEW.xdelta
 
 9.   tar -zxf emacs-NEW.tar.gz; cd emacs-NEW
-     configure && make && make -n install
+     ./configure && make && make -n install
     Use `script' or M-x compile to save the compilation log in
     compile-NEW.log and compare it against an old one.  The easiest way
     to do that is to visit the old log in Emacs, change the version
     number of the old Emacs to __, do the same with the new log and do
-    M-x ediff. Especially check that Info files aren't built.
+    M-x ediff.  Especially check that Info files aren't built.
 
 10.  cd EMACS_ROOT_DIR; cvs tag TAG
     TAG is EMACS_PRETEST_XX_YY_ZZZ for a pretest, EMACS_XX_YY for a
--- a/admin/nt/makedist.bat	Thu Apr 21 05:57:27 2005 +0000
+++ b/admin/nt/makedist.bat	Thu Apr 21 05:59:53 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/configure	Thu Apr 21 05:57:27 2005 +0000
+++ b/configure	Thu Apr 21 05:59:53 2005 +0000
@@ -5297,11 +5297,12 @@
 
 
 
+
 for ac_header in sys/select.h sys/timeb.h sys/time.h unistd.h utime.h \
   linux/version.h sys/systeminfo.h termios.h limits.h string.h stdlib.h \
   termcap.h stdio_ext.h fcntl.h strings.h coff.h pty.h sys/mman.h \
   sys/param.h sys/vlimit.h sys/resource.h locale.h sys/_mbstate_t.h \
-  sys/utsname.h
+  sys/utsname.h pwd.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
--- a/configure.in	Thu Apr 21 05:57:27 2005 +0000
+++ b/configure.in	Thu Apr 21 05:59:53 2005 +0000
@@ -1455,7 +1455,7 @@
   linux/version.h sys/systeminfo.h termios.h limits.h string.h stdlib.h \
   termcap.h stdio_ext.h fcntl.h strings.h coff.h pty.h sys/mman.h \
   sys/param.h sys/vlimit.h sys/resource.h locale.h sys/_mbstate_t.h \
-  sys/utsname.h)
+  sys/utsname.h pwd.h)
 
 AC_MSG_CHECKING(if personality LINUX32 can be set)
 AC_TRY_COMPILE([#include <sys/personality.h>], [personality (PER_LINUX32)],
@@ -1555,7 +1555,7 @@
 		[AC_DEFINE(HAVE_TM_GMTOFF, 1,
 			   [Define to 1 if `tm_gmtoff' is member of `struct tm'.])],,
 		[#include <time.h>])
-AC_CHECK_MEMBERS([struct ifreq.ifr_flags, struct ifreq.ifr_hwaddr, 
+AC_CHECK_MEMBERS([struct ifreq.ifr_flags, struct ifreq.ifr_hwaddr,
 		  struct ifreq.ifr_netmask, struct ifreq.ifr_broadaddr,
 		  struct ifreq.ifr_addr], , ,
 		 [AC_INCLUDES_DEFAULT
@@ -1765,7 +1765,7 @@
   HAVE_XFREE386=no
 fi
 AC_MSG_RESULT($HAVE_XFREE386)
-  
+
 dnl Check for need for bigtoc support on IBM AIX
 
 case ${host_os} in
@@ -2178,7 +2178,7 @@
   AC_DEFINE(USE_XIM, 1,
 	    [Define to 1 if we should use XIM, if it is available.])
 fi
- 
+
 
 if test "${HAVE_XIM}" != "no"; then
   late_CFLAGS=$CFLAGS
@@ -2662,7 +2662,7 @@
 dnl
 dnl AC_SYS_POSIX_TERMIOS
 dnl if test $ac_cv_sys_posix_termios = yes; then
-dnl    AC_DEFINE(HAVE_TERMIOS, 1, [Define to 1 if you have POSIX-style functions 
+dnl    AC_DEFINE(HAVE_TERMIOS, 1, [Define to 1 if you have POSIX-style functions
 dnl                                and macros for terminal control.])
 dnl    AC_DEFINE(HAVE_TCATTR, 1, [Define to 1 if you have tcgetattr and tcsetattr.])
 dnl fi
--- a/etc/NEWS	Thu Apr 21 05:57:27 2005 +0000
+++ b/etc/NEWS	Thu Apr 21 05:59:53 2005 +0000
@@ -182,19 +182,6 @@
 
 * Changes in Emacs 22.1
 
-** Xterm Mouse mode is now enabled by default in terminal emulators
-compatible with xterm.  This means that simple use of the mouse is
-now, by default, controlled by Emacs--basically, only non-modified
-single clicks are supported.  The normal xterm mouse functionality
-for such clicks is still available by holding down the SHIFT key
-when you press the mouse button.
-
-This is not without problems.  For instance, clicking with the mouse
-on the wrong place may produce unexpected results without warning.
-Put `(xterm-mouse-mode 0)' in your .emacs, or disable the option
-`xterm-mouse-mode' through Custom, if you prefer all mouse clicks to
-be handled by the terminal emulator.
-
 ** Improved Thai support.  A new minor mode `thai-word-mode' (which is
 automatically activated if you select Thai as a language
 environment) changes key bindings of most word-oriented commands to
@@ -211,7 +198,7 @@
 ** iso-acc.el is now obsolete.  Use one of the latin input methods instead.
 
 ---
-** Languange environment and various default coding systems are setup
+** Language environment and various default coding systems are setup
 more correctly according to the current locale name.  If the locale
 name doesn't specify a charset, the default is what glibc defines.
 This change may result in using the different coding systems as
@@ -230,7 +217,11 @@
 M-o M-o requests refontification.
 
 +++
-** M-g is now a prefix key.  M-g g and M-g M-g run goto-line.
+** M-g is now a prefix key.
+
+M-g g and M-g M-g run goto-line.
+M-g n and M-g M-n run next-error (like C-x `).
+M-g p and M-g M-p run previous-error.
 
 +++
 ** font-lock-lines-before specifies a number of lines before the
@@ -397,8 +388,9 @@
 in the current input method to input a character at point.
 
 +++
-** Convenient commands to switch buffers in a cyclic order are C-x <left>
-(prev-buffer) and C-x <right> (next-buffer).
+** You can now switch buffers in a cyclic order with C-x C-left and
+(prev-buffer) and C-x C-right (next-buffer).  C-x left and C-x right
+can be used as well.
 
 ---
 ** Commands winner-redo and winner-undo, from winner.el, are now bound to
@@ -2837,12 +2829,10 @@
 
 * Lisp Changes in Emacs 22.1
 
----
-** easy-mmode-define-global-mode has been renamed to
-define-global-minor-mode.  The old name remains as an alias.
-
-+++
-** The new function `filter-buffer-substring' extracts a buffer
+** New functions, macros, and commands
+
++++
+*** The new function `filter-buffer-substring' extracts a buffer
 substring, passes it through a set of filter functions, and returns
 the filtered substring.  It is used instead of `buffer-substring' or
 `delete-and-extract-region' when copying text into a user-accessible
@@ -2853,6 +2843,81 @@
 text.
 
 +++
+*** (while-no-input BODY...) runs BODY, but only so long as no input
+arrives.  If the user types or clicks anything, BODY stops as if a
+quit had occurred.  while-no-input returns the value of BODY, if BODY
+finishes.  It returns nil if BODY was aborted.
+
++++
+*** New function `looking-back' checks whether a regular expression matches
+the text before point.  Specifying the LIMIT argument bounds how far
+back the match can start; this is a way to keep it from taking too long.
+
++++
+*** New functions `make-progress-reporter', `progress-reporter-update',
+`progress-reporter-force-update', `progress-reporter-done', and
+`dotimes-with-progress-reporter' provide a simple and efficient way for
+a command to present progress messages for the user.
+
++++
+*** The new primitive `get-internal-run-time' returns the processor
+run time used by Emacs since start-up.
+
++++
+*** The new function `called-interactively-p' does what many people
+have mistakenly believed `interactive-p' did: it returns t if the
+calling function was called through `call-interactively'.  This should
+only be used when you cannot add a new "interactive" argument to the
+command.
+
++++
+*** The new function `assoc-string' replaces `assoc-ignore-case' and
+`assoc-ignore-representation', which are still available, but have
+been declared obsolete.
+
+---
+*** New function quail-find-key returns a list of keys to type in the
+current input method to input a character.
+
++++
+*** New functions posn-at-point and posn-at-x-y return
+click-event-style position information for a given visible buffer
+position or for a given window pixel coordinate.
+
++++
+*** The new primitive `set-file-times' sets a file's access and
+modification times.  Magic file name handlers can handle this
+operation.
+
++++
+*** The new function syntax-after returns the syntax code
+of the character after a specified buffer position, taking account
+of text properties as well as the character code.
+
+*** `syntax-class' extracts the class of a syntax code (as returned
+by syntax-after).
+
++++
+*** New function `line-number-at-pos' returns line number of current
+line in current buffer, or if optional buffer position is given, line
+number of corresponding line in current buffer.
+
++++
+*** New function `macroexpand-all' expands all macros in a form.
+It is similar to the Common-Lisp function of the same name.
+One difference is that it guarantees to return the original argument
+if no expansion is done, which may be tested using `eq'.
+
++++
+*** New macro with-local-quit temporarily sets inhibit-quit to nil for use
+around potentially blocking or long-running code in timers
+and post-command-hooks.
+
+---
+** easy-mmode-define-global-mode has been renamed to
+define-global-minor-mode.  The old name remains as an alias.
+
++++
 ** An element of buffer-undo-list can now have the form (apply FUNNAME
 . ARGS), where FUNNAME is a symbol other than t or nil.  That stands
 for a high-level change that should be undone by evaluating (apply
@@ -2884,28 +2949,11 @@
 function used by the new `mouse-1-click-follows-link' functionality.
 
 +++
-** (while-no-input BODY...) runs BODY, but only so long as no input
-arrives.  If the user types or clicks anything, BODY stops as if a
-quit had occurred.  while-no-input returns the value of BODY, if BODY
-finishes.  It returns nil if BODY was aborted.
-
-+++
 ** `set-auto-mode' now gives the interpreter magic line (if present)
 precedence over the file name.  Likewise an <?xml or <!DOCTYPE declaration
 will give the buffer XML or SGML mode, based on the new var
 `magic-mode-alist'.
 
-+++
-** New function `looking-back' checks whether a regular expression matches
-the text before point.  Specifying the LIMIT argument bounds how far
-back the match can start; this is a way to keep it from taking too long.
-
-+++
-** New functions `make-progress-reporter', `progress-reporter-update',
-`progress-reporter-force-update', `progress-reporter-done', and
-`dotimes-with-progress-reporter' provide a simple and efficient way for
-a command to present progress messages for the user.
-
 ---
 ** To manipulate the File menu using easy-menu, you must specify the
 proper name "file".  In previous Emacs versions, you had to specify
@@ -2934,27 +2982,6 @@
 NOMODIFY.  If it is non-nil, it means don't mark the buffer modified.
 
 +++
-** The new function syntax-after returns the syntax code
-of the character after a specified buffer position, taking account
-of text properties as well as the character code.
-
-+++
-** The new primitive `get-internal-run-time' returns the processor
-run time used by Emacs since start-up.
-
-+++
-** The new function `called-interactively-p' does what many people
-have mistakenly believed `interactive-p' did: it returns t if the
-calling function was called through `call-interactively'.  This should
-only be used when you cannot add a new "interactive" argument to the
-command.
-
-+++
-** The new function `assoc-string' replaces `assoc-ignore-case' and
-`assoc-ignore-representation', which are still available, but have
-been declared obsolete.
-
-+++
 ** An interactive specification may now use the code letter 'U' to get
 the up-event that was discarded in case the last key sequence read for a
 previous 'k' or 'K' argument was a down-event; otherwise nil is used.
@@ -3013,15 +3040,6 @@
 undo-outer-limit, garbage collection empties it.  This is to prevent
 it from using up the available memory and choking Emacs.
 
----
-** New function quail-find-key returns a list of keys to type in the
-current input method to input a character.
-
-+++
-** New functions posn-at-point and posn-at-x-y return
-click-event-style position information for a given visible buffer
-position or for a given window pixel coordinate.
-
 +++
 ** skip-chars-forward and skip-chars-backward now handle
 character classes such as [:alpha:], along with individual characters
@@ -3036,11 +3054,6 @@
 ** The function `eql' is now available without requiring the CL package.
 
 +++
-** The new primitive `set-file-times' sets a file's access and
-modification times.  Magic file name handlers can handle this
-operation.
-
-+++
 ** The display space :width and :align-to text properties are now
 supported on text terminals.
 
@@ -3164,11 +3177,6 @@
 position.  The cursor may now be placed on any character of such
 strings by giving that character a non-nil `cursor' text property.
 
-+++
-** New macro with-local-quit temporarily sets inhibit-quit to nil for use
-around potentially blocking or long-running code in timers
-and post-command-hooks.
-
 ** The first face specification element in a defface can specify
 `default' instead of frame classification.  Then its attributes act as
 defaults that apply to all the subsequent cases (and may be overridden
@@ -3226,11 +3234,6 @@
 'overlay-arrow-fringe-bitmap' will be used.
 
 +++
-** New function `line-number-at-pos' returns line number of current
-line in current buffer, or if optional buffer position is given, line
-number of corresponding line in current buffer.
-
-+++
 ** The default value of `sentence-end' is now defined using the new
 variable `sentence-end-without-space' which contains such characters
 that end a sentence without following spaces.
@@ -3248,12 +3251,6 @@
 implemented (such as "*") are no longer accepted.
 
 +++
-** New function `macroexpand-all' expands all macros in a form.
-It is similar to the Common-Lisp function of the same name.
-One difference is that it guarantees to return the original argument
-if no expansion is done, which may be tested using `eq'.
-
-+++
 ** New function `delete-dups' destructively removes `equal' duplicates
 from a list.  Of several `equal' occurrences of an element in the list,
 the first one is kept.
@@ -4278,9 +4275,15 @@
 specified) window as a string with or without text properties.
 
 +++
-** New function safe-plist-get.
-
-This function is like plist-get, but never signals an error for
+** New function `safe-get'.
+
+This function is like `get', but never signals an error for
+a malformed symbol property list.
+
++++
+** New function `safe-plist-get'.
+
+This function is like `plist-get', but never signals an error for
 a malformed property list.
 
 +++
--- a/etc/TODO	Thu Apr 21 05:57:27 2005 +0000
+++ b/etc/TODO	Thu Apr 21 05:59:53 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	Thu Apr 21 05:57:27 2005 +0000
+++ b/etc/TUTORIAL.ru	Thu Apr 21 05:59:53 2005 +0000
@@ -1,4 +1,4 @@
-ŐŢĹÂÎÉË Emacs.
+őŢĹÂÎÉË Emacs. őÓĚĎ×ÉŃ ŇÁÓĐŇĎÓÔŇÁÎĹÎÉŃ ÓÍĎÔŇÉÔĹ × ËĎÎĂĹ ĆÁĘĚÁ
 Copyright (c) 1985, 1996, 2004 Free Software Foundation, Inc.
 
 äĚŃ ŐĐŇÁ×ĚĹÎÉŃ Emacs ĎÂŮŢÎĎ ÉÓĐĎĚŘÚŐĹÔÓŃ ËĚŔŢ (ÓĎŢĹÔÁÎÉĹ ËĚÁ×ÉŰ ËĚÁ×ÉÁÔŐŇŮ
--- a/etc/TUTORIAL.th	Thu Apr 21 05:57:27 2005 +0000
+++ b/etc/TUTORIAL.th	Thu Apr 21 05:59:53 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	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/ChangeLog	Thu Apr 21 05:59:53 2005 +0000
@@ -1,3 +1,273 @@
+2005-04-21  Kenichi Handa  <handa@m17n.org>
+
+	* international/mule-cmds.el: Add autoload for widget-value in
+	eval-when-compile
+
+2005-04-21  Nick Roberts  <nickrob@snap.net.nz>
+
+	* menu-bar.el (menu-bar-options-save, menu-bar-showhide-menu): 
+	Add tooltip-mode.
+
+	* bindings.el (mode-line-mode-menu): Remove tooltip-mode.
+
+2005-04-20  Luc Teirlinck  <teirllm@auburn.edu>
+
+	* progmodes/inf-lisp.el (inferior-lisp): New defgroup.
+	(inferior-lisp-filter-regexp, inferior-lisp-program)
+	(inferior-lisp-load-command, inferior-lisp-prompt)
+	(inferior-lisp-mode-hook, lisp-source-modes)
+	(inferior-lisp-load-hook): defvar->defcustom.
+	(inferior-lisp-program, inferior-lisp-prompt)
+	(inferior-lisp-load-hook): Doc fixes.
+	(inferior-lisp-install-letter-bindings): Small change in
+	introductory comment.
+
+2005-04-20  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc.el (vc-annotate-color-map): Change some colors so that text
+	using them as foreground is readable on both white and black
+	backgrounds.
+
+2005-04-20  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* international/mule-conf.el (translation-table-for-input):
+	Remove redundant declaration.
+
+2005-04-20  Nick Roberts  <nickrob@snap.net.nz>
+
+	* progmodes/gud.el (gud-menu-map): Add tooltip-toggle-gud-tips.
+
+	* tooltip.el (tooltip-gud-tips-p): Expand documentation.
+	(tooltip-toggle-gud-tips): New function.
+
+2005-04-20  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* term/mac-win.el (mac-symbol-encoder): Fix mappings of left and
+	right angle brackets.
+
+2005-04-20  Nick Roberts  <nickrob@snap.net.nz>
+
+	* tooltip.el (tooltip-use-echo-area): Replace as alias and deprecate.
+
+2005-04-19  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* progmodes/flymake.el (flymake-get-absolute-file-name-basedir):
+	Remove.  Update callers to use expand-file-name instead.
+
+	* subr.el (syntax-class): New function.
+
+	* simple.el (blink-matching-open): Use it.
+
+	* paren.el (show-paren-function): Use it to recognize parens that are
+	also used in 2-char comment markers.
+
+2005-04-19  Lute Kamstra  <lute@gnu.org>
+
+	* loadhist.el (unload-feature): Update for new format of
+	load-history.  Simplify the code.
+
+2005-04-19  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* term/mac-win.el: Add coding: tag and set it to iso-2022-7bit.
+	(mac-add-charset-info): New function.  Initialize variable
+	mac-charset-info-alist using it.
+	(mac-centraleurroman, mac-cyrillic): Do not use UCS in table data
+	for translation.
+	(mac-symbol-encoder, mac-dingbats-encoder): New translation table.
+	(mac-font-encoder-list): Add entries for mac-symbol and mac-dingbats.
+	(ccl-encode-mac-symbol-font, ccl-encode-mac-dingbats-font):
+	New CCL programs.
+
+2005-04-19  Kim F. Storm  <storm@cua.dk>
+
+	* simple.el (next-buffer, prev-buffer, next-error)
+	(scroll-other-window, keyboard-quit, keyboard-escape-quit)
+	(clone-indirect-buffer-other-window): Move bindings to bindings.el.
+
+	* bindings.el (next-buffer, prev-buffer, next-error)
+	(scroll-other-window, keyboard-quit, keyboard-escape-quit)
+	(clone-indirect-buffer-other-window): Move bindings from simple.el.
+	(next-buffer, prev-buffer): Add C-x C-right and C-x C-left bindings.
+	(next-error, previous-error): Add M-g M-n/n and M-g M-p/p bindings.
+
+2005-04-18  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* isearch.el (isearch-edit-string): Make the search-ring available for
+	minibuffer history commands.
+	(minibuffer-local-isearch-map): Remove bindings for M-p	and M-n,
+	the default history commands now work just as well.
+	(isearch-ring-retreat-edit, isearch-ring-advance-edit): Remove.
+
+2005-04-18  Kim F. Storm  <storm@cua.dk>
+
+	* emulation/cua-base.el (cua--pre-command-handler): Add more
+	elaborate check for shift modifier on non-window systems.
+
+2005-04-18  Lars Hansen  <larsh@math.ku.dk>
+
+	* desktop.el: Make "--no-desktop" turn off `desktop-save-mode'.
+
+2005-04-18  Kim F. Storm  <storm@cua.dk>
+
+	* tooltip.el (tooltip-show): Change second arg to USE-ECHO-AREA
+	and make it optional.  Don't test tooltip-gud-echo-area here.
+	(tooltip-gud-process-output, gdb-tooltip-print):
+	Pass tooltip-gud-echo-area to tooltip-show.
+	(tooltip-help-tips): Remove second optional arg to tooltip-show.
+
+2005-04-18  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* tooltip.el (tooltip-mode): `emacs-quick-startup' and
+	`display-graphic-p' may not be bound yet.
+
+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
@@ -92,8 +362,8 @@
 
 2005-04-12  Lute Kamstra  <lute@gnu.org>
 
-	* generic-x.el (rc-generic-mode, rul-generic-mode): Fix
-	auto-mode-alist entries.
+	* 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.
@@ -101,8 +371,8 @@
 
 2005-04-11  Rajesh Vaidheeswarran  <rv@gnu.org>
 
-	* whitespace.el (whitespace-buffer-leading,
-	whitespace-buffer-trailing): Revert the incorrect test
+	* 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.
 
@@ -110,8 +380,8 @@
 
 	* whitespace.el (whitespace-version): Bump to 3.5
 
-	(whitespace-buffer-leading, whitespace-buffer-trailing): Invert
-	sense of the test to highlight the whitespace.
+	(whitespace-buffer-leading, whitespace-buffer-trailing):
+	Invert sense of the test to highlight the whitespace.
 
 2005-04-12  Nick Roberts  <nickrob@snap.net.nz>
 
@@ -144,15 +414,15 @@
 	(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-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): Moved to dnd.el (without x-).
+	(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.
 
@@ -280,8 +550,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>
 
@@ -394,8 +664,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/bindings.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/bindings.el	Thu Apr 21 05:59:53 2005 +0000
@@ -392,9 +392,6 @@
   "Return the value of symbol VAR if it is bound, else nil."
   `(and (boundp (quote ,var)) ,var))
 
-(define-key mode-line-mode-menu [tooltip-mode]
-  `(menu-item ,(purecopy "Tooltip") tooltip-mode
-	      :button (:toggle . tooltip-mode)))
 (define-key mode-line-mode-menu [overwrite-mode]
   `(menu-item ,(purecopy "Overwrite (Ovwrt)") overwrite-mode
 	      :button (:toggle . overwrite-mode)))
@@ -622,6 +619,10 @@
 ;; (define-key ctl-x-map "n" 'narrow-to-region)
 ;; (define-key ctl-x-map "w" 'widen)
 
+;; Quitting
+(define-key global-map "\e\e\e" 'keyboard-escape-quit)
+(define-key global-map "\C-g" 'keyboard-quit)
+
 (define-key global-map "\C-j" 'newline-and-indent)
 (define-key global-map "\C-m" 'newline)
 (define-key global-map "\C-o" 'open-line)
@@ -646,9 +647,18 @@
 ;; Many people are used to typing C-/ on X terminals and getting C-_.
 (define-key global-map [?\C-/] 'undo)
 (define-key global-map "\C-_" 'undo)
+;; Richard said that we should not use C-x <uppercase letter> and I have
+;; no idea whereas to bind it.  Any suggestion welcome.  -stef
+;; (define-key ctl-x-map "U" 'undo-only)
+
 (define-key esc-map "!" 'shell-command)
 (define-key esc-map "|" 'shell-command-on-region)
 
+(define-key global-map [?\C-x right] 'next-buffer)
+(define-key global-map [?\C-x C-right] 'next-buffer)
+(define-key global-map [?\C-x left] 'prev-buffer)
+(define-key global-map [?\C-x C-left] 'prev-buffer)
+
 (let ((map minibuffer-local-map))
   (define-key map "\en"   'next-history-element)
   (define-key map [next]  'next-history-element)
@@ -703,6 +713,13 @@
 (define-key esc-map "g\M-g" 'goto-line)
 (define-key esc-map "gg" 'goto-line)
 
+(define-key esc-map "gn" 'next-error)
+(define-key esc-map "g\M-n" 'next-error)
+(define-key ctl-x-map "`" 'next-error)
+
+(define-key esc-map "gp" 'previous-error)
+(define-key esc-map "g\M-p" 'previous-error)
+
 ;;(defun function-key-error ()
 ;;  (interactive)
 ;;  (error "That function key is not bound to anything"))
@@ -731,6 +748,7 @@
 (define-key global-map [C-next]		'scroll-left)
 (define-key global-map [M-next]		'scroll-other-window)
 (define-key global-map [M-prior]	'scroll-other-window-down)
+(define-key esc-map [?\C-\S-v]		'scroll-other-window-down)
 (define-key global-map [end]		'end-of-line)
 (define-key global-map [C-end]		'end-of-buffer)
 (define-key global-map [M-end]		'end-of-buffer-other-window)
@@ -1014,6 +1032,8 @@
 
 (define-key ctl-x-map "z" 'repeat)
 
+(define-key ctl-x-4-map "c" 'clone-indirect-buffer-other-window)
+
 ;; Don't look for autoload cookies in this file.
 ;; Local Variables:
 ;; no-update-autoloads: t
--- a/lisp/comint.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/comint.el	Thu Apr 21 05:59:53 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-theme.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/cus-theme.el	Thu Apr 21 05:59:53 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/desktop.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/desktop.el	Thu Apr 21 05:59:53 2005 +0000
@@ -1030,9 +1030,10 @@
   'after-init-hook
   '(lambda ()
     (let ((key "--no-desktop"))
-      (if (member key command-line-args)
-        (delete key command-line-args)
-        (when desktop-save-mode (desktop-read))))))
+      (when (member key command-line-args)
+        (setq command-line-args (delete key command-line-args))
+        (setq desktop-save-mode nil)))
+    (when desktop-save-mode (desktop-read))))
 
 (provide 'desktop)
 
--- a/lisp/emulation/cua-base.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/emulation/cua-base.el	Thu Apr 21 05:59:53 2005 +0000
@@ -405,7 +405,8 @@
   :group 'cua)
 
 (defface cua-global-mark-face
-  '((((class color)) :foreground "black" :background "yellow")
+  '((((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)
@@ -1065,10 +1066,20 @@
 	;; If rectangle is active, expand rectangle in specified direction and ignore the movement.
 	(if movement
 	    (cond
-	     ((memq 'shift (event-modifiers
-			    (aref (if window-system
-				      (this-single-command-raw-keys)
-				    (this-single-command-keys)) 0)))
+	     ((if window-system
+		  (memq 'shift (event-modifiers
+				(aref (this-single-command-raw-keys) 0)))
+		(or
+		 (memq 'shift (event-modifiers
+			       (aref (this-single-command-keys) 0)))
+		 ;; See if raw escape sequence maps to a shifted event, e.g. S-up or C-S-home.
+		 (and (boundp 'function-key-map)
+		      function-key-map
+		      (let ((ev (lookup-key function-key-map
+					   (this-single-command-raw-keys))))
+			(and (vector ev)
+			     (symbolp (setq ev (aref ev 0)))
+			     (string-match "S-" (symbol-name ev)))))))
 	      (unless mark-active
 		(push-mark-command nil t))
 	      (setq cua--last-region-shifted t)
--- a/lisp/files.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/files.el	Thu Apr 21 05:59:53 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	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/filesets.el	Thu Apr 21 05:59:53 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/gnus/ChangeLog	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/gnus/ChangeLog	Thu Apr 21 05:59:53 2005 +0000
@@ -1,3 +1,7 @@
+2005-04-18  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* qp.el (quoted-printable-encode-region): Save excursion.
+
 2005-04-13  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 	* gnus-art.el (gnus-mime-inline-part): Use mm-string-to-multibyte.
--- a/lisp/gnus/qp.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/gnus/qp.el	Thu Apr 21 05:59:53 2005 +0000
@@ -1,6 +1,7 @@
 ;;; qp.el --- Quoted-Printable functions
 
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005
+;;        Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: mail, extensions
@@ -100,15 +101,15 @@
 If `mm-use-ultra-safe-encoding' is set, fold lines unconditionally and
 encode lines starting with \"From\"."
   (interactive "r")
-  (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="
     (setq class "\010-\012\014\040-\074\076-\177"))
   (save-excursion
+    (goto-char from)
+    (if (re-search-forward (mm-string-to-multibyte "[^\x0-\x7f\x80-\xff]")
+			   to t)
+	(error "Multibyte character in QP encoding region"))
     (save-restriction
       (narrow-to-region from to)
       ;; Encode all the non-ascii and control characters.
--- a/lisp/international/mule-cmds.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/international/mule-cmds.el	Thu Apr 21 05:59:53 2005 +0000
@@ -30,7 +30,9 @@
 
 ;;; Code:
 
-(eval-when-compile (defvar dos-codepage))
+(eval-when-compile
+  (defvar dos-codepage)
+  (autoload 'widget-value "wid-edit"))
 
 ;;; MULE related key bindings and menus.
 
@@ -2358,6 +2360,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,
@@ -2389,7 +2400,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/mule-conf.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/international/mule-conf.el	Thu Apr 21 05:59:53 2005 +0000
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 1997 Electrotechnical Laboratory, JAPAN.
 ;;   Licensed to the Free Software Foundation.
-;; Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2005  Free Software Foundation, Inc.
 ;; Copyright (C) 2003
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
 ;;   Registration Number H13PRO009
@@ -1158,12 +1158,6 @@
 (setq standard-translation-table-for-decode nil)
 
 (setq standard-translation-table-for-encode nil)
-
-;; Fixme: should this be retained?  I guess it could be useful for
-;; non-unified charsets.
-(defvar translation-table-for-input nil
-  "If non-nil, a char table used to translate characters from input methods.
-\(Currently only used by Quail.)")
 
 ;;; Make fundamental coding systems.
 
@@ -1495,5 +1489,5 @@
 ;; no-byte-compile: t
 ;; End:
 
-;;; arch-tag: 7d5fed55-b6df-42f6-8d3d-0011190551f5
+;; arch-tag: 7d5fed55-b6df-42f6-8d3d-0011190551f5
 ;;; mule-conf.el ends here
--- a/lisp/isearch.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/isearch.el	Thu Apr 21 05:59:53 2005 +0000
@@ -401,12 +401,6 @@
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map minibuffer-local-map)
     (define-key map "\r"    'isearch-nonincremental-exit-minibuffer)
-    (define-key map "\M-n"  'isearch-ring-advance-edit)
-    (define-key map [next]  'isearch-ring-advance-edit)
-    (define-key map [down]  'isearch-ring-advance-edit)
-    (define-key map "\M-p"  'isearch-ring-retreat-edit)
-    (define-key map [prior] 'isearch-ring-retreat-edit)
-    (define-key map [up]    'isearch-ring-retreat-edit)
     (define-key map "\M-\t" 'isearch-complete-edit)
     (define-key map "\C-s"  'isearch-forward-exit-minibuffer)
     (define-key map "\C-r"  'isearch-reverse-exit-minibuffer)
@@ -933,8 +927,6 @@
 \\[isearch-nonincremental-exit-minibuffer] to do one nonincremental search.
 \\[isearch-forward-exit-minibuffer] to resume isearching forward.
 \\[isearch-reverse-exit-minibuffer] to resume isearching backward.
-\\[isearch-ring-advance-edit] to replace the search string with the next item in the search ring.
-\\[isearch-ring-retreat-edit] to replace the search string with the previous item in the search ring.
 \\[isearch-complete-edit] to complete the search string using the search ring.
 \\<isearch-mode-map>
 If first char entered is \\[isearch-yank-word-or-char], then do word search instead."
@@ -1020,12 +1012,12 @@
 		  (isearch-unread e))
 		(setq cursor-in-echo-area nil)
 		(setq isearch-new-string
-		      (let (junk-ring)
-			(read-from-minibuffer
-			 (isearch-message-prefix nil nil isearch-nonincremental)
-			 isearch-string
-			 minibuffer-local-isearch-map nil
-			 'junk-ring nil t))
+                      (read-from-minibuffer
+                       (isearch-message-prefix nil nil isearch-nonincremental)
+                       isearch-string
+                       minibuffer-local-isearch-map nil
+                       (if isearch-regexp 'regexp-search-ring 'search-ring)
+                       nil t)
 		      isearch-new-message
 		      (mapconcat 'isearch-text-char-description
 				 isearch-new-string "")))
@@ -1856,49 +1848,6 @@
   (interactive)
   (isearch-ring-adjust nil))
 
-(defun isearch-ring-advance-edit (n)
-  "Insert the next element of the search history into the minibuffer.
-With prefix arg N, insert the Nth element."
-  (interactive "p")
-  (let* ((yank-pointer-name (if isearch-regexp
-				'regexp-search-ring-yank-pointer
-			      'search-ring-yank-pointer))
-	 (yank-pointer (eval yank-pointer-name))
-	 (ring (if isearch-regexp regexp-search-ring search-ring))
-	 (length (length ring)))
-    (if (zerop length)
-	()
-      (set yank-pointer-name
-	   (setq yank-pointer
-		 (mod (- (or yank-pointer 0) n)
-		      length)))
-
-      (delete-field)
-      (insert (nth yank-pointer ring))
-      (goto-char (point-max)))))
-
-(defun isearch-ring-retreat-edit (n)
-  "Insert the previous element of the search history into the minibuffer.
-With prefix arg N, insert the Nth element."
-  (interactive "p")
-  (isearch-ring-advance-edit (- n)))
-
-;;(defun isearch-ring-adjust-edit (advance)
-;;  "Use the next or previous search string in the ring while in minibuffer."
-;;  (isearch-ring-adjust1 advance)
-;;  (erase-buffer)
-;;  (insert isearch-string))
-
-;;(defun isearch-ring-advance-edit ()
-;;  (interactive)
-;;  (isearch-ring-adjust-edit 'advance))
-
-;;(defun isearch-ring-retreat-edit ()
-;;  "Retreat to the previous search string in the ring while in the minibuffer."
-;;  (interactive)
-;;  (isearch-ring-adjust-edit nil))
-
-
 (defun isearch-complete1 ()
   ;; Helper for isearch-complete and isearch-complete-edit
   ;; Return t if completion OK, nil if no completion exists.
--- a/lisp/jka-compr.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/jka-compr.el	Thu Apr 21 05:59:53 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	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/loadhist.el	Thu Apr 21 05:59:53 2005 +0000
@@ -1,6 +1,6 @@
 ;;; loadhist.el --- lisp functions for working with feature groups
 
-;; Copyright (C) 1995, 1998, 2000 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1998, 2000, 2005 Free Software Foundation, Inc.
 
 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
 ;; Maintainer: FSF
@@ -155,16 +155,16 @@
 in the event that the package has done something normally-ill-advised,
 such as redefining an Emacs function."
   (interactive (list (read-feature "Feature: ") current-prefix-arg))
-  (if (not (featurep feature))
-      (error "%s is not a currently loaded feature" (symbol-name feature)))
-  (if (not force)
-      (let* ((file (feature-file feature))
-	     (dependents (delete file (copy-sequence (file-dependents file)))))
-	(if dependents
-	    (error "Loaded libraries %s depend on %s"
-		   (prin1-to-string dependents) file))))
+  (unless (featurep feature)
+    (error "%s is not a currently loaded feature" (symbol-name feature)))
+  (unless force
+    (let* ((file (feature-file feature))
+	   (dependents (delete file (copy-sequence (file-dependents file)))))
+      (when dependents
+	(error "Loaded libraries %s depend on %s"
+	       (prin1-to-string dependents) file))))
   (let* ((unload-hook-features-list (feature-symbols feature))
-         (file (car unload-hook-features-list))
+         (file (pop unload-hook-features-list))
          (unload-hook (intern-soft (concat (symbol-name feature)
                                            "-unload-hook"))))
     ;; Try to avoid losing badly when hooks installed in critical
@@ -183,40 +183,39 @@
       ;; normally works.
       (mapatoms
        (lambda (x)
-         (if (or (and (boundp x)        ; Random hooks.
-                      (consp (symbol-value x))
-                      (string-match "-hooks?\\'" (symbol-name x)))
-                 (and (boundp x)       ; Known abnormal hooks etc.
-                      (memq x unload-feature-special-hooks)))
-	     (dolist (y (cdr unload-hook-features-list))
-	       (remove-hook x y))))))
-    (if (fboundp 'elp-restore-function)	; remove ELP stuff first
-	(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))
+         (when (and (boundp x)
+		    (or (and (consp (symbol-value x)) ; Random hooks.
+			     (string-match "-hooks?\\'" (symbol-name x)))
+			(memq x unload-feature-special-hooks)))	; Known abnormal hooks etc.
+	   (dolist (y unload-hook-features-list)
+	     (when (eq (car-safe y) 'defun)
+	       (remove-hook x (cdr y))))))))
+    (when (fboundp 'elp-restore-function) ; remove ELP stuff first
+      (dolist (elt unload-hook-features-list)
+	(when (symbolp elt)
+	  (elp-restore-function elt))))
+    (dolist (x unload-hook-features-list)
+      (if (consp x)
+	  (progn
+	    ;; Remove any feature names that this file provided.
+	    (when (eq (car x) 'provide)
+	      (setq features (delq (cdr x) features)))
+	    (when (eq (car x) 'defun)
+	      (let ((fun (cdr x)))
+		(when (fboundp fun)
+		  (when (fboundp 'ad-unadvise)
+		    (ad-unadvise fun))
+		  (fmakunbound fun)
+		  (let ((aload (get fun 'autoload)))
+		    (when aload 
+		      (fset fun (cons 'autoload aload))))))))
+	;; Kill local values as much as possible.
+	(dolist (buf (buffer-list))
+	  (with-current-buffer buf
+	    (kill-local-variable x)))
+	;; Get rid of the default binding if we can.
+	(unless (local-variable-if-set-p x)
+	  (makunbound x))))
     ;; 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	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/loadup.el	Thu Apr 21 05:59:53 2005 +0000
@@ -180,6 +180,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	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/mail/rmail.el	Thu Apr 21 05:59:53 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	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/mail/sendmail.el	Thu Apr 21 05:59:53 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/menu-bar.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/menu-bar.el	Thu Apr 21 05:59:53 2005 +0000
@@ -646,7 +646,8 @@
 	   (setq need-save t)))
     ;; These are set with `customize-set-variable'.
     (dolist (elt '(scroll-bar-mode
-		   debug-on-quit debug-on-error menu-bar-mode tool-bar-mode
+		   debug-on-quit debug-on-error
+		   tooltip-mode menu-bar-mode tool-bar-mode
 		   save-place uniquify-buffer-name-style fringe-mode
 		   fringe-indicators case-fold-search
 		   display-time-mode auto-compression-mode
@@ -910,6 +911,12 @@
 	:visible `(display-graphic-p)
 	:help "Select scroll-bar mode"))
 
+(define-key menu-bar-showhide-menu [showhide-tooltip-mode]
+  (list 'menu-item "Tooltips" 'tooltip-mode
+	:help "Toggle tooltips on/off"
+	:visible  `(and (display-graphic-p) (fboundp 'x-show-tip))
+	:button `(:toggle . tooltip-mode)))
+
 (define-key menu-bar-showhide-menu [menu-bar-mode]
   '(menu-item "Menu-bar" menu-bar-mode
 	      :help "Toggle menu-bar on/off"
--- a/lisp/paren.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/paren.el	Thu Apr 21 05:59:53 2005 +0000
@@ -1,6 +1,6 @@
 ;;; paren.el --- highlight matching paren
 
-;; Copyright (C) 1993, 1996, 2001, 2004  Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1996, 2001, 2004, 2005  Free Software Foundation, Inc.
 
 ;; Author: rms@gnu.org
 ;; Maintainer: FSF
@@ -139,8 +139,8 @@
 (defun show-paren-function ()
   (if show-paren-mode
       (let ((oldpos (point))
-	    (dir (cond ((eq (car (syntax-after (1- (point)))) 5) -1)
-		       ((eq (car (syntax-after (point))) 4) 1)))
+	    (dir (cond ((eq (syntax-class (syntax-after (1- (point)))) 5) -1)
+                       ((eq (syntax-class (syntax-after (point)))      4) 1)))
 	    pos mismatch face)
 	;;
 	;; Find the other end of the sexp.
@@ -169,7 +169,7 @@
 	      ;; kind of paren to match the one we started at.
 	      (when (integerp pos)
 		(let ((beg (min pos oldpos)) (end (max pos oldpos)))
-		  (unless (eq (car (syntax-after beg)) 8) ;Not syntax `$'.
+		  (unless (eq (syntax-class (syntax-after beg)) 8)
 		    (setq mismatch
 			  (not (or (eq (char-before end)
 				       ;; This can give nil.
--- a/lisp/progmodes/flymake.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/progmodes/flymake.el	Thu Apr 21 05:59:53 2005 +0000
@@ -1765,7 +1765,7 @@
 	       (this-real-name  (nth 1 (nth (1- file-count) files))))
 	  ;;+(flymake-log 0 "this-dir=%s this-file=%s this-real=%s msg-file=%s" this-dir this-file this-real-name file-name-from-err-msg)
 	  (when (and this-dir this-file (flymake-same-files
-					 (flymake-get-absolute-file-name-basedir file-name-from-err-msg this-dir)
+					 (expand-file-name file-name-from-err-msg this-dir)
 					 this-file))
 	    (setq real-name this-real-name)))
 	(setq file-count (1- file-count)))
@@ -1778,18 +1778,13 @@
 	(setq real-name file-name-from-err-msg)
       (let* ((base-dirs-count  (length base-dirs)))
 	(while (and (not real-name) (> base-dirs-count 0))
-	  (let* ((full-name (flymake-get-absolute-file-name-basedir file-name-from-err-msg
-								    (nth (1- base-dirs-count) base-dirs))))
+	  (let* ((full-name (expand-file-name file-name-from-err-msg
+					      (nth (1- base-dirs-count) base-dirs))))
 	    (if (file-exists-p full-name)
 		(setq real-name full-name))
 	    (setq base-dirs-count (1- base-dirs-count))))))
     real-name))
 
-(defun flymake-get-absolute-file-name-basedir (file-name dir-name)
-  (if (file-name-absolute-p file-name)
-      file-name
-    (concat dir-name "/" file-name)))
-
 (defun flymake-init-find-buildfile-dir (buffer source-file-name buildfile-name)
   "Find buildfile, store its dir in buffer data and return its dir, if found."
   (let* ((buildfile-dir  (flymake-find-buildfile buildfile-name
--- a/lisp/progmodes/gud.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/progmodes/gud.el	Thu Apr 21 05:59:53 2005 +0000
@@ -89,19 +89,35 @@
 
 (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)
+    ([tooltips] menu-item "Toggle GUD tooltips" tooltip-toggle-gud-tips
+                  :enable  (and (not emacs-basic-display)
+				(display-graphic-p)
+				(fboundp 'x-show-tip))
+	          :button (:toggle . tooltip-gud-tips-p))
     ([refresh]	"Refresh" . gud-refresh)
     ([run]	menu-item "Run" gud-run
                   :enable (and (not gud-running)
--- a/lisp/progmodes/inf-lisp.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/progmodes/inf-lisp.el	Thu Apr 21 05:59:53 2005 +0000
@@ -66,12 +66,20 @@
 (require 'lisp-mode)
 
 
+(defgroup inferior-lisp nil
+  "Run an outside Lisp in an Emacs buffer."
+  :group 'lisp
+  :version "22.1")
+
 ;;;###autoload
-(defvar inferior-lisp-filter-regexp "\\`\\s *\\(:\\(\\w\\|\\s_\\)\\)?\\s *\\'"
+(defcustom inferior-lisp-filter-regexp
+  "\\`\\s *\\(:\\(\\w\\|\\s_\\)\\)?\\s *\\'"
   "*What not to save on inferior Lisp's input history.
 Input matching this regexp is not saved on the input history in Inferior Lisp
 mode.  Default is whitespace followed by 0 or 1 single-letter colon-keyword
-\(as in :a, :c, etc.)")
+\(as in :a, :c, etc.)"
+  :type 'regexp
+  :group 'inferior-lisp)
 
 (defvar inferior-lisp-mode-map nil)
 (unless inferior-lisp-mode-map
@@ -111,7 +119,7 @@
 ;;;where they are more accessible. C-c <letter> bindings are reserved for the
 ;;;user, so these bindings are non-standard. If you want them, you should
 ;;;have this function called by the inferior-lisp-load-hook:
-;;;    (setq inferior-lisp-load-hook '(inferior-lisp-install-letter-bindings))
+;;;  (add-hook 'inferior-lisp-load-hook 'inferior-lisp-install-letter-bindings)
 ;;;You can modify this function to install just the bindings you want."
 (defun inferior-lisp-install-letter-bindings ()
   (define-key lisp-mode-map "\C-ce" 'lisp-eval-defun-and-go)
@@ -133,23 +141,26 @@
   (define-key inferior-lisp-mode-map "\C-cv"
     'lisp-show-variable-documentation))
 
+;;;###autoload
+(defcustom inferior-lisp-program "lisp"
+  "*Program name for invoking an inferior Lisp in Inferior Lisp mode."
+  :type 'string
+  :group 'inferior-lisp)
 
 ;;;###autoload
-(defvar inferior-lisp-program "lisp"
-  "*Program name for invoking an inferior Lisp with for Inferior Lisp mode.")
-
-;;;###autoload
-(defvar inferior-lisp-load-command "(load \"%s\")\n"
+(defcustom inferior-lisp-load-command "(load \"%s\")\n"
   "*Format-string for building a Lisp expression to load a file.
 This format string should use `%s' to substitute a file name
 and should result in a Lisp expression that will command the inferior Lisp
 to load that file.  The default works acceptably on most Lisps.
 The string \"(progn (load \\\"%s\\\" :verbose nil :print t) (values))\\n\"
 produces cosmetically superior output for this application,
-but it works only in Common Lisp.")
+but it works only in Common Lisp."
+  :type 'string
+  :group 'inferior-lisp)
 
 ;;;###autoload
-(defvar inferior-lisp-prompt "^[^> \n]*>+:? *"
+(defcustom inferior-lisp-prompt "^[^> \n]*>+:? *"
   "Regexp to recognise prompts in the Inferior Lisp mode.
 Defaults to \"^[^> \\n]*>+:? *\", which works pretty good for Lucid, kcl,
 and franz.  This variable is used to initialize `comint-prompt-regexp' in the
@@ -163,7 +174,9 @@
 franz: \"^\\\\(->\\\\|<[0-9]*>:\\\\) *\"
 kcl: \"^>+ *\"
 
-This is a fine thing to set in your .emacs file.")
+This is a fine thing to set in your .emacs file or through Custom."
+  :type 'regexp
+  :group 'inferior-lisp)
 
 (defvar inferior-lisp-buffer nil "*The current inferior-lisp process buffer.
 
@@ -201,8 +214,10 @@
 buffer with \\[set-variable].")
 
 ;;;###autoload
-(defvar inferior-lisp-mode-hook '()
-  "*Hook for customising Inferior Lisp mode.")
+(defcustom inferior-lisp-mode-hook '()
+  "*Hook for customising Inferior Lisp mode."
+  :type 'hook
+  :group 'inferior-lisp)
 
 (put 'inferior-lisp-mode 'mode-class 'special)
 
@@ -427,11 +442,13 @@
 This holds a cons cell of the form `(DIRECTORY . FILE)'
 describing the last `lisp-load-file' or `lisp-compile-file' command.")
 
-(defvar lisp-source-modes '(lisp-mode)
+(defcustom lisp-source-modes '(lisp-mode)
   "*Used to determine if a buffer contains Lisp source code.
 If it's loaded into a buffer that is in one of these major modes, it's
 considered a Lisp source file by `lisp-load-file' and `lisp-compile-file'.
-Used by these commands to determine defaults.")
+Used by these commands to determine defaults."
+  :type '(repeat symbol)
+  :group 'inferior-lisp)
 
 (defun lisp-load-file (file-name)
   "Load a Lisp file into the inferior Lisp process."
@@ -573,9 +590,10 @@
 
 ;;; Do the user's customisation...
 ;;;===============================
-(defvar inferior-lisp-load-hook nil
-  "This hook is run when the library `inf-lisp' is loaded.
-This is a good place to put keybindings.")
+(defcustom inferior-lisp-load-hook nil
+  "This hook is run when the library `inf-lisp' is loaded."
+  :type 'hook
+  :group 'inferior-lisp)
 
 (run-hooks 'inferior-lisp-load-hook)
 
--- a/lisp/repeat.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/repeat.el	Thu Apr 21 05:59:53 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	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/simple.el	Thu Apr 21 05:59:53 2005 +0000
@@ -51,8 +51,6 @@
   "Highlight (un)matching of parens and expressions."
   :group 'matching)
 
-(define-key global-map [?\C-x right] 'next-buffer)
-(define-key global-map [?\C-x left] 'prev-buffer)
 (defun next-buffer ()
   "Switch to the next buffer in cyclic order."
   (interactive)
@@ -258,8 +256,6 @@
 (defalias 'goto-next-locus 'next-error)
 (defalias 'next-match 'next-error)
 
-(define-key ctl-x-map "`" 'next-error)
-
 (defun previous-error (&optional n)
   "Visit previous next-error message and corresponding source code.
 
@@ -1398,9 +1394,6 @@
 Contrary to `undo', this will not redo a previous undo."
   (interactive "*p")
   (let ((undo-no-redo t)) (undo arg)))
-;; Richard said that we should not use C-x <uppercase letter> and I have
-;; no idea whereas to bind it.  Any suggestion welcome.  -stef
-;; (define-key ctl-x-map "U" 'undo-only)
 
 (defvar undo-in-progress nil
   "Non-nil while performing an undo.
@@ -2548,7 +2541,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."
@@ -3631,7 +3624,6 @@
    (if (eq lines '-) nil
      (if (null lines) '-
        (- (prefix-numeric-value lines))))))
-(define-key esc-map [?\C-\S-v] 'scroll-other-window-down)
 
 (defun beginning-of-buffer-other-window (arg)
   "Move point to the beginning of the buffer in the other window.
@@ -4201,11 +4193,12 @@
 		   (setq blinkpos (scan-sexps oldpos -1)))
 	       (error nil)))
 	   (and blinkpos
-		(not (eq (car (syntax-after blinkpos)) 8)) ;Not syntax '$'.
+                ;; Not syntax '$'.
+		(not (eq (syntax-class (syntax-after blinkpos)) 8))
 		(setq matching-paren
 		      (let ((syntax (syntax-after blinkpos)))
 			(and (consp syntax)
-			     (eq (logand (car syntax) 255) 4)
+			     (eq (syntax-class syntax) 4)
 			     (cdr syntax)))
 		      mismatch
 		      (or (null matching-paren)
@@ -4275,8 +4268,6 @@
   (setq defining-kbd-macro nil)
   (signal 'quit nil))
 
-(define-key global-map "\C-g" 'keyboard-quit)
-
 (defvar buffer-quit-function nil
   "Function to call to \"quit\" the current buffer, or nil if none.
 \\[keyboard-escape-quit] calls this function when its more local actions
@@ -4319,7 +4310,6 @@
     (push 'sound sound)
     (play-sound sound)))
 
-(define-key global-map "\e\e\e" 'keyboard-escape-quit)
 
 (defcustom read-mail-command 'rmail
   "*Your preference for a mail reading package.
@@ -5112,7 +5102,6 @@
     (set-buffer buffer)
     (clone-indirect-buffer nil t norecord)))
 
-(define-key ctl-x-4-map "c" 'clone-indirect-buffer-other-window)
 
 ;;; Handling of Backspace and Delete keys.
 
--- a/lisp/startup.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/startup.el	Thu Apr 21 05:59:53 2005 +0000
@@ -719,7 +719,7 @@
     (frame-initialize))
 
   ;; Turn off blinking cursor if so specified in X resources.  This is here
-  ;; only because all other settings of no-blinking-cursor 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))
@@ -746,22 +746,15 @@
   (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))
               (not (fboundp 'x-show-tip)))
     (tooltip-mode 1))
 
-  ;; If you change the code below, you need to also change the
-  ;; corresponding code in the xterm-mouse-mode defcustom.  The two need
-  ;; to be equivalent under all conditions, or Custom will get confused.
-  (unless (or noninteractive
-	      window-system)
-    (let ((term (getenv "TERM")))
-      (and term
-	   (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)" term)
-	   (xterm-mouse-mode 1))))
-
   ;; Register default TTY colors for the case the terminal hasn't a
   ;; terminal init file.
   (unless (memq window-system '(x w32))
@@ -1082,15 +1075,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)
 
@@ -1271,7 +1264,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/subr.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/subr.el	Thu Apr 21 05:59:53 2005 +0000
@@ -2286,6 +2286,10 @@
       (if (consp st) st
 	(aref (or st (syntax-table)) (char-after pos))))))
 
+(defun syntax-class (syntax)
+  "Return the syntax class part of the syntax descriptor SYNTAX."
+  (logand (car syntax) 255))
+
 (defun add-to-invisibility-spec (arg)
   "Add elements to `buffer-invisibility-spec'.
 See documentation for `buffer-invisibility-spec' for the kind of elements
--- a/lisp/term/mac-win.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/term/mac-win.el	Thu Apr 21 05:59:53 2005 +0000
@@ -1,4 +1,4 @@
-;;; mac-win.el --- parse switches controlling interface with Mac window system
+;;; mac-win.el --- parse switches controlling interface with Mac window system -*-coding: iso-2022-7bit;-*-
 
 ;; Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005
 ;;   Free Software Foundation, Inc.
@@ -1085,7 +1085,7 @@
 (put 'escape 'ascii-character ?\e)
 
 
-;;;; Keyboard layout/language change events
+;;;; Script codes and coding systems
 (defconst mac-script-code-coding-systems
   '((0 . mac-roman)			; smRoman
     (1 . japanese-shift-jis)		; smJapanese
@@ -1097,6 +1097,40 @@
     )
   "Alist of Mac script codes vs Emacs coding systems.")
 
+(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.")
+
+(defun mac-add-charset-info (xlfd-charset mac-text-encoding)
+  "Function to add character sets to display with Mac fonts.
+Creates entries in `mac-charset-info-alist'.
+XLFD-CHARSET is a string which will appear in the XLFD font name
+to identify the character set.  MAC-TEXT-ENCODING is the
+correspoinding TextEncodingBase value."
+  (add-to-list 'mac-charset-info-alist
+               (list xlfd-charset mac-text-encoding
+		     (cdr (assq mac-text-encoding
+				mac-script-code-coding-systems)))))
+
+(setq mac-charset-info-alist nil)
+(mac-add-charset-info "mac-roman" 0)
+(mac-add-charset-info "jisx0208.1983-sjis" 1)
+(mac-add-charset-info "jisx0201.1976-0" 1)
+(mac-add-charset-info "big5-0" 2)
+(mac-add-charset-info "ksc5601.1989-0" 3)
+(mac-add-charset-info "mac-cyrillic" 7)
+(mac-add-charset-info "gb2312.1980-0" 25)
+(mac-add-charset-info "mac-centraleurroman" 29)
+(mac-add-charset-info "mac-symbol" 33)
+(mac-add-charset-info "adobe-fontspecific" 33) ; for X-Symbol
+(mac-add-charset-info "mac-dingbats" 34)
+
+
 ;;;; Keyboard layout/language change events
 (defun mac-handle-language-change (event)
   (interactive "e")
@@ -1356,14 +1390,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.
@@ -1380,7 +1411,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/textmodes/org.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/textmodes/org.el	Thu Apr 21 05:59:53 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	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/tooltip.el	Thu Apr 21 05:59:53 2005 +0000
@@ -117,7 +117,10 @@
   :group 'tooltip)
 
 (defcustom tooltip-gud-tips-p nil
-  "*Non-nil means show tooltips in GUD sessions."
+  "*Non-nil means show tooltips in GUD sessions.
+
+This allows you to display a variable's value in a tooltip simply by
+pointing at it with the mouse."
   :type 'boolean
   :tag "GUD"
   :group 'tooltip)
@@ -139,14 +142,14 @@
   :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)
 
+(defvaralias 'tooltip-use-echo-area 'tooltip-gud-echo-area)
+(make-obsolete-variable 'tooltip-use-echo-area 'tooltip-gud-echo-area "22.1")
 
 ;;; Variables that are not customizable.
 
@@ -187,6 +190,13 @@
   "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
+		       (and (boundp 'emacs-quick-startup) emacs-quick-startup)
+		       (not (and (fboundp 'display-graphic-p)
+				 (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 +295,20 @@
       (push (cons key value) alist))
     alist))
 
-(defun tooltip-show (text)
+(defun tooltip-show (text &optional use-echo-area)
   "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.
+
+Optional second arg USE-ECHO-AREA non-nil means to show tooltip
+in echo area."
+  (if use-echo-area
       (message "%s" text)
     (condition-case error
 	(let ((params (copy-sequence tooltip-frame-parameters))
@@ -402,16 +415,27 @@
     (message "Dereferencing is now %s."
 	     (if tooltip-gud-dereference "on" "off"))))
 
+(defun tooltip-toggle-gud-tips ()
+  "Toggle the display of GUD tooltips."
+  (interactive)
+  (setq tooltip-gud-tips-p (not tooltip-gud-tips-p))
+  ;; Reconsider for all buffers whether mouse motion events are desired.
+  (tooltip-change-major-mode)
+  (when (interactive-p)
+    (message (format "GUD tooltips %sabled"
+		     (if tooltip-gud-tips-p "en" "dis")))))
+
 ; This will only display data that comes in one chunk.
 ; Larger arrays (say 400 elements) are displayed in
 ; the tootip incompletely and spill over into the gud buffer.
 ; Switching the process-filter creates timing problems and
-; it may be difficult to do better. gdba in gdb-ui.el
-; gets round this problem.
+; it may be difficult to do better. Using annotations as in
+; gdb-ui.el gets round this problem.
 (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)
+		tooltip-gud-echo-area))
 
 (defun tooltip-gud-print-command (expr)
   "Return a suitable command to print the expression EXPR.
@@ -457,8 +481,9 @@
   (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))))
+   tooltip-gud-echo-area))
 
 
 ;;; Tooltip help.
--- a/lisp/url/ChangeLog	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/url/ChangeLog	Thu Apr 21 05:59:53 2005 +0000
@@ -1,3 +1,8 @@
+2005-04-18  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* url.el (url-retrieve-synchronously): Work around the fact that
+	url-http sometimes doesn't call the callback.
+
 2005-04-04  Lute Kamstra  <lute@gnu.org>
 
 	* url-handlers.el (url-handler-mode): Specify :group.
--- a/lisp/url/url.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/url/url.el	Thu Apr 21 05:59:53 2005 +0000
@@ -180,15 +180,23 @@
 	  (url-debug 'retrieval
 		     "Spinning in url-retrieve-synchronously: %S (%S)"
 		     retrieval-done asynch-buffer)
-	  ;; We used to use `sit-for' here, but in some cases it wouldn't
-	  ;; work because apparently pending keyboard input would always
-	  ;; interrupt it before it got a chance to handle process input.
-	  ;; `sleep-for' was tried but it lead to other forms of
-	  ;; hanging.  --Stef
-	  (unless (accept-process-output proc)
-	    ;; accept-process-output returned nil, maybe because the process
-	    ;; exited (and may have been replaced with another).
-	    (setq proc (get-buffer-process asynch-buffer)))))
+	  (if (memq (process-status proc) '(closed exit signal failed))
+	      ;; FIXME: It's not clear whether url-retrieve's callback is
+	      ;; guaranteed to be called or not.  It seems that url-http
+	      ;; decides sometimes consciously not to call it, so it's not
+	      ;; clear that it's a bug, but even if we need to decide how
+	      ;; url-http can then warn us that the download has completed.
+              ;; In the mean time, we use this here workaround.
+              (setq retrieval-done t)
+            ;; We used to use `sit-for' here, but in some cases it wouldn't
+            ;; work because apparently pending keyboard input would always
+            ;; interrupt it before it got a chance to handle process input.
+            ;; `sleep-for' was tried but it lead to other forms of
+            ;; hanging.  --Stef
+            (unless (accept-process-output proc)
+              ;; accept-process-output returned nil, maybe because the process
+              ;; exited (and may have been replaced with another).
+              (setq proc (get-buffer-process asynch-buffer))))))
       asynch-buffer)))
 
 (defun url-mm-callback (&rest ignored)
--- a/lisp/vc.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/vc.el	Thu Apr 21 05:59:53 2005 +0000
@@ -616,23 +616,23 @@
 
 ;; Annotate customization
 (defcustom vc-annotate-color-map
-  '(( 20. . "#FF0000")
-    ( 40. . "#FF3800")
-    ( 60. . "#FF7000")
-    ( 80. . "#FFA800")
-    (100. . "#FFE000")
-    (120. . "#E7FF00")
-    (140. . "#AFFF00")
-    (160. . "#77FF00")
-    (180. . "#3FFF00")
-    (200. . "#07FF00")
-    (220. . "#00FF31")
-    (240. . "#00FF69")
-    (260. . "#00FFA1")
-    (280. . "#00FFD9")
-    (300. . "#00EEFF")
-    (320. . "#00B6FF")
-    (340. . "#007EFF"))
+  '(( 20. . "#FFCC00")
+    ( 40. . "#FF6666")
+    ( 60. . "#FF6600")
+    ( 80. . "#FF3300")
+    (100. . "#FF00FF")
+    (120. . "#FF0000")
+    (140. . "#CCCC00")
+    (160. . "#CC00CC")
+    (180. . "#BC8F8F")
+    (200. . "#99CC00")
+    (220. . "#999900")
+    (240. . "#7AC5CD")
+    (260. . "#66CC00")
+    (280. . "#33CC33")
+    (300. . "#00CCFF")
+    (320. . "#00CC99")
+    (340. . "#0099FF"))
   "*Association list of age versus color, for \\[vc-annotate].
 Ages are given in units of fractional days.  Default is eighteen steps
 using a twenty day increment."
--- a/lisp/xt-mouse.el	Thu Apr 21 05:57:27 2005 +0000
+++ b/lisp/xt-mouse.el	Thu Apr 21 05:59:53 2005 +0000
@@ -162,15 +162,6 @@
 mouse functionality for such clicks is still available by holding
 down the SHIFT key while pressing the mouse button."
   :global t :group 'mouse
-   ;; If you change the code below, you also need to change the
-   ;; corresponding code in startup.el.
-  :init-value (unless (or noninteractive
-			  window-system)
-		(let ((term (getenv "TERM")))
-		  (and term
-		       (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)"
-				     term)
-		       t)))
   (if xterm-mouse-mode
       ;; Turn it on
       (unless window-system
--- a/lispref/ChangeLog	Thu Apr 21 05:57:27 2005 +0000
+++ b/lispref/ChangeLog	Thu Apr 21 05:59:53 2005 +0000
@@ -1,3 +1,31 @@
+2005-04-19  Richard M. Stallman  <rms@gnu.org>
+
+	* modes.texi (Search-based Fontification): Explain that
+	facespec is an expression to be evaluated.
+
+2005-04-19  Kevin Ryde  <user42@zip.com.au>
+
+        * streams.texi (Output Functions): Fix xref.
+	* strings.texi (String Conversion): Fix xref.
+
+2005-04-19  Kim F. Storm  <storm@cua.dk>
+
+	* symbols.texi (Symbol Plists): Add safe-get.
+	Mention that `get' may signal an error.
+
+2005-04-18  Nick Roberts  <nickrob@snap.net.nz>
+
+	* customize.texi (Variable Definitions): Replace tooltip-mode
+	example with save-place.
+
+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	Thu Apr 21 05:57:27 2005 +0000
+++ b/lispref/buffers.texi	Thu Apr 21 05:59:53 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/customize.texi	Thu Apr 21 05:57:27 2005 +0000
+++ b/lispref/customize.texi	Thu Apr 21 05:59:53 2005 +0000
@@ -283,17 +283,14 @@
 operation of a certain feature.  Assuming that the package is coded to
 check the value of the option, you still need to arrange for the package
 to be loaded.  You can do that with @code{:require}.  @xref{Common
-Keywords}.  Here is an example, from the library @file{tooltip.el}:
+Keywords}.  Here is an example, from the library @file{saveplace.el}:
 
 @example
-(defcustom tooltip-mode nil
-  "Non-nil if Tooltip mode is enabled..."
-  :set (lambda (symbol value)
-	 (tooltip-mode (or value 0)))
-  :initialize 'custom-initialize-default
+(defcustom save-place nil
+  "*Non-nil means automatically save place in each file..."
   :type 'boolean
-  :require 'tooltip
-  :group 'tooltip)
+  :require 'saveplace
+  :group 'save-place)
 @end example
 
 If a customization item has a type such as @code{hook} or @code{alist},
--- a/lispref/modes.texi	Thu Apr 21 05:57:27 2005 +0000
+++ b/lispref/modes.texi	Thu Apr 21 05:59:53 2005 +0000
@@ -2163,9 +2163,10 @@
 Functions}) to calculate the value for @var{subexp}.
 
 @item (@var{matcher} . @var{facespec})
-In this kind of element, @var{facespec} is an object which specifies
-the face variable to use for highlighting.  In the simplest case, it
-is a Lisp variable (a symbol), whose value should be a face name.
+In this kind of element, @var{facespec} is an expression whose value
+specifies the face to use for highlighting.  In the simplest case,
+@var{facespec} is a Lisp variable (a symbol) whose value is a face
+name.
 
 @example
 ;; @r{Highlight occurrences of @samp{fubar},}
@@ -2173,12 +2174,13 @@
 ("fubar" . fubar-face)
 @end example
 
-However, @var{facespec} can also be a list of the form:
+However, @var{facespec} can also evaluate to a list of this form:
 
 @example
 (face @var{face} @var{prop1} @var{val1} @var{prop2} @var{val2}@dots{})
 @end example
 
+@noindent
 to specify the face @var{face} and various additional text properties
 to put on the text that matches.  If you do this, be sure to add the
 other text property names that you set in this way to the value of
@@ -2198,7 +2200,8 @@
 
 The @sc{car}, @var{subexp}, is an integer specifying which subexpression
 of the match to fontify (0 means the entire matching text).  The second
-subelement, @var{facespec}, specifies the face, as described above.
+subelement, @var{facespec}, is an expression whose value specifies the
+face, as described above.
 
 The last two values in @var{subexp-highlighter}, @var{override} and
 @var{laxmatch}, are optional flags.  If @var{override} is @code{t},
--- a/lispref/positions.texi	Thu Apr 21 05:57:27 2005 +0000
+++ b/lispref/positions.texi	Thu Apr 21 05:59:53 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/streams.texi	Thu Apr 21 05:57:27 2005 +0000
+++ b/lispref/streams.texi	Thu Apr 21 05:59:53 2005 +0000
@@ -659,7 +659,7 @@
 @end group
 @end example
 
-See @code{format}, in @ref{String Conversion}, for other ways to obtain
+See @code{format}, in @ref{Formatting Strings}, for other ways to obtain
 the printed representation of a Lisp object as a string.
 @end defun
 
--- a/lispref/strings.texi	Thu Apr 21 05:57:27 2005 +0000
+++ b/lispref/strings.texi	Thu Apr 21 05:59:53 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}.
@@ -548,7 +549,8 @@
 @cindex conversion of strings
 
   This section describes functions for conversions between characters,
-strings and integers.  @code{format} and @code{prin1-to-string}
+strings and integers.  @code{format} (@pxref{Formatting Strings})
+and @code{prin1-to-string}
 (@pxref{Output Functions}) can also convert Lisp objects into strings.
 @code{read-from-string} (@pxref{Input Functions}) can ``convert'' a
 string representation of a Lisp object into an object.  The functions
--- a/lispref/symbols.texi	Thu Apr 21 05:57:27 2005 +0000
+++ b/lispref/symbols.texi	Thu Apr 21 05:59:53 2005 +0000
@@ -496,6 +496,8 @@
 @var{symbol}'s property list.  If there is no such property, @code{nil}
 is returned.  Thus, there is no distinction between a value of
 @code{nil} and the absence of the property.
+A @code{wrong-type-argument} error may be signaled if @var{symbol}
+has a malformed property list.
 
 The name @var{property} is compared with the existing property names
 using @code{eq}, so any object is a legitimate property.
@@ -503,6 +505,12 @@
 See @code{put} for an example.
 @end defun
 
+@defun safe-get symbol property
+This function finds the value of the property named @var{property} in
+@var{symbol}'s property list.  Unlike @code{get}, it just returns
+@code{nil} if @var{symbol} has a malformed property list.
+@end defun
+
 @defun put symbol property value
 This function puts @var{value} onto @var{symbol}'s property list under
 the property name @var{property}, replacing any previous property value.
--- a/lispref/syntax.texi	Thu Apr 21 05:57:27 2005 +0000
+++ b/lispref/syntax.texi	Thu Apr 21 05:59:53 2005 +0000
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2004
+@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2004, 2005
 @c   Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @setfilename ../info/syntax
@@ -943,6 +943,10 @@
 as the syntax table.
 @end defun
 
+@defun syntax-class syntax
+This function returns the syntax class of a syntax code.
+@end defun
+
 @node Categories
 @section Categories
 @cindex categories of characters
--- a/mac/ChangeLog	Thu Apr 21 05:57:27 2005 +0000
+++ b/mac/ChangeLog	Thu Apr 21 05:59:53 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	Thu Apr 21 05:57:27 2005 +0000
+++ b/mac/makefile.MPW	Thu Apr 21 05:59:53 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	Thu Apr 21 05:57:27 2005 +0000
+++ b/make-dist	Thu Apr 21 05:59:53 2005 +0000
@@ -184,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
@@ -196,9 +196,9 @@
   rm -f /tmp/el /tmp/elc
 
   ### Check for .el files with no corresponding .elc 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 > /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 | sed 's/\.elc$/.el/' > /tmp/elc
   losers="`comm -23 /tmp/el /tmp/elc`"
   bogosities=
@@ -344,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
@@ -384,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
@@ -404,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	Thu Apr 21 05:57:27 2005 +0000
+++ b/man/ChangeLog	Thu Apr 21 05:59:53 2005 +0000
@@ -1,3 +1,23 @@
+2005-04-19  Kim F. Storm  <storm@cua.dk>
+
+	* building.texi (Compilation Mode): Add M-g M-n and M-g M-p bindings.
+
+2005-04-18  Lars Hansen  <larsh@math.ku.dk>
+
+	* misc.texi (Saving Emacs Sessions): Add that "--no-desktop" now
+	turns off desktop-save-mode.
+
+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.
--- a/man/building.texi	Thu Apr 21 05:57:27 2005 +0000
+++ b/man/building.texi	Thu Apr 21 05:59:53 2005 +0000
@@ -163,8 +163,13 @@
 follow output as it comes in.
 
 @table @kbd
-@item C-x `
+@item M-g M-n
+@itemx M-g n
+@itemx C-x `
 Visit the locus of the next compiler error message or @code{grep} match.
+@item M-g M-p
+@itemx M-g p
+Visit the locus of the previous compiler error message or @code{grep} match.
 @item @key{RET}
 Visit the locus of the error message that point is on.
 This command is used in the compilation buffer.
@@ -187,6 +192,8 @@
 compilation buffer produce automatic source display.
 @end table
 
+@kindex M-g M-n
+@kindex M-g n
 @kindex C-x `
 @findex next-error
   You can visit the source for any particular error message by moving
--- a/man/custom.texi	Thu Apr 21 05:57:27 2005 +0000
+++ b/man/custom.texi	Thu Apr 21 05:59:53 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	Thu Apr 21 05:57:27 2005 +0000
+++ b/man/frames.texi	Thu Apr 21 05:59:53 2005 +0000
@@ -1055,15 +1055,14 @@
 
 Some terminal emulators under X support mouse clicks in the terminal
 window.  In a terminal emulator which is compatible with @code{xterm},
-simple use of the mouse is, by default, controlled by Emacs---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.
+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.
 
-Put @code{(xterm-mouse-mode 0)} in your @file{.emacs}, or disable the
-option @code{xterm-mouse-mode} through the @samp{Customize} interface
-(@pxref{Easy Customization}), if you prefer all mouse clicks to be
-handled by the terminal emulator.
+  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/misc.texi	Thu Apr 21 05:57:27 2005 +0000
+++ b/man/misc.texi	Thu Apr 21 05:59:53 2005 +0000
@@ -1937,7 +1937,8 @@
 @kbd{M-x desktop-revert} reverts to the desktop previously reloaded.
 
   Specify the option @samp{--no-desktop} on the command line when you
-don't want it to reload any saved desktop.
+don't want it to reload any saved desktop.  This turns off
+@code{desktop-save-mode} for the current session.
 
 @vindex desktop-restore-eager
   By default, all the buffers in the desktop are restored at one go.
--- a/man/org.texi	Thu Apr 21 05:57:27 2005 +0000
+++ b/man/org.texi	Thu Apr 21 05:59:53 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/src/ChangeLog	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/ChangeLog	Thu Apr 21 05:59:53 2005 +0000
@@ -1,3 +1,223 @@
+2005-04-20  Thien-Thi Nguyen  <ttn@gnu.org>
+
+	* sysdep.c: Remove reference to defunct vms-pwd.h.
+	* dired.c: Likewise.  Also, for pwd.h, use HAVE_PWD_H, not !VMS.
+	* editfns.c, fileio.c, filelock.c, sysdep.c, xrdb.c: Likewise.
+
+	* config.in: Regenerate.
+
+2005-04-20  Kenichi Handa  <handa@m17n.org>
+
+	* lisp.h (CHAR_TABLE_DEFAULT_SLOT_ASCII): New macro.
+	(CHAR_TABLE_DEFAULT_SLOT_8_BIT_CONTROL): New macro.
+	(CHAR_TABLE_DEFAULT_SLOT_8_BIT_GRAPHIC): New macro.
+
+	* alloc.c (make_sub_char_table): Argument changed to initial
+	value of the slots.
+
+	* data.c (Faref): Handle special slots used as default values of
+	ascii, eight-bit-control, eight-bit-control.  Don't ignore a
+	default value set for a group of characters.
+	(Faset): Signal an error if IDXVAL is not a valid character code.
+	Make a sub-chartable with correct initial value.
+
+	* fns.c (Fset_char_table_range): Don't set slots used as default
+	values for ascii, eight-bit-control, eight-bit-graphic.  Don't
+	call Faref with charset-id.
+	(Fset_char_table_default): Document how to treat normal character
+	argument.  Handle special slots used as default values of ascii,
+	eight-bit-control, eight-bit-control.  Make a sub chartable if
+	necessary.
+
+2005-04-20  Kenichi Handa  <handa@m17n.org>
+
+	* search.c (boyer_moore): Fix previous change.
+
+2005-04-19  Kim F. Storm  <storm@cua.dk>
+
+	* xdisp.c (setup_for_ellipsis): Reset saved_face_id to use default
+	face unless last visible char and first invisible char have the
+	same face.  Also use default face if saved_face_id is undefined.
+
+2005-04-19  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* macgui.h (MacFontStruct): Remove member `fontname'.  Add member
+	`full_name'.
+	[TARGET_API_MAC_CARBON] (MacFontStruct): Use type int for
+	mac_scriptcode member.
+
+	* macterm.c (Qbig5, Qcn_gb, Qsjis, Qeuc_kr): Remove variables.
+	(syms_of_mac): Don't initialize them.
+	(Vmac_charset_info_alist): New variable.
+	(syms_of_mac): Defvar it.
+	(create_text_encoding_info_alist): New function.
+	(decode_mac_font_name, mac_to_x_fontname)
+	(x_font_name_to_mac_font_name, init_font_name_table): Don't hard
+	code the correspondence among XLFD charsets, Mac script codes, and
+	Emacs coding systems.  Use Vmac_charset_info_alist and result of
+	create_text_encoding_info_alist instead.
+	(init_font_name_table) [TARGET_API_MAC_CARBON]: Use Font Manager
+	routines also on Mac OS Classic.
+	(init_font_name_table) [!TARGET_API_MAC_CARBON]: Use
+	add_font_name_table_entry.
+	(mac_do_list_fonts): Regard 0 in XLFD scaleble fields as
+	specified.  Derive unspecified scalable fields from specified one.
+	(x_list_fonts): Consider Valternate_fontname_alist.
+	(kDefaultFontSize): Change value from 9 to 12.
+	(XLoadQueryFont): Get decoded font family, font face, and charset
+	from x_font_name_to_mac_font_name.  Set full name of loaded font.
+	(mac_unload_font): Free `full_name' member.
+	(x_load_font): Don't try XLoadQueryFont if x_list_fonts returns
+	NULL.  Copy full_name member of struct MacFontStruct to that of
+	struct font_info.
+
+2005-04-19  Kim F. Storm  <storm@cua.dk>
+
+	* xdisp.c (handle_stop): Set saved_face_id to current face if
+	selective_display_ellipsis_p so ellipsis will be shown in same
+	face as preceding text.
+	(setup_for_ellipsis): Don't set saved_face_id here.
+	(next_element_from_display_vector): Default to saved_face_id.
+
+	* fns.c (Fsafe_get): New function.
+	(syms_of_fns): Defsubr it.
+
+	* lisp.h (Fsafe_get): EXFUN it.
+
+	* xfaces.c (resolve_face_name): Use Fsafe_get to avoid redisplay
+	loops in case of bad face property lists.  Limit number of face
+	alias lookups to 10 (in case of face alias loops).
+
+2005-04-18  Kim F. Storm  <storm@cua.dk>
+
+	* dispextern.h (struct glyph_row): New member overlay_arrow_bitmap.
+	It replaces the corresponding member from struct window, as a
+	window may now show multiple overlay arrows.
+	Remove member overlay_arrow_p, superseeded by overlay_arrow_bitmap.
+
+	* dispnew.c (row_equal_p, update_window_line, scrolling_window):
+	Compare overlay_arrow_bitmap than overlay_arrow_p members.
+
+	* fringe.c (draw_fringe_bitmap): Use overlay_arrow_bitmap from row
+	rather than from window.
+	(update_window_fringes): Compare overlay_arrow_bitmap rather than
+	overlay_arrow_p members.
+	(Ffringe_bitmaps_at_pos): Return fringe overlay_arrow_bitmap name
+	if not default.
+
+	* window.h (struct window): Remove member overlay_arrow_bitmap.
+
+	* window.c (make_window): Don't initialize overlay_arrow_bitmap.
+
+	* xdisp.c (overlay_arrow_string_or_property): Remove PBITMAP arg.
+	Calls changed.  Don't check for overlay-arrow-bitmap property here.
+	(overlay_arrow_at_row): Remove PBITMAP arg.  Instead, if left
+	fringe is present, return Lisp integer for bitmap (or -1 for default).
+	Fix value of overlay-arrow-bitmap property to be a symbol, use
+	lookup_fringe_bitmap to parse it.
+	(display_line): Change call to overlay_arrow_at_row.  Store integer
+	return value as overlay bitmap in row rather than window.
+	Only show overlay arrow if row displays text, or if no other overlay
+	arrow is seen in window (if overlay marker is at point-max).
+
+2005-04-18  Thien-Thi Nguyen  <ttn@gnu.org>
+
+	* xfaces.c (realize_x_face) [!HAVE_WINDOW_SYSTEM]: Return NULL.
+
+2005-04-18  Lute Kamstra  <lute@gnu.org>
+
+	* lread.c (Vloads_in_progress): Static.
+	* fns.c (Vloads_in_progress): Remove extern.
+	(load_in_progress): Add extern.
+	(Frequire): Use load_in_progress instead of Vloads_in_progress.
+
+2005-04-18  Thien-Thi Nguyen  <ttn@gnu.org>
+
+	* xmenu.c (Fx_popup_menu): Initialize error_name to NULL.
+
+2005-04-18  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* macterm.c (XTread_socket): Don't beep on keyboard input even if
+	no frame is visible.
+
+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
@@ -13,13 +233,11 @@
 
 	* 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'.
+	(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.
+	* termhooks.h (enum event_kind) [MAC_OS]: Add LANGUAGE_CHANGE_EVENT.
 
 2005-04-10  Richard M. Stallman  <rms@gnu.org>
 
@@ -34,7 +252,6 @@
 	into "(any string)".
 
 	* lread.c (Vloads_in_progress): Not static.
-
 	* fns.c (Vloads_in_progress): Add extern.
 	(Frequire): Don't do LOADHIST_ATTACH if Vloads_in_progress is nil.
 
@@ -908,9 +1125,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>
@@ -1054,6 +1271,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
@@ -3554,8 +3772,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>
 
@@ -5042,7 +5260,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>
 
@@ -5497,10 +5715,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>
 
@@ -6210,7 +6428,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>
@@ -11150,7 +11368,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>
@@ -11509,7 +11727,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.
 
@@ -11552,7 +11770,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	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/Makefile.in	Thu Apr 21 05:59:53 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.
@@ -771,6 +777,7 @@
 	${lispsource}emacs-lisp/timer.elc \
 	${lispsource}vc-hooks.elc \
 	${lispsource}ediff-hook.elc \
+	TOOLTIP_SUPPORT \
 	VMS_SUPPORT \
 	MSDOS_SUPPORT \
 	WINNT_SUPPORT \
@@ -868,6 +875,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
 
@@ -1221,7 +1229,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/config.in	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/config.in	Thu Apr 21 05:59:53 2005 +0000
@@ -451,6 +451,9 @@
 /* Define to 1 if you have the <pty.h> header file. */
 #undef HAVE_PTY_H
 
+/* Define to 1 if you have the <pwd.h> header file. */
+#undef HAVE_PWD_H
+
 /* Define to 1 if you have the `random' function. */
 #undef HAVE_RANDOM
 
@@ -779,9 +782,9 @@
 /* If using the C implementation of alloca, define if you know the
    direction of stack growth for your system; otherwise it will be
    automatically deduced at run-time.
-        STACK_DIRECTION > 0 => grows toward higher addresses
-        STACK_DIRECTION < 0 => grows toward lower addresses
-        STACK_DIRECTION = 0 => direction of growth unknown */
+	STACK_DIRECTION > 0 => grows toward higher addresses
+	STACK_DIRECTION < 0 => grows toward lower addresses
+	STACK_DIRECTION = 0 => direction of growth unknown */
 #undef STACK_DIRECTION
 
 /* Define to 1 if you have the ANSI C header files. */
--- a/src/dired.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/dired.c	Thu Apr 21 05:59:53 2005 +0000
@@ -26,10 +26,10 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#ifdef VMS
-#include "vms-pwd.h"
-#else
+#ifdef HAVE_PWD_H
 #include <pwd.h>
+#endif
+#ifndef VMS
 #include <grp.h>
 #endif
 
--- a/src/dispextern.h	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/dispextern.h	Thu Apr 21 05:59:53 2005 +0000
@@ -726,6 +726,11 @@
      position of the next row.  */
   struct display_pos end;
 
+  /* Non-zero means the overlay arrow bitmap is on this line.
+     -1 means use default overlay arrow bitmap, else
+     it specifies actual fringe bitmap number.  */
+  int overlay_arrow_bitmap;
+
   /* Left fringe bitmap number (enum fringe_bitmap_type).  */
   unsigned left_user_fringe_bitmap : FRINGE_ID_BITS;
 
@@ -764,9 +769,6 @@
   unsigned truncated_on_left_p : 1;
   unsigned truncated_on_right_p : 1;
 
-  /* 1 means the overlay arrow is on this line.  */
-  unsigned overlay_arrow_p : 1;
-
   /* 1 means that this row displays a continued line, i.e. it has a
      continuation mark at the right side.  */
   unsigned continued_p : 1;
--- a/src/dispnew.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/dispnew.c	Thu Apr 21 05:59:53 2005 +0000
@@ -1519,7 +1519,7 @@
 	  || a->left_fringe_face_id != b->left_fringe_face_id
 	  || a->right_fringe_bitmap != b->right_fringe_bitmap
 	  || a->right_fringe_face_id != b->right_fringe_face_id
-	  || a->overlay_arrow_p != b->overlay_arrow_p
+	  || a->overlay_arrow_bitmap != b->overlay_arrow_bitmap
 	  || a->exact_window_width_line_p != b->exact_window_width_line_p
 	  || a->overlapped_p != b->overlapped_p
 	  || (MATRIX_ROW_CONTINUATION_LINE_P (a)
@@ -4521,7 +4521,7 @@
 	  || desired_row->y != current_row->y
 	  || desired_row->visible_height != current_row->visible_height
 	  || desired_row->cursor_in_fringe_p != current_row->cursor_in_fringe_p
-	  || desired_row->overlay_arrow_p != current_row->overlay_arrow_p
+	  || desired_row->overlay_arrow_bitmap != current_row->overlay_arrow_bitmap
 	  || current_row->redraw_fringe_bitmaps_p
 	  || desired_row->mode_line_p != current_row->mode_line_p
 	  || desired_row->exact_window_width_line_p != current_row->exact_window_width_line_p
@@ -5031,7 +5031,7 @@
 		    || to->right_fringe_bitmap != from->right_fringe_bitmap
 		    || to->left_fringe_face_id != from->left_fringe_face_id
 		    || to->right_fringe_face_id != from->right_fringe_face_id
-		    || to->overlay_arrow_p != from->overlay_arrow_p))
+		    || to->overlay_arrow_bitmap != from->overlay_arrow_bitmap))
 	      from->redraw_fringe_bitmaps_p = 1;
 	    assign_row (to, from);
 	    to->enabled_p = 1, from->enabled_p = 0;
--- a/src/editfns.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/editfns.c	Thu Apr 21 05:59:53 2005 +0000
@@ -24,9 +24,7 @@
 #include <sys/types.h>
 #include <stdio.h>
 
-#ifdef VMS
-#include "vms-pwd.h"
-#else
+#ifdef HAVE_PWD_H
 #include <pwd.h>
 #endif
 
--- a/src/fileio.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/fileio.c	Thu Apr 21 05:59:53 2005 +0000
@@ -45,9 +45,7 @@
 #  define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
 #endif
 
-#ifdef VMS
-#include "vms-pwd.h"
-#else
+#ifdef HAVE_PWD_H
 #include <pwd.h>
 #endif
 
--- a/src/filelock.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/filelock.c	Thu Apr 21 05:59:53 2005 +0000
@@ -26,11 +26,9 @@
 #include <signal.h>
 #include <stdio.h>
 
-#ifdef VMS
-#include "vms-pwd.h"
-#else
+#ifdef HAVE_PWD_H
 #include <pwd.h>
-#endif /* not VMS */
+#endif
 
 #include <sys/file.h>
 #ifdef HAVE_FCNTL_H
--- a/src/fns.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/fns.c	Thu Apr 21 05:59:53 2005 +0000
@@ -66,7 +66,7 @@
 extern int minibuffer_auto_raise;
 extern Lisp_Object minibuf_window;
 extern Lisp_Object Vlocale_coding_system;
-extern Lisp_Object Vloads_in_progress;
+extern int load_in_progress;
 
 Lisp_Object Qstring_lessp, Qprovide, Qrequire;
 Lisp_Object Qyes_or_no_p_history;
@@ -1971,6 +1971,18 @@
   return Fplist_get (XSYMBOL (symbol)->plist, propname);
 }
 
+DEFUN ("safe-get", Fsafe_get, Ssafe_get, 2, 2, 0,
+       doc: /* Return the value of SYMBOL's PROPNAME property.
+This is the last value stored with `(put SYMBOL PROPNAME VALUE)'.
+This function never signals an error.  */)
+     (symbol, propname)
+     Lisp_Object symbol, propname;
+{
+  if (!SYMBOLP (symbol))
+    return Qnil;
+  return Fsafe_plist_get (XSYMBOL (symbol)->plist, propname);
+}
+
 DEFUN ("plist-put", Fplist_put, Splist_put, 3, 3, 0,
        doc: /* Change value in PLIST of PROP to VAL.
 PLIST is a property list, which is a list of the form
@@ -2916,7 +2928,7 @@
      even if the feature specified is already loaded.
      But not more than once in any file,
      and not when we aren't loading a file.  */
-  if (! NILP (Vloads_in_progress))
+  if (load_in_progress)
     {
       tem = Fcons (Qrequire, feature);
       if (NILP (Fmember (tem, Vcurrent_load_list)))
@@ -5253,6 +5265,7 @@
   defsubr (&Splist_get);
   defsubr (&Ssafe_plist_get);
   defsubr (&Sget);
+  defsubr (&Ssafe_get);
   defsubr (&Splist_put);
   defsubr (&Sput);
   defsubr (&Slax_plist_get);
--- a/src/fringe.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/fringe.c	Thu Apr 21 05:59:53 2005 +0000
@@ -699,11 +699,11 @@
 
   draw_fringe_bitmap_1 (w, row, left_p, overlay, NO_FRINGE_BITMAP);
 
-  if (left_p && row->overlay_arrow_p)
+  if (left_p && row->overlay_arrow_bitmap != NO_FRINGE_BITMAP)
     draw_fringe_bitmap_1 (w, row, 1, 1,
-			  (w->overlay_arrow_bitmap
-			   ? w->overlay_arrow_bitmap
-			   : OVERLAY_ARROW_BITMAP));
+			  (row->overlay_arrow_bitmap < 0
+			   ? OVERLAY_ARROW_BITMAP
+			   : row->overlay_arrow_bitmap));
 }
 
 
@@ -959,10 +959,10 @@
 	  cur->right_fringe_face_id = right_face_id;
 	}
 
-      if (row->overlay_arrow_p != cur->overlay_arrow_p)
+      if (row->overlay_arrow_bitmap != cur->overlay_arrow_bitmap)
 	{
 	  redraw_p = row->redraw_fringe_bitmaps_p = cur->redraw_fringe_bitmaps_p = 1;
-	  cur->overlay_arrow_p = row->overlay_arrow_p;
+	  cur->overlay_arrow_bitmap = row->overlay_arrow_bitmap;
 	}
 
       row->left_fringe_bitmap = left;
@@ -1408,7 +1408,9 @@
   if (row)
     return list3 (get_fringe_bitmap_name (row->left_fringe_bitmap),
 		  get_fringe_bitmap_name (row->right_fringe_bitmap),
-		  (row->overlay_arrow_p ? Qt : Qnil));
+		  (row->overlay_arrow_bitmap == 0 ? Qnil
+		   : row->overlay_arrow_bitmap < 0 ? Qt
+		   : get_fringe_bitmap_name (row->overlay_arrow_bitmap)));
   else
     return Qnil;
 }
--- a/src/image.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/image.c	Thu Apr 21 05:59:53 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/lisp.h	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/lisp.h	Thu Apr 21 05:59:53 2005 +0000
@@ -2346,6 +2346,7 @@
 EXFUN (Freverse, 1);
 EXFUN (Fnreverse, 1);
 EXFUN (Fget, 2);
+EXFUN (Fsafe_get, 2);
 EXFUN (Fput, 3);
 EXFUN (Fequal, 2);
 EXFUN (Ffillarray, 2);
--- a/src/lread.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/lread.c	Thu Apr 21 05:59:53 2005 +0000
@@ -1,6 +1,6 @@
 /* Lisp parsing and input streams.
    Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994, 1995, 1997, 1998,
-     1999, 2000, 2001, 2003, 2004  Free Software Foundation, Inc.
+     1999, 2000, 2001, 2003, 2004, 2005  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -97,7 +97,7 @@
 extern Lisp_Object Qevent_symbol_element_mask;
 extern Lisp_Object Qfile_exists_p;
 
-/* non-zero if inside `load' */
+/* non-zero iff inside `load' */
 int load_in_progress;
 
 /* Directory in which the sources were found.  */
@@ -203,7 +203,7 @@
 /* A list of file names for files being loaded in Fload.  Used to
    check for recursive loads.  */
 
-Lisp_Object Vloads_in_progress;
+static Lisp_Object Vloads_in_progress;
 
 /* Non-zero means load dangerous compiled Lisp files.  */
 
--- a/src/mac.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/mac.c	Thu Apr 21 05:59:53 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	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/macfns.c	Thu Apr 21 05:59:53 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/macgui.h	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/macgui.h	Thu Apr 21 05:59:53 2005 +0000
@@ -101,12 +101,16 @@
    (xcs).descent = (bds).bottom)
 
 struct MacFontStruct {
-  char *fontname;
+  char *full_name;
 
   short mac_fontnum;  /* font number of font used in this window */
   int mac_fontsize;  /* size of font */
   short mac_fontface;  /* plain, bold, italics, etc. */
+#if TARGET_API_MAC_CARBON
+  int mac_scriptcode;  /* Mac OS script code for font used */
+#else
   short mac_scriptcode;  /* Mac OS script code for font used */
+#endif
 
 #if 0
   SInt16 mFontNum;  /* font number of font used in this window */
--- a/src/macterm.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/macterm.c	Thu Apr 21 05:59:53 2005 +0000
@@ -97,6 +97,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.  */
@@ -112,9 +113,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.  */
 
@@ -275,14 +275,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 *));
@@ -1200,15 +1202,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)
@@ -3500,6 +3493,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);
 }
 
@@ -3507,6 +3508,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);
 }
 
@@ -3549,6 +3558,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
@@ -3986,25 +4057,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.
@@ -4037,13 +4102,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)
@@ -4610,7 +4672,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;
@@ -5067,7 +5134,7 @@
     fontset = new_fontset_from_font_name (result);
 
   /* Since x_new_font doesn't update any fontset information, do it now.  */
-  FRAME_FONTSET(f) = fontset;
+  FRAME_FONTSET (f) = fontset;
 
   return fontset_name (fontset);
 }
@@ -5515,6 +5582,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
@@ -5784,121 +5858,59 @@
 int font_name_table_size = 0;
 int font_name_count = 0;
 
-#if 0
-/* compare two strings ignoring case */
-static int
-stricmp (const char *s, const char *t)
-{
-  for ( ; tolower (*s) == tolower (*t); s++, t++)
-    if (*s == '\0')
-      return 0;
-  return tolower (*s) - tolower (*t);
-}
-
-/* compare two strings ignoring case and handling wildcard */
-static int
-wildstrieq (char *s1, char *s2)
-{
-  if (strcmp (s1, "*") == 0 || strcmp (s2, "*") == 0)
-    return true;
-
-  return stricmp (s1, s2) == 0;
-}
-
-/* Assume parameter 1 is fully qualified, no wildcards. */
-static int
-mac_font_pattern_match (fontname, pattern)
-    char * fontname;
-    char * pattern;
-{
-  char *regex = (char *) alloca (strlen (pattern) * 2 + 3);
-  char *font_name_copy = (char *) alloca (strlen (fontname) + 1);
-  char *ptr;
-
-  /* Copy fontname so we can modify it during comparison.  */
-  strcpy (font_name_copy, fontname);
-
-  ptr = regex;
-  *ptr++ = '^';
-
-  /* Turn pattern into a regexp and do a regexp match.  */
-  for (; *pattern; pattern++)
-    {
-      if (*pattern == '?')
-        *ptr++ = '.';
-      else if (*pattern == '*')
-        {
-          *ptr++ = '.';
-          *ptr++ = '*';
-        }
+/* Alist linking character set strings to Mac text encoding and Emacs
+   coding system. */
+static Lisp_Object Vmac_charset_info_alist;
+
+static Lisp_Object
+create_text_encoding_info_alist ()
+{
+  Lisp_Object result = Qnil, rest;
+
+  for (rest = Vmac_charset_info_alist; CONSP (rest); rest = XCDR (rest))
+    {
+      Lisp_Object charset_info = XCAR (rest);
+      Lisp_Object charset, coding_system, text_encoding;
+      Lisp_Object existing_info;
+
+      if (!(CONSP (charset_info)
+	    && STRINGP (charset = XCAR (charset_info))
+	    && CONSP (XCDR (charset_info))
+	    && INTEGERP (text_encoding = XCAR (XCDR (charset_info)))
+	    && CONSP (XCDR (XCDR (charset_info)))
+	    && SYMBOLP (coding_system = XCAR (XCDR (XCDR (charset_info))))))
+	continue;
+
+      existing_info = assq_no_quit (text_encoding, result);
+      if (NILP (existing_info))
+	result = Fcons (list3 (text_encoding, coding_system, charset),
+			result);
       else
-        *ptr++ = *pattern;
-    }
-  *ptr = '$';
-  *(ptr + 1) = '\0';
-
-  return (fast_c_string_match_ignore_case (build_string (regex),
-                                           font_name_copy) >= 0);
-}
-
-/* Two font specs are considered to match if their foundry, family,
-   weight, slant, and charset match.  */
-static int
-mac_font_match (char *mf, char *xf)
-{
-  char m_foundry[50], m_family[50], m_weight[20], m_slant[2], m_charset[20];
-  char x_foundry[50], x_family[50], x_weight[20], x_slant[2], x_charset[20];
-
-  if (sscanf (mf, "-%49[^-]-%49[^-]-%19[^-]-%1[^-]-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%19s",
-              m_foundry, m_family, m_weight, m_slant, m_charset) != 5)
-    return mac_font_pattern_match (mf, xf);
-
-  if (sscanf (xf, "-%49[^-]-%49[^-]-%19[^-]-%1[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%19s",
-              x_foundry, x_family, x_weight, x_slant, x_charset) != 5)
-    return mac_font_pattern_match (mf, xf);
-
-  return (wildstrieq (m_foundry, x_foundry)
-          && wildstrieq (m_family, x_family)
-          && wildstrieq (m_weight, x_weight)
-          && wildstrieq (m_slant, x_slant)
-          && wildstrieq (m_charset, x_charset))
-         || mac_font_pattern_match (mf, xf);
-}
-#endif
-
-static Lisp_Object Qbig5, Qcn_gb, Qsjis, Qeuc_kr;
-
-static void
-decode_mac_font_name (name, size, scriptcode)
+	if (NILP (Fmember (charset, XCDR (XCDR (existing_info)))))
+	  XSETCDR (XCDR (existing_info),
+		   Fcons (charset, XCDR (XCDR (existing_info))));
+    }
+
+  return result;
+}
+
+
+static void
+decode_mac_font_name (name, size, coding_system)
      char *name;
      int size;
-#if TARGET_API_MAC_CARBON
-     int scriptcode;
-#else
-     short scriptcode;
-#endif
-{
-  Lisp_Object coding_system;
+     Lisp_Object coding_system;
+{
   struct coding_system coding;
-  char *buf;
-
-  switch (scriptcode)
-    {
-    case smTradChinese:
-      coding_system = Qbig5;
-      break;
-    case smSimpChinese:
-      coding_system = Qcn_gb;
+  char *buf, *p;
+
+  for (p = name; *p; p++)
+    if (!isascii (*p) || iscntrl (*p))
       break;
-    case smJapanese:
-      coding_system = Qsjis;
-      break;
-    case smKorean:
-      coding_system = Qeuc_kr;
-      break;
-    default:
-      return;
-    }
+
+  if (*p == '\0'
+      || NILP (coding_system) || NILP (Fcoding_system_p (coding_system)))
+    return;
 
   #if 0
   /* MAC_TODO: Fix encoding system... */
@@ -5918,68 +5930,26 @@
 
 
 static char *
-mac_to_x_fontname (name, size, style, scriptcode)
+mac_to_x_fontname (name, size, style, charset)
      char *name;
      int size;
      Style style;
-#if TARGET_API_MAC_CARBON
-     int scriptcode;
-#else
-     short scriptcode;
-#endif
+     char *charset;
 {
   char foundry[32], family[32], cs[32];
   char xf[256], *result, *p;
 
-  if (sscanf (name, "%31[^-]-%31[^-]-%31s", foundry, family, cs) != 3)
+  if (sscanf (name, "%31[^-]-%31[^-]-%31s", foundry, family, cs) == 3)
+    charset = cs;
+  else
     {
       strcpy(foundry, "Apple");
       strcpy(family, name);
-
-      switch (scriptcode)
-      {
-      case smTradChinese:	/* == kTextEncodingMacChineseTrad */
-        strcpy(cs, "big5-0");
-        break;
-      case smSimpChinese:	/* == kTextEncodingMacChineseSimp */
-        strcpy(cs, "gb2312.1980-0");
-        break;
-      case smJapanese:		/* == kTextEncodingMacJapanese */
-        strcpy(cs, "jisx0208.1983-sjis");
-        break;
-      case -smJapanese:
-	/* Each Apple Japanese font is entered into the font table
-	   twice: once as a jisx0208.1983-sjis font and once as a
-	   jisx0201.1976-0 font.  The latter can be used to display
-	   the ascii charset and katakana-jisx0201 charset.  A
-	   negative script code signals that the name of this latter
-	   font is being built.  */
-	strcpy(cs, "jisx0201.1976-0");
-	break;
-      case smKorean:		/* == kTextEncodingMacKorean */
-        strcpy(cs, "ksc5601.1989-0");
-        break;
-#if TARGET_API_MAC_CARBON
-      case kTextEncodingMacCyrillic:
-	strcpy(cs, "mac-cyrillic");
-	break;
-      case kTextEncodingMacCentralEurRoman:
-	strcpy(cs, "mac-centraleurroman");
-	break;
-      case kTextEncodingMacSymbol:
-      case kTextEncodingMacDingbats:
-	strcpy(cs, "adobe-fontspecific");
-	break;
-#endif
-      default:
-	strcpy(cs, "mac-roman");
-	break;
-      }
     }
 
   sprintf(xf, "-%s-%s-%s-%c-normal--%d-%d-75-75-m-%d-%s",
           foundry, family, style & bold ? "bold" : "medium",
-	  style & italic ? 'i' : 'r', size, size * 10, size * 10, cs);
+	  style & italic ? 'i' : 'r', size, size * 10, size * 10, charset);
 
   result = (char *) xmalloc (strlen (xf) + 1);
   strcpy (result, xf);
@@ -5997,10 +5967,13 @@
    "ETL-Fixed-iso8859-1", "ETL-Fixed-koi8-r", etc.  Both types of font
    names are handled accordingly.  */
 static void
-x_font_name_to_mac_font_name (char *xf, char *mf)
-{
-  char foundry[32], family[32], weight[20], slant[2], cs[32];
-  Lisp_Object coding_system = Qnil;
+x_font_name_to_mac_font_name (xf, mf, mf_decoded, style, cs)
+     char *xf, *mf, *mf_decoded;
+     Style *style;
+     char *cs;
+{
+  char foundry[32], family[32], weight[20], slant[2], *p;
+  Lisp_Object charset_info, coding_system = Qnil;
   struct coding_system coding;
 
   strcpy (mf, "");
@@ -6011,22 +5984,20 @@
               foundry, family, weight, slant, cs) != 5)
     return;
 
-  if (strcmp (cs, "big5-0") == 0)
-    coding_system = Qbig5;
-  else if (strcmp (cs, "gb2312.1980-0") == 0)
-    coding_system = Qcn_gb;
-  else if (strcmp (cs, "jisx0208.1983-sjis") == 0
-	   || strcmp (cs, "jisx0201.1976-0") == 0)
-    coding_system = Qsjis;
-  else if (strcmp (cs, "ksc5601.1989-0") == 0)
-    coding_system = Qeuc_kr;
-  else if (strcmp (cs, "mac-roman") == 0
-	   || strcmp (cs, "mac-cyrillic") == 0
-	   || strcmp (cs, "mac-centraleurroman") == 0
-	   || strcmp (cs, "adobe-fontspecific") == 0)
-    strcpy (mf, family);
+  *style = normal;
+  if (strcmp (weight, "bold") == 0)
+    *style |= bold;
+  if (*slant == 'i')
+    *style |= italic;
+
+  charset_info = Fassoc (build_string (cs), Vmac_charset_info_alist);
+  if (!NILP (charset_info))
+    {
+      strcpy (mf_decoded, family);
+      coding_system = Fcar (Fcdr (Fcdr (charset_info)));
+    }
   else
-    sprintf (mf, "%s-%s-%s", foundry, family, cs);
+    sprintf (mf_decoded, "%s-%s-%s", foundry, family, cs);
 
 #if 0
   /* MAC_TODO: Fix coding system to use objects */
@@ -6072,181 +6043,180 @@
 init_font_name_table ()
 {
 #if TARGET_API_MAC_CARBON
-  SInt32 sv;
-
-  if (Gestalt (gestaltSystemVersion, &sv) == noErr && sv >= 0x1000)
-    {
-      FMFontFamilyIterator ffi;
-      FMFontFamilyInstanceIterator ffii;
-      FMFontFamily ff;
-
-      /* Create a dummy instance iterator here to avoid creating and
-	 destroying it in the loop.  */
-      if (FMCreateFontFamilyInstanceIterator (0, &ffii) != noErr)
-	return;
-      /* Create an iterator to enumerate the font families.  */
-      if (FMCreateFontFamilyIterator (NULL, NULL, kFMDefaultOptions, &ffi)
-	  != noErr)
-	{
-	  FMDisposeFontFamilyInstanceIterator (&ffii);
-	  return;
-	}
-
-      while (FMGetNextFontFamily (&ffi, &ff) == noErr)
+  FMFontFamilyIterator ffi;
+  FMFontFamilyInstanceIterator ffii;
+  FMFontFamily ff;
+  Lisp_Object text_encoding_info_alist;
+  struct gcpro gcpro1;
+
+  /* Create a dummy instance iterator here to avoid creating and
+     destroying it in the loop.  */
+  if (FMCreateFontFamilyInstanceIterator (0, &ffii) != noErr)
+    return;
+  /* Create an iterator to enumerate the font families.  */
+  if (FMCreateFontFamilyIterator (NULL, NULL, kFMDefaultOptions, &ffi)
+      != noErr)
+    {
+      FMDisposeFontFamilyInstanceIterator (&ffii);
+      return;
+    }
+
+  text_encoding_info_alist = create_text_encoding_info_alist ();
+
+  GCPRO1 (text_encoding_info_alist);
+
+  while (FMGetNextFontFamily (&ffi, &ff) == noErr)
+    {
+      Str255 name;
+      FMFont font;
+      FMFontStyle style;
+      FMFontSize size;
+      TextEncoding encoding;
+      TextEncodingBase sc;
+      Lisp_Object text_encoding_info;
+
+      if (FMGetFontFamilyName (ff, name) != noErr)
+	break;
+      p2cstr (name);
+      if (*name == '.')
+	continue;
+
+      if (FMGetFontFamilyTextEncoding (ff, &encoding) != noErr)
+	break;
+      sc = GetTextEncodingBase (encoding);
+      text_encoding_info = assq_no_quit (make_number (sc),
+					 text_encoding_info_alist);
+      if (!NILP (text_encoding_info))
+	decode_mac_font_name (name, sizeof (name),
+			      XCAR (XCDR (text_encoding_info)));
+      else
+	text_encoding_info = assq_no_quit (make_number (kTextEncodingMacRoman),
+					   text_encoding_info_alist);
+
+      /* Point the instance iterator at the current font family.  */
+      if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr)
+	break;
+
+      while (FMGetNextFontFamilyInstance (&ffii, &font, &style, &size)
+	     == noErr)
 	{
-	  Str255 name;
-	  FMFont font;
-	  FMFontStyle style;
-	  FMFontSize size;
-	  TextEncoding encoding;
-	  TextEncodingBase sc;
-
-	  if (FMGetFontFamilyName (ff, name) != noErr)
-	    break;
-	  p2cstr (name);
-	  if (*name == '.')
-	    continue;
-
-	  if (FMGetFontFamilyTextEncoding (ff, &encoding) != noErr)
-	    break;
-	  sc = GetTextEncodingBase (encoding);
-	  decode_mac_font_name (name, sizeof (name), sc);
-
-	  /* Point the instance iterator at the current font family.  */
-	  if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr)
-	    break;
-
-	  while (FMGetNextFontFamilyInstance (&ffii, &font, &style, &size)
-		 == noErr)
+	  Lisp_Object rest = XCDR (XCDR (text_encoding_info));
+
+	  for (; !NILP (rest); rest = XCDR (rest))
 	    {
-	      /* Both jisx0208.1983-sjis and jisx0201.1976-0 parts are
-		 contained in Apple Japanese (SJIS) font.  */
-	    again:
+	      char *cs = SDATA (XCAR (rest));
+
 	      if (size == 0)
 		{
 		  add_font_name_table_entry (mac_to_x_fontname (name, size,
-								style, sc));
+								style, cs));
 		  add_font_name_table_entry (mac_to_x_fontname (name, size,
-								italic, sc));
+								italic, cs));
 		  add_font_name_table_entry (mac_to_x_fontname (name, size,
-								bold, sc));
+								bold, cs));
 		  add_font_name_table_entry (mac_to_x_fontname (name, size,
 								italic | bold,
-								sc));
+								cs));
 		}
 	      else
-		add_font_name_table_entry (mac_to_x_fontname (name, size,
-							      style, sc));
-	      if (sc == smJapanese)
 		{
-		  sc = -smJapanese;
-		  goto again;
+		  add_font_name_table_entry (mac_to_x_fontname (name, size,
+								style, cs));
 		}
-	      else if (sc == -smJapanese)
-		sc = smJapanese;
 	    }
 	}
-
-      /* Dispose of the iterators.  */
-      FMDisposeFontFamilyIterator (&ffi);
-      FMDisposeFontFamilyInstanceIterator (&ffii);
-    }
-  else
-    {
-#endif  /* TARGET_API_MAC_CARBON */
-      GrafPtr port;
-      SInt16 fontnum, old_fontnum;
-      int num_mac_fonts = CountResources('FOND');
-      int i, j;
-      Handle font_handle, font_handle_2;
-      short id, scriptcode;
-      ResType type;
-      Str32 name;
-      struct FontAssoc *fat;
-      struct AsscEntry *assc_entry;
-
-      GetPort (&port);  /* save the current font number used */
-#if TARGET_API_MAC_CARBON
-      old_fontnum = GetPortTextFont (port);
-#else
-      old_fontnum = port->txFont;
-#endif
-
-      for (i = 1; i <= num_mac_fonts; i++)  /* get all available fonts */
+    }
+
+  UNGCPRO;
+
+  /* Dispose of the iterators.  */
+  FMDisposeFontFamilyIterator (&ffi);
+  FMDisposeFontFamilyInstanceIterator (&ffii);
+#else  /* !TARGET_API_MAC_CARBON */
+  GrafPtr port;
+  SInt16 fontnum, old_fontnum;
+  int num_mac_fonts = CountResources('FOND');
+  int i, j;
+  Handle font_handle, font_handle_2;
+  short id, scriptcode;
+  ResType type;
+  Str32 name;
+  struct FontAssoc *fat;
+  struct AsscEntry *assc_entry;
+  Lisp_Object text_encoding_info_alist, text_encoding_info;
+  struct gcpro gcpro1;
+
+  GetPort (&port);  /* save the current font number used */
+  old_fontnum = port->txFont;
+
+  text_encoding_info_alist = create_text_encoding_info_alist ();
+
+  GCPRO1 (text_encoding_info_alist);
+
+  for (i = 1; i <= num_mac_fonts; i++)  /* get all available fonts */
+    {
+      font_handle = GetIndResource ('FOND', i);
+      if (!font_handle)
+	continue;
+
+      GetResInfo (font_handle, &id, &type, name);
+      GetFNum (name, &fontnum);
+      p2cstr (name);
+      if (fontnum == 0)
+	continue;
+
+      TextFont (fontnum);
+      scriptcode = FontToScript (fontnum);
+      text_encoding_info = assq_no_quit (make_number (scriptcode),
+					 text_encoding_info_alist);
+      if (!NILP (text_encoding_info))
+	decode_mac_font_name (name, sizeof (name),
+			      XCAR (XCDR (text_encoding_info)));
+      else
+	text_encoding_info = assq_no_quit (make_number (smRoman),
+					   text_encoding_info_alist);
+      do
 	{
-	  font_handle = GetIndResource ('FOND', i);
-	  if (!font_handle)
-	    continue;
-
-	  GetResInfo (font_handle, &id, &type, name);
-	  GetFNum (name, &fontnum);
-	  p2cstr (name);
-	  if (fontnum == 0)
-	    continue;
-
-	  TextFont (fontnum);
-	  scriptcode = FontToScript (fontnum);
-	  decode_mac_font_name (name, sizeof (name), scriptcode);
-	  do
+	  HLock (font_handle);
+
+	  if (GetResourceSizeOnDisk (font_handle)
+	      >= sizeof (struct FamRec))
 	    {
-	      HLock (font_handle);
-
-	      if (GetResourceSizeOnDisk (font_handle)
-		  >= sizeof (struct FamRec))
+	      fat = (struct FontAssoc *) (*font_handle
+					  + sizeof (struct FamRec));
+	      assc_entry
+		= (struct AsscEntry *) (*font_handle
+					+ sizeof (struct FamRec)
+					+ sizeof (struct FontAssoc));
+
+	      for (j = 0; j <= fat->numAssoc; j++, assc_entry++)
 		{
-		  fat = (struct FontAssoc *) (*font_handle
-					      + sizeof (struct FamRec));
-		  assc_entry
-		    = (struct AsscEntry *) (*font_handle
-					    + sizeof (struct FamRec)
-					    + sizeof (struct FontAssoc));
-
-		  for (j = 0; j <= fat->numAssoc; j++, assc_entry++)
+		  Lisp_Object rest = XCDR (XCDR (text_encoding_info));
+
+		  for (; !NILP (rest); rest = XCDR (rest))
 		    {
-		      if (font_name_table_size == 0)
-			{
-			  font_name_table_size = 16;
-			  font_name_table = (char **)
-			    xmalloc (font_name_table_size * sizeof (char *));
-			}
-		      else if (font_name_count >= font_name_table_size)
-			{
-			  font_name_table_size += 16;
-			  font_name_table = (char **)
-			    xrealloc (font_name_table,
-				      font_name_table_size * sizeof (char *));
-			}
-		      font_name_table[font_name_count++]
-			= mac_to_x_fontname (name,
-					     assc_entry->fontSize,
-					     assc_entry->fontStyle,
-					     scriptcode);
-		      /* Both jisx0208.1983-sjis and jisx0201.1976-0
-			 parts are contained in Apple Japanese (SJIS)
-			 font.  */
-		      if (smJapanese == scriptcode)
-			{
-			  font_name_table[font_name_count++]
-			    = mac_to_x_fontname (name,
-						 assc_entry->fontSize,
-						 assc_entry->fontStyle,
-						 -smJapanese);
-			}
+		      char *cs = SDATA (XCAR (rest));
+
+		      add_font_name_table_entry (mac_to_x_fontname (name,
+								    assc_entry->fontSize,
+								    assc_entry->fontStyle,
+								    cs));
 		    }
 		}
-
-	      HUnlock (font_handle);
-	      font_handle_2 = GetNextFOND (font_handle);
-	      ReleaseResource (font_handle);
-	      font_handle = font_handle_2;
 	    }
-	  while (ResError () == noErr && font_handle);
+
+	  HUnlock (font_handle);
+	  font_handle_2 = GetNextFOND (font_handle);
+	  ReleaseResource (font_handle);
+	  font_handle = font_handle_2;
 	}
-
-      TextFont (old_fontnum);
-#if TARGET_API_MAC_CARBON
-    }
-#endif  /* TARGET_API_MAC_CARBON */
+      while (ResError () == noErr && font_handle);
+    }
+
+  UNGCPRO;
+
+  TextFont (old_fontnum);
+#endif  /* !TARGET_API_MAC_CARBON */
 }
 
 
@@ -6334,7 +6304,7 @@
 	ptr++;
 	if (i == *field)
 	  {
-	    if ('1' <= *ptr && *ptr <= '9')
+	    if ('0' <= *ptr && *ptr <= '9')
 	      {
 		*val = *ptr++ - '0';
 		while ('0' <= *ptr && *ptr <= '9' && *val < 10000)
@@ -6352,21 +6322,21 @@
 
   if (i == 14 && ptr == NULL)
     {
-      if (scl_val[XLFD_SCL_POINT_SIZE] > 0)
-	{
-	  scl_val[XLFD_SCL_PIXEL_SIZE] = scl_val[XLFD_SCL_POINT_SIZE] / 10;
-	  scl_val[XLFD_SCL_AVGWIDTH] = scl_val[XLFD_SCL_POINT_SIZE];
-	}
-      else if (scl_val[XLFD_SCL_PIXEL_SIZE] > 0)
-	{
-	  scl_val[XLFD_SCL_POINT_SIZE] =
-	    scl_val[XLFD_SCL_AVGWIDTH] = scl_val[XLFD_SCL_PIXEL_SIZE] * 10;
-	}
-      else if (scl_val[XLFD_SCL_AVGWIDTH] > 0)
-	{
-	  scl_val[XLFD_SCL_PIXEL_SIZE] = scl_val[XLFD_SCL_AVGWIDTH] / 10;
-	  scl_val[XLFD_SCL_POINT_SIZE] = scl_val[XLFD_SCL_AVGWIDTH];
-	}
+      if (scl_val[XLFD_SCL_PIXEL_SIZE] < 0)
+	scl_val[XLFD_SCL_PIXEL_SIZE] =
+	  (scl_val[XLFD_SCL_POINT_SIZE] > 0 ? scl_val[XLFD_SCL_POINT_SIZE] / 10
+	   : (scl_val[XLFD_SCL_AVGWIDTH] > 0 ? scl_val[XLFD_SCL_AVGWIDTH] / 10
+	      : -1));
+      if (scl_val[XLFD_SCL_POINT_SIZE] < 0)
+	scl_val[XLFD_SCL_POINT_SIZE] =
+	  (scl_val[XLFD_SCL_PIXEL_SIZE] > 0 ? scl_val[XLFD_SCL_PIXEL_SIZE] * 10
+	   : (scl_val[XLFD_SCL_AVGWIDTH] > 0 ? scl_val[XLFD_SCL_AVGWIDTH]
+	      : -1));
+      if (scl_val[XLFD_SCL_AVGWIDTH] < 0)
+	scl_val[XLFD_SCL_AVGWIDTH] =
+	  (scl_val[XLFD_SCL_PIXEL_SIZE] > 0 ? scl_val[XLFD_SCL_PIXEL_SIZE] * 10
+	   : (scl_val[XLFD_SCL_POINT_SIZE] > 0 ? scl_val[XLFD_SCL_POINT_SIZE]
+	      : -1));
     }
   else
     scl_val[XLFD_SCL_PIXEL_SIZE] = -1;
@@ -6457,49 +6427,62 @@
   return font_list;
 }
 
-/* Return a list of at most MAXNAMES font specs matching the one in
-   PATTERN.  Cache matching fonts for patterns in
-   dpyinfo->name_list_element to avoid looking them up again by
-   calling mac_font_pattern_match (slow).  Return as many matching
-   fonts as possible if MAXNAMES = -1.  */
+/* Return a list of names of available fonts matching PATTERN on frame F.
+
+   Frame F null means we have not yet created any frame on Mac, and
+   consult the first display in x_display_list.  MAXNAMES sets a limit
+   on how many fonts to match.  */
 
 Lisp_Object
-x_list_fonts (struct frame *f,
-              Lisp_Object pattern,
-              int size,
-              int maxnames)
-{
-  Lisp_Object newlist = Qnil, tem, key;
-  struct mac_display_info *dpyinfo = f ? FRAME_MAC_DISPLAY_INFO (f) : NULL;
-
-  if (dpyinfo)
-    {
+x_list_fonts (f, pattern, size, maxnames)
+     struct frame *f;
+     Lisp_Object pattern;
+     int size, maxnames;
+{
+  Lisp_Object list = Qnil, patterns, tem, key;
+  struct mac_display_info *dpyinfo
+    = f ? FRAME_MAC_DISPLAY_INFO (f) : x_display_list;
+
+  xassert (size <= 0);
+
+  patterns = Fassoc (pattern, Valternate_fontname_alist);
+  if (NILP (patterns))
+    patterns = Fcons (pattern, Qnil);
+
+  for (; CONSP (patterns); patterns = XCDR (patterns))
+    {
+      pattern = XCAR (patterns);
+
+      if (!STRINGP (pattern))
+        continue;
+
       tem = XCAR (XCDR (dpyinfo->name_list_element));
       key = Fcons (pattern, make_number (maxnames));
 
-      newlist = Fassoc (key, tem);
-      if (!NILP (newlist))
+      list = Fassoc (key, tem);
+      if (!NILP (list))
 	{
-	  newlist = Fcdr_safe (newlist);
+	  list = Fcdr_safe (list);
+	  /* We have a cashed list.  Don't have to get the list again.  */
 	  goto label_cached;
 	}
-    }
-
-  BLOCK_INPUT;
-  newlist = mac_do_list_fonts (SDATA (pattern), maxnames);
-  UNBLOCK_INPUT;
-
-  /* MAC_TODO: add code for matching outline fonts here */
-
-  if (dpyinfo)
-    {
+
+      BLOCK_INPUT;
+      list = mac_do_list_fonts (SDATA (pattern), maxnames);
+      UNBLOCK_INPUT;
+
+      /* MAC_TODO: add code for matching outline fonts here */
+
+      /* Now store the result in the cache.  */
       XSETCAR (XCDR (dpyinfo->name_list_element),
-	       Fcons (Fcons (key, newlist),
+	       Fcons (Fcons (key, list),
 		      XCAR (XCDR (dpyinfo->name_list_element))));
-    }
- label_cached:
-
-  return newlist;
+
+    label_cached:
+      if (NILP (list)) continue; /* Try the remaining alternatives.  */
+    }
+
+  return list;
 }
 
 
@@ -6618,7 +6601,7 @@
 }
 
 
-const int kDefaultFontSize = 9;
+const int kDefaultFontSize = 12;
 
 
 /* XLoadQueryFont creates and returns an internal representation for a
@@ -6630,17 +6613,25 @@
 static MacFontStruct *
 XLoadQueryFont (Display *dpy, char *fontname)
 {
-  int i, size, is_two_byte_font, char_width;
+  int i, size, point_size, avgwidth, is_two_byte_font, char_width;
   char *name;
   GrafPtr port;
   SInt16 old_fontnum, old_fontsize;
   Style old_fontface;
-  Str32 mfontname;
+  Str32 mfontname, mfontname_decoded, charset;
   SInt16 fontnum;
-  Style fontface = normal;
+  Style fontface;
+#if TARGET_API_MAC_CARBON
+  TextEncoding encoding;
+  int scriptcode;
+#else
+  short scriptcode;
+#endif
   MacFontStruct *font;
   FontInfo the_fontinfo;
-  char s_weight[7], c_slant;
+#ifdef MAC_OSX
+  UInt32 old_flags, new_flags;
+#endif
 
   if (is_fully_specified_xlfd (fontname))
     name = fontname;
@@ -6665,46 +6656,50 @@
   old_fontface = port->txFace;
 #endif
 
-  if (sscanf (name, "-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]--%d-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%*s", &size) != 1)
+  if (sscanf (name, "-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]--%d-%d-%*[^-]-%*[^-]-%*c-%d-%*s", &size, &point_size, &avgwidth) != 3)
+    size = 0;
+  else
+    {
+      if (size == 0)
+	if (point_size > 0)
+	  size = point_size / 10;
+	else if (avgwidth > 0)
+	  size = avgwidth / 10;
+    }
+  if (size == 0)
     size = kDefaultFontSize;
 
-  if (sscanf (name, "-%*[^-]-%*[^-]-%6[^-]-%*c-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%*s", s_weight) == 1)
-    if (strcmp (s_weight, "bold") == 0)
-      fontface |= bold;
-
-  if (sscanf (name, "-%*[^-]-%*[^-]-%*[^-]-%c-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%*s", &c_slant) == 1)
-    if (c_slant == 'i')
-      fontface |= italic;
-
-  x_font_name_to_mac_font_name (name, mfontname);
+  x_font_name_to_mac_font_name (name, mfontname, mfontname_decoded,
+				&fontface, charset);
   c2pstr (mfontname);
+#if TARGET_API_MAC_CARBON
+  fontnum = FMGetFontFamilyFromName (mfontname);
+  if (fontnum == kInvalidFontFamily
+      || FMGetFontFamilyTextEncoding (fontnum, &encoding) != noErr)
+    return NULL;
+  scriptcode = GetTextEncodingBase (encoding);
+#else
   GetFNum (mfontname, &fontnum);
   if (fontnum == 0)
     return NULL;
+  scriptcode = FontToScript (fontnum);
+#endif
 
   font = (MacFontStruct *) xmalloc (sizeof (struct MacFontStruct));
 
-  font->fontname = (char *) xmalloc (strlen (name) + 1);
-  bcopy (name, font->fontname, strlen (name) + 1);
-
   font->mac_fontnum = fontnum;
   font->mac_fontsize = size;
   font->mac_fontface = fontface;
-  font->mac_scriptcode = FontToScript (fontnum);
+  font->mac_scriptcode = scriptcode;
 
   /* Apple Japanese (SJIS) font is listed as both
      "*-jisx0208.1983-sjis" (Japanese script) and "*-jisx0201.1976-0"
      (Roman script) in init_font_name_table ().  The latter should be
      treated as a one-byte font.  */
-  {
-    char cs[32];
-
-    if (sscanf (name,
-		"-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%31s",
-		cs) == 1
-	&& 0 == strcmp (cs, "jisx0201.1976-0"))
-      font->mac_scriptcode = smRoman;
-  }
+  if (scriptcode == smJapanese && strcmp (charset, "jisx0201.1976-0") == 0)
+    font->mac_scriptcode = smRoman;
+
+  font->full_name = mac_to_x_fontname (mfontname_decoded, size, fontface, charset);
 
   is_two_byte_font = font->mac_scriptcode == smJapanese ||
                      font->mac_scriptcode == smTradChinese ||
@@ -6829,7 +6824,7 @@
      struct mac_display_info *dpyinfo;
      XFontStruct *font;
 {
-  xfree (font->fontname);
+  xfree (font->full_name);
   if (font->per_char)
     xfree (font->per_char);
   xfree (font);
@@ -6869,6 +6864,8 @@
 			      SDATA (XCAR (tail)))))
 	    return (dpyinfo->font_table + i);
     }
+  else
+    return NULL;
 
   /* Load the font and add it to the table.  */
   {
@@ -6878,13 +6875,7 @@
     unsigned long value;
     int i;
 
-    /* If we have found fonts by x_list_font, load one of them.  If
-       not, we still try to load a font by the name given as FONTNAME
-       because XListFonts (called in x_list_font) of some X server has
-       a bug of not finding a font even if the font surely exists and
-       is loadable by XLoadQueryFont.  */
-    if (size > 0 && !NILP (font_names))
-      fontname = (char *) SDATA (XCAR (font_names));
+    fontname = (char *) SDATA (XCAR (font_names));
 
     BLOCK_INPUT;
     font = (MacFontStruct *) XLoadQueryFont (FRAME_MAC_DISPLAY (f), fontname);
@@ -6917,8 +6908,8 @@
     bzero (fontp, sizeof (*fontp));
     fontp->font = font;
     fontp->font_idx = i;
-    fontp->name = (char *) xmalloc (strlen (font->fontname) + 1);
-    bcopy (font->fontname, fontp->name, strlen (font->fontname) + 1);
+    fontp->name = (char *) xmalloc (strlen (fontname) + 1);
+    bcopy (fontname, fontp->name, strlen (fontname) + 1);
 
     if (font->min_bounds.width == font->max_bounds.width)
       {
@@ -6949,7 +6940,8 @@
 	  fontp->average_width = FONT_WIDTH (font);
       }
 
-    fontp->full_name = fontp->name;
+    fontp->full_name = (char *) xmalloc (strlen (font->full_name) + 1);
+    bcopy (font->full_name, fontp->full_name, strlen (font->full_name) + 1);
 
     fontp->size = font->max_bounds.width;
     fontp->height = FONT_HEIGHT (font);
@@ -7096,7 +7088,6 @@
 #include <Dialogs.h>
 #include <Script.h>
 #include <Types.h>
-#include <TextEncodingConverter.h>
 #include <Resources.h>
 
 #if __MWERKS__
@@ -7481,21 +7472,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
@@ -7506,21 +7482,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
@@ -7528,40 +7489,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
@@ -7597,7 +7524,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)
           {
@@ -7675,13 +7602,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;
@@ -7737,7 +7665,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 */
@@ -8603,13 +8531,18 @@
 	      {
 		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 0
+		if (dpyinfo->x_focus_frame == NULL)
 		  {
+		    /* Beep if wheel move occurs when all the frames
+		       are invisible.  */
 		    SysBeep(1);
 		    break;
 		  }
+#endif
 
 		GetEventParameter(eventRef, kEventParamMouseWheelDelta,
 				  typeSInt32, NULL, sizeof (SInt32),
@@ -8622,6 +8555,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);
@@ -8680,14 +8614,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
 		  {
@@ -8878,7 +8812,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
@@ -8892,7 +8880,6 @@
 	case activateEvt:
 	  {
 	    WindowPtr window_ptr = (WindowPtr) er.message;
-	    ControlRef root_control;
 
 #if USE_CARBON_EVENTS
 	    if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
@@ -8908,16 +8895,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);
@@ -8931,13 +8914,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
@@ -8978,13 +8957,16 @@
 		break;
 #endif
 
-#if TARGET_API_MAC_CARBON
-	    if (!IsValidWindowPtr (front_emacs_window ()))
+#if 0
+	    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);
@@ -8992,7 +8974,7 @@
 	      if (last_key_script != current_key_script)
 		{
 		  struct input_event event;
-		  
+
 		  EVENT_INIT (event);
 		  event.kind = LANGUAGE_CHANGE_EVENT;
 		  event.arg = Qnil;
@@ -9036,18 +9018,20 @@
 		    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;
@@ -9059,8 +9043,7 @@
 #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;
 
@@ -9073,22 +9056,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);
@@ -9105,10 +9076,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
 		{
@@ -9120,6 +9093,7 @@
 #else /* not TARGET_API_MAC_CARBON */
                 InvalRect (&(wp->portRect));
 #endif /* not TARGET_API_MAC_CARBON */
+#endif
 	    }
 	default:
 	  break;
@@ -9599,7 +9573,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);
@@ -9780,22 +9754,6 @@
   Qmac_ready_for_drag_n_drop = intern ("mac-ready-for-drag-n-drop");
   staticpro (&Qmac_ready_for_drag_n_drop);
 
-  Qbig5 = intern ("big5");
-  staticpro (&Qbig5);
-
-  Qcn_gb = intern ("cn-gb");
-  staticpro (&Qcn_gb);
-
-  Qsjis = intern ("sjis");
-  staticpro (&Qsjis);
-
-  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;
@@ -9855,10 +9813,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,
@@ -9866,6 +9820,22 @@
 The text will be rendered using Core Graphics text rendering which
 may anti-alias the text.  */);
   Vmac_use_core_graphics = Qnil;
+
+  /* Register an entry for `mac-roman' so that it can be used when
+     creating the terminal frame on Mac OS 9 before loading
+     term/mac-win.elc.  */
+  DEFVAR_LISP ("mac-charset-info-alist", &Vmac_charset_info_alist,
+               doc: /* Alist linking Emacs character sets to Mac text encoding and Emacs coding system.
+Each entry should be of the form:
+
+   (CHARSET-NAME TEXT-ENCODING CODING-SYSTEM)
+
+where CHARSET-NAME is a string used in font names to identify the
+charset, TEXT-ENCODING is a TextEncodingBase value, and CODING_SYSTEM
+is a coding system corresponding to TEXT-ENCODING.  */);
+  Vmac_charset_info_alist =
+    Fcons (list3 (build_string ("mac-roman"),
+		  make_number (smRoman), Qnil), Qnil);
 }
 
 /* arch-tag: f2259165-4454-4c04-a029-a133c8af7b5b
--- a/src/macterm.h	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/macterm.h	Thu Apr 21 05:59:53 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;
 
@@ -421,7 +421,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)
 
@@ -627,6 +627,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/sysdep.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/sysdep.c	Thu Apr 21 05:59:53 2005 +0000
@@ -3803,7 +3803,6 @@
 
 /* Functions for VMS */
 #ifdef VMS
-#include "vms-pwd.h"
 #include <acldef.h>
 #include <chpdef.h>
 #include <jpidef.h>
--- a/src/term.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/term.c	Thu Apr 21 05:59:53 2005 +0000
@@ -1476,7 +1476,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/window.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/window.c	Thu Apr 21 05:59:53 2005 +0000
@@ -286,7 +286,6 @@
   p->fringes_outside_margins = Qnil;
   p->scroll_bar_width = Qnil;
   p->vertical_scroll_bar_type = Qt;
-  p->overlay_arrow_bitmap = 0;
 
   Vwindow_list = Qnil;
   return val;
--- a/src/window.h	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/window.h	Thu Apr 21 05:59:53 2005 +0000
@@ -259,9 +259,6 @@
     /* This is handy for undrawing the cursor.  */
     int phys_cursor_ascent, phys_cursor_height;
 
-    /* Alternate overlay-arrow-bitmap in this window.  */
-    int overlay_arrow_bitmap;
-
     /* Non-zero means the cursor is currently displayed.  This can be
        set to zero by functions overpainting the cursor image.  */
     unsigned phys_cursor_on_p : 1;
--- a/src/xdisp.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/xdisp.c	Thu Apr 21 05:59:53 2005 +0000
@@ -568,12 +568,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];
 
@@ -2700,6 +2709,10 @@
   it->dpvec = NULL;
   it->current.dpvec_index = -1;
 
+  /* Use face of preceding text for ellipsis (if invisible) */
+  if (it->selective_display_ellipsis_p)
+    it->saved_face_id = it->face_id;
+
   do
     {
       handled = HANDLED_NORMALLY;
@@ -3377,8 +3390,11 @@
   it->dpvec_face_id = -1;
 
   /* Remember the current face id in case glyphs specify faces.
-     IT's face is restored in set_iterator_to_next.  */
-  it->saved_face_id = it->face_id;
+     IT's face is restored in set_iterator_to_next.
+     saved_face_id was set to preceding char's face in handle_stop.  */
+  if (it->saved_face_id < 0 || it->saved_face_id != it->face_id)
+    it->saved_face_id = it->face_id = DEFAULT_FACE_ID;
+
   it->method = GET_FROM_DISPLAY_VECTOR;
   it->ellipsis_p = 1;
 }
@@ -5514,6 +5530,8 @@
   /* Precondition.  */
   xassert (it->dpvec && it->current.dpvec_index >= 0);
 
+  it->face_id = it->saved_face_id;
+
   if (INTEGERP (*it->dpvec)
       && GLYPH_CHAR_VALID_P (XFASTINT (*it->dpvec)))
     {
@@ -7328,10 +7346,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
@@ -7356,17 +7370,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.  */
@@ -7986,7 +7989,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;
@@ -8018,6 +8021,7 @@
 
   /* Insert new message at BEG.  */
   TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
+  Ferase_buffer ();
 
   if (STRINGP (string))
     {
@@ -8235,10 +8239,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
@@ -9762,22 +9764,14 @@
 
 
 static Lisp_Object
-overlay_arrow_string_or_property (var, pbitmap)
+overlay_arrow_string_or_property (var)
      Lisp_Object var;
-     int *pbitmap;
-{
-  Lisp_Object pstr = Fget (var, Qoverlay_arrow_string);
-  Lisp_Object bitmap;
-
-  if (pbitmap)
-    {
-      *pbitmap = 0;
-      if (bitmap  = Fget (var, Qoverlay_arrow_bitmap), INTEGERP (bitmap))
-	*pbitmap = XINT (bitmap);
-    }
-
-  if (!NILP (pstr))
-    return pstr;
+{
+  Lisp_Object val;
+
+  if (val = Fget (var, Qoverlay_arrow_string), STRINGP (val))
+    return val;
+
   return Voverlay_arrow_string;
 }
 
@@ -9827,7 +9821,7 @@
 	continue;
       if (! EQ (COERCE_MARKER (val),
 		Fget (var, Qlast_arrow_position))
-	  || ! (pstr = overlay_arrow_string_or_property (var, 0),
+	  || ! (pstr = overlay_arrow_string_or_property (var),
 		EQ (pstr, Fget (var, Qlast_arrow_string))))
 	return 1;
     }
@@ -9857,7 +9851,7 @@
 	  Fput (var, Qlast_arrow_position,
 		COERCE_MARKER (val));
 	  Fput (var, Qlast_arrow_string,
-		overlay_arrow_string_or_property (var, 0));
+		overlay_arrow_string_or_property (var));
 	}
       else if (up_to_date < 0
 	       || !NILP (Fget (var, Qlast_arrow_position)))
@@ -9870,14 +9864,13 @@
 
 
 /* Return overlay arrow string to display at row.
-   Return t if display as bitmap in left fringe.
+   Return integer (bitmap number) for arrow bitmap in left fringe.
    Return nil if no overlay arrow.  */
 
 static Lisp_Object
-overlay_arrow_at_row (it, row, pbitmap)
+overlay_arrow_at_row (it, row)
      struct it *it;
      struct glyph_row *row;
-     int *pbitmap;
 {
   Lisp_Object vlist;
 
@@ -9897,17 +9890,21 @@
 	  && current_buffer == XMARKER (val)->buffer
 	  && (MATRIX_ROW_START_CHARPOS (row) == marker_position (val)))
 	{
-	  val = overlay_arrow_string_or_property (var, pbitmap);
 	  if (FRAME_WINDOW_P (it->f)
 	      && WINDOW_LEFT_FRINGE_WIDTH (it->w) > 0)
-	    return Qt;
-	  if (STRINGP (val))
-	    return val;
-	  break;
-	}
-    }
-
-  *pbitmap = 0;
+	    {
+	      if (val = Fget (var, Qoverlay_arrow_bitmap), SYMBOLP (val))
+		{
+		  int fringe_bitmap;
+		  if ((fringe_bitmap = lookup_fringe_bitmap (val)) != 0)
+		    return make_number (fringe_bitmap);
+		}
+	      return make_number (-1); /* Use default arrow bitmap */
+	    }
+	  return overlay_arrow_string_or_property (var);
+	}
+    }
+
   return Qnil;
 }
 
@@ -14954,7 +14951,6 @@
      struct it *it;
 {
   struct glyph_row *row = it->glyph_row;
-  int overlay_arrow_bitmap;
   Lisp_Object overlay_arrow_string;
 
   /* We always start displaying at hpos zero even if hscrolled.  */
@@ -15362,9 +15358,9 @@
      mark this glyph row as the one containing the overlay arrow.
      This is clearly a mess with variable size fonts.  It would be
      better to let it be displayed like cursors under X.  */
-  if ((overlay_arrow_string
-       = overlay_arrow_at_row (it, row, &overlay_arrow_bitmap),
-       !NILP (overlay_arrow_string)))
+  if ((row->displays_text_p || !overlay_arrow_seen)
+      && (overlay_arrow_string = overlay_arrow_at_row (it, row),
+	  !NILP (overlay_arrow_string)))
     {
       /* Overlay arrow in window redisplay is a fringe bitmap.  */
       if (STRINGP (overlay_arrow_string))
@@ -15394,8 +15390,8 @@
 	}
       else
 	{
-	  it->w->overlay_arrow_bitmap = overlay_arrow_bitmap;
-	  row->overlay_arrow_p = 1;
+	  xassert (INTEGERP (overlay_arrow_string));
+	  row->overlay_arrow_bitmap = XINT (overlay_arrow_string);
 	}
       overlay_arrow_seen = 1;
     }
--- a/src/xfaces.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/xfaces.c	Thu Apr 21 05:59:53 2005 +0000
@@ -3274,17 +3274,19 @@
      Lisp_Object face_name;
 {
   Lisp_Object aliased;
+  int alias_loop_max = 10;
 
   if (STRINGP (face_name))
     face_name = intern (SDATA (face_name));
 
   while (SYMBOLP (face_name))
     {
-      aliased = Fget (face_name, Qface_alias);
+      aliased = Fsafe_get (face_name, Qface_alias);
       if (NILP (aliased))
 	break;
-      else
-	face_name = aliased;
+      if (--alias_loop_max == 0)
+	break;
+      face_name = aliased;
     }
 
   return face_name;
@@ -7301,8 +7303,9 @@
      struct face_cache *cache;
      Lisp_Object *attrs;
 {
+  struct face *face = NULL;
 #ifdef HAVE_WINDOW_SYSTEM
-  struct face *face, *default_face;
+  struct face *default_face;
   struct frame *f;
   Lisp_Object stipple, overline, strike_through, box;
 
@@ -7476,9 +7479,9 @@
   stipple = attrs[LFACE_STIPPLE_INDEX];
   if (!NILP (stipple))
     face->stipple = load_pixmap (f, stipple, &face->pixmap_w, &face->pixmap_h);
+#endif /* HAVE_WINDOW_SYSTEM */
 
   return face;
-#endif /* HAVE_WINDOW_SYSTEM */
 }
 
 
--- a/src/xmenu.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/xmenu.c	Thu Apr 21 05:59:53 2005 +0000
@@ -771,7 +771,7 @@
   Lisp_Object keymap, tem;
   int xpos = 0, ypos = 0;
   Lisp_Object title;
-  char *error_name;
+  char *error_name = NULL;
   Lisp_Object selection;
   FRAME_PTR f = NULL;
   Lisp_Object x, y, window;
@@ -2483,7 +2483,7 @@
         if (FRAME_X_DISPLAY_INFO (f)->grabbed & (1 << i))
           break;
     }
-  
+
   /* Display the menu.  */
   gtk_widget_show_all (menu);
   gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i, 0);
@@ -2601,7 +2601,7 @@
   /* Display the menu.  */
   lw_popup_menu (menu, (XEvent *) &dummy);
   popup_activated_flag = 1;
-  
+
   {
     int fact = 4 * sizeof (LWLIB_ID);
     int specpdl_count = SPECPDL_INDEX ();
@@ -3225,7 +3225,7 @@
 {
   struct Lisp_Save_Value *p1 = XSAVE_VALUE (Fcar (arg));
   struct Lisp_Save_Value *p2 = XSAVE_VALUE (Fcdr (arg));
-  
+
   FRAME_PTR f = p1->pointer;
   XMenu *menu = p2->pointer;
 
@@ -3459,7 +3459,7 @@
 #ifndef MSDOS
   XMenuActivateSetWaitFunction (x_menu_wait_for_event, FRAME_X_DISPLAY (f));
 #endif
-  
+
   record_unwind_protect (pop_down_menu,
                          Fcons (make_save_value (f, 0),
                                 make_save_value (menu, 0)));
--- a/src/xrdb.c	Thu Apr 21 05:57:27 2005 +0000
+++ b/src/xrdb.c	Thu Apr 21 05:59:53 2005 +0000
@@ -53,9 +53,7 @@
 #include <X11/X.h>
 #include <X11/Xutil.h>
 #include <X11/Xresource.h>
-#ifdef VMS
-#include "vms-pwd.h"
-#else
+#ifdef HAVE_PWD_H
 #include <pwd.h>
 #endif
 #include <sys/stat.h>