changeset 83271:1830bcd0eec0

Merged from miles@gnu.org--gnu-2005 (patch 39-44, 184-191) Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-184 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-185 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-186 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-187 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-188 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-189 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-190 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-191 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-39 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-40 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-41 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-42 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-43 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-44 Merge from emacs--cvs-trunk--0 git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-311
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 19 Mar 2005 17:55:13 +0000
parents 42406ecdf5bf (current diff) 086d1f41fbb3 (diff)
children b877c1847af1
files ChangeLog admin/FOR-RELEASE etc/TODO lib-src/emacsclient.c lisp/ChangeLog lisp/bindings.el lisp/files.el lisp/font-lock.el lisp/progmodes/idlwave.el lisp/simple.el lisp/subr.el lispref/ChangeLog src/buffer.c src/coding.h src/dispnew.c src/emacs.c src/fileio.c src/frame.c src/keyboard.c src/macterm.c src/macterm.h src/process.c src/xfaces.c src/xfns.c src/xmenu.c
diffstat 82 files changed, 3280 insertions(+), 1210 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Mar 16 16:06:45 2005 +0000
+++ b/ChangeLog	Sat Mar 19 17:55:13 2005 +0000
@@ -1,3 +1,8 @@
+2005-03-16  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* configure.in <Motif>: Don't let a special LessTif/Motif1.2 install
+	shadow the main Lesstif/Motif-2.1 libs and includes.
+
 2005-03-10  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
 	* configure.in: Only add XASSERTS to cppflags.
--- a/admin/FOR-RELEASE	Wed Mar 16 16:06:45 2005 +0000
+++ b/admin/FOR-RELEASE	Sat Mar 19 17:55:13 2005 +0000
@@ -18,13 +18,6 @@
 
 * FATAL ERRORS
 
-** Investigate face cache related crash.
-
-Indications: Face cache seems to have been cleared, but
-redisplay uses an invalidated face_id with FACE_FROM_ID
-which then returns a NULL pointer.  Said to happen with
-isearch faces.
-
 ** Investigate reported crashes in compact_small_strings.
 
 ** Investigate reported crashes related to using an
@@ -73,28 +66,6 @@
 
 * REDISPLAY RELATED BUGS
 
-** Strange text scrolling with Emacs + GTK
-
-> I could reproduce the problem with the latest CVS.
->
->   % emacs -Q
->   M-x info RET
->   M->
->   C-l
->   C-x ( C-u - 1 C-v C-x )
->   C-x e e e e ...
->
-> I see the problem around "CC mode" and "Forms".
-
-It is not specific for the first line of a buffer.
-
-Rather it happens for lines which are indented but the
-indentation is controlled by a display property and
-the newline is part of that display property -- in
-that case, the indentation is not recognized for the
-first display line.
-
-
 ** Avoid unbreakable loops in redisplay.
 
 Redisplay may loop if there is an error in some display property, e.g.
@@ -104,16 +75,6 @@
 is encountered.
 
 
-** Problem with modeline and window margins:
-
-The mode line's right "box" line is misplaced under the right margin,
-rather than at the right window edge.
-
-emacs -Q
-(set-window-margins nil 25 25)
-C-x 2
-
-
 ** custom mode-line face makes Emacs freeze up
 
 From: Stephen Berman <Stephen.Berman@gmx.net>
@@ -208,12 +169,12 @@
 man/msdog.texi      Chong Yidong
 man/mule.texi       "Luc Teirlinck"
 man/m-x.texi        "Luc Teirlinck"  Chong Yidong
-man/picture.texi    Joakim Verona <joakim@verona.se>
+man/picture.texi    Joakim Verona <joakim@verona.se>   Chong Yidong
 man/programs.texi   "Stephen Eglen"  Chong Yidong
 man/regs.texi       "Luc Teirlinck"   Chong Yidong
 man/rmail.texi      Chong Yidong
-man/screen.texi     "Luc Teirlinck"  Chong Yidong
-man/search.texi     "Luc Teirlinck"
+man/screen.texi     "Luc Teirlinck"   Chong Yidong
+man/search.texi     "Luc Teirlinck"   Chong Yidong
 man/sending.texi    Chong Yidong
 man/text.texi       "Luc Teirlinck"   Chong Yidong
 man/trouble.texi    Chong Yidong
@@ -268,7 +229,7 @@
 lispref/os.texi		 "Luc Teirlinck"   Chong Yidong
 lispref/positions.texi	 "Luc Teirlinck"   Chong Yidong
 lispref/processes.texi   Chong Yidong
-lispref/searching.texi	 "Luc Teirlinck"
+lispref/searching.texi	 "Luc Teirlinck"   Chong Yidong
 lispref/sequences.texi	 "Luc Teirlinck"   Chong Yidong
 lispref/streams.texi	 "Luc Teirlinck"   Chong Yidong
 lispref/strings.texi	 "Luc Teirlinck"   Chong Yidong
--- a/configure	Wed Mar 16 16:06:45 2005 +0000
+++ b/configure	Sat Mar 19 17:55:13 2005 +0000
@@ -10680,78 +10680,6 @@
 fi
 
 if test "${USE_X_TOOLKIT}" = "MOTIF"; then
-  echo "$as_me:$LINENO: checking for LessTif where some systems put it" >&5
-echo $ECHO_N "checking for LessTif where some systems put it... $ECHO_C" >&6
-if test "${emacs_cv_lesstif+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  # We put this in CFLAGS temporarily to precede other -I options
-  # that might be in CFLAGS temporarily.
-  # We put this in CPPFLAGS where it precedes the other -I options.
-  OLD_CPPFLAGS=$CPPFLAGS
-  OLD_CFLAGS=$CFLAGS
-  CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CPPFLAGS"
-  CFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CFLAGS"
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include </usr/X11R6/LessTif/Motif1.2/include/Xm/Xm.h>
-int
-main ()
-{
-int x = 5;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  emacs_cv_lesstif=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-emacs_cv_lesstif=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $emacs_cv_lesstif" >&5
-echo "${ECHO_T}$emacs_cv_lesstif" >&6
-  if test $emacs_cv_lesstif = yes; then
-    # Make sure this -I option remains in CPPFLAGS after it is set
-    # back to REAL_CPPFLAGS.
-    # There is no need to change REAL_CFLAGS, because REAL_CFLAGS does not
-    # have those other -I options anyway.  Ultimately, having this
-    # directory ultimately in CPPFLAGS will be enough.
-    REAL_CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $REAL_CPPFLAGS"
-    LDFLAGS="-L/usr/X11R6/LessTif/Motif1.2/lib $LDFLAGS"
-  else
-    CFLAGS=$OLD_CFLAGS
-    CPPFLAGS=$OLD_CPPFLAGS
-  fi
   echo "$as_me:$LINENO: checking for Motif version 2.1" >&5
 echo $ECHO_N "checking for Motif version 2.1... $ECHO_C" >&6
 if test "${emacs_cv_motif_version_2_1+set}" = set; then
@@ -10892,6 +10820,79 @@
 _ACEOF
 
     fi
+  else
+    echo "$as_me:$LINENO: checking for LessTif where some systems put it" >&5
+echo $ECHO_N "checking for LessTif where some systems put it... $ECHO_C" >&6
+if test "${emacs_cv_lesstif+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  # We put this in CFLAGS temporarily to precede other -I options
+    # that might be in CFLAGS temporarily.
+    # We put this in CPPFLAGS where it precedes the other -I options.
+    OLD_CPPFLAGS=$CPPFLAGS
+    OLD_CFLAGS=$CFLAGS
+    CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CPPFLAGS"
+    CFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CFLAGS"
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include </usr/X11R6/LessTif/Motif1.2/include/Xm/Xm.h>
+int
+main ()
+{
+int x = 5;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  emacs_cv_lesstif=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+emacs_cv_lesstif=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $emacs_cv_lesstif" >&5
+echo "${ECHO_T}$emacs_cv_lesstif" >&6
+    if test $emacs_cv_lesstif = yes; then
+      # Make sure this -I option remains in CPPFLAGS after it is set
+      # back to REAL_CPPFLAGS.
+      # There is no need to change REAL_CFLAGS, because REAL_CFLAGS does not
+      # have those other -I options anyway.  Ultimately, having this
+      # directory ultimately in CPPFLAGS will be enough.
+      REAL_CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $REAL_CPPFLAGS"
+      LDFLAGS="-L/usr/X11R6/LessTif/Motif1.2/lib $LDFLAGS"
+    else
+      CFLAGS=$OLD_CFLAGS
+      CPPFLAGS=$OLD_CPPFLAGS
+    fi
   fi
 fi
 
--- a/configure.in	Wed Mar 16 16:06:45 2005 +0000
+++ b/configure.in	Sat Mar 19 17:55:13 2005 +0000
@@ -3,7 +3,7 @@
 dnl 	autoconf
 dnl in the directory containing this script.
 dnl
-dnl  Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2003, 2004
+dnl  Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2003, 2004, 2005
 dnl  Free Software Foundation, Inc.
 dnl
 dnl  This file is part of GNU Emacs.
@@ -2080,29 +2080,6 @@
 fi
 
 if test "${USE_X_TOOLKIT}" = "MOTIF"; then
-  AC_CACHE_CHECK(for LessTif where some systems put it, emacs_cv_lesstif,
-  # We put this in CFLAGS temporarily to precede other -I options
-  # that might be in CFLAGS temporarily.
-  # We put this in CPPFLAGS where it precedes the other -I options.
-  OLD_CPPFLAGS=$CPPFLAGS
-  OLD_CFLAGS=$CFLAGS
-  CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CPPFLAGS"
-  CFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CFLAGS"
-  [AC_TRY_COMPILE([#include </usr/X11R6/LessTif/Motif1.2/include/Xm/Xm.h>],
-    [int x = 5;],
-    emacs_cv_lesstif=yes, emacs_cv_lesstif=no)])
-  if test $emacs_cv_lesstif = yes; then
-    # Make sure this -I option remains in CPPFLAGS after it is set
-    # back to REAL_CPPFLAGS.
-    # There is no need to change REAL_CFLAGS, because REAL_CFLAGS does not
-    # have those other -I options anyway.  Ultimately, having this
-    # directory ultimately in CPPFLAGS will be enough.
-    REAL_CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $REAL_CPPFLAGS"
-    LDFLAGS="-L/usr/X11R6/LessTif/Motif1.2/lib $LDFLAGS"
-  else
-    CFLAGS=$OLD_CFLAGS
-    CPPFLAGS=$OLD_CPPFLAGS
-  fi
   AC_CACHE_CHECK(for Motif version 2.1, emacs_cv_motif_version_2_1,
   [AC_TRY_COMPILE([#include <Xm/Xm.h>],
     [#if XmVERSION > 2 || (XmVERSION == 2 && XmREVISION >= 1)
@@ -2121,6 +2098,30 @@
       AC_DEFINE(HAVE_LIBXP, 1,
 		[Define to 1 if you have the Xp library (-lXp).])
     fi
+  else
+    AC_CACHE_CHECK(for LessTif where some systems put it, emacs_cv_lesstif,
+    # We put this in CFLAGS temporarily to precede other -I options
+    # that might be in CFLAGS temporarily.
+    # We put this in CPPFLAGS where it precedes the other -I options.
+    OLD_CPPFLAGS=$CPPFLAGS
+    OLD_CFLAGS=$CFLAGS
+    CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CPPFLAGS"
+    CFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CFLAGS"
+    [AC_TRY_COMPILE([#include </usr/X11R6/LessTif/Motif1.2/include/Xm/Xm.h>],
+      [int x = 5;],
+      emacs_cv_lesstif=yes, emacs_cv_lesstif=no)])
+    if test $emacs_cv_lesstif = yes; then
+      # Make sure this -I option remains in CPPFLAGS after it is set
+      # back to REAL_CPPFLAGS.
+      # There is no need to change REAL_CFLAGS, because REAL_CFLAGS does not
+      # have those other -I options anyway.  Ultimately, having this
+      # directory ultimately in CPPFLAGS will be enough.
+      REAL_CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $REAL_CPPFLAGS"
+      LDFLAGS="-L/usr/X11R6/LessTif/Motif1.2/lib $LDFLAGS"
+    else
+      CFLAGS=$OLD_CFLAGS
+      CPPFLAGS=$OLD_CPPFLAGS
+    fi
   fi
 fi
 
--- a/etc/NEWS	Wed Mar 16 16:06:45 2005 +0000
+++ b/etc/NEWS	Sat Mar 19 17:55:13 2005 +0000
@@ -110,14 +110,23 @@
 commands cp, mv, and ln follow.)  Thus, M-x copy-file RET ~/foo RET
 /tmp RET copies ~/foo to /tmp/foo.
 
+** M-o now is the prefix key for setting text properties;
+M-o M-o requests refontification.
+
+** M-g is now a prefix key.  M-g g and M-g M-g run goto-line.
+
+** font-lock-lines-before specifies a number of lines before the
+current line that should be refontified when you change the buffer.
+The default value is 1.
+
 ** C-u M-x goto-line now switches to the most recent previous buffer,
 and goes to the specified line in that buffer.
 
 When goto-line starts to execute, if there's a number in the buffer at
 point then it acts as the default argument for the minibuffer.
 
-** Emacs now responds to mouse-clicks on the mode-line, header-line and
-display margin, when run in an xterm.
+** Emacs now responds to mouse-clicks on the mode-line, header-line
+and display margin, when run in an xterm.
 
 ** M-SPC (just-one-space) when given a numeric argument N
 converts whitespace around point to N spaces.
@@ -721,9 +730,13 @@
 with the number appended to the *info* buffer name (e.g. "*info*<2>").
 
 *** isearch in Info uses Info-search and searches through multiple nodes.
-Failed isearch wraps to the top/final node.  The user option
-`Info-isearch-search' controls whether to use Info-search or the
-default isearch search function.
+Before leaving the initial Info node isearch fails once with the error
+message [initial node], and with subsequent C-s/C-r continues through
+other nodes.  When isearch fails for the rest of the manual, it wraps
+aroung the whole manual to the top/final node.  The user option
+`Info-isearch-search' controls whether to use Info-search for isearch,
+or the default isearch search function that wraps around the current
+Info node.
 
 *** New search commands: `Info-search-case-sensitively' (bound to S),
 `Info-search-backward', and `Info-search-next' which repeats the last
@@ -2529,10 +2542,20 @@
 
 * Lisp Changes in Emacs 22.1
 
-** An element of buffer-undo-list can now have the form (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 FUNNAME
-ARGS).
++++
+** The new interactive-specification `G' reads a file name
+much like `F', but if the input is a directory name (even defaulted),
+it returns just the directory name.
+
++++
+** 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
+FUNNAME ARGS).
+
+These entries can also have the form (apply DELTA BEG END FUNNAME . ARGS)
+which indicates that the change which took place was limited to the
+range BEG...END and increased the buffer size by DELTA.
 
 +++
 ** The line-move, scroll-up, and scroll-down functions will now
@@ -12280,7 +12303,7 @@
 this feature is enabled subsequent lines in the buffer will be correctly
 refontified to reflect their new syntactic context.  Previously, only the line
 containing the deleted character would be refontified and you would have to use
-the command M-g M-g (font-lock-fontify-block) to refontify some lines.
+the command M-o M-o (font-lock-fontify-block) to refontify some lines.
 
 As a consequence of this new feature, two other variables have changed:
 
--- a/etc/TODO	Wed Mar 16 16:06:45 2005 +0000
+++ b/etc/TODO	Sat Mar 19 17:55:13 2005 +0000
@@ -65,11 +65,12 @@
 ** Make the Lucid menu widget display multilingual text.  [This
   probably needs to be done from actual Emacs buffers, either directly
   in the menu or by rendering in an unmapped window and copying the
-  pixels.  Note that the relevant Xlib functions assume a specific
-  locale; that isn't good enough even if X can render the arbitrary
-  text, which it often can't as far as I can tell.  -- fx] [The gtk
+  pixels.  The current code assumes a specific locale; that isn't good
+  enough even if X can render the arbitrary text] [The gtk
   port now displays multilingual text in menus, but only insofar as
   Emacs can encode it as utf-8 and gtk can display the result.]
+  Maybe making Lucid menus work like Gtk's (i.e. just force utf-8) is good
+  enough now that Emacs can encode most chars into utf-8.
 
 ** Remove the limitation that window and frame widths and heights can
   be only full columns/lines.
--- a/leim/ChangeLog	Wed Mar 16 16:06:45 2005 +0000
+++ b/leim/ChangeLog	Sat Mar 19 17:55:13 2005 +0000
@@ -1,3 +1,10 @@
+2005-03-18  handa  <handa@m17n.org>
+
+	* quail/thai.el (quail-thai-update-translation): Delete it.
+	(thai-generate-quail-map): Generate is simple map.
+	("thai-kesmanee"): Don't use quail-thai-update-translation.
+	(thai-generate-quail-map): Likewise.
+
 2005-03-15  Kenichi Handa  <handa@m17n.org>
 
 	* quail/thai.el (thai-generate-quail-map): Fix the kesmanee layout.
--- a/leim/quail/thai.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/leim/quail/thai.el	Sat Mar 19 17:55:13 2005 +0000
@@ -2,6 +2,9 @@
 
 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
 ;; Licensed to the Free Software Foundation.
+;; Copyright (C) 2005
+;;   National Institute of Advanced Industrial Science and Technology (AIST)
+;;   Registration Number H14PRO021
 
 ;; Keywords: multilingual, input method, Thai
 
@@ -29,46 +32,16 @@
 (require 'quail)
 (require 'thai-util)
 
-(defun quail-thai-update-translation (control-flag)
-  (if (integerp control-flag)
-      ;; Non-composable character typed.
-      (setq quail-current-str
-	    (buffer-substring (overlay-start quail-overlay)
-			      (overlay-end quail-overlay))
-	    unread-command-events
-	    (string-to-list
-	     (substring quail-current-key control-flag)))
-    (setq quail-current-str
-	  (compose-string (quail-lookup-map-and-concat quail-current-key))))
-  control-flag)
-
-(defun thai-generate-quail-map (translation-table)
-  (let ((i 0)
-	consonant vowel tone voweltone others)
-    ;; Categorize Thai characters into one of above.
-    (while (< i 128)
-      (let ((trans (aref translation-table i))
-	    ptype)
-	(if (eq trans 0)
-	    nil
-	  (if (> (length trans) 1)
-	      (setq ptype 'voweltone
-		    trans (vector (compose-string trans)))
-	    (setq ptype (get-char-code-property (aref trans 0) 'phonetic-type))
-	    (cond ((memq ptype '(vowel-upper vowel-lower))
-		   (setq ptype 'vowel))
-		  ((not (memq ptype '(consonant tone)))
-		   (setq ptype 'others))))
-	  (set ptype (cons (cons (char-to-string i) trans)
-			   (symbol-value ptype)))))
-      (setq i (1+ i)))
-
-    (quail-map-from-table
-     '((base-state (consonant . vt-state)
-		   vowel tone voweltone others)
-       (vt-state (vowel . t-state)
-		 voweltone tone)
-       (t-state tone)))))
+(defmacro thai-generate-quail-map (translation-table)
+  (let (map)
+     (dotimes (i (length translation-table))
+       (let ((trans (aref translation-table i)))
+	 (when (not (eq trans 0))
+	   (if (> (length trans) 1)
+	       (setq trans (vector trans))
+	     (setq trans (aref trans 0)))
+	   (setq map (cons (list (char-to-string i) trans) map)))))
+     `(quail-define-rules ,@map)))
 
 ;; Thai Kesmanee keyboard support.
 
@@ -80,7 +53,7 @@
     ',T_(B' and ',To(B' are assigned to '\\' and '|' respectively,
     ',T#(B' and ',T%(B' are assigned to '`' and '~' respectively,
     Don't know where to assign characters ',Tz(B' and ',T{(B'."
- nil t t t t nil nil nil 'quail-thai-update-translation nil t)
+ nil t t t t nil nil nil nil nil t)
 
 (quail-install-map
  (thai-generate-quail-map
@@ -122,7 +95,7 @@
 (quail-define-package
  "thai-pattachote" "Thai" ",T!;(B>" t
  "Thai Pattachote input method with TIS620 keyboard layout"
- nil t t t t nil nil nil 'quail-thai-update-translation nil t)
+ nil t t t t nil nil nil nil nil t)
 
 (quail-install-map
  (thai-generate-quail-map
--- a/lib-src/ChangeLog	Wed Mar 16 16:06:45 2005 +0000
+++ b/lib-src/ChangeLog	Sat Mar 19 17:55:13 2005 +0000
@@ -1,3 +1,7 @@
+2005-03-18  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* emacsclient.c: Avoid expansion of getcwd when defined as a macro.
+
 2005-03-04  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
 	* make-docfile.c: Undo previous change.
--- a/lib-src/emacsclient.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/lib-src/emacsclient.c	Sat Mar 19 17:55:13 2005 +0000
@@ -46,7 +46,7 @@
 
 
 char *getenv (), *getwd ();
-char *getcwd ();
+char *(getcwd) ();
 
 #ifndef VERSION
 #define VERSION "unspecified"
--- a/lisp/ChangeLog	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/ChangeLog	Sat Mar 19 17:55:13 2005 +0000
@@ -1,3 +1,177 @@
+2005-03-18  Tak Ota  <Takaaki.Ota@am.sony.com>
+
+	* textmodes/table.el (table--line-column-position): New idiom.
+	(table--row-column-insertion-point-p): New function to test
+	validity of row and column insertion operation at a location.
+	(table-global-menu, table-cell-menu): Use above functions for
+	deterministic test operation.
+	(table--editable-cell-p): Behave in deterministic fashion.
+
+2005-03-18  Juri Linkov  <juri@jurta.org>
+
+	* isearch.el (isearch-lazy-highlight-new-loop):
+	Make arguments beg and end optional.
+	(isearch-update): Remove optional arguments nil from
+	isearch-lazy-highlight-new-loop.
+	(isearch-lazy-highlight-search): Let-bind case-fold-search to
+	isearch-lazy-highlight-case-fold-search instead of
+	isearch-case-fold-search, and let-bind isearch-regexp to
+	isearch-lazy-highlight-regexp.
+	Use isearch-lazy-highlight-last-string instead of isearch-string.
+
+	* replace.el (perform-replace): Remove bindings of global
+	variables isearch-string, isearch-regexp, isearch-case-fold-search.
+	Add three new arguments to `replace-highlight'.
+	(replace-highlight): Add arguments string, regexp, case-fold.
+	Let-bind isearch-string, isearch-regexp, isearch-case-fold-search
+	to allow isearch-lazy-highlight-new-loop to use these values
+	to set corresponding isearch-lazy-highlight-* internal
+	variables whose values lazy highlighting will use regardless of
+	changes to global variables isearch-string, isearch-regexp,
+	isearch-case-fold-search during lazy highlighting loop.
+	(replace-dehighlight): Rename `isearch-lazy-highlight-cleanup'
+	to `lazy-highlight-cleanup'.
+
+	* textmodes/ispell.el (ispell-lazy-highlight): New defcustom.
+	(ispell-highlight-face): Set default face to `isearch' when
+	lazy highlighting is enabled.
+	(ispell-highlight-spelling-error-overlay): Set `ispell-overlay'
+	priority to 1.  Add lazy highlighting.
+	(ispell-highlight-spelling-error-xemacs): Remove obsolete arg
+	from `isearch-dehighlight'.
+
+2005-03-18  David Ponce  <david@dponce.com>
+
+	* files.el (hack-local-variables): Do a case-insensitive search
+	for End.
+
+2005-03-18  Juri Linkov  <juri@jurta.org>
+
+	* isearch.el (lazy-highlight-cleanup) <command>: Rename from
+	`isearch-lazy-highlight-cleanup', add alias to old name and
+	declare obsolete.  Add release numbers to other obsolete vars.
+	(isearch-done, isearch-lazy-highlight-new-loop):
+	Rename `isearch-lazy-highlight-cleanup' to `lazy-highlight-cleanup'.
+	(lazy-highlight-cleanup) <variable>: Doc fix.
+	(isearch-lazy-highlight-update): Rename obsolete
+	`isearch-lazy-highlight-face' to `lazy-highlight-face'.
+
+2005-03-18  Kenichi Handa  <handa@m17n.org>
+
+	* language/thai-util.el: Fix categorization of Thai characters in
+	thai-category-table.
+	(thai-composition-pattern): Adjust it for the above change.
+	(thai-self-insert-command, thai-compose-syllable): New functions.
+	(thai-compose-region): Use thai-compose-syllable.
+	(thai-compose-string): Likewise.
+	(thai-composition-function): Likewise.
+	(thai-auto-composition): New function.
+	(thai-auto-composition-mode): New minor mode.
+
+	* language/thai.el: Fix patterns to be registered in
+	composition-function-table.
+
+	* international/quail.el (quail-input-method): Locally bind
+	inhibit-modification-hooks to t.
+
+2005-03-17  Richard M. Stallman  <rms@gnu.org>
+
+	* progmodes/perl-mode.el (perl-mode-hook): Defvar it.
+	(perl-mode): Use run-mode-hooks.
+
+	* mail/rmail.el (rmail-movemail-program, rmail-pop-password)
+	(rmail-pop-password-required, rmail-remote-password): Doc fixes.
+	(rmail-preserve-inbox, rmail-probe, rmail-autodetect): Doc fix.
+
+	* mail/sendmail.el (sendmail-send-it): Reenable the code
+	to compute resend-to-address and use it.
+
+	* tar-mode.el (tar-mode): Turn off undo unconditionally.
+
+	* image-mode.el: New file.
+
+	* image.el (insert-sliced-image): Add autoload cookie.
+
+	* font-lock.el (font-lock-lines-before): New user option.
+	(font-lock-after-change-function): Obey it.
+
+	* bindings.el (esc-map): Make M-g a prefix.
+	Bind M-g g and M-g M-g to goto-line.
+
+	* faces.el (face-id): Doc fix.
+
+2005-03-17  Frederik Fouvry  <fouvry@CoLi.Uni-SB.DE>
+
+	* mail/rmail.el (rmail-unknown-mail-followup-to): New function.
+	(rmail-show-message): Use rmail-unknown-mail-followup-to.
+	(rmail-reply): Recognize Mail-Followup-To and Mail-Reply-To headers.
+
+	* mail/sendmail.el (mail-yank-ignored-headers)
+	(mail-font-lock-keywords, mail-mode-fill-paragraph):
+	Add Mail-Followup-To and Mail-Reply-To headers.
+	(mail-citation-hook): Add autoload cookie.
+	(mail-mode): Doc fix.
+	(mail-mode-map): Bind mail-mail-followup-to and mail-mail-reply-to.
+	(mail-send): Compute Mail-Followup-To and Mail-Reply-To headers.
+	(mail-mode-fill-paragraph): Handle those headers.
+	(mail-mailing-lists): New variable.
+	(mail-mail-reply-to, mail-mail-followup-to): New functions.
+
+2005-03-17  Juri Linkov  <juri@jurta.org>
+
+	* isearch.el (isearch-fallback): Check for `(car previous)'
+	before calling `isearch-other-end-state'.
+
+2005-03-17  Kim F. Storm  <storm@cua.dk>
+
+	* simple.el (move-beginning-of-line): Move to beginning of buffer
+	line, as well as beginning of screen line.
+
+2005-03-16  Glenn Morris  <gmorris@ast.cam.ac.uk>
+
+	* calendar/diary-lib.el (mark-diary-entries): Use new optional
+	argument REDRAW rather than calendar-redrawing variable.
+	* calendar/calendar.el (calendar-redrawing): Delete.
+	(redraw-calendar): Do not bind calendar-redrawing.
+
+2005-03-16  Matt Hodges  <MPHodges@member.fsf.org>
+
+	* calendar/diary-lib.el (diary-redraw-calendar): Preserve point in
+	diary-file buffer.
+
+2005-03-16  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* help.el (describe-mode): Allow a :minor-mode-function property to
+	specify a different minor mode toggle function than the variable.
+	* simple.el (auto-fill-function):
+	* subr.el (add-minor-mode): Use it.
+
+2005-03-16  Kenichi Handa  <handa@m17n.org>
+
+	* language/ethio-util.el (sera-being-called-by-w3): New variable.
+	(ethio-sera-to-fidel-ethio): Check also sera-being-called-by-w3.
+	(ethio-fidel-to-sera-buffer): Likewise.
+
+2005-03-16  Juri Linkov  <juri@jurta.org>
+
+	* emacs-lisp/find-func.el (find-function-regexp):
+	Add defun-emitting macro `menu-bar-make-toggle'.
+
+	* isearch.el: Put `isearch-scroll' property to
+	`split-window-horizontally'.
+
+	* info.el: Update error messages for `debug-ignored-errors'.
+	(Info-isearch-search): Doc fix.
+	(Info-find-node): Move up code to go into info buffer before
+	recording the node to the history.
+	(Info-fontify-node): Fontify titles only if the next line
+	has two or more `*', `=', `-', `.'.
+	Display "go to this node" for empty (match-string 3).
+
+2005-03-16  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* term/mac-win.el: Add mouse pointer shape constants.
+
 2005-03-15  Kim F. Storm  <storm@cua.dk>
 
 	* simple.el (move-beginning-of-line): Use vertical-motion.
@@ -6,7 +180,7 @@
 
 	* isearch.el (isearch-error): New variable.
 	(isearch-invalid-regexp, isearch-within-brackets): Remove.
-	(isearch-error-state): Renamed from `isearch-invalid-regexp-state'.
+	(isearch-error-state): Rename from `isearch-invalid-regexp-state'.
 	(isearch-within-brackets-state): Remove.
 	(isearch-case-fold-search-state, isearch-pop-fun-state):
 	Decrease frame index.
@@ -47,7 +221,7 @@
 	* international/mule-cmds.el (locale-language-names): Modify the
 	format of elements and add more entries.
 	(locale-preferred-coding-systems): Add more entries.
-	(set-locale-environment): Adjusted for the change of
+	(set-locale-environment): Adjust for the change of
 	locale-language-names.
 
 2005-03-14  Stefan Monnier  <monnier@iro.umontreal.ca>
@@ -121,7 +295,7 @@
 2005-03-11  Kenichi Handa  <handa@m17n.org>
 
 	* international/mule.el (make-coding-system): Set property
-	'coding-system-define-form to nil.
+	coding-system-define-form to nil.
 	(define-coding-system-alias): Likewise.
 
 2005-03-11  Kenichi Handa  <handa@m17n.org>
--- a/lisp/bindings.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/bindings.el	Sat Mar 19 17:55:13 2005 +0000
@@ -705,7 +705,9 @@
 (define-key ctl-x-map "\C-n" 'set-goal-column)
 (define-key global-map "\C-a" 'move-beginning-of-line)
 (define-key global-map "\C-e" 'move-end-of-line)
-(define-key esc-map "g" 'goto-line)
+(define-key esc-map "g" (make-sparse-keymap))
+(define-key esc-map "g\M-g" 'goto-line)
+(define-key esc-map "gg" 'goto-line)
 
 ;;(defun function-key-error ()
 ;;  (interactive)
--- a/lisp/calendar/calendar.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/calendar/calendar.el	Sat Mar 19 17:55:13 2005 +0000
@@ -2150,16 +2150,12 @@
 	  (forward-line 1))))
   t)
 
-(defvar calendar-redrawing nil
-  "Internal calendar variable, non-nil if inside redraw-calendar.")
-
 (defun redraw-calendar ()
   "Redraw the calendar display, if `calendar-buffer' is live."
   (interactive)
   (if (get-buffer calendar-buffer)
       (with-current-buffer calendar-buffer
-        (let ((cursor-date (calendar-cursor-to-nearest-date))
-              (calendar-redrawing t))
+        (let ((cursor-date (calendar-cursor-to-nearest-date)))
           (generate-calendar-window displayed-month displayed-year)
           (calendar-cursor-to-visible-date cursor-date)))))
 
--- a/lisp/calendar/diary-lib.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/calendar/diary-lib.el	Sat Mar 19 17:55:13 2005 +0000
@@ -835,21 +835,23 @@
 (defvar marking-diary-entry nil
   "True during the marking of diary entries, if current entry is marking.")
 
-(defun mark-diary-entries ()
+(defun mark-diary-entries (&optional redraw)
   "Mark days in the calendar window that have diary entries.
-Each entry in the diary file visible in the calendar window is marked.
-After the entries are marked, the hooks `nongregorian-diary-marking-hook' and
-`mark-diary-entries-hook' are run."
-  (interactive)
-  ;; To remove any deleted diary entries.
-  (when (and mark-diary-entries-in-calendar
-             ;; Avoid redrawing when called recursively, eg through
-             ;; mark-diary-entries-hook for #include's, else only get
-             ;; the last set of diary marks.
-             (not marking-diary-entries)
-             ;; If called from redraw-calendar, the calendar has been
-             ;; erased, so no need to unmark the diary entries.
-             (not calendar-redrawing))
+Each entry in the diary file visible in the calendar window is
+marked.  After the entries are marked, the hooks
+`nongregorian-diary-marking-hook' and `mark-diary-entries-hook'
+are run.  If the optional argument REDRAW is non-nil (which is
+the case interactively, for example) then any existing diary
+marks are first removed. This is intended to deal with deleted
+diary entries."
+  (interactive "p")
+  ;; To remove any deleted diary entries. Do not redraw when:
+  ;; i) processing #include diary files (else only get the marks from
+  ;; the last #include file processed).
+  ;; ii) called via calendar-redraw (since calendar has already been
+  ;; erased).
+  ;; Use of REDRAW handles both of these cases.
+  (when (and redraw mark-diary-entries-in-calendar)
     (setq mark-diary-entries-in-calendar nil)
     (redraw-calendar))
   (let ((marking-diary-entries t)
@@ -1661,7 +1663,8 @@
 (defun diary-redraw-calendar ()
   "If `calendar-buffer' is live and diary entries are marked, redraw it."
   (and mark-diary-entries-in-calendar
-       (redraw-calendar))
+       (save-excursion
+         (redraw-calendar)))
   ;; Return value suitable for `write-contents-functions'.
   nil)
 
--- a/lisp/emacs-lisp/find-func.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/emacs-lisp/find-func.el	Sat Mar 19 17:55:13 2005 +0000
@@ -63,7 +63,8 @@
   (concat
    "^\\s-*(\\(def\\(ine-skeleton\\|ine-generic-mode\\|ine-derived-mode\\|\
 ine-minor-mode\\|un-cvs-mode\\|foo\\|[^cfgv]\\w+\\*?\\)\
-\\|easy-mmode-define-global-mode\\)" find-function-space-re
+\\|easy-mmode-define-global-mode\\|menu-bar-make-toggle\\)"
+   find-function-space-re
    "\\('\\|\(quote \\)?%s\\(\\s-\\|$\\|\(\\|\)\\)")
   "The regexp used by `find-function' to search for a function definition.
 Note it must contain a `%s' at the place where `format'
--- a/lisp/files.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/files.el	Sat Mar 19 17:55:13 2005 +0000
@@ -2247,10 +2247,11 @@
 		endpos
 		(thisbuf (current-buffer)))
 	    (save-excursion
-	      (if (not (re-search-forward
-			(concat prefix "[ \t]*End:[ \t]*" suffix)
-			nil t))
-		  (error "Local variables list is not properly terminated"))
+	      (unless (let ((case-fold-search t))
+			(re-search-forward
+			 (concat prefix "[ \t]*End:[ \t]*" suffix)
+			 nil t))
+		(error "Local variables list is not properly terminated"))
 	      (beginning-of-line)
 	      (setq endpos (point)))
 
--- a/lisp/font-lock.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/font-lock.el	Sat Mar 19 17:55:13 2005 +0000
@@ -292,6 +292,12 @@
 		 (other :tag "always" t)
 		 (integer :tag "size"))
   :group 'font-lock)
+
+(defcustom font-lock-lines-before 1
+  "*Number of lines before the changed text to include in refontification."
+  :type 'integer
+  :group 'font-lock
+  :version "22.1")
 
 
 ;; Originally these variable values were face names such as `bold' etc.
@@ -1062,7 +1068,8 @@
       (save-match-data
 	;; Rescan between start of lines enclosing the region.
 	(font-lock-fontify-region
-	 (progn (goto-char beg) (beginning-of-line) (point))
+	 (progn (goto-char beg)
+		(forward-line (- font-lock-lines-before)) (point))
 	 (progn (goto-char end) (forward-line 1) (point)))))))
 
 (defun font-lock-fontify-block (&optional arg)
--- a/lisp/gnus/ChangeLog	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/gnus/ChangeLog	Sat Mar 19 17:55:13 2005 +0000
@@ -1,3 +1,42 @@
+2005-03-16  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* nnimap.el (nnimap-open-connection): Print which authinfo file is
+	used.
+
+	* nneething.el (nneething-map-file-directory): Derive from
+	`gnus-directory'.
+
+	* gnus-art.el (gnus-header-button-alist): Use `gnus-msg-mail' for
+	the To/Cc button.
+
+2005-03-15  Reiner Steib  <Reiner.Steib@gmx.de>
+
+	* nnmaildir.el (nnmaildir-request-accept-article): Use
+	`nnheader-cancel-timer' for compatibility with current XEmacs.
+
+2005-03-13  Steve Youngs  <steve@sxemacs.org>
+
+	* gnus.el: Don't try and mark `gnus-agent-save-groups' as an
+	autoloaded function.
+	From: Andrey Slusar <anrays@gmail.com>.
+
+2005-03-13  Steve Youngs  <steve@sxemacs.org>
+
+	* mm-url.el: Require timer-funcs at compile time when in XEmacs
+	for `with-timeout'.
+
+	* mail-source.el: Require timer-funcs at compile time when in
+	XEmacs for `run-with-idle-timer'.  
+
+	* gnus-async.el: Ditto.
+
+	* dgnushack.el: No need to ignore `run-with-idle-timer', XEmacs
+	has this function now. 
+
+2005-03-16  Lute Kamstra  <lute@gnu.org>
+
+	* message.el (message-make-date): Require parse-time.
+
 2005-03-10  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* nnimap.el (nnimap-retrieve-headers-from-server): Fix last change.
--- a/lisp/gnus/gnus-art.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/gnus/gnus-art.el	Sat Mar 19 17:55:13 2005 +0000
@@ -6336,7 +6336,7 @@
     ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
      1 (>= gnus-button-message-level 0) gnus-button-reply 1)
     ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
-     0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
+     0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
     ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
      0 (>= gnus-button-browse-level 0) browse-url 0)
     ("^Subject:" gnus-button-url-regexp
--- a/lisp/gnus/gnus-async.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/gnus/gnus-async.el	Sat Mar 19 17:55:13 2005 +0000
@@ -32,6 +32,10 @@
 (require 'gnus-sum)
 (require 'nntp)
 
+(eval-when-compile
+  (when (featurep 'xemacs)
+    (require 'timer-funcs)))
+
 (defgroup gnus-asynchronous nil
   "Support for asynchronous operations."
   :group 'gnus)
--- a/lisp/gnus/gnus.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/gnus/gnus.el	Sat Mar 19 17:55:13 2005 +0000
@@ -2726,7 +2726,7 @@
       gnus-async-prefetch-article gnus-async-prefetch-remove-group
       gnus-async-halt-prefetch)
      ("gnus-agent" gnus-open-agent gnus-agent-get-function
-      gnus-agent-save-groups gnus-agent-save-active gnus-agent-method-p
+      gnus-agent-save-active gnus-agent-method-p
       gnus-agent-get-undownloaded-list gnus-agent-fetch-session
       gnus-summary-set-agent-mark gnus-agent-save-group-info
       gnus-agent-request-article gnus-agent-retrieve-headers)
--- a/lisp/gnus/mail-source.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/gnus/mail-source.el	Sat Mar 19 17:55:13 2005 +0000
@@ -862,7 +862,7 @@
 
 (eval-when-compile
   (if (featurep 'xemacs)
-      (require 'itimer)
+      (require 'timer-funcs)
     (require 'timer)))
 
 (defun mail-source-start-idle-timer ()
--- a/lisp/gnus/message.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/gnus/message.el	Sat Mar 19 17:55:13 2005 +0000
@@ -4567,6 +4567,7 @@
 (defun message-make-date (&optional now)
   "Make a valid data header.
 If NOW, use that time instead."
+  (require 'parse-time)
   (let* ((now (or now (current-time)))
 	 (zone (nth 8 (decode-time now)))
 	 (sign "+"))
--- a/lisp/gnus/mm-url.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/gnus/mm-url.el	Sat Mar 19 17:55:13 2005 +0000
@@ -38,7 +38,9 @@
   (autoload 'executable-find "executable"))
 
 (eval-when-compile
-  (require 'timer))
+  (if (featurep 'xemacs)
+      (require 'timer-funcs)
+    (require 'timer)))
 
 (defgroup mm-url nil
   "A wrapper of url package and external url command for Gnus."
--- a/lisp/gnus/nneething.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/gnus/nneething.el	Sat Mar 19 17:55:13 2005 +0000
@@ -37,7 +37,8 @@
 
 (nnoo-declare nneething)
 
-(defvoo nneething-map-file-directory "~/.nneething/"
+(defvoo nneething-map-file-directory
+  (nnheader-concat gnus-directory ".nneething/")
   "Where nneething stores the map files.")
 
 (defvoo nneething-map-file ".nneething"
--- a/lisp/gnus/nnimap.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/gnus/nnimap.el	Sat Mar 19 17:55:13 2005 +0000
@@ -728,7 +728,9 @@
 		(imap-capability 'IMAP4rev1 nnimap-server-buffer))
       (imap-close nnimap-server-buffer)
       (nnheader-report 'nnimap "Server %s is not IMAP4 compliant" server))
-    (let* ((list (gnus-parse-netrc nnimap-authinfo-file))
+    (let* ((list (progn (gnus-message 7 "Parsing authinfo file `%s'."
+				      nnimap-authinfo-file)
+			(gnus-parse-netrc nnimap-authinfo-file)))
 	   (port (if nnimap-server-port
 		     (int-to-string nnimap-server-port)
 		   "imap"))
--- a/lisp/gnus/nnmaildir.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/gnus/nnmaildir.el	Sat Mar 19 17:55:13 2005 +0000
@@ -1344,7 +1344,7 @@
 	 (write-region (point-min) (point-max) tmpfile nil 'no-message nil
 		       'excl)
 	 (unix-sync))) ;; no fsync :(
-      (cancel-timer 24h)
+      (nnheader-cancel-timer 24h)
       (condition-case err
 	  (add-name-to-file tmpfile curfile)
 	(error
--- a/lisp/help.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/help.el	Sat Mar 19 17:55:13 2005 +0000
@@ -703,32 +703,29 @@
 	(dolist (mode minor-mode-list)
 	  ;; Document a minor mode if it is listed in minor-mode-alist,
 	  ;; non-nil, and has a function definition.
-	  (and (boundp mode) (symbol-value mode)
-	       (fboundp mode)
-	       (let ((pretty-minor-mode mode))
-		 (if (string-match "\\(-minor\\)?-mode\\'"
-				   (symbol-name mode))
-		     (setq pretty-minor-mode
-			   (capitalize
-			    (substring (symbol-name mode)
-				       0 (match-beginning 0)))))
-		 (push (list pretty-minor-mode mode
-			     (format-mode-line (assq mode minor-mode-alist)))
-		       minor-modes))))
-	(if auto-fill-function
-	    ;; copy pure string so we can add face property to it below.
-	    (push (list (copy-sequence "Auto Fill") 'auto-fill-mode " Fill")
-		  minor-modes))
+	  (let ((fmode (or (get mode :minor-mode-function) mode)))
+	    (and (boundp mode) (symbol-value mode)
+		 (fboundp fmode)
+		 (let ((pretty-minor-mode
+			(if (string-match "\\(\\(-minor\\)?-mode\\)?\\'"
+					  (symbol-name fmode))
+			    (capitalize
+			     (substring (symbol-name fmode)
+					0 (match-beginning 0)))
+			  fmode)))
+		   (push (list fmode pretty-minor-mode
+			       (format-mode-line (assq mode minor-mode-alist)))
+			 minor-modes)))))
 	(setq minor-modes
 	      (sort minor-modes
-		    (lambda (a b) (string-lessp (car a) (car b)))))
+		    (lambda (a b) (string-lessp (cadr a) (cadr b)))))
 	(when minor-modes
 	  (princ "Summary of minor modes:\n")
 	  (make-local-variable 'help-button-cache)
 	  (with-current-buffer standard-output
 	    (dolist (mode minor-modes)
-	      (let ((pretty-minor-mode (nth 0 mode))
-		    (mode-function (nth 1 mode))
+	      (let ((mode-function (nth 0 mode))
+		    (pretty-minor-mode (nth 1 mode))
 		    (indicator (nth 2 mode)))
 		(setq indicator (if (zerop (length indicator))
 				    "no indicator"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/image-mode.el	Sat Mar 19 17:55:13 2005 +0000
@@ -0,0 +1,113 @@
+;;; image-mode.el --- support for visiting image files
+;;
+;; Copyright (C) 2005 Free Software Foundation, Inc.
+;;
+;; Author: Richard Stallman <rms@gnu.org>
+;; Keywords: multimedia
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; Defines a major mode for visiting image files
+;; that allows conversion between viewing the text of the file
+;; and viewing the file as an image.  Viewing the image
+;; works by putting a `display' text-property on the
+;; image data, with the image-data still present underneath; if the
+;; resulting buffer file is saved to another name it will correctly save
+;; the image data to the new file.
+
+;;; Code:
+
+(require 'image)
+
+;;;###autoload (push '("\\.jpg\\'" . image-mode) auto-mode-alist)
+;;;###autoload (push '("\\.jpeg\\'" . image-mode) auto-mode-alist)
+;;;###autoload (push '("\\.gif\\'" . image-mode) auto-mode-alist)
+;;;###autoload (push '("\\.png\\'" . image-mode) auto-mode-alist)
+;;;###autoload (push '("\\.tiff\\'" . image-mode) auto-mode-alist)
+;;;###autoload (push '("\\.tif\\'" . image-mode) auto-mode-alist)
+;;;###autoload (push '("\\.xbm\\'" . image-mode) auto-mode-alist)
+;;;###autoload (push '("\\.pbm\\'" . image-mode) auto-mode-alist)
+;;;###autoload (push '("\\.pgm\\'" . image-mode) auto-mode-alist)
+;;;###autoload (push '("\\.ppm\\'" . image-mode) auto-mode-alist)
+;;;###autoload (push '("\\.pnm\\'" . image-mode) auto-mode-alist)
+
+(defvar image-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\C-c\C-c" 'image-toggle-display)
+    map)
+  "Major mode keymap for Image mode.")
+
+;;;###autoload
+(defun image-mode ()
+  "Major mode for image files.
+You can use \\<image-mode-map>\\[image-toggle-display]
+to toggle between display as an image and display as text."
+  (interactive)
+  (kill-all-local-variables)
+  (setq mode-name "Image")
+  (setq major-mode 'image-mode)
+  (use-local-map image-mode-map)
+  (run-mode-hooks 'image-mode-hook)
+  (message (substitute-command-keys
+	    "Type \\[image-toggle-display] to view the image as an image.")))
+
+(defun image-toggle-display ()
+  "Start or stop displaying an image file as the actual image.
+This command toggles between showing the text of the image file
+and showing the image as an image."
+  (interactive)
+  (if (get-text-property (point-min) 'display)
+      (let ((inhibit-read-only t)
+	    (buffer-undo-list t))
+	(remove-list-of-text-properties (point-min) (point-max)
+					'(display intangible read-nonsticky
+						  read-only front-sticky))
+	(kill-local-variable 'cursor-type)
+	(kill-local-variable 'truncate-lines)
+	(message "Repeat this command to go back to displaying the image"))
+    ;; Turn the image data into a real image, but only if the whole file
+    ;; was inserted
+    (let* ((data
+	    (string-make-unibyte
+	     (buffer-substring-no-properties (point-min) (point-max))))
+	   (image
+	    (create-image data nil t))
+	   (props
+	    `(display ,image
+		      intangible ,image
+		      rear-nonsticky (display intangible)
+		      ;; This a cheap attempt to make the whole buffer
+		      ;; read-only when we're visiting the file (as
+		      ;; opposed to just inserting it).
+		      read-only t front-sticky (read-only)))
+	   (buffer-undo-list t))
+      (add-text-properties (point-min) (point-max) props)
+      ;; Inhibit the cursor when the buffer contains only an image,
+      ;; because cursors look very strange on top of images.
+      (setq cursor-type nil)
+      ;; This just makes the arrow displayed in the right fringe
+      ;; area look correct when the image is wider than the window.
+      (setq truncate-lines t)
+      (message "Repeat this command to go back to displaying the file as text"))))
+
+(provide 'image-mode)
+
+;; arch-tag: b5b2b7e6-26a7-4b79-96e3-1546b5c4c6cb
+;;; image-mode.el ends here
--- a/lisp/image.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/image.el	Sat Mar 19 17:55:13 2005 +0000
@@ -227,6 +227,7 @@
 				      image) rear-nonsticky (display)))))
 
 
+;;;###autoload
 (defun insert-sliced-image (image &optional string area rows cols)
   "Insert IMAGE into current buffer at point.
 IMAGE is displayed by inserting STRING into the current buffer
--- a/lisp/info.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/info.el	Sat Mar 19 17:55:13 2005 +0000
@@ -202,10 +202,17 @@
   :group 'info)
 
 (defcustom Info-isearch-search t
-  "*If non-nil, isearch invoked in Info mode uses `Info-search' function.
-This allows isearch to search through multiple nodes.
-When isearch fails, it wraps and restarts the search from the
-top/final node depending on search direction."
+  "*If non-nil, isearch in Info searches through multiple nodes.
+Before leaving the initial Info node, where isearch was started,
+it fails once with the error message [initial node], and with
+subsequent C-s/C-r continues through other nodes without failing
+with this error message in other nodes.  When isearch fails for
+the rest of the manual, it wraps aroung the whole manual and
+restarts the search from the top/final node depending on
+search direction.
+
+Setting this option to nil restores the default isearch behavior
+with wrapping around the current Info node."
   :version "22.1"
   :type 'boolean
   :group 'info)
@@ -625,13 +632,13 @@
 it says do not attempt further (recursive) error recovery."
   (info-initialize)
   (setq filename (Info-find-file filename))
+  ;; Go into info buffer.
+  (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
   ;; Record the node we are leaving.
   (if (and Info-current-file (not no-going-back))
       (setq Info-history
             (cons (list Info-current-file Info-current-node (point))
                   Info-history)))
-  ;; Go into info buffer.
-  (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
   (Info-find-node-2 filename nodename no-going-back))
 
 (defun Info-on-current-buffer (&optional nodename)
@@ -3616,7 +3623,7 @@
       ;; Fontify titles
       (goto-char (point-min))
       (when not-fontified-p
-        (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\|\\.+\\)$"
+        (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*\\*+\\|==+\\|--+\\|\\.\\.+\\)$"
                                   nil t)
           (let* ((c (preceding-char))
                  (face
@@ -3793,7 +3800,8 @@
               (add-text-properties
                (match-beginning 1) (match-end 1)
                (list
-                'help-echo (if (match-end 3)
+                'help-echo (if (and (match-end 3)
+                                    (not (equal (match-string 3) "")))
                                (concat "mouse-2: go to " (match-string 3))
                              "mouse-2: go to this node")
                 'mouse-face 'highlight)))
@@ -4071,12 +4079,24 @@
   (Info-speedbar-hierarchy-buttons nil 0)
   )
 
-(dolist (mess '("^Node has no Previous$"
+(dolist (mess '("^First node in file$"
+		"^No `.*' in index$"
+		"^No cross-reference named"
+		"^No cross.references in this node$"
+		"^No current info node$"
 		"^No menu in this node$"
-		"^Node has no Next$"
-                "^No cross-references in this node^"
-                search-failed
-		"^No \".*\" in index$"))
+		"^No more items in menu$"
+		"^No more nodes$"
+		"^No pointer \\(?:forward\\|backward\\) from this node$"
+		"^No previous `i' command$"
+		"^No previous items in menu$"
+		"^No previous nodes$"
+		"^No such item in menu$"
+		"^No such node or anchor"
+		"^Node has no"
+		"^Point neither on reference nor in menu item description$"
+		"^This is the \\(?:first\\|last\\) Info node you looked at$"
+		search-failed))
   (add-to-list 'debug-ignored-errors mess))
 
 ;;;;  Desktop support
--- a/lisp/international/quail.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/international/quail.el	Sat Mar 19 17:55:13 2005 +0000
@@ -3,6 +3,9 @@
 ;; Copyright (C) 1995, 2000 Electrotechnical Laboratory, JAPAN.
 ;; Licensed to the Free Software Foundation.
 ;; Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+;; Copyright (C) 2005
+;;   National Institute of Advanced Industrial Science and Technology (AIST)
+;;   Registration Number H14PRO021
 
 ;; Author: Kenichi HANDA <handa@etl.go.jp>
 ;;	   Naoto TAKAHASHI <ntakahas@etl.go.jp>
@@ -1312,7 +1315,8 @@
       (list key)
     (quail-setup-overlays (quail-conversion-keymap))
     (let ((modified-p (buffer-modified-p))
-	  (buffer-undo-list t))
+	  (buffer-undo-list t)
+	  (inhibit-modification-hooks t))
       (unwind-protect
 	  (let ((input-string (if (quail-conversion-keymap)
 				  (quail-start-conversion key)
--- a/lisp/isearch.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/isearch.el	Sat Mar 19 17:55:13 2005 +0000
@@ -238,25 +238,25 @@
 (defcustom lazy-highlight-cleanup t
   "*Controls whether to remove extra highlighting after a search.
 If this is nil, extra highlighting can be \"manually\" removed with
-\\[isearch-lazy-highlight-cleanup]."
+\\[lazy-highlight-cleanup]."
   :type 'boolean
   :group 'lazy-highlight)
 (defvaralias 'isearch-lazy-highlight-cleanup 'lazy-highlight-cleanup)
-(make-obsolete-variable 'isearch-lazy-highlight-cleanup 'lazy-highlight-cleanup)
+(make-obsolete-variable 'isearch-lazy-highlight-cleanup 'lazy-highlight-cleanup "22.1")
 
 (defcustom lazy-highlight-initial-delay 0.25
   "*Seconds to wait before beginning to lazily highlight all matches."
   :type 'number
   :group 'lazy-highlight)
 (defvaralias 'isearch-lazy-highlight-initial-delay 'lazy-highlight-initial-delay)
-(make-obsolete-variable 'isearch-lazy-highlight-initial-delay 'lazy-highlight-initial-delay)
+(make-obsolete-variable 'isearch-lazy-highlight-initial-delay 'lazy-highlight-initial-delay "22.1")
 
 (defcustom lazy-highlight-interval 0 ; 0.0625
   "*Seconds between lazily highlighting successive matches."
   :type 'number
   :group 'lazy-highlight)
 (defvaralias 'isearch-lazy-highlight-interval 'lazy-highlight-interval)
-(make-obsolete-variable 'isearch-lazy-highlight-interval 'lazy-highlight-interval)
+(make-obsolete-variable 'isearch-lazy-highlight-interval 'lazy-highlight-interval "22.1")
 
 (defcustom lazy-highlight-max-at-a-time 20
   "*Maximum matches to highlight at a time (for `lazy-highlight').
@@ -267,7 +267,7 @@
 		 (integer :tag "Some"))
   :group 'lazy-highlight)
 (defvaralias 'isearch-lazy-highlight-max-at-a-time 'lazy-highlight-max-at-a-time)
-(make-obsolete-variable 'isearch-lazy-highlight-max-at-a-time 'lazy-highlight-max-at-a-time)
+(make-obsolete-variable 'isearch-lazy-highlight-max-at-a-time 'lazy-highlight-max-at-a-time "22.1")
 
 (defface lazy-highlight
   '((((class color) (min-colors 88) (background light))
@@ -284,7 +284,7 @@
 (put 'isearch-lazy-highlight-face 'face-alias 'lazy-highlight)
 (defvar lazy-highlight-face 'lazy-highlight)
 (defvaralias 'isearch-lazy-highlight-face 'lazy-highlight-face)
-(make-obsolete-variable 'isearch-lazy-highlight-face 'lazy-highlight-face)
+(make-obsolete-variable 'isearch-lazy-highlight-face 'lazy-highlight-face "22.1")
 
 ;; Define isearch-mode keymap.
 
@@ -744,7 +744,7 @@
    isearch-adjusted nil
    isearch-yank-flag nil)
   (when isearch-lazy-highlight
-    (isearch-lazy-highlight-new-loop nil nil))
+    (isearch-lazy-highlight-new-loop))
   ;; We must prevent the point moving to the end of composition when a
   ;; part of the composition has just been searched.
   (setq disable-point-adjustment t))
@@ -768,7 +768,7 @@
   ;; (setq pre-command-hook isearch-old-pre-command-hook) ; for lemacs
   (setq minibuffer-message-timeout isearch-original-minibuffer-message-timeout)
   (isearch-dehighlight)
-  (isearch-lazy-highlight-cleanup lazy-highlight-cleanup)
+  (lazy-highlight-cleanup lazy-highlight-cleanup)
   (let ((found-start (window-start (selected-window)))
 	(found-point (point)))
     (if isearch-window-configuration
@@ -1458,8 +1458,10 @@
 	  ;; `stack' now refers the most recent valid regexp that is not at
 	  ;; all optional in its last term.  Now dig one level deeper and find
 	  ;; what matched before that.
-	  (let ((last-other-end (or (isearch-other-end-state (car previous))
-				    isearch-barrier)))
+	  (let ((last-other-end
+		 (or (and (car previous)
+			  (isearch-other-end-state (car previous)))
+		     isearch-barrier)))
 	    (goto-char (if isearch-forward
 			   (max last-other-end isearch-barrier)
 			 (min last-other-end isearch-barrier)))
@@ -1553,6 +1555,7 @@
 (put 'delete-other-windows 'isearch-scroll t)
 (put 'balance-windows 'isearch-scroll t)
 (put 'split-window-vertically 'isearch-scroll t)
+(put 'split-window-horizontally 'isearch-scroll t)
 (put 'enlarge-window 'isearch-scroll t)
 
 ;; Universal argument commands
@@ -2326,7 +2329,7 @@
 (defvar isearch-lazy-highlight-case-fold-search nil)
 (defvar isearch-lazy-highlight-regexp nil)
 
-(defun isearch-lazy-highlight-cleanup (&optional force)
+(defun lazy-highlight-cleanup (&optional force)
   "Stop lazy highlighting and remove extra highlighting from current buffer.
 FORCE non-nil means do it whether or not `lazy-highlight-cleanup'
 is nil.  This function is called when exiting an incremental search if
@@ -2341,7 +2344,10 @@
     (cancel-timer isearch-lazy-highlight-timer)
     (setq isearch-lazy-highlight-timer nil)))
 
-(defun isearch-lazy-highlight-new-loop (beg end)
+(defalias 'isearch-lazy-highlight-cleanup 'lazy-highlight-cleanup)
+(make-obsolete 'isearch-lazy-highlight-cleanup 'lazy-highlight-cleanup "22.1")
+
+(defun isearch-lazy-highlight-new-loop (&optional beg end)
   "Cleanup any previous `lazy-highlight' loop and begin a new one.
 BEG and END specify the bounds within which highlighting should occur.
 This is called when `isearch-update' is invoked (which can cause the
@@ -2362,7 +2368,7 @@
                  (not (= (window-end)   ; Window may have been split/joined.
                          isearch-lazy-highlight-window-end))))
     ;; something important did indeed change
-    (isearch-lazy-highlight-cleanup t) ;kill old loop & remove overlays
+    (lazy-highlight-cleanup t) ;kill old loop & remove overlays
     (when (not isearch-error)
       (setq isearch-lazy-highlight-start-limit beg
 	    isearch-lazy-highlight-end-limit end)
@@ -2383,11 +2389,12 @@
 (defun isearch-lazy-highlight-search ()
   "Search ahead for the next or previous match, for lazy highlighting.
 Attempt to do the search exactly the way the pending isearch would."
-  (let ((case-fold-search isearch-case-fold-search)
+  (let ((case-fold-search isearch-lazy-highlight-case-fold-search)
+	(isearch-regexp isearch-lazy-highlight-regexp)
 	(search-spaces-regexp search-whitespace-regexp))
     (condition-case nil
 	(funcall (isearch-search-fun)
-		 isearch-string
+		 isearch-lazy-highlight-last-string
 		 (if isearch-forward
 		     (min (or isearch-lazy-highlight-end-limit (point-max))
 			  (if isearch-lazy-highlight-wrapped
@@ -2440,7 +2447,7 @@
 			;; non-zero-length match
 			(let ((ov (make-overlay mb me)))
 			  (push ov isearch-lazy-highlight-overlays)
-			  (overlay-put ov 'face isearch-lazy-highlight-face)
+			  (overlay-put ov 'face lazy-highlight-face)
 			  (overlay-put ov 'priority 0) ;lower than main overlay
 			  (overlay-put ov 'window (selected-window))))
 		      (if isearch-forward
--- a/lisp/language/ethio-util.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/language/ethio-util.el	Sat Mar 19 17:55:13 2005 +0000
@@ -419,6 +419,8 @@
 
 ;; To avoid byte-compiler warnings.  It should never be set globally.
 (defvar ethio-sera-being-called-by-w3)
+;; This variable will be bound by some third-party package.
+(defvar sera-being-called-by-w3)
 
 ;;;###autoload
 (defun ethio-sera-to-fidel-region (beg end &optional secondary force)
@@ -590,9 +592,11 @@
       (cond
 
        ;; skip from "<" to ">" (or from "&" to ";") if in w3-mode
-       ((and (boundp 'ethio-sera-being-called-by-w3)
-	     ethio-sera-being-called-by-w3
-	     (or (= ch ?<) (= ch ?&)))
+       ((and (or (= ch ?<) (= ch ?&))
+	     (or (and (boundp 'ethio-sera-being-called-by-w3)
+		      ethio-sera-being-called-by-w3)
+		 (and (boundp 'sera-being-called-by-w3)
+		      sera-being-called-by-w3)))
 	(search-forward (if (= ch ?<) ">" ";")
 			nil 0))
 
@@ -1177,9 +1181,11 @@
 	  (goto-char (1+ (match-end 0)))) ; because we inserted one byte (\)
 
 	 ;; skip from "<" to ">" (or from "&" to ";") if called from w3
-	 ((and (boundp 'ethio-sera-being-called-by-w3)
-	       ethio-sera-being-called-by-w3
-	       (or (= ch ?<) (= ch ?&)))
+	 ((and (or (= ch ?<) (= ch ?&))
+	       (or (and (boundp 'ethio-sera-being-called-by-w3)
+			ethio-sera-being-called-by-w3)
+		   (and (boundp 'sera-being-called-by-w3)
+			sera-being-called-by-w3)))
 	  (search-forward (if (= ch ?<) ">" ";")
 			  nil 0))
 
--- a/lisp/language/thai-util.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/language/thai-util.el	Sat Mar 19 17:55:13 2005 +0000
@@ -2,6 +2,9 @@
 
 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
 ;; Licensed to the Free Software Foundation.
+;; Copyright (C) 2005
+;;   National Institute of Advanced Industrial Science and Technology (AIST)
+;;   Registration Number H14PRO021
 
 ;; Keywords: mule, multilingual, thai
 
@@ -31,19 +34,37 @@
 (defconst thai-category-table (make-category-table))
 (define-category ?c "Thai consonant" thai-category-table)
 (define-category ?v "Thai upper/lower vowel" thai-category-table)
-(define-category ?t "Thai tone" thai-category-table)
+(define-category ?t "Thai tone mark" thai-category-table)
+(define-category ?u "Thai tone mark and upper sign" thai-category-table)
+(define-category ?I "THAI CHARACTER SARA I" thai-category-table)
+(define-category ?U "THAI CHARACTER THANTHAKHAT" thai-category-table)
 
 ;; The general composing rules are as follows:
 ;;
 ;;                          T
-;;       V        T         V                  T
-;; CV -> C, CT -> C, CVT -> C, Cv -> C, CvT -> C
+;;       V        U         V                  U
+;; CV -> C, CU -> C, CVT -> C, Cv -> C, CvU -> C
 ;;                                   v         v
 ;;
-;; where C: consonant, V: vowel upper, v: vowel lower, T: tone mark.
+;; where C: consonant, V: vowel upper, v: vowel lower,
+;;       T: tone mark, U: tone mark and upper sign.
+;; Special rule: The sign `,Tl(B' can be put on the vowel `,TT(B'.
+
+
+(defvar thai-composition-pattern
+  "\\cc\\(\\cu\\|\\cI\\cU\\|\\cv\\ct?\\)\\|\\cv\\ct\\|\\cI\\cU"
+  "Regular expression matching a Thai composite sequence.")
 
-(defvar thai-composition-pattern "\\cc\\(\\ct\\|\\cv\\ct?\\)"
-  "Regular expression matching a Thai composite sequence.")
+(defun thai-self-insert-command (&optional n)
+  "Insert the Thai character you type.
+The character will be composed with the surrounding Thai character
+if necessary."
+  (interactive "*p")
+  (let ((pos (point))
+	category-set ch)
+    (self-insert-command n)
+    (or thai-auto-composition-mode
+	(thai-auto-composition (1- (point)) (point) 0))))
 
 (let ((l '((?,T!(B consonant "LETTER KO KAI")				; 0xA1
 	   (?,T"(B consonant "LETTER KHO KHAI")				; 0xA2
@@ -115,14 +136,14 @@
 	   (?,Td(B vowel-base "VOWEL SIGN SARA MAI MALAI")			; 0xE4
 	   (?,Te(B vowel-base "LAK KHANG YAO")				; 0xE5
 	   (?,Tf(B special "MAI YAMOK (repetion)")				; 0xE6
-	   (?,Tg(B vowel-upper "VOWEL SIGN MAI TAI KHU N/S-T")		; 0xE7
+	   (?,Tg(B sign-upper "VOWEL SIGN MAI TAI KHU N/S-T")		; 0xE7
 	   (?,Th(B tone "TONE MAI EK N/S-T")				; 0xE8
 	   (?,Ti(B tone "TONE MAI THO N/S-T")				; 0xE9
 	   (?,Tj(B tone "TONE MAI TRI N/S-T")				; 0xEA
 	   (?,Tk(B tone "TONE MAI CHATTAWA N/S-T")				; 0xEB
-	   (?,Tl(B tone "THANTHAKHAT N/S-T (cancellation mark)")		; 0xEC
-	   (?,Tm(B tone "NIKKHAHIT N/S-T (final nasal)")			; 0xED
-	   (?,Tn(B vowel-upper "YAMAKKAN N/S-T")				; 0xEE
+	   (?,Tl(B sign-upper "THANTHAKHAT N/S-T (cancellation mark)")	; 0xEC
+	   (?,Tm(B sign-upper "NIKKHAHIT N/S-T (final nasal)")		; 0xED
+	   (?,Tn(B sign-upper "YAMAKKAN N/S-T")				; 0xEE
 	   (?,To(B special "FONRMAN")					; 0xEF
 	   (?,Tp(B special "DIGIT ZERO")					; 0xF0
 	   (?,Tq(B special "DIGIT ONE")					; 0xF1
@@ -207,14 +228,14 @@
 	   (?$,1CD(B vowel-base "VOWEL SIGN SARA MAI MALAI")
 	   (?$,1CE(B vowel-base "LAK KHANG YAO")
 	   (?$,1CF(B special "MAI YAMOK (repetion)")
-	   (?$,1CG(B vowel-upper "VOWEL SIGN MAI TAI KHU N/S-T")
+	   (?$,1CG(B sign-upper "VOWEL SIGN MAI TAI KHU N/S-T")
 	   (?$,1CH(B tone "TONE MAI EK N/S-T")
 	   (?$,1CI(B tone "TONE MAI THO N/S-T")
 	   (?$,1CJ(B tone "TONE MAI TRI N/S-T")
 	   (?$,1CK(B tone "TONE MAI CHATTAWA N/S-T")
-	   (?$,1CL(B tone "THANTHAKHAT N/S-T (cancellation mark)")
-	   (?$,1CM(B tone "NIKKHAHIT N/S-T (final nasal)")
-	   (?$,1CN(B vowel-upper "YAMAKKAN N/S-T")
+	   (?$,1CL(B sign-upper "THANTHAKHAT N/S-T (cancellation mark)")
+	   (?$,1CM(B sign-upper "NIKKHAHIT N/S-T (final nasal)")
+	   (?$,1CN(B sign-upper "YAMAKKAN N/S-T")
 	   (?$,1CO(B special "FONRMAN")
 	   (?$,1CP(B special "DIGIT ZERO")
 	   (?$,1CQ(B special "DIGIT ONE")
@@ -236,25 +257,61 @@
 	  (ptype (nth 1 elm)))
       (put-char-code-property char 'phonetic-type ptype)
       (cond ((eq ptype 'consonant)
-	     (modify-category-entry char ?c thai-category-table))
+	     (modify-category-entry char ?c thai-category-table)
+	     (global-set-key (vector char) 'thai-self-insert-command))
 	    ((memq ptype '(vowel-upper vowel-lower))
-	     (modify-category-entry char ?v thai-category-table))
+	     (modify-category-entry char ?v thai-category-table)
+	     (if (or (= char ?,TT(B) (= char ?$,1C4(B))
+		 ;; Give category `I' to "SARA I".
+		 (modify-category-entry char ?I thai-category-table))
+	     (global-set-key (vector char) 'thai-self-insert-command))
 	    ((eq ptype 'tone)
-	     (modify-category-entry char ?t thai-category-table)))
+	     (modify-category-entry char ?t thai-category-table)
+	     (modify-category-entry char ?u thai-category-table)
+	     (global-set-key (vector char) 'thai-self-insert-command))
+	    ((eq ptype 'sign-upper)
+	     (modify-category-entry char ?u thai-category-table)
+	     (if (or (= char ?,Tl(B) (= char ?$,1CL(B))
+		 ;; Give category `U' to "THANTHAKHAT".
+		 (modify-category-entry char ?U thai-category-table))
+	     (global-set-key (vector char) 'thai-self-insert-command)))
       (put-char-code-property char 'name (nth 2 elm)))))
 
+(defun thai-compose-syllable (beg end &optional category-set string)
+  (or category-set
+      (setq category-set 
+	    (char-category-set (if string (aref string beg) (char-after beg)))))
+  (if (aref category-set ?c)
+      ;; Starting with a consonant.  We do relative composition.
+      (if string
+	  (compose-string string beg end)
+	(compose-region beg end))
+    ;; Vowel tone sequence.
+    (if string
+	(compose-string string beg end (list (aref string beg) '(Bc . Bc) 
+					     (aref string (1+ beg))))
+      (compose-region beg end (list (char-after beg) '(Bc . Bc) 
+				    (char-after (1+ beg))))))
+  (- end beg))
+
 ;;;###autoload
 (defun thai-compose-region (beg end)
   "Compose Thai characters in the region.
 When called from a program, expects two arguments,
 positions (integers or markers) specifying the region."
   (interactive "r")
-  (save-restriction
-    (narrow-to-region beg end)
-    (goto-char (point-min))
-    (with-category-table thai-category-table
-      (while (re-search-forward thai-composition-pattern nil t)
-	(compose-region (match-beginning 0) (match-end 0))))))
+  (let ((pos (point)))
+    (save-restriction
+      (narrow-to-region beg end)
+      (goto-char (point-min))
+      (with-category-table thai-category-table
+	(while (re-search-forward thai-composition-pattern nil t)
+	  (setq beg (match-beginning 0) end (match-end 0))
+	  (if (and (> pos beg) (< pos end))
+	      (setq pos end))
+	  (thai-compose-syllable beg end
+				 (char-category-set (char-after beg))))))
+    (goto-char pos)))
 
 ;;;###autoload
 (defun thai-compose-string (string)
@@ -262,7 +319,7 @@
   (with-category-table thai-category-table
     (let ((idx 0))
       (while (setq idx (string-match thai-composition-pattern string idx))
-	(compose-string string idx (match-end 0))
+	(thai-compose-syllable idx (match-end 0) nil string)
 	(setq idx (match-end 0)))))
   string)
 
@@ -285,12 +342,45 @@
 to compose.
 
 The return value is number of composed characters."
-  (if (< (1+ from) to)
-      (progn
-	(if string
-	    (compose-string string from to)
-	  (compose-region from to))
-	(- to from))))
+  (when (and (not thai-auto-composition-mode)
+	     (< (1+ from) to))
+    (with-category-table thai-category-table
+      (if string
+	  (if (eq (string-match thai-composition-pattern string from) from)
+	      (thai-compose-syllable from (match-end 0) nil string))
+	(if (save-excursion 
+	      (goto-char from)
+	      (and (looking-at thai-composition-pattern)
+		   (setq to (match-end 0))))
+	    (thai-compose-syllable from to))))))
+
+(defun thai-auto-composition (beg end len)
+  (with-category-table thai-category-table
+    (let (category-set)
+      (while (and (> beg (point-min))
+		  (setq category-set (char-category-set (char-after (1- beg))))
+		  (or (aref category-set ?v) (aref category-set ?u)))
+	  (setq beg (1- beg)))
+      (if (and (> beg (point-min))
+	       (aref (char-category-set (char-after (1- beg))) ?c))
+	  (setq beg (1- beg)))
+      (while (and (< end (point-max))
+		  (setq category-set (char-category-set (char-after end)))
+		  (or (aref category-set ?v) (aref category-set ?u)))
+	(setq end (1+ end)))
+      (if (< beg end)
+	  (thai-compose-region beg end)))))
+
+(put 'thai-auto-composition-mode 'permanent-local t)
+
+;;;###autoload
+(define-minor-mode thai-auto-composition-mode
+  "Minor mode for automatically correct Thai character composition."
+  nil nil nil
+  (cond ((null thai-auto-composition-mode)
+	 (remove-hook 'after-change-functions 'thai-auto-composition))
+	(t
+	 (add-hook 'after-change-functions 'thai-auto-composition))))
 
 ;;
 (provide 'thai-util)
--- a/lisp/language/thai.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/language/thai.el	Sat Mar 19 17:55:13 2005 +0000
@@ -2,6 +2,9 @@
 
 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
 ;; Licensed to the Free Software Foundation.
+;; Copyright (C) 2005
+;;   National Institute of Advanced Industrial Science and Technology (AIST)
+;;   Registration Number H14PRO021
 
 ;; Keywords: multilingual, Thai
 
@@ -57,7 +60,7 @@
 
 
 ;; Register a function to compose Thai characters.
-(let ((patterns '(("\\c0\\c4\\|\\c0\\(\\c2\\|\\c3\\)\\c4?"
+(let ((patterns '(("\\c0?\\(\\c2\\|\\c3\\|\\c4\\)+"
 		   . thai-composition-function))))
   (aset composition-function-table (make-char 'thai-tis620) patterns)
   (dotimes (i (1+ (- #xe7f #xe00)))
--- a/lisp/mail/rmail.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/mail/rmail.el	Sat Mar 19 17:55:13 2005 +0000
@@ -96,23 +96,26 @@
   :group 'rmail)
 
 (defcustom rmail-movemail-program nil
-  "If non-nil, name of program for fetching new mail."
+  "If non-nil, the file name of the `movemail' program."
   :group 'rmail-retrieve
   :type '(choice (const nil) string))
 
 (defcustom rmail-pop-password nil
-  "*Password to use when reading mail from POP server. Please, use rmail-remote-password instead."
+  "*Password to use when reading mail from POP server.
+Please use `rmail-remote-password' instead."
   :type '(choice (string :tag "Password")
 		 (const :tag "Not Required" nil))
   :group 'rmail-obsolete)
 
 (defcustom rmail-pop-password-required nil
-  "*Non-nil if a password is required when reading mail from a POP server. Please, use rmail-remote-password-required instead."
+  "*Non-nil if a password is required when reading mail from a POP server. 
+Please use rmail-remote-password-required instead."
   :type 'boolean
   :group 'rmail-obsolete)
 
 (defcustom rmail-remote-password nil
-  "*Password to use when reading mail from a remote server. This setting is ignored for mailboxes whose URL already contains a password."
+  "*Password to use when reading mail from a remote server.
+This setting is ignored for mailboxes whose URL already contains a password."
   :type '(choice (string :tag "Password")
 		 (const :tag "Not Required" nil))
   :set-after '(rmail-pop-password)
@@ -160,8 +163,7 @@
 (defvar rmail-encoded-remote-password nil)
 
 (defcustom rmail-preserve-inbox nil
-  "*Non-nil if incoming mail should be left in the user's inbox,
-rather than deleted, after it is retrieved."
+  "*Non-nil means leave incoming mail in the user's inbox--don't delete it."
   :type 'boolean
   :group 'rmail-retrieve)
 
@@ -171,8 +173,8 @@
     :type '(repeat (directory)))
 
 (defun rmail-probe (prog)
-  "Determine what flavor of movemail PROG is by executing it with --version
-command line option and analyzing its output."
+  "Determine what flavor of movemail PROG is.
+We do this by executing it with `--version' and analyzing its output."
   (with-temp-buffer
     (let ((tbuf (current-buffer)))
       (buffer-disable-undo tbuf)
@@ -191,10 +193,10 @@
 	  'emacs))))))
 
 (defun rmail-autodetect ()
-  "Determine and return the flavor of `movemail' program in use. If
-rmail-movemail-program is set, use it. Otherwise, look for `movemail'
-in the path constructed by appending rmail-movemail-search-path,
-exec-path and exec-directory."
+  "Determine and return the file name of the `movemail' program.
+If `rmail-movemail-program' is non-nil, use it.
+Otherwise, look for `movemail' in the directories in
+`rmail-movemail-search-path', those in `exec-path', and `exec-directory'."
   (if rmail-movemail-program
       (rmail-probe rmail-movemail-program)
     (catch 'scan
@@ -2609,6 +2611,39 @@
   (interactive)
   (rmail-show-message rmail-current-message))
 
+(defun rmail-unknown-mail-followup-to ()
+  "Handle a \"Mail-Followup-To\" header field with an unknown mailing list.
+Ask the user whether to add that list name to `mail-mailing-lists'."
+   (save-restriction
+     (rmail-narrow-to-non-pruned-header)
+     (let ((mail-followup-to (mail-fetch-field "mail-followup-to" nil t)))
+       (when mail-followup-to
+	 (let ((addresses
+		(split-string 
+		 (mail-strip-quoted-names mail-followup-to)
+		 ",[[:space:]]+" t)))
+	   (dolist (addr addresses)
+	     (when (and (not (member addr mail-mailing-lists))
+			(not
+			 ;; taken from rmailsum.el
+			 (string-match
+			  (or rmail-user-mail-address-regexp
+			      (concat "^\\("
+				      (regexp-quote (user-login-name))
+				      "\\($\\|@\\)\\|"
+				      (regexp-quote
+				       (or user-mail-address
+					   (concat (user-login-name) "@"
+						   (or mail-host-address
+						       (system-name)))))
+				      "\\>\\)"))
+			  addr))
+			(y-or-n-p
+			 (format "Add `%s' to `mail-mailing-lists'? "
+				 addr)))
+	       (customize-save-variable 'mail-mailing-lists
+					(cons addr mail-mailing-lists)))))))))
+
 (defun rmail-show-message (&optional n no-summary)
   "Show message number N (prefix argument), counting from start of file.
 If summary buffer is currently displayed, update current message there also."
@@ -2677,8 +2712,9 @@
 	(rmail-display-labels)
 	(if (eq rmail-enable-mime t)
 	    (funcall rmail-show-mime-function)
-	  (setq rmail-view-buffer rmail-buffer)
-	  )
+	  (setq rmail-view-buffer rmail-buffer))
+	(when mail-mailing-lists
+	  (rmail-unknown-mail-followup-to))
 	(rmail-highlight-headers)
 	(if transient-mark-mode (deactivate-mark))
 	(run-hooks 'rmail-show-message-hook)
@@ -3367,9 +3403,14 @@
 			      (progn (search-forward "\n*** EOOH ***\n")
 				     (beginning-of-line) (point)))))
 	(setq from (mail-fetch-field "from")
-	      reply-to (or (mail-fetch-field "reply-to" nil t)
+	      reply-to (or (if just-sender
+			       (mail-fetch-field "mail-reply-to" nil t)
+			     (mail-fetch-field "mail-followup-to" nil t))
+			   (mail-fetch-field "reply-to" nil t)
 			   from)
 	      cc (and (not just-sender)
+		      ;; mail-followup-to, if given, overrides cc.
+		      (not (mail-fetch-field "mail-followup-to" nil t))
 		      (mail-fetch-field "cc" nil t))
 	      subject (mail-fetch-field "subject")
 	      date (mail-fetch-field "date")
--- a/lisp/mail/sendmail.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/mail/sendmail.el	Sat Mar 19 17:55:13 2005 +0000
@@ -107,7 +107,7 @@
   :group 'sendmail)
 
 ;;;###autoload
-(defcustom mail-yank-ignored-headers "^via:\\|^mail-from:\\|^origin:\\|^status:\\|^remailed\\|^received:\\|^message-id:\\|^summary-line:\\|^to:\\|^subject:\\|^in-reply-to:\\|^return-path:" "\
+(defcustom mail-yank-ignored-headers "^via:\\|^mail-from:\\|^origin:\\|^status:\\|^remailed\\|^received:\\|^message-id:\\|^summary-line:\\|^to:\\|^subject:\\|^in-reply-to:\\|^return-path:\\|^mail-reply-to:\\|^mail-followup-to:" "\
 *Delete these headers from old message when it's inserted in a reply."
   :type 'regexp
   :group 'sendmail)
@@ -213,6 +213,7 @@
 This is a normal hook, misnamed for historical reasons.
 It is semi-obsolete and mail agents should no longer use it.")
 
+;;;###autoload
 (defcustom mail-citation-hook nil
   "*Hook for modifying a citation just inserted in the mail buffer.
 Each hook function can find the citation between (point) and (mark t),
@@ -363,7 +364,7 @@
 	   (cite-prefix "[:alpha:]")
 	   (cite-suffix (concat cite-prefix "0-9_.@-`'\"")))
       (list '("^\\(To\\|Newsgroups\\):" . font-lock-function-name-face)
-	    '("^\\(B?CC\\|Reply-to\\):" . font-lock-keyword-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))
 	    ;; Use EVAL to delay in case `mail-header-separator' gets changed.
@@ -492,6 +493,8 @@
 	 \\[mail-to]  move to To:	\\[mail-subject]  move to Subject:
 	 \\[mail-cc]  move to CC:	\\[mail-bcc]  move to BCC:
 	 \\[mail-fcc]  move to FCC:	\\[mail-reply-to] move to Reply-To:
+         \\[mail-mail-reply-to]  move to Mail-Reply-To:
+         \\[mail-mail-followup-to] move to Mail-Followup-To:
 \\[mail-text]  mail-text (move to beginning of message text).
 \\[mail-signature]  mail-signature (insert `mail-signature-file' file).
 \\[mail-yank-original]  mail-yank-original (insert current message, in Rmail).
@@ -599,6 +602,7 @@
 	;; make sure we can fill after each address.
 	(if (member fieldname
 		    '("to" "cc" "bcc" "from" "reply-to"
+		      "mail-reply-to" "mail-followup-to"
 		      "resent-to" "resent-cc" "resent-bcc"
 		      "resent-from" "resent-reply-to"))
 	    (while (search-forward "," end t)
@@ -627,6 +631,8 @@
   (define-key mail-mode-map "\C-c\C-f\C-c" 'mail-cc)
   (define-key mail-mode-map "\C-c\C-f\C-s" 'mail-subject)
   (define-key mail-mode-map "\C-c\C-f\C-r" 'mail-reply-to)
+  (define-key mail-mode-map "\C-c\C-f\C-a" 'mail-mail-reply-to) ; author
+  (define-key mail-mode-map "\C-c\C-f\C-l" 'mail-mail-followup-to) ; list
   (define-key mail-mode-map "\C-c\C-t" 'mail-text)
   (define-key mail-mode-map "\C-c\C-y" 'mail-yank-original)
   (define-key mail-mode-map "\C-c\C-r" 'mail-yank-region)
@@ -674,6 +680,12 @@
 (define-key mail-mode-map [menu-bar headers sent-via]
   '("Sent Via" . mail-sent-via))
 
+(define-key mail-mode-map [menu-bar headers mail-reply-to]
+  '("Mail Reply To" . mail-mail-reply-to))
+
+(define-key mail-mode-map [menu-bar headers mail-followup-to]
+  '("Mail Followup To" . mail-mail-followup-to))
+
 (define-key mail-mode-map [menu-bar headers reply-to]
   '("Reply-To" . mail-reply-to))
 
@@ -745,6 +757,16 @@
   :options '(flyspell-mode-off)
   :group 'sendmail)
 
+;;;###autoload
+(defcustom mail-mailing-lists nil "\
+*List of mailing list addresses the user is subscribed to.
+
+The variable is used to trigger insertion of the \"Mail-Followup-To\"
+header when sending a message to a mailing list."
+  :type '(repeat string)
+  :group 'sendmail)
+
+
 (defun mail-send ()
   "Send the message in the current buffer.
 If `mail-interactive' is non-nil, wait for success indication
@@ -757,7 +779,45 @@
 	(or (buffer-modified-p)
 	    (y-or-n-p "Message already sent; resend? ")))
       (let ((inhibit-read-only t)
-	    (opoint (point)))
+	    (opoint (point))
+	    (ml (when mail-mailing-lists
+                ;; The surrounding regexp assumes the use of
+                ;; `mail-strip-quoted-names' on addresses before matching
+                ;; Cannot deal with full RFC 822 freedom, but that is
+                ;; unlikely to be problematic.
+                (concat "\\(?:[[:space:];,]\\|\\`\\)"
+                        (regexp-opt mail-mailing-lists t)
+                        "\\(?:[[:space:];,]\\|\\'\\)"))))
+	;; If there are mailing lists defined
+	(when ml
+	  (save-excursion
+	    (let* ((to (mail-fetch-field "to" nil t))
+		   (cc (mail-fetch-field "cc" nil t))
+		   (new-header-values	; To: and Cc:
+		    (mail-strip-quoted-names
+		     (concat to (when cc (concat ", " cc))))))
+	      ;; If message goes to known mailing list ...
+	      (when (string-match ml new-header-values)
+		;; Add Mail-Followup-To if none yet
+		(unless (mail-fetch-field "mail-followup-to")
+		  (goto-char (mail-header-end))
+		  (insert "Mail-Followup-To: "
+			  (let ((l))
+			    (mapc
+			     ;; remove duplicates
+			     '(lambda (e)
+				(unless (member e l)
+				  (push e l)))
+			     (split-string new-header-values ", +" t))
+			    (mapconcat 'identity l ", "))
+			  "\n"))
+		;; Add Mail-Reply-To if none yet
+		(unless (mail-fetch-field "mail-reply-to")
+		  (goto-char (mail-header-end))
+		  (insert "Mail-Reply-To: "
+			  (or (mail-fetch-field "reply-to")
+			      user-mail-address)
+			  "\n"))))))
 	(unless (memq mail-send-nonascii '(t mime))
 	  (goto-char (point-min))
 	  (skip-chars-forward "\0-\177")
@@ -833,7 +893,7 @@
 	(multibyte enable-multibyte-characters)
 	(case-fold-search nil)
 	(selected-coding (select-message-coding-system))
-;;;	resend-to-addresses
+	resend-to-addresses
 	delimline
 	fcc-was-found
 	(mailbuf (current-buffer))
@@ -869,39 +929,42 @@
 		      (< (point) delimline))
 	    (replace-match "\n"))
 	  (goto-char (point-min))
+	  ;; Look for Resent- headers.  They require sending
+	  ;; the message specially.
 	  (let ((case-fold-search t))
-;;;	    (goto-char (point-min))
-;;;	    (while (re-search-forward "^Resent-\\(to\\|cc\\|bcc\\):" delimline t)
-;;;	      (setq resend-to-addresses
-;;;		    (save-restriction
-;;;		      (narrow-to-region (point)
-;;;					(save-excursion
-;;;					  (forward-line 1)
-;;;					  (while (looking-at "^[ \t]")
-;;;					    (forward-line 1))
-;;;					  (point)))
-;;;		      (append (mail-parse-comma-list)
-;;;			      resend-to-addresses)))
-;;;	      ;; Delete Resent-BCC ourselves
-;;;	      (if (save-excursion (beginning-of-line)
-;;;				  (looking-at "resent-bcc"))
-;;;		  (delete-region (save-excursion (beginning-of-line) (point))
-;;;				 (save-excursion (end-of-line) (1+ (point))))))
-;;; Apparently this causes a duplicate Sender.
-;;;	    ;; If the From is different than current user, insert Sender.
-;;;	    (goto-char (point-min))
-;;;	    (and (re-search-forward "^From:"  delimline t)
-;;;		 (progn
-;;;		   (require 'mail-utils)
-;;;		   (not (string-equal
-;;;			 (mail-strip-quoted-names
-;;;			  (save-restriction
-;;;			    (narrow-to-region (point-min) delimline)
-;;;			    (mail-fetch-field "From")))
-;;;			 (user-login-name))))
-;;;		 (progn
-;;;		   (forward-line 1)
-;;;		   (insert "Sender: " (user-login-name) "\n")))
+	    (goto-char (point-min))
+	    (while (re-search-forward "^Resent-\\(to\\|cc\\|bcc\\):" delimline t)
+	      ;; Put a list of such addresses in resend-to-addresses.
+	      (setq resend-to-addresses
+		    (save-restriction
+		      (narrow-to-region (point)
+					(save-excursion
+					  (forward-line 1)
+					  (while (looking-at "^[ \t]")
+					    (forward-line 1))
+					  (point)))
+		      (append (mail-parse-comma-list)
+			      resend-to-addresses)))
+	      ;; Delete Resent-BCC ourselves
+	      (if (save-excursion (beginning-of-line)
+				  (looking-at "resent-bcc"))
+		  (delete-region (save-excursion (beginning-of-line) (point))
+				 (save-excursion (end-of-line) (1+ (point))))))
+;;;  Apparently this causes a duplicate Sender.
+;;; 	    ;; If the From is different than current user, insert Sender.
+;;; 	    (goto-char (point-min))
+;;; 	    (and (re-search-forward "^From:"  delimline t)
+;;; 		 (progn
+;;; 		   (require 'mail-utils)
+;;; 		   (not (string-equal
+;;; 			 (mail-strip-quoted-names
+;;; 			  (save-restriction
+;;; 			    (narrow-to-region (point-min) delimline)
+;;; 			    (mail-fetch-field "From")))
+;;; 			 (user-login-name))))
+;;; 		 (progn
+;;; 		   (forward-line 1)
+;;; 		   (insert "Sender: " (user-login-name) "\n")))
 	    ;; Don't send out a blank subject line
 	    (goto-char (point-min))
 	    (if (re-search-forward "^Subject:\\([ \t]*\n\\)+\\b" delimline t)
@@ -1000,9 +1063,9 @@
 		  (erase-buffer))))
 	  (goto-char (point-min))
 	  (if (let ((case-fold-search t))
-		(re-search-forward "^To:\\|^cc:\\|^bcc:\\|^resent-to:\
-\\|^resent-cc:\\|^resent-bcc:"
-				   delimline t))
+		(or resend-to-addresses
+		    (re-search-forward "^To:\\|^cc:\\|^bcc:"
+				       delimline t)))
 	      (let* ((default-directory "/")
 		     (coding-system-for-write selected-coding)
 		     (args
@@ -1023,14 +1086,14 @@
 				;; These mean "report errors by mail"
 				;; and "deliver in background".
 				'("-oem" "-odb"))
-;;;			      ;; Get the addresses from the message
-;;;			      ;; unless this is a resend.
-;;;			      ;; We must not do that for a resend
-;;;			      ;; because we would find the original addresses.
-;;;			      ;; For a resend, include the specific addresses.
-;;;			      (or resend-to-addresses
+			      ;; Get the addresses from the message
+			      ;; unless this is a resend.
+			      ;; We must not do that for a resend
+			      ;; because we would find the original addresses.
+			      ;; For a resend, include the specific addresses.
+			      (or resend-to-addresses
 				  '("-t")
-;;;				  )
+				  )
 			      (if mail-use-dsn
 				  (list "-N" (mapconcat 'symbol-name
 							mail-use-dsn ",")))
@@ -1249,6 +1312,24 @@
   (expand-abbrev)
   (mail-position-on-field "Reply-To"))
 
+(defun mail-mail-reply-to ()
+  "Move point to end of Mail-Reply-To field.
+Create a Mail-Reply-To field if none."
+  (interactive)
+  (expand-abbrev)
+  (or (mail-position-on-field "mail-reply-to" t)
+      (progn (mail-position-on-field "to")
+           (insert "\nMail-Reply-To: "))))
+
+(defun mail-mail-followup-to ()
+  "Move point to end of Mail-Followup-To field.
+Create a Mail-Followup-To field if none."
+  (interactive)
+  (expand-abbrev)
+  (or (mail-position-on-field "mail-followup-to" t)
+      (progn (mail-position-on-field "to")
+           (insert "\nMail-Followup-To: "))))
+
 (defun mail-position-on-field (field &optional soft)
   (let (end
 	(case-fold-search t))
--- a/lisp/progmodes/idlwave.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/progmodes/idlwave.el	Sat Mar 19 17:55:13 2005 +0000
@@ -2,7 +2,7 @@
 ;; Copyright (c) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation
 
 ;; Authors: J.D. Smith <jdsmith@as.arizona.edu>
-;;          Carsten Dominik <dominik@astro.uva.nl>
+;;          Carsten Dominik <dominik@science.uva.nl>
 ;;          Chris Chase <chase@att.com>
 ;; Maintainer: J.D. Smith <jdsmith@as.arizona.edu>
 ;; Version: 5.5
--- a/lisp/progmodes/perl-mode.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/progmodes/perl-mode.el	Sat Mar 19 17:55:13 2005 +0000
@@ -427,6 +427,9 @@
    ((looking-at "=cut") 1)
    (t 3)))
 
+(defvar perl-mode-hook nil
+  "Normal hook to run when entering Perl mode.")
+
 ;;;###autoload
 (defun perl-mode ()
   "Major mode for editing Perl code.
@@ -519,7 +522,7 @@
   ;; Setup outline-minor-mode.
   (set (make-local-variable 'outline-regexp) perl-outline-regexp)
   (set (make-local-variable 'outline-level) 'perl-outline-level)
-  (run-hooks 'perl-mode-hook))
+  (run-mode-hooks 'perl-mode-hook))
 
 ;; This is used by indent-for-comment
 ;; to decide how much to indent a comment in Perl code
--- a/lisp/replace.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/replace.el	Sat Mar 19 17:55:13 2005 +0000
@@ -1344,9 +1344,6 @@
 	;; (match-data); otherwise it is t if a match is possible at point.
 	(match-again t)
 
-	(isearch-string isearch-string)
-	(isearch-regexp isearch-regexp)
-	(isearch-case-fold-search isearch-case-fold-search)
 	(message
 	 (if query-flag
 	     (substitute-command-keys
@@ -1380,10 +1377,7 @@
 				      (regexp-quote from-string))
 				    "\\b")))
     (when query-replace-lazy-highlight
-      (setq isearch-string search-string
-	    isearch-regexp (or delimited-flag regexp-flag)
-	    isearch-case-fold-search case-fold-search
-	    isearch-lazy-highlight-last-string nil))
+      (setq isearch-lazy-highlight-last-string nil))
 
     (push-mark)
     (undo-boundary)
@@ -1453,9 +1447,10 @@
 		(let ((inhibit-read-only
 		       query-replace-skip-read-only))
 		  (unless (or literal noedit)
-		    (replace-highlight (nth 0 real-match-data)
-				       (nth 1 real-match-data)
-				       start end))
+		    (replace-highlight
+		     (nth 0 real-match-data) (nth 1 real-match-data)
+		     start end search-string
+		     (or delimited-flag regexp-flag) case-fold-search))
 		  (setq noedit
 			(replace-match-maybe-edit
 			 next-replacement nocasify literal
@@ -1471,8 +1466,10 @@
 		;; `real-match-data'.
 		(while (not done)
 		  (set-match-data real-match-data)
-		  (replace-highlight (match-beginning 0) (match-end 0)
-				     start end)
+		  (replace-highlight
+		   (match-beginning 0) (match-end 0)
+		   start end search-string
+		   (or delimited-flag regexp-flag) case-fold-search)
 		  ;; Bind message-log-max so we don't fill up the message log
 		  ;; with a bunch of identical messages.
 		  (let ((message-log-max nil))
@@ -1604,11 +1601,6 @@
 				       unread-command-events))
 			 (setq done t)))
 		  (when query-replace-lazy-highlight
-		    ;; Restore isearch data for lazy highlighting
-		    ;; in case of isearching during recursive edit
-		    (setq isearch-string search-string
-			  isearch-regexp (or delimited-flag regexp-flag)
-			  isearch-case-fold-search case-fold-search)
 		    ;; Force lazy rehighlighting only after replacements
 		    (if (not (memq def '(skip backup)))
 			(setq isearch-lazy-highlight-last-string nil))))
@@ -1648,21 +1640,25 @@
 
 (defvar replace-overlay nil)
 
-(defun replace-highlight (match-beg match-end range-beg range-end)
+(defun replace-highlight (match-beg match-end range-beg range-end
+			  string regexp case-fold)
   (if query-replace-highlight
       (if replace-overlay
 	  (move-overlay replace-overlay match-beg match-end (current-buffer))
 	(setq replace-overlay (make-overlay match-beg match-end))
 	(overlay-put replace-overlay 'priority 1) ;higher than lazy overlays
 	(overlay-put replace-overlay 'face 'query-replace)))
-  (when query-replace-lazy-highlight
-    (isearch-lazy-highlight-new-loop range-beg range-end)))
+  (if query-replace-lazy-highlight
+      (let ((isearch-string string)
+	    (isearch-regexp regexp)
+	    (isearch-case-fold-search case-fold))
+	(isearch-lazy-highlight-new-loop range-beg range-end))))
 
 (defun replace-dehighlight ()
   (when replace-overlay
     (delete-overlay replace-overlay))
   (when query-replace-lazy-highlight
-    (isearch-lazy-highlight-cleanup lazy-highlight-cleanup)
+    (lazy-highlight-cleanup lazy-highlight-cleanup)
     (setq isearch-lazy-highlight-last-string nil)))
 
 ;; arch-tag: 16b4cd61-fd40-497b-b86f-b667c4cf88e4
--- a/lisp/simple.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/simple.el	Sat Mar 19 17:55:13 2005 +0000
@@ -3540,9 +3540,11 @@
   (or arg (setq arg 1))
   (if (/= arg 1)
       (line-move (1- arg) t))
+  (beginning-of-line 1)
   (let ((orig (point)))
     (vertical-motion 0)
-    (goto-char (constrain-to-field (point) orig (/= arg 1) t nil))))
+    (if (/= orig (point))
+	(goto-char (constrain-to-field (point) orig (/= arg 1) t nil)))))
 
 
 ;;; Many people have said they rarely use this feature, and often type
@@ -3929,6 +3931,7 @@
   "The function to use for `auto-fill-function' if Auto Fill mode is turned on.
 Some major modes set this.")
 
+(put 'auto-fill-function :minor-mode-function 'auto-fill-mode)
 ;; FIXME: turn into a proper minor mode.
 ;; Add a global minor mode version of it.
 (defun auto-fill-mode (&optional arg)
--- a/lisp/subr.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/subr.el	Sat Mar 19 17:55:13 2005 +0000
@@ -2469,6 +2469,8 @@
     (push toggle minor-mode-list))
 
   (unless toggle-fun (setq toggle-fun toggle))
+  (unless (eq toggle-fun toggle)
+    (put toggle :minor-mode-function toggle-fun))
   ;; Add the name to the minor-mode-alist.
   (when name
     (let ((existing (assq toggle minor-mode-alist)))
--- a/lisp/tar-mode.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/tar-mode.el	Sat Mar 19 17:55:13 2005 +0000
@@ -579,6 +579,7 @@
   (set (make-local-variable 'file-precious-flag) t)
   (auto-save-mode 0)
   (set (make-local-variable 'write-contents-functions) '(tar-mode-write-file))
+  (buffer-disable-undo)
   (widen)
   (if (and (boundp 'tar-header-offset) tar-header-offset)
       (narrow-to-region (point-min) (byte-to-position tar-header-offset))
--- a/lisp/term/mac-win.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/term/mac-win.el	Sat Mar 19 17:55:13 2005 +0000
@@ -230,6 +230,55 @@
 	    (funcall handler this-switch))
 	(setq args (cons orig-this-switch args)))))
   (nconc (nreverse args) x-invocation-args))
+
+
+;;
+;; Standard Mac cursor shapes
+;;
+
+(defconst mac-pointer-arrow 0)
+(defconst mac-pointer-copy-arrow 1)
+(defconst mac-pointer-alias-arrow 2)
+(defconst mac-pointer-contextual-menu-arrow 3)
+(defconst mac-pointer-I-beam 4)
+(defconst mac-pointer-cross 5)
+(defconst mac-pointer-plus 6)
+(defconst mac-pointer-watch 7)
+(defconst mac-pointer-closed-hand 8)
+(defconst mac-pointer-open-hand 9)
+(defconst mac-pointer-pointing-hand 10)
+(defconst mac-pointer-counting-up-hand 11)
+(defconst mac-pointer-counting-down-hand 12)
+(defconst mac-pointer-counting-up-and-down-hand 13)
+(defconst mac-pointer-spinning 14)
+(defconst mac-pointer-resize-left 15)
+(defconst mac-pointer-resize-right 16)
+(defconst mac-pointer-resize-left-right 17)
+;; Mac OS X 10.2 and later
+(defconst mac-pointer-not-allowed 18)
+;; Mac OS X 10.3 and later
+(defconst mac-pointer-resize-up 19)
+(defconst mac-pointer-resize-down 20)
+(defconst mac-pointer-resize-up-down 21)
+(defconst mac-pointer-poof 22)
+
+;;
+;; Standard X cursor shapes that have Mac counterparts
+;;
+
+(defconst x-pointer-left-ptr mac-pointer-arrow)
+(defconst x-pointer-xterm mac-pointer-I-beam)
+(defconst x-pointer-crosshair mac-pointer-cross)
+(defconst x-pointer-plus mac-pointer-plus)
+(defconst x-pointer-watch mac-pointer-watch)
+(defconst x-pointer-hand2 mac-pointer-pointing-hand)
+(defconst x-pointer-left-side mac-pointer-resize-left)
+(defconst x-pointer-right-side mac-pointer-resize-right)
+(defconst x-pointer-sb-h-double-arrow mac-pointer-resize-left-right)
+(defconst x-pointer-top-side mac-pointer-resize-up)
+(defconst x-pointer-bottom-side mac-pointer-resize-down)
+(defconst x-pointer-sb-v-double-arrow mac-pointer-resize-up-down)
+
 
 ;;
 ;; Available colors
--- a/lisp/textmodes/ispell.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/textmodes/ispell.el	Sat Mar 19 17:55:13 2005 +0000
@@ -238,7 +238,17 @@
   :type '(choice (const block) (const :tag "off" nil) (const :tag "on" t))
   :group 'ispell)
 
-(defcustom ispell-highlight-face 'highlight
+(defcustom ispell-lazy-highlight (boundp 'lazy-highlight-cleanup)
+  "*Controls the lazy-highlighting of spelling errors.
+When non-nil, all text in the buffer matching the current spelling
+error is highlighted lazily using isearch lazy highlighting (see
+`lazy-highlight-initial-delay' and `lazy-highlight-interval')."
+  :type 'boolean
+  :group 'lazy-highlight
+  :group 'ispell
+  :version "22.1")
+
+(defcustom ispell-highlight-face (if ispell-lazy-highlight 'isearch 'highlight)
   "*The face used for Ispell highlighting.  For Emacses with overlays.
 Possible values are `highlight', `modeline', `secondary-selection',
 `region', and `underline'.
@@ -2160,7 +2170,7 @@
 otherwise it is displayed normally."
   (if highlight
       (isearch-highlight start end)
-    (isearch-dehighlight t))
+    (isearch-dehighlight))
   ;;(sit-for 0)
   )
 
@@ -2174,8 +2184,23 @@
   (if highlight
       (progn
 	(setq ispell-overlay (make-overlay start end))
+	(overlay-put ispell-overlay 'priority 1) ;higher than lazy overlays
 	(overlay-put ispell-overlay 'face ispell-highlight-face))
-    (delete-overlay ispell-overlay)))
+    (delete-overlay ispell-overlay))
+  (if (and ispell-lazy-highlight (boundp 'lazy-highlight-cleanup))
+      (if highlight
+	  (let ((isearch-string
+		 (concat
+		  "\\b"
+		  (regexp-quote (buffer-substring-no-properties start end))
+		  "\\b"))
+		(isearch-regexp t)
+		(isearch-case-fold-search nil))
+	    (isearch-lazy-highlight-new-loop
+	     (if (boundp 'reg-start) reg-start)
+	     (if (boundp 'reg-end)   reg-end)))
+	(lazy-highlight-cleanup lazy-highlight-cleanup)
+	(setq isearch-lazy-highlight-last-string nil))))
 
 
 (defun ispell-highlight-spelling-error (start end &optional highlight refresh)
--- a/lisp/textmodes/table.el	Wed Mar 16 16:06:45 2005 +0000
+++ b/lisp/textmodes/table.el	Sat Mar 19 17:55:13 2005 +0000
@@ -1,11 +1,12 @@
 ;;; table.el --- create and edit WYSIWYG text based embedded tables
 
-;; Copyright (C) 2000, 01, 02, 03, 04 Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005
+;;           Free Software Foundation, Inc.
 
 ;; Keywords: wp, convenience
 ;; Author: Takaaki Ota <Takaaki.Ota@am.sony.com>
 ;; Created: Sat Jul 08 2000 13:28:45 (PST)
-;; Revised: Tue Jun 01 2004 11:36:39 (PDT)
+;; Revised: Fri Mar 18 2005 13:50:13 (PST)
 
 ;; This file is part of GNU Emacs.
 
@@ -1024,16 +1025,10 @@
       :active (and (not buffer-read-only) (not (table--probe-cell)))
       :help "Insert a text based table at point"]
      ["Row" table-insert-row
-      :active (and (not buffer-read-only)
-		   (or (table--probe-cell)
-		       (save-excursion
-			 (table--find-row-column nil t))))
+      :active (table--row-column-insertion-point-p)
       :help "Insert row(s) of cells in table"]
      ["Column" table-insert-column
-      :active (and (not buffer-read-only)
-		   (or (table--probe-cell)
-		       (save-excursion
-			 (table--find-row-column 'column t))))
+      :active (table--row-column-insertion-point-p 'column)
       :help "Insert column(s) of cells in table"])
     "----"
     ("Recognize"
@@ -1076,16 +1071,10 @@
   '("Table"
     ("Insert"
      ["Row" table-insert-row
-      :active (and (not buffer-read-only)
-		   (or (table--probe-cell)
-		       (save-excursion
-			 (table--find-row-column nil t))))
+      :active (table--row-column-insertion-point-p)
       :help "Insert row(s) of cells in table"]
      ["Column" table-insert-column
-      :active (and (not buffer-read-only)
-		   (or (table--probe-cell)
-		       (save-excursion
-			 (table--find-row-column 'column t))))
+      :active (table--row-column-insertion-point-p 'column)
       :help "Insert column(s) of cells in table"])
     ("Delete"
      ["Row" table-delete-row
@@ -4698,6 +4687,30 @@
       (setq multiplier (1- multiplier)))
     ret-str))
 
+(defun table--line-column-position (line column)
+  "Return the location of LINE forward at COLUMN."
+  (save-excursion
+    (forward-line line)
+    (move-to-column column)
+    (point)))
+
+(defun table--row-column-insertion-point-p (&optional columnp)
+  "Return non nil if it makes sense to insert a row or a column at point."
+  (and (not buffer-read-only)
+       (or (get-text-property (point) 'table-cell)
+	   (let ((column (current-column)))
+	     (if columnp
+		 (or (text-property-any (line-beginning-position 0)
+					(table--line-column-position -1 column)
+					'table-cell t)
+		     (text-property-any (line-beginning-position) (point) 'table-cell t)
+		     (text-property-any (line-beginning-position 2)
+					(table--line-column-position 1 column)
+					'table-cell t))
+	       (text-property-any (table--line-column-position -2 column)
+				  (table--line-column-position -2 (+ 2 column))
+				  'table-cell t))))))
+
 (defun table--find-row-column (&optional columnp no-error)
   "Search table and return a cell coordinate list of row or column."
   (let ((current-coordinate (table--get-coordinate)))
@@ -5136,7 +5149,7 @@
 
 (defun table--editable-cell-p (&optional abort-on-error)
   (and (not buffer-read-only)
-       (table--probe-cell abort-on-error)))
+       (get-text-property (point) 'table-cell)))
 
 (defun table--probe-cell (&optional abort-on-error)
   "Probes a table cell around the point.
@@ -5603,5 +5616,5 @@
 ;; End: ***
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-;;; arch-tag: 0d69b03e-aa5f-4e72-8806-5727217617e0
+;; arch-tag: 0d69b03e-aa5f-4e72-8806-5727217617e0
 ;;; table.el ends here
--- a/lispref/ChangeLog	Wed Mar 16 16:06:45 2005 +0000
+++ b/lispref/ChangeLog	Sat Mar 19 17:55:13 2005 +0000
@@ -1,3 +1,26 @@
+2005-03-17  Richard M. Stallman  <rms@gnu.org>
+
+	* text.texi (Undo): Document extensible undo entries.
+
+	* searching.texi (String Search, Regexp Search, Regexp Search):
+	Cleanups.
+
+	* nonascii.texi (Character Codes): Minor fix.
+
+	* display.texi (Display Property): Explain the significance
+	of having text properties that are eq.
+	(Other Display Specs): Explain string as display spec.
+
+	* commands.texi (Interactive Codes): Document G option.
+
+2005-03-17  Chong Yidong  <cyd@stupidchicken.com>
+
+	* text.texi (Filling): Add sentence-end-without-period and
+	sentence-end-without-space.
+	(Changing Properties): Minor fix.
+
+	* anti.texi: Total rewrite.
+
 2005-03-15  Lute Kamstra  <lute@gnu.org>
 
 	* edebug.texi (Instrumenting Macro Calls): Fix typos.
@@ -42,11 +65,6 @@
 	and calendar-today-marker are strings, not chars.
 	(Holiday Customizing): Minor fix.
 
-	* nonascii.texi (Text Representations): Clarify position-bytes.
-	(Character Sets): Add list-charset-chars.
-	(Scanning Charsets): Add charset-after.
-	(Encoding and I/O): Minor fix.
-
 	* internals.texi (Writing Emacs Primitives): Update `or' example.
 	Update limit on # args of subr.
 
@@ -59,6 +77,12 @@
 	(Variable Definitions, Group Definitions): Not here.
 	(Variable Definitions): Clarify symbol arg to :initialize and :set fns.
 
+2005-03-07  Chong Yidong  <cyd@stupidchicken.com>
+	* nonascii.texi (Text Representations): Clarify position-bytes.
+	(Character Sets): Add list-charset-chars.
+	(Scanning Charsets): Add charset-after.
+	(Encoding and I/O): Minor fix.
+
 2005-03-06  Richard M. Stallman  <rms@gnu.org>
 
 	* windows.texi (Vertical Scrolling): Get rid of "Emacs 21".
--- a/lispref/anti.texi	Wed Mar 16 16:06:45 2005 +0000
+++ b/lispref/anti.texi	Sat Mar 19 17:55:13 2005 +0000
@@ -1,298 +1,437 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1999 Free Software Foundation, Inc.
+@c Copyright (C) 2005 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 
 @c This node must have no pointers.
 
 @node Antinews, GNU Free Documentation License, System Interface, Top
-@appendix Emacs 20 Antinews
+@appendix Emacs 21 Antinews
 
 For those users who live backwards in time, here is information about
-downgrading to Emacs version 20.4.  We hope you will enjoy the greater
-simplicity that results from the absence of many Emacs 21 features.  In
-the following section, we carry this information back to Emacs
-20.3, for which the previous printed edition of this manual was made.
+downgrading to Emacs version 21.4.  We hope you will enjoy the greater
+simplicity that results from the absence of many Emacs 22 features.
 
-@section Old Lisp Features in Emacs 20
+@section Old Lisp Features in Emacs 21
 
 @itemize @bullet
 @item
-The @code{push} and @code{pop} macros are not defined.
-Neither are @code{dolist} and @code{dotimes}.
+Many unnecessary features of redisplay have been eliminated.  (The
+earlier major release, Emacs 20, will have a completely rewritten
+redisplay engine, which will be even simpler.)
 
+@itemize @minus
 @item
-You can't display images in buffers.  (Emacs is meant for editing text.)
-With no images, there are no display margins, and no tool bars.
+The function @code{force-window-update} has been removed.  It
+shouldn't be needed, since changes in window contents are detected
+automatically.  In case they aren't, call @code{redraw-display} to
+redraw everything.
 
 @item
-The @code{display} text property has no special meaning; you can use it
-freely in Lisp programs, with no effects except what you implement for
-yourself.  With no images, who needs the @code{display} text property?
-
-@item
-The @code{field} text property has no special meaning; buffers are no
-longer subdivided into fields.  (The division of information into
-fields is always rather arbitrary.)
+Point no longer moves out from underneath invisible text at the end of
+each command.  This allows the user to detect invisible text by moving
+the cursor around---if the cursor gets stuck, there is something
+invisible in the way.  If you really want cursor motion to ignore the
+text, try marking it as intangible.
 
 @item
-Faces have fewer attributes.  The attributes @code{:family},
-@code{:height}, @code{:width}, @code{:weight}, and @code{:slant},
-have been replaced with a font name, a ``bold'' flag, and an
-``italic'' flag.
+Support for image maps and image slices has been removed.  Emacs was
+always meant for editing text, anyway.
 
-The attributes @code{:overline}, @code{:strike-through} and @code{:box}
-have been eliminated too.  Underlining now always has the same color as
-the text---using any other color would be bad taste.
-
-With fewer font attributes, there are no functions
-@code{set-face-attribute} and @code{face-attribute}.  Instead, you
-access these attributes using functions such as @code{face-font}, and
-set them with functions such as @code{set-face-font}.  (These functions
-were available in Emacs 21, but are not as useful there.)
+@item
+The mode line now accepts all text properties, as well as
+@code{:propertize} and @code{:eval} forms, regardless of the
+@code{risky-local-variable} property.
 
 @item
-The standard faces @code{scroll-bar}, @code{menu}, @code{border},
-@code{cursor}, and @code{mouse} have been eliminated.  They are rather
-strange, as faces, and therefore shouldn't really exist.  You can use
-@code{set-border-color}, @code{set-cursor-color} and
-@code{set-mouse-color} to specify the colors for the frame border, the
-text cursor, and the mouse cursor.  To specify menu colors, use X
-resources.
+The @code{line-height} and @code{line-spacing} properties no longer
+have any meaning for newline characters.  Such properties wouldn't
+make sense, since newlines are not really characters; they just tell
+you where to break a line.
 
 @item
-Colors and other face attributes are no longer supported on character
-terminals, so you no longer have to worry about terminals making faces
-at you.
-
-@item
-Emacs will respect your peace and quiet, aside from occasional beeps,
-because there are no facilities for playing sounds.
+Considerable simplifications have been made to the display
+specification @code{(space . @var{props})}, which is used for
+displaying a space of specified width and height.  Pixel-based
+specifications and Lisp expressions are no longer accepted.
 
 @item
-Emacs 20 provides a complex and badly designed method for handling
-character composition for languages such as Thai that display several
-letters as a single combined image.  We are too ashamed of it to tell
-you any more than that.
-
-@item
-@code{delete-and-extract-region} has been deleted; instead, use
-@code{buffer-substring} to extract the text, then use
-@code{delete-region} to delete it.
+Many features associated with the fringe areas have been removed, to
+encourage people to concentrate on the main editing area (the fringe
+will be completely removed in Emacs 20.)  Arbitrary bitmaps can no
+longer be displayed in the fringe; an overlay arrow can still be
+displayed, but there can only be one overlay arrow at a time (any more
+would be confusing.)  The fringe widths cannot be adjusted, and
+individual windows cannot have their own fringe settings.  A mouse
+click on the fringe no longer generates a special event.
 
 @item
-Regular expressions do not support the POSIX character classes
-such as @samp{[:alpha:]}.  All characters are created equal.
+Individual windows cannot have their own scroll-bar settings.
+
+@item
+You can no longer use @samp{default} in a @code{defface} to specify
+defaults for subsequent faces.
 
 @item
-Hash tables have been eliminated; use alists instead.
+The function @code{display-supports-face-attributes-p} has been
+removed.  In @code{defface} specifications, the @code{supports}
+predicate is no longer supported.
 
 @item
-The Lisp printer does not detect and report circular structure.  That is
-ok, because the Lisp reader cannot recreate circular structure anyway.
-However, there is a library @samp{cust-print.el} which can report
-circular structure.
+@code{face-attribute-relative-p} and @code{merge-face-attribute} have
+been removed.
 
 @item
-Emacs provides its own implementation of scroll bars, instead
-of using those of the X toolkit.  They always use the frame foreground
-and background colors, so you cannot specify different colors for
-the scroll bars.
+The priority of faces in a list supplied by the @code{:inherit} face
+attribute has been reversed.  We like to make changes like this once
+in a while, to keep Emacs Lisp programmers on their toes.
 
 @item
-For simplicity, all @acronym{ASCII} characters now have the same height and width.
-(Certain characters, such as Chinese characters, always have twice
-the standard width.)  All characters are created equal.
+The @code{min-colors} face attribute, used for tailoring faces to
+limited-color displays, does not exist.  If in doubt, use colors like
+``white'' and ``black'', which ought to be defined everywhere.
+
+@item
+The @code{tty-color-mode} frame parameter does not exist.  You should
+just trust the terminal capabilities database.
+@end itemize
 
 @item
-You can now resize any Emacs window, and size changes in one window can
-propagate to all others.  Windows can no longer use
-@code{window-size-fixed} to get special privileges.
+Several simplifications have been made to mouse support:
 
+@itemize @minus
 @item
-The function @code{intern-soft} no longer accepts a symbol as argument.
+Clicking @kbd{mouse-1} won't follow links, as that is alien to the
+spirit of Emacs.  Therefore, the @code{follow-link} property doesn't
+has any special meaning, and the function @code{mouse-on-link-p} has
+been removed.
 
 @item
-The function @code{bitmap-spec-p} has been renamed to
-@code{pixmap-spec-p} to encourage users to practice Emacs' help system
-while trying to find it.
-
-@item
-Tooltips operate using ordinary Emacs frames.
-
-@item
-Areas of the mode line are not mouse-sensitive; however, some mouse
-commands are available for the mode line as a whole.
+The variable @code{void-text-area-pointer} has been removed, so the
+mouse pointer shape remains unchanged when moving between valid text
+areas and void text areas.  The @code{pointer} image and text
+properties are no longer supported.
 
 @item
-Windows cannot have header lines.  Conversely, there is no way to turn
-off the mode line of a window unless it is a minibuffer.
-
-@item
-Plain dashes are the only separators you can use in a menu.
-
-@item
-Vertical fractional scrolling does not exist.
+Mouse events will no longer specify the timestamp, the object clicked,
+equivalent buffer positions (for marginal or fringe areas), glyph
+coordinates, or relative pixel coordinates.
+@end itemize
 
 @item
-The functions @code{format} and @code{message} ignore and discard text
-properties.
+Simplifications have also been made to the way Emacs handles keymaps
+and key sequences:
+
+@itemize @minus
+@item
+The @code{kbd} macro has been removed.  It isn't that difficult to
+write key sequences using the string and vector representations, and
+we want to encourage users to learn.
 
 @item
-The function @code{propertize} does not exist;
-you can get the job done using @code{set-text-properties}.
-
-@item
-Colors are supported only on window systems, not on text-only terminals.
-So the support functions for colors on text-only terminals are
-not needed, and have been eliminated.
+Emacs no longer supports key remapping.  You can do pretty much the
+same thing with @code{substitute-key-definition}, or by advising the
+relevant command.
 
 @item
-The functions @code{color-values}, @code{color-defined-p} and
-@code{defined-colors} have been renamed to @code{x-color-values},
-@code{x-color-defined-p} and @code{x-defined-colors}.
+The @code{keymap} text and overlay property is now overridden by minor
+mode keymaps, and will not work at the ends of text properties and
+overlays.
 
 @item
-Windows cannot be made fixed-width or fixed-height;
-Emacs will adjust the size of all windows when it needs to.
+The functions @code{map-keymap}, @code{keymap-prompt}, and
+@code{current-active-maps} have been removed.
+@end itemize
 
 @item
-The string used as the value of the @code{before-string} or
-@code{after-string} property must contain only characters that display
-as a single column---control characters, including tabs and newlines,
-will give strange results.
+Process support has been pared down to a functional minimum.  The
+functions @code{call-process-shell-command} and @code{process-file}
+have been deleted.  Processes no longer maintain property lists, and
+they won't ask any questions when the user tries to exit Emacs (which
+would simply be rude.)  The function @code{signal-process} won't
+accept a process object, only the process id; determining the process
+id from a process object is left as an exercise to the programmer.
 
 @item
-The minibuffer prompt does not actually appear in content of the
-minibuffer; it is displayed specially in the minibuffer window.
-
-@item
-The ``exclusive open'' feature of @code{write-region}
-has been eliminated; any non-@code{nil} value for the seventh
-argument now means to ask the user for confirmation.
-
-@item
-The function @code{buffer-size} always reports on the
-current buffer.
+Networking has also been simplified: @code{make-network-process} and
+its various associated function have all been replaced with a single
+easy-to-use function, @code{open-network-stream}, which can't use UDP,
+can't act as a server, and can't set up non-blocking connections.
+Also, deleting a network process with @code{delete-process} won't call
+the sentinel.
 
 @item
-The function @code{assq-delete-all} has itself been deleted.
-So there!
-
-@item
-The keyword @code{:set-after} no longer does anything in
-@code{defcustom}.
+Many programming shortcuts have been deleted, to provide you with the
+enjoyment of ``rolling your own''.  The macros @code{while-no-input},
+@code{with-local-quit}, @code{with-selected-window},
+@code{dynamic-completion-table}, and @code{lazy-completion-table} no
+longer exist.  Also, there are no built-in progress reporters.
 
 @item
-The variable @code{small-temporary-file-directory} has no special
-meaning.  There's only one variable for specifying which directory to
-use for temporary files, @code{temporary-file-directory}, but not all
-Emacs features use it anyway.  Some use the @code{TMP} environment
-variable, and some use the @code{TMPDIR} environment variable.
+Variable aliases are no longer supported.  Aliases are for functions,
+not for variables.
 
 @item
-If the second argument of @code{save-some-buffers}, @var{pred}, is not
-@code{nil}, then the precise value no longer matters.  Any
-non-@code{nil} value means the same as @code{t}: offer to save each
-non-file buffer that has a non-@code{nil} value for
-@code{buffer-offer-save}.
+The variables @code{most-positive-fixnum} and
+@code{most-negative-fixnum} do not exist.  On 32 bit machines, the
+most positive integer is probably 134217727, and the most negative
+integer is probably -134217728.
 
 @item
-The variable @code{inhibit-modification-hooks}
-has no special meaning.
+The functions @code{eql} and @code{macroexpand-all} are no longer
+available.  However, you can find similar functions in the @code{cl}
+package.
 
 @item
-The hook @code{fontification-functions} has been eliminated,
-but there are other hooks, such as @code{window-scroll-functions},
-that you can use to do a similar job.
+The list returned by @code{split-string} won't include null substrings
+for separators at the beginning or end of a string.  If you want to
+check for such separators, do it separately.
 
 @item
-The variable  @code{redisplay-dont-pause}
-has no special meaning.
-
-@item
-The hook @code{calendar-move-hook} has been deleted.
+The function @code{assoc-string} has been removed.  Use
+@code{assoc-ignore-case} or @code{assoc-ignore-representation} (which
+are no longer obsolete.)
 
 @item
-The function @code{move-to-column} treats any non-@code{nil}
-second argument just like @code{t}.
-@end itemize
-
-@section Old Lisp Features in Emacs 20.3
-
-Here are the most important of the features that you will learn
-to do without in Emacs 20.3:
-
-Here are changes in the Lisp language itself:
-
-@itemize @bullet
-@item
-The functions @code{line-beginning-position} and @code{line-end-position}
-have been eliminated.
+The escape sequence @samp{\s} is always interpreted as a super
+modifier, never a space.
 
 @item
-The functions @code{directory-files-and-attributes},
-@code{file-attributes-lessp}, and @code{file-expand-wildcards}, have
+The variable @code{buffer-save-without-query} has been removed, to
+prevent Emacs from sneakily saving buffers.  Also, the hook
+@code{before-save-hook} has been removed, so if you want something to
+be done before saving, advise or redefine @code{basic-save-buffer}.
+
+@item
+The variable @code{buffer-auto-save-file-format} has been renamed to
+@code{auto-save-file-format}, and is no longer a permanent local.
+
+@item
+The function @code{visited-file-modtime} now returns a cons, instead
+of a list of two integers.  The primitive @code{set-file-times} has
 been eliminated.
 
 @item
-The functions @code{decode-coding-region} and @code{encode-coding-region}
-leave text properties untouched, in case that is useful.  (It rarely makes
-any sense, though.)
+The function @code{file-remote-p} is no longer available.
+
+@item
+When determining the filename extension, a leading dot in a filename
+is no longer ignored.  Thus, @file{.emacs} is considered to have
+extension @file{emacs}, rather than being extensionless.
+
+@item
+Emacs looks for special file handlers in a more efficient manner: it
+will choose the first matching handler in
+@code{file-name-handler-alist}, rather than trying to figure out which
+provides the closest match.
+
+@item
+The @code{predicate} argument for @code{read-file-name} has been
+removed, and so have the variables @code{read-file-name-function} and
+@code{read-file-name-completion-ignore-case}.  The function
+@code{read-directory-name} has also been removed.
 
 @item
-The functions @code{position-bytes} and @code{byte-to-position} have
-been eliminated.
+The functions @code{all-completions} and @code{try-completion} will no
+longer accept lists of strings or hash tables (it will still accept
+alists, obarrays, and functions.)  In addition, the function
+@code{test-completion} is no longer available.
+
+@item
+Arbitrary Lisp functions can no longer be recorded into
+@code{buffer-undo-list}.  As a consequence, @code{yank-undo-function}
+is obsolete, and has been removed.
+
+@item
+Emacs will never complain about commands that accumulate too much undo
+information, so you no longer have to worry about binding
+@code{buffer-undo-list} to @code{t} for such commands (though you may
+want to do that anyway, to avoid taking up unnecessary memory space.)
+
+@item
+Atomic change groups are no longer supported.
+
+@item
+The list returned by @code{(match-data t)} no longer records the
+buffer as a final element.
 
 @item
-Temporary buffers made with @code{with-output-to-temp-buffer} are now
-modifiable by default, and use Fundamental mode rather than Help mode.
+The function @code{looking-back} has been removed, so we no longer
+have the benefit of hindsight.
+
+@item
+The variable @code{search-spaces-regexp} does not exist.  Spaces
+always stand for themselves in regular expression searches.
+
+@item
+The functions @code{skip-chars-forward} and @code{skip-chars-backward}
+no longer accepts character classes such as @samp{[:alpha:]}.  All
+characters are created equal.
+
+@item
+The @code{yank-handler} text property no longer has any meaning.
+Also, @code{yank-excluded-properties}, @code{insert-for-yank}, and
+@code{insert-buffer-substring-as-yank} have all been removed.
+
+@item
+The variable @code{char-property-alias-alist} has been deleted.
+Aliases are for functions, not for properties.
 
 @item
-The functions @code{sref} interprets its @var{index} argument as a
-number of bytes, not a number of characters.  And the function
-@code{char-bytes} actually tries to report on the number of bytes that a
-character occupies.
+The function @code{get-char-property-and-overlay} has been deleted.
+If you want the properties at a point, find the text properties at the
+point; then, find the overlays at the point, and find the properties
+on those overlays.
 
 @item
-The function @code{process-running-child-p} has been eliminated.
+Font Lock mode only manages @code{face} properties; you can't use
+font-lock keywords to specify arbitrary text properties for it to
+manage.  After all, it is called Font Lock mode, not Arbitrary
+Properties Lock mode.
+
+@item
+The arguments to @code{remove-overlays} are no longer optional.
+
+@item
+In @code{replace-match}, the replacement text now inherits properties
+from the surrounding text.
+
+@item
+@code{mode-line-format} no longer supports the @code{:propertize},
+@code{%i}, and @code{%I} constructs.  The function
+@code{format-mode-line} has been removed.
 
 @item
-The function @code{interrupt-process} and similar functions no longer do
-anything special when the second argument is @code{lambda}.
+The functions @code{window-inside-edges} and @code{window-body-height}
+have been removed.  You should do the relevant calculations yourself,
+starting with @code{window-width} and @code{window-height}.
+
+@item
+The functions @code{window-pixel-edges} and
+@code{window-inside-pixel-edges} have been removed.  We prefer to
+think in terms of lines and columns, not pixel coordinates.  (Sometime
+in the distant past, we will do away with graphical terminals
+entirely, in favor of text terminals.)  For similar reasons, the
+functions @code{posn-at-point}, @code{posn-at-x-y}, and
+@code{pos-visible-in-window-p} have been removed.
+
+@item
+The macro @code{save-selected-window} only saves the selected window
+of the selected frame, so don't try selecting windows in other frames.
+
+@item
+The function @code{minibufferp} is no longer available.
 
 @item
-The function @code{define-prefix-command} accepts only two arguments.
+The function @code{modify-all-frames-parameters} has been removed (we
+always suspected the name was ungrammatical, anyway.)
+
+@item
+The @code{line-spacing} variable no longer accepts float values.
+
+@item
+The function @code{tool-bar-local-item-from-menu} has been deleted.
+If you need to make an entry in the tool bar, you can still use
+@code{tool-bar-add-item-from-menu}, but that modifies the binding in
+the source keymap instead of copying it into the local keymap.
+
+@item
+When determining the major mode, the file name takes precedence over
+the interpreter magic line.  The variable @code{magic-mode-alist},
+which associates certain buffer beginnings with major modes, has been
+eliminated.
+
+@item
+The hook @code{after-change-major-mode-hook} is not defined, and
+neither are @code{run-mode-hooks} and @code{delay-mode-hooks}.
+
+@item
+The variable @code{minor-mode-list} has been removed.
 
 @item
-The meaning of the second argument to @code{read-char},
-@code{read-event}, and @code{read-char-exclusive} has been reversed:
-they use the current input method if the argument is if @code{nil}.
+@code{define-derived-mode} will copy abbrevs from the parent mode's
+abbrev table, instead of creating a new, empty abbrev table.
+
+@item
+There are no ``system'' abbrevs.  When the user saves into the abbrevs
+file, all abbrevs are saved.
+
+@item
+The Warnings facility has been removed.  Just use @code{error}.
 
 @item
-The function @code{with-temp-message} has been eliminated.
+Several hook variables have been renamed to flout the Emacs naming
+conventions.  We feel that consistency is boring, and having
+non-standard hook names encourages users to check the documentation
+before using a hook.  For instance, the normal hook
+@code{find-file-hook} has been renamed to @code{find-file-hooks}, and
+the abnormal hook @code{delete-frame-functions} has been renamed to
+@code{delete-frame-hook}.
+
+@item
+The function @code{symbol-file} does not exist.  If you want to know
+which file defined a function or variable, try grepping for it.
 
 @item
-The function @code{clear-this-command-keys} has been eliminated.
+The variable @code{load-history} records function definitions just
+like variable definitions, instead of indicating which functions were
+previously autoloaded.
+
+@item
+There is a new variable, @code{recursive-load-depth-limit}, which
+specifies how many times files can recursively load themselves; it is
+50 by default, and nil means infinity.  Previously, Emacs signalled an
+error after just 3 recursive loads, which was boring.
 
 @item
-The functions @code{gap-position} and @code{gap-size} have been eliminated.
+Byte-compiler warnings and error messages will leave out the line and
+character positions, in order to exercise your debugging skills.
+Also, there is no @code{with-no-warnings} macro---instead of
+suppressing compiler warnings, fix your code to avoid them!
 
 @item
-In @code{modify-face}, an argument of @code{(nil)} has no special
+The function @code{unsafep} has been removed.
+
+@item
+File local variables can now specify a string with text properties.
+Since arbitrary Lisp expressions can be embedded in text properties,
+this can provide you with a great deal of flexibility and power.  On
+the other hand, @code{safe-local-eval-forms} and the
+@code{safe-local-eval-function} function property have no special
 meaning.
 
 @item
-The base64 conversion functions have been eliminated.
+You can no longer use @code{char-displayable-p} to test if Emacs can
+display a certain character.
+
+@item
+The function @code{string-to-multibyte} is no longer available.
+
+@item
+The @code{translation-table-for-input} translation table has been
+removed.  Also, translation hash tables are no longer available, so we
+don't need the functions @code{lookup-character} and
+@code{lookup-integer}.
 
 @item
-Wildcard support has been eliminated from @code{find-file}
-and allied functions.
+The @code{table} argument to @code{translate-region} can no longer be
+a char-table; it has to be a string.
 
 @item
-@code{file-attributes} returns the file size and the file inode number
-only as a simple integer.
-Also @acronym{UID} and @acronym{GID} are always returned as integers.
+The functions @code{merge-coding-systems} and
+@code{decode-coding-inserted-region}, and the variable
+@code{auto-coding-functions}, have been deleted.  The
+@code{mime-text-unsuitable} coding system property no longer has any
+special meaning.
+
+@item
+If pure storage overflows while dumping, Emacs won't tell you how much
+additional pure storage it needs.  Try adding in increments of 20000,
+until you have enough.
+
+@item
+The variables @code{gc-elapsed}, @code{gcs-done}, and
+@code{post-gc-hook} have been garbage-collected.
 @end itemize
 
 @ignore
--- a/lispref/commands.texi	Wed Mar 16 16:06:45 2005 +0000
+++ b/lispref/commands.texi	Sat Mar 19 17:55:13 2005 +0000
@@ -350,6 +350,11 @@
 @item F
 A file name.  The file need not exist.  Completion, Default, Prompt.
 
+@item G
+A file name.  The file need not exist.  If the user enters just a
+directory name, then the value is just that directory name, with no
+file name within the directory added.  Completion, Default, Prompt.
+
 @item i
 An irrelevant argument.  This code always supplies @code{nil} as
 the argument's value.  No I/O.
--- a/lispref/display.texi	Wed Mar 16 16:06:45 2005 +0000
+++ b/lispref/display.texi	Sat Mar 19 17:55:13 2005 +0000
@@ -3064,7 +3064,55 @@
 insert images into text, and also control other aspects of how text
 displays.  The value of the @code{display} property should be a
 display specification, or a list or vector containing several display
-specifications.  The rest of this section describes several kinds of
+specifications.
+
+  Some kinds of @code{display} properties specify something to display
+instead of the text that has the property.  In this case, ``the text''
+means all the consecutive characters that have the same Lisp object as
+their @code{display} property; these characters are replaced as a
+single unit.  By contrast, characters that have similar but distinct
+Lisp objects as their @code{display} properties are handled
+separately.  Here's a function that illustrates this point:
+
+@example
+(defun foo ()
+  (goto-char (point-min))
+  (dotimes (i 5)
+    (let ((string (concat "A")))
+      (put-text-property (point) (1+ (point)) 'display string)
+      (forward-char 1)
+      (put-text-property (point) (1+ (point)) 'display string)
+      (forward-char 1))))
+@end example
+
+@noindent
+It gives each of the first ten characters in the buffer string
+@code{"A"} as the @code{display} property, but they don't all get the
+same string.  The first two characters get the same string, so they
+together are replaced with one @samp{A}.  The next two characters get
+a second string, so they together are replaced with one @samp{A}.
+Likewise for each following pair of characters.  Thus, the ten
+characters appear as five A's.  This function would have the same
+results:
+
+@example
+(defun foo ()
+  (goto-char (point-min))
+  (dotimes (i 5)
+    (let ((string (concat "A")))
+      (put-text-property (point) (2+ (point)) 'display string)
+      (put-text-property (point) (1+ (point)) 'display string)
+      (forward-char 2))))
+@end example
+
+@noindent
+This illustrates that what matters is the property value for
+each character.  If two consecutive characters have the same
+object as the @code{display} property value, it's irrelevent
+whether they got this property from a single call to
+@code{put-text-property} or from two different calls.
+
+  The rest of this section describes several kinds of
 display specifications and what they mean.
 
 @menu
@@ -3216,6 +3264,9 @@
 in the @code{display} text property.
 
 @table @code
+@item @var{string}
+Display @var{string} instead of the text that has this property.
+
 @item (image . @var{image-props})
 This display specification is an image descriptor (@pxref{Images}).
 When used as a display specification, it means to display the image
--- a/lispref/nonascii.texi	Wed Mar 16 16:06:45 2005 +0000
+++ b/lispref/nonascii.texi	Sat Mar 19 17:55:13 2005 +0000
@@ -293,8 +293,8 @@
 0 through 127 are completely legitimate in both representations.
 
 @defun char-valid-p charcode &optional genericp
-This returns @code{t} if @var{charcode} is valid for either one of the two
-text representations.
+This returns @code{t} if @var{charcode} is valid (either for unibyte
+text or for multibyte text).
 
 @example
 (char-valid-p 65)
--- a/lispref/searching.texi	Wed Mar 16 16:06:45 2005 +0000
+++ b/lispref/searching.texi	Sat Mar 19 17:55:13 2005 +0000
@@ -136,9 +136,9 @@
 @end group
 @end example
 
-If @var{limit} is non-@code{nil} (it must be a position in the current
-buffer), then it is the upper bound to the search.  The match found must
-not extend after that position.
+If @var{limit} is non-@code{nil}, it must be a position in the current
+buffer; it specifies the upper bound to the search.  The match found
+must not extend after that position.
 
 If @var{noerror} is @code{nil}, then @code{word-search-forward} signals
 an error if the search fails.  If @var{noerror} is @code{t}, then it
@@ -844,15 +844,15 @@
 @var{regexp}, and leaves point at the end of the first match found.
 It returns the new value of point.
 
-If @var{limit} is non-@code{nil} (it must be a position in the current
-buffer), then it is the upper bound to the search.  No match extending
-after that position is accepted.
+If @var{limit} is non-@code{nil}, it must be a position in the current
+buffer.  It specifies the upper bound to the search.  No match
+extending after that position is accepted.
 
-If @var{repeat} is supplied (it must be a positive number), then the
-search is repeated that many times (each time starting at the end of the
-previous time's match).  If all these successive searches succeed, the
-function succeeds, moving point and returning its new value.  Otherwise
-the function fails.
+If @var{repeat} is supplied, it must be a positive number; the search
+is repeated that many times; each repetition starts at the end of the
+previous match.  If all these successive searches succeed, the
+function succeeds, moving point and returning its new value.
+Otherwise the function fails.
 
 What happens when the function fails depends on the value of
 @var{noerror}.  If @var{noerror} is @code{nil}, a @code{search-failed}
@@ -1004,10 +1004,14 @@
 @defvar search-spaces-regexp
 If this variable is non-@code{nil}, it should be a regular expression
 that says how to search for whitespace.  In that case, any group of
-spaces within in a regular expression being searched for stands for
-use of this regular expression.  However, spaces inside of constructs
-such as @samp{[@dots{}]} and @samp{*}, @samp{+}, @samp{?} are not
-affected by @code{search-spaces-regexp}.
+spaces in a regular expression being searched for stands for use of
+this regular expression.  However, spaces inside of constructs such as
+@samp{[@dots{}]} and @samp{*}, @samp{+}, @samp{?} are not affected by
+@code{search-spaces-regexp}.
+
+Since this variable affects all regular expression search and match
+constructs, you should bind it temporarily for as small as possible
+a part of the code.
 @end defvar
 
 @node POSIX Regexps
--- a/lispref/text.texi	Wed Mar 16 16:06:45 2005 +0000
+++ b/lispref/text.texi	Sat Mar 19 17:55:13 2005 +0000
@@ -1228,6 +1228,16 @@
 @var{adjustment} character positions.  Undoing this element moves
 @var{marker} @minus{} @var{adjustment} characters.
 
+@item (apply @var{funname} . @var{args})
+This is an extensible undo item, which is undone by calling
+@var{funname} with arguments @var{args}.
+
+@item (apply @var{delta} @var{beg} @var{end} @var{funname} . @var{args})
+This is an extensible undo item, which records a change limited to the
+range @var{beg} to @var{end}, which increased the size of the buffer
+by @var{delta}.  It is undone by calling @var{funname} with arguments
+@var{args}.
+
 @item nil
 This element is a boundary.  The elements between two boundaries are
 called a @dfn{change group}; normally, each change group corresponds to
@@ -1480,6 +1490,17 @@
 avoid breaking the line at such a place.
 @end defopt
 
+@defopt sentence-end-without-period
+If this variable is non-@code{nil}, a sentence can end without a
+period.  This is used for languages like Thai, where sentences end
+with a double space but without a period.
+@end defopt
+
+@defopt sentence-end-without-space
+If this variable is non-@code{nil}, it should be a string of
+characters that can end a sentence without following spaces.
+@end defopt
+
 @defvar fill-paragraph-function
 This variable provides a way for major modes to override the filling of
 paragraphs.  If the value is non-@code{nil}, @code{fill-paragraph} calls
@@ -2619,9 +2640,9 @@
 @end defun
 
 @defun remove-list-of-text-properties start end list-of-properties &optional object
-Like @code{remove-list-properties} except that
+Like @code{remove-text-properties} except that
 @var{list-of-properties} is a list property names only, not an
-alternating list of property values.
+alternating list of property names and values.
 @end defun
 
 @defun set-text-properties start end props &optional object
--- a/lwlib/ChangeLog	Wed Mar 16 16:06:45 2005 +0000
+++ b/lwlib/ChangeLog	Sat Mar 19 17:55:13 2005 +0000
@@ -1,3 +1,26 @@
+2005-03-17  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	Add support for I18N to Lucid menus.
+
+	* xlwmenuP.h (struct _XlwMenu_part) [HAVE_X_I18N]: Change `font' to be
+	a fontset.  Add a `font_extents' element.
+
+	* xlwmenu.c (xlwMenuResources) [HAVE_X_I18N]: Use a fontset for the
+	`font' resource.
+	(string_width) [HAVE_X_I18N]: Use XmbTextExtents;
+	(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): New macros.
+	(arrow_width, toggle_button_width, size_menu_item, draw_arrow)
+	(draw_toggle, draw_radio, display_menu_item): Use them.
+	(display_menu_item) [HAVE_X_I18N]: Use XmbDrawString.
+	(make_drawing_gcs) [HAVE_X_I18N]: Don't mess with fonts.
+	(XlwMenuInitialize) [HAVE_X_I18N]: Initialize font_extents.
+	(XlwMenuSetValues) [HAVE_X_I18N]: Refresh font_extents if font changes.
+
+	* lwlib-Xm.c (xm_update_label, xm_update_list): Use the recommended
+	XmStringCreateLocalized function.  Add missing copyright.
+
+	* lwlib-Xm.h: Add missing copyright and license notice.
+
 2005-03-12  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* xlwmenuP.h:
--- a/lwlib/lwlib-Xm.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/lwlib/lwlib-Xm.c	Sat Mar 19 17:55:13 2005 +0000
@@ -1,11 +1,13 @@
 /* The lwlib interface to Motif widgets.
+   Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2003, 2004, 2005
+             Free Software Foundation, Inc.
    Copyright (C) 1992 Lucid, Inc.
 
 This file is part of the Lucid Widget Library.
 
 The Lucid Widget Library is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
+the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
 The Lucid Widget Library is distributed in the hope that it will be useful,
@@ -368,7 +370,7 @@
       else
 	{
 	  built_string =
-	    XmStringCreateLtoR (val->value, XmSTRING_DEFAULT_CHARSET);
+	    XmStringCreateLocalized (val->value);
 	  XtSetArg (al [ac], XmNlabelString, built_string); ac++;
 	}
 
@@ -377,7 +379,7 @@
 
   if (val->key)
     {
-      key_string = XmStringCreateLtoR (val->key, XmSTRING_DEFAULT_CHARSET);
+      key_string = XmStringCreateLocalized (val->key);
       XtSetArg (al [ac], XmNacceleratorText, key_string); ac++;
     }
 
@@ -406,7 +408,7 @@
   for (cur = val->contents, i = 0; cur; cur = cur->next)
     if (cur->value)
       {
-	XmString xmstr = XmStringCreate (cur->value, XmSTRING_DEFAULT_CHARSET);
+	XmString xmstr = XmStringCreateLocalized (cur->value);
 	i += 1;
 	XmListAddItem (widget, xmstr, 0);
 	if (cur->selected)
--- a/lwlib/lwlib-Xm.h	Wed Mar 16 16:06:45 2005 +0000
+++ b/lwlib/lwlib-Xm.h	Sat Mar 19 17:55:13 2005 +0000
@@ -1,3 +1,24 @@
+/* The lwlib interface to Motif widgets.
+   Copyright (C) 1994, 2000  Free Software Foundation, Inc.
+   Copyright (C) 1992 Lucid, Inc.
+
+This file is part of the Lucid Widget Library.
+
+The Lucid Widget Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+The Lucid Widget Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
 #ifndef LWLIB_XM_H
 #define LWLIB_XM_H
 
--- a/lwlib/xlwmenu.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/lwlib/xlwmenu.c	Sat Mar 19 17:55:13 2005 +0000
@@ -1,6 +1,6 @@
 /* Implements a lightweight menubar widget.
    Copyright (C) 1992 Lucid, Inc.
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2005 Free Software Foundation, Inc.
 
 This file is part of the Lucid Widget Library.
 
@@ -135,8 +135,13 @@
 static XtResource
 xlwMenuResources[] =
 {
+#ifdef HAVE_X_I18N
+  {XtNfont,  XtCFont, XtRFontSet, sizeof(XFontSet),
+     offset(menu.font), XtRString, "XtDefaultFontSet"},
+#else
   {XtNfont,  XtCFont, XtRFontStruct, sizeof(XFontStruct *),
-     offset(menu.font),XtRString, "XtDefaultFont"},
+     offset(menu.font), XtRString, "XtDefaultFont"},
+#endif
   {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
      offset(menu.foreground), XtRString, "XtDefaultForeground"},
   {XtNdisabledForeground, XtCDisabledForeground, XtRPixel, sizeof(Pixel),
@@ -235,7 +240,7 @@
     XtNumber(xlwMenuResources),		/* resource_count	  */
     NULLQUARK,				/* xrm_class		  */
     TRUE,				/* compress_motion	  */
-    TRUE,				/* compress_exposure	  */
+    XtExposeCompressMaximal,		/* compress_exposure	  */
     TRUE,				/* compress_enterleave    */
     FALSE,				/* visible_interest	  */
     XlwMenuDestroy,			/* destroy		  */
@@ -353,18 +358,35 @@
      XlwMenuWidget mw;
      char *s;
 {
+#ifdef HAVE_X_I18N
+  XRectangle ink, logical;
+  XmbTextExtents (mw->menu.font, s, strlen (s), &ink, &logical);
+  return logical.width;
+#else
   XCharStruct xcs;
   int drop;
 
   XTextExtents (mw->menu.font, s, strlen (s), &drop, &drop, &drop, &xcs);
   return xcs.width;
+#endif
 }
 
+#ifdef HAVE_X_I18N
+#define MENU_FONT_HEIGHT(mw) \
+  ((mw)->menu.font_extents->max_logical_extent.height)
+#define MENU_FONT_ASCENT(mw) \
+  (- (mw)->menu.font_extents->max_logical_extent.y)
+#else
+#define MENU_FONT_HEIGHT(mw) \
+  ((mw)->menu.font->ascent + (mw)->menu.font->descent)
+#define MENU_FONT_ASCENT(mw) ((mw)->menu.font->ascent)
+#endif
+
 static int
 arrow_width (mw)
      XlwMenuWidget mw;
 {
-  return (mw->menu.font->ascent * 3/4) | 1;
+  return (MENU_FONT_ASCENT (mw) * 3/4) | 1;
 }
 
 /* Return the width of toggle buttons of widget MW.  */
@@ -373,7 +395,7 @@
 toggle_button_width (mw)
      XlwMenuWidget mw;
 {
-  return ((mw->menu.font->ascent + mw->menu.font->descent) * 2 / 3) | 1;
+  return (MENU_FONT_HEIGHT (mw) * 2 / 3) | 1;
 }
 
 
@@ -454,9 +476,8 @@
     }
   else
     {
-      *height =
-	mw->menu.font->ascent + mw->menu.font->descent
-	  + 2 * mw->menu.vertical_spacing + 2 * mw->menu.shadow_thickness;
+      *height = MENU_FONT_HEIGHT (mw)
+	+ 2 * mw->menu.vertical_spacing + 2 * mw->menu.shadow_thickness;
 
       *label_width =
 	string_width (mw, resource_widget_value (mw, val))
@@ -571,7 +592,7 @@
   double factor = 1.62;
   int thickness2 = thickness * factor;
 
-  y += (mw->menu.font->ascent + mw->menu.font->descent - height) / 2;
+  y += (MENU_FONT_HEIGHT (mw) - height) / 2;
 
   if (down_p)
     {
@@ -757,7 +778,7 @@
   width = toggle_button_width (mw);
   height = width;
   x += mw->menu.horizontal_spacing;
-  y += (mw->menu.font->ascent - height) / 2;
+  y += (MENU_FONT_ASCENT (mw) - height) / 2;
   draw_shadow_rectangle (mw, window, x, y, width, height, False, selected_p);
 }
 
@@ -777,7 +798,7 @@
   width = radio_button_width (mw);
   height = width;
   x += mw->menu.horizontal_spacing;
-  y += (mw->menu.font->ascent - height) / 2;
+  y += (MENU_FONT_ASCENT (mw) - height) / 2;
   draw_shadow_rhombus (mw, window, x, y, width, height, False, selected_p);
 }
 
@@ -954,8 +975,8 @@
 {
   GC deco_gc;
   GC text_gc;
-  int font_ascent = mw->menu.font->ascent;
-  int font_descent = mw->menu.font->descent;
+  int font_height = MENU_FONT_HEIGHT (mw);
+  int font_ascent = MENU_FONT_ASCENT (mw);
   int shadow = mw->menu.shadow_thickness;
   int margin = mw->menu.margin;
   int h_spacing = mw->menu.horizontal_spacing;
@@ -1028,7 +1049,12 @@
 	    x_offset += ws->button_width;
 
 
-          XDrawString (XtDisplay (mw), ws->window, text_gc, x_offset,
+#ifdef HAVE_X_I18N
+          XmbDrawString (XtDisplay (mw), ws->window, mw->menu.font,
+#else
+          XDrawString (XtDisplay (mw), ws->window,
+#endif
+		       text_gc, x_offset,
 		       y + v_spacing + shadow + font_ascent,
 		       display_string, strlen (display_string));
 
@@ -1053,7 +1079,12 @@
 		}
 	      else if (val->key)
 		{
-		  XDrawString (XtDisplay (mw), ws->window, text_gc,
+#ifdef HAVE_X_I18N
+		  XmbDrawString (XtDisplay (mw), ws->window, mw->menu.font,
+#else
+		  XDrawString (XtDisplay (mw), ws->window,
+#endif
+			       text_gc,
 			       x + label_width + mw->menu.arrow_spacing,
 			       y + v_spacing + shadow + font_ascent,
 			       val->key, strlen (val->key));
@@ -1065,7 +1096,7 @@
 			      mw->menu.background_gc,
 			      x + shadow, y + shadow,
 			      label_width + h_spacing - 1,
-			      font_ascent + font_descent + 2 * v_spacing - 1);
+			      font_height + 2 * v_spacing - 1);
 	      draw_shadow_rectangle (mw, ws->window, x, y, width, height,
 				     True, False);
 	    }
@@ -1460,21 +1491,33 @@
   XGCValues xgcv;
   float scale;
 
+#ifndef HAVE_X_I18N
   xgcv.font = mw->menu.font->fid;
+#endif
   xgcv.foreground = mw->menu.foreground;
   xgcv.background = mw->core.background_pixel;
   mw->menu.foreground_gc = XtGetGC ((Widget)mw,
-				    GCFont | GCForeground | GCBackground,
+#ifndef HAVE_X_I18N
+				    GCFont |
+#endif
+				    GCForeground | GCBackground,
 				    &xgcv);
 
+#ifndef HAVE_X_I18N
   xgcv.font = mw->menu.font->fid;
+#endif
   xgcv.foreground = mw->menu.button_foreground;
   xgcv.background = mw->core.background_pixel;
   mw->menu.button_gc = XtGetGC ((Widget)mw,
-				GCFont | GCForeground | GCBackground,
+#ifndef HAVE_X_I18N
+				GCFont |
+#endif
+				GCForeground | GCBackground,
 				&xgcv);
 
+#ifndef HAVE_X_I18N
   xgcv.font = mw->menu.font->fid;
+#endif
   xgcv.background = mw->core.background_pixel;
 
 #define BRIGHTNESS(color) (((color) & 0xff) + (((color) >> 8) & 0xff) + (((color) >> 16) & 0xff))
@@ -1500,31 +1543,47 @@
       xgcv.fill_style = FillStippled;
       xgcv.stipple = mw->menu.gray_pixmap;
       mw->menu.disabled_gc = XtGetGC ((Widget)mw,
-				      (GCFont | GCForeground | GCBackground
-				       | GCFillStyle | GCStipple), &xgcv);
+#ifndef HAVE_X_I18N
+				      GCFont |
+#endif
+				      GCForeground | GCBackground
+				      | GCFillStyle | GCStipple, &xgcv);
     }
   else
     {
       /* Many colors available, use disabled pixel.  */
       xgcv.foreground = mw->menu.disabled_foreground;
       mw->menu.disabled_gc = XtGetGC ((Widget)mw,
-				      (GCFont | GCForeground | GCBackground), &xgcv);
+#ifndef HAVE_X_I18N
+				      GCFont |
+#endif
+				      GCForeground | GCBackground, &xgcv);
     }
 
+#ifndef HAVE_X_I18N
   xgcv.font = mw->menu.font->fid;
+#endif
   xgcv.foreground = mw->menu.button_foreground;
   xgcv.background = mw->core.background_pixel;
   xgcv.fill_style = FillStippled;
   xgcv.stipple = mw->menu.gray_pixmap;
   mw->menu.inactive_button_gc = XtGetGC ((Widget)mw,
-				  (GCFont | GCForeground | GCBackground
-				   | GCFillStyle | GCStipple), &xgcv);
+#ifndef HAVE_X_I18N
+					 GCFont |
+#endif
+					 GCForeground | GCBackground
+					 | GCFillStyle | GCStipple, &xgcv);
 
+#ifndef HAVE_X_I18N
   xgcv.font = mw->menu.font->fid;
+#endif
   xgcv.foreground = mw->core.background_pixel;
   xgcv.background = mw->menu.foreground;
   mw->menu.background_gc = XtGetGC ((Widget)mw,
-				    GCFont | GCForeground | GCBackground,
+#ifndef HAVE_X_I18N
+				    GCFont |
+#endif
+				    GCForeground | GCBackground,
 				    &xgcv);
 }
 
@@ -1731,12 +1790,16 @@
 				   gray_bitmap_width, gray_bitmap_height,
 				   (unsigned long)1, (unsigned long)0, 1);
 
+#ifndef HAVE_X_I18N
   /* I don't understand why this ends up 0 sometimes,
      but it does.  This kludge works around it.
      Can anyone find a real fix?   -- rms.  */
   if (mw->menu.font == 0)
     mw->menu.font = xlwmenu_default_font;
-
+#else
+  mw->menu.font_extents = XExtentsOfFontSet (mw->menu.font);
+#endif
+      
   make_drawing_gcs (mw);
   make_shadow_gcs (mw);
 
@@ -1903,7 +1966,10 @@
 
   if (newmw->core.background_pixel != oldmw->core.background_pixel
       || newmw->menu.foreground != oldmw->menu.foreground
-      || newmw->menu.font != oldmw->menu.font)
+#ifndef HAVE_X_I18N
+      || newmw->menu.font != oldmw->menu.font
+#endif
+      )
     {
       release_drawing_gcs (newmw);
       make_drawing_gcs (newmw);
@@ -1929,6 +1995,14 @@
 	  }
     }
 
+#ifdef HAVE_X_I18N
+  if (newmw->menu.font != oldmw->menu.font)
+    {
+      redisplay = True;
+      newmw->menu.font_extents = XExtentsOfFontSet (newmw->menu.font);
+    }
+#endif
+
   return redisplay;
 }
 
--- a/lwlib/xlwmenuP.h	Wed Mar 16 16:06:45 2005 +0000
+++ b/lwlib/xlwmenuP.h	Sat Mar 19 17:55:13 2005 +0000
@@ -43,7 +43,12 @@
 typedef struct _XlwMenu_part
 {
   /* slots set by the resources */
+#ifdef HAVE_X_I18N
+  XFontSet	font;
+  XFontSetExtents *font_extents;
+#else
   XFontStruct*	font;
+#endif
   Pixel		foreground;
   Pixel		disabled_foreground;
   Pixel		button_foreground;
--- a/mac/ChangeLog	Wed Mar 16 16:06:45 2005 +0000
+++ b/mac/ChangeLog	Sat Mar 19 17:55:13 2005 +0000
@@ -1,14 +1,19 @@
+2005-03-16  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* Emacs.app/Contents/Info.plist (CFBundleIdentifier): Change to
+	org.gnu.Emacs.
+
 2005-03-05  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
 	* INSTALL: Mention new target `NonCarbon'.
-	
+
 2005-03-04  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
 	* makefile.MPW (NonCarbon): New target.  The target `Emacs' is now
 	used for the Carbon build that defines HAVE_CARBON.
 
 	* inc/config.h (HAVE_STDLIB_H): Define to 1.
-	
+
 	* src/EmacsMPW.r (SIZE): Increase preferred memory size to 32MB.
 	[HAVE_CARBON] (crfg): New resource for extra stack space.
 
--- a/mac/Emacs.app/Contents/Info.plist	Wed Mar 16 16:06:45 2005 +0000
+++ b/mac/Emacs.app/Contents/Info.plist	Sat Mar 19 17:55:13 2005 +0000
@@ -26,7 +26,7 @@
 	<key>CFBundleIconFile</key>
 	<string>Emacs.icns</string>
 	<key>CFBundleIdentifier</key>
-	<string>com.gnu.Emacs</string>
+	<string>org.gnu.Emacs</string>
 	<key>CFBundleInfoDictionaryVersion</key>
 	<string>6.0</string>
 	<key>CFBundlePackageType</key>
--- a/src/ChangeLog	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/ChangeLog	Sat Mar 19 17:55:13 2005 +0000
@@ -1,7 +1,176 @@
+2005-03-18  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* xfns.c (x_create_tip_frame): Removed setting of Vx_resource_name so
+	that it doesn't become "tooltip".  The specbind is enough.
+
+	* xrdb.c (x_load_resources): Use different char *helv when I18N
+	is present.
+
+2005-03-17  Kenichi Handa  <handa@m17n.org>
+
+	* coding.c (syms_of_coding): Docstring of coding-category-list
+	fixed.
+
+2005-03-17  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* xfaces.c (x_update_menu_appearance) [HAVE_X_I18N]:
+	Use xic_create_fontsetname even for non-Motif menus.
+	Don't forget to free the fontsetname.
+
+	* xfns.c (xic_create_fontsetname): Add a final catch-all font pattern.
+
+2005-03-17  Richard M. Stallman  <rms@gnu.org>
+
+	* dispnew.c (mirror_line_dance): Set W2 according to FRAME_FROM.
+
+	* fileio.c (Fcopy_file, Frename_file, Fadd_name_to_file)
+	(Fmake_symbolic_link): Use G to read the new file name.
+
+	* callint.c (Finteractive): Document G option.
+	(Fcall_interactively): Implement G option.
+
+	* buffer.c (buffer_lisp_local_variables): New function,
+	broken out from Fbuffer_local_variables.
+	(clone_per_buffer_values): Use buffer_lisp_local_variables.
+
+2005-03-17  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* xfns.c (xic_create_fontsetname): Add `motif' argument.
+	Always return a freshly allocated string.
+	(xic_create_xfontset): Adjust call.
+
+	* xfaces.c (x_update_menu_appearance) [USE_MOTIF]:
+	Use xic_create_fontsetname to create a fontset so utf-8 locales work.
+	(dump_realized_face): Fix warning.
+
+	* emacs.c (Fkill_emacs): YAILOM.
+
+	* frame.c (Fignore_event): Fix ancient obscure C-u handling bug.
+
+2005-03-17  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* mac.c (HASHKEY_TERMINAL): Remove.
+	(HASHKEY_MAX_NID): New macro.
+	(xrm_q_get_resource_1): Rename from xrm_q_get_resource.  Add extra
+	argument.
+	(xrm_q_get_resource): Call xrm_q_get_resource_1 with extra argument.
+	(xrm_create_database, xrm_q_put_resource)
+	(xrm_merge_string_database, xrm_q_get_resource_1)
+	(xrm_q_get_resource): Change resource database representation so
+	that it may not use multiple hash tables for a single database.
+	[TARGET_API_MAC_CARBON] (xrm_cfproperty_list_to_value): YAILOM.
+
+2005-03-16  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* xmenu.c (ENCODE_MENU_STRING) [HAVE_X_I18N]: Use ENCODE_SYSTEM.
+
+	* coding.h (ENCODE_SYSTEM, DECODE_SYSTEM) [!WINDOWSNT]: Use the
+	locale-coding-system, as was already done for WINDOWSNT.
+
+	* keyboard.c (read_char): Only do the 7-bit-meta -> 27-bit-meta
+	translation for chars in the 0-255 range.
+
+2005-03-16  Lute Kamstra  <lute@gnu.org>
+
+	* floatfns.c (Ffloor): Doc fix.
+
+2005-03-16  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* mac.c: Include macterm.h instead of directly including Carbon.h.
+	[TARGET_API_MAC_CARBON] (Qstring, Qnumber, Qboolean, Qdate, Qdata)
+	(Qarray, Qdictionary): New variables.
+	(syms_of_mac) [TARGET_API_MAC_CARBON]: Initialize them.
+	[TARGET_API_MAC_CARBON] (Qutf_8): Add extern.
+	[TARGET_API_MAC_CARBON] (DECODE_UTF_8): New macro.
+	[TARGET_API_MAC_CARBON] (struct cfdict_context): New struct used
+	in callback for CFDictionaryApplyFunction.
+	[TARGET_API_MAC_CARBON] (cfdata_to_lisp, cfstring_to_lisp)
+	(cfnumber_to_lisp, cfdate_to_lisp, cfboolean_to_lisp)
+	(cfobject_desc_to_lisp, cfdictionary_add_to_list)
+	(cfdictionary_puthash, cfproperty_list_to_lisp): New functions.
+	[TARGET_API_MAC_CARBON] (Fmac_get_preference): New function.
+	(syms_of_mac) [TARGET_API_MAC_CARBON]: Defsubr it.
+	(P, LOOSE_BINDING, SINGLE_COMPONENT, HASHKEY_TERMINAL): New macro.
+	(skip_white_space, parse_comment, parse_include_file)
+	(parse_binding, parse_component, parse_resource_name, parse_value)
+	(parse_resource_line, xrm_create_database, xrm_q_put_resource)
+	(xrm_merge_string_database, xrm_q_get_resource, xrm_get_resource)
+	(xrm_cfproperty_list_to_value, xrm_get_preference_database):
+	New functions.
+
+	* macfns.c (mac_get_rdb_resource): Remove function.
+	(x_get_string_resource): Use xrm_get_resource.
+
+	* macgui.h (XrmDatabase): Typedef to Lisp_Object.
+
+	* macterm.c (x_list_fonts): FONT-LIST-CACHE is now cadr part of
+	name_list_element.
+	(mac_make_rdb): Create resource database from preferences and
+	argument string.
+	(mac_term_init): Save resource database to cddr part of
+	name_list_element.
+
+	* macterm.h (xrm_merge_string_database, xrm_get_resource)
+	(xrm_get_preference_database): Add externs.
+	[TARGET_API_MAC_CARBON] (cfdata_to_lisp, cfstring_to_lisp)
+	(cfnumber_to_lisp, cfdate_to_lisp, cfboolean_to_lisp)
+	(cfobject_desc_to_lisp, cfproperty_list_to_lisp): Likewise.
+
+	* process.c (init_process): Change `#ifdef DARWIN' to `#if
+	defined (DARWIN) || defined (MAC_OSX)'
+
+	* s/darwin.h (DARWIN): Don't define.
+
+2005-03-16  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+
+	* macfns.c (Qhyper, Qsuper, Qmeta, Qalt, Qctrl, Qcontrol, Qshift):
+	Remove unused variables.
+	(syms_of_macfns): Don't initialize them.  Likewise for
+	Qface_set_after_frame_default.  Defvar and initialize
+	Vx_window_horizontal_drag_shape.
+	(x_set_mouse_color): Change mouse pointer shape.
+	(mac_window) [!MAC_OSX]: Create root control.
+	(Fx_create_frame): Remove initializations of mouse pointer shapes.
+	(hourglass_started): New function (from xfns.c).
+	(start_hourglass, cancel_hourglass): Put function body in #ifdef
+	MAC_OSX.
+	(show_hourglass) [TARGET_API_MAC_CARBON]: Create progress
+	indicator for each non-tooltip frame if needed, and show it.
+	(hide_hourglass) [TARGET_API_MAC_CARBON]: Hide progress indicators.
+
+	* macgui.h [!TARGET_API_MAC_CARBON]: Include Appearance.h and
+	Controls.h.  Use ThemeCursor instead of CursHandle.
+
+	* macterm.c (activate_scroll_bars, deactivate_scroll_bars):
+	Remove functions and declarations.
+	(mac_set_colors): Take argument for saving background color.
+	All callers changed.
+	(XDrawLine, XClearArea, mac_draw_bitmap, XFillRectangle)
+	(mac_draw_rectangle, mac_draw_string_common): Save and Restore
+	background color.
+	(x_update_end, mac_do_track_drag): Don't reset background color.
+	(mac_define_frame_cursor) [!TARGET_API_MAC_CARBON]:
+	Use SetThemeCursor.
+	(x_set_window_size) [TARGET_API_MAC_CARBON]: Move progress
+	indicator control to the upper-right corner of the window.
+	(arrow_cursor) [!TARGET_API_MAC_CARBON]: Remove variable.
+	(do_init_managers) [!TARGET_API_MAC_CARBON]: Don't initialize it.
+	(do_window_update): Update controls after updating content area.
+	(mac_handle_window_event): Remove unused extern.
+	(XTread_socket): Check both control handle and control part code
+	to determine whether a scroll bar is clicked.  Activate/deactivate
+	root control instead of contained scroll bar controls.
+	(make_mac_terminal_frame): Use ThemeCursor constants.
+
+	* macterm.h (struct mac_output) [TARGET_API_MAC_CARBON]:
+	New member hourglass_control.
+	(HOURGLASS_WIDTH, HOURGLASS_HEIGHT): New defines.
+	(activate_scroll_bars, deactivate_scroll_bars): Remove declarations.
+
 2005-03-15  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
 	* macterm.c (keycode_to_xkeysym_table): Change mapping so that it
-	coincide with that in Apple X11 except `clear', `enter' on
+	coincides with that in Apple X11 except `clear', `enter' on
 	laptops, and fn + `enter' on laptops.
 
 2005-03-12  Stefan Monnier  <monnier@iro.umontreal.ca>
@@ -414,8 +583,8 @@
 
 	* xselect.c (selection_data_to_lisp_data): For the special case
 	type == XA_ATOM, data contains array of int, not array of Atom.
-	(x_property_data_to_lisp, selection_data_to_lisp_data): Comment
-	update: data must be array of int for format == 32.
+	(x_property_data_to_lisp, selection_data_to_lisp_data):
+	Comment update: data must be array of int for format == 32.
 
 2005-02-08  Stefan Monnier  <monnier@iro.umontreal.ca>
 
--- a/src/buffer.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/buffer.c	Sat Mar 19 17:55:13 2005 +0000
@@ -182,6 +182,7 @@
 static void free_buffer_text P_ ((struct buffer *b));
 static struct Lisp_Overlay * copy_overlays P_ ((struct buffer *, struct Lisp_Overlay *));
 static void modify_overlay P_ ((struct buffer *, EMACS_INT, EMACS_INT));
+static Lisp_Object buffer_lisp_local_variables P_ ((struct buffer *));
 
 
 /* For debugging; temporary.  See set_buffer_internal.  */
@@ -515,16 +516,11 @@
   to->overlays_before = copy_overlays (to, from->overlays_before);
   to->overlays_after = copy_overlays (to, from->overlays_after);
 
-  /* Copy the alist of local variables,
-     and all the alist elements too.  */
-  to->local_var_alist
-    = Fcopy_sequence (from->local_var_alist);
-  for (tem = to->local_var_alist; CONSP (tem);
-       tem = XCDR (tem))
-    XSETCAR (tem, Fcons (XCAR (XCAR (tem)), XCDR (XCAR (tem))));
+  /* Get (a copy of) the alist of Lisp-level local variables of FROM
+     and install that in TO.  */
+  to->local_var_alist = buffer_lisp_local_variables (from);
 }
 
-
 DEFUN ("make-indirect-buffer", Fmake_indirect_buffer, Smake_indirect_buffer,
        2, 3,
        "bMake indirect buffer (to buffer): \nBName of indirect buffer: ",
@@ -934,6 +930,43 @@
   return result;
 }
 
+/* Return an alist of the Lisp-level buffer-local bindings of
+   buffer BUF.  That is, do't include  the variables maintained
+   in special slots in the buffer object.  */
+
+static Lisp_Object
+buffer_lisp_local_variables (buf)
+     struct buffer *buf;
+{
+  Lisp_Object result = Qnil;
+  register Lisp_Object tail;
+  for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail))
+    {
+      Lisp_Object val, elt;
+
+      elt = XCAR (tail);
+
+      /* Reference each variable in the alist in buf.
+	 If inquiring about the current buffer, this gets the current values,
+	 so store them into the alist so the alist is up to date.
+	 If inquiring about some other buffer, this swaps out any values
+	 for that buffer, making the alist up to date automatically.  */
+      val = find_symbol_value (XCAR (elt));
+      /* Use the current buffer value only if buf is the current buffer.  */
+      if (buf != current_buffer)
+	val = XCDR (elt);
+
+      /* If symbol is unbound, put just the symbol in the list.  */
+      if (EQ (val, Qunbound))
+	result = Fcons (XCAR (elt), result);
+      /* Otherwise, put (symbol . value) in the list.  */
+      else
+	result = Fcons (Fcons (XCAR (elt), val), result);
+    }
+
+  return result;
+}
+
 DEFUN ("buffer-local-variables", Fbuffer_local_variables,
        Sbuffer_local_variables, 0, 1, 0,
        doc: /* Return an alist of variables that are buffer-local in BUFFER.
@@ -955,34 +988,7 @@
       buf = XBUFFER (buffer);
     }
 
-  result = Qnil;
-
-  {
-    register Lisp_Object tail;
-    for (tail = buf->local_var_alist; CONSP (tail); tail = XCDR (tail))
-      {
-	Lisp_Object val, elt;
-
-	elt = XCAR (tail);
-
-	/* Reference each variable in the alist in buf.
-	   If inquiring about the current buffer, this gets the current values,
-	   so store them into the alist so the alist is up to date.
-	   If inquiring about some other buffer, this swaps out any values
-	   for that buffer, making the alist up to date automatically.  */
-	val = find_symbol_value (XCAR (elt));
-	/* Use the current buffer value only if buf is the current buffer.  */
-	if (buf != current_buffer)
-	  val = XCDR (elt);
-
-	/* If symbol is unbound, put just the symbol in the list.  */
-	if (EQ (val, Qunbound))
-	  result = Fcons (XCAR (elt), result);
-	/* Otherwise, put (symbol . value) in the list.  */
-	else
-	  result = Fcons (Fcons (XCAR (elt), val), result);
-      }
-  }
+  result = buffer_lisp_local_variables (buf);
 
   /* Add on all the variables stored in special slots.  */
   {
@@ -1004,7 +1010,6 @@
 
   return result;
 }
-
 
 DEFUN ("buffer-modified-p", Fbuffer_modified_p, Sbuffer_modified_p,
        0, 1, 0,
--- a/src/callint.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/callint.c	Sat Mar 19 17:55:13 2005 +0000
@@ -98,6 +98,7 @@
      This skips events that are integers or symbols.
 f -- Existing file name.
 F -- Possibly nonexistent file name.
+G -- Possibly nonexistent file name, defaulting to just directory name.
 i -- Ignored, i.e. always nil.  Does not do I/O.
 k -- Key sequence (downcase the last event if needed to get a definition).
 K -- Key sequence to be redefined (do not downcase the last event).
@@ -605,6 +606,12 @@
 				     Qnil, Qnil, Qnil, Qnil, Qnil);
 	  break;
 
+	case 'G':		/* Possibly nonexistent file name,
+				   default to directory alone. */
+	  args[i] = Fread_file_name (build_string (callint_message),
+				     Qnil, Qnil, Qnil, build_string (""), Qnil);
+	  break;
+
 	case 'i':		/* Ignore an argument -- Does not do I/O */
 	  varies[i] = -1;
 	  break;
--- a/src/coding.h	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/coding.h	Sat Mar 19 17:55:13 2005 +0000
@@ -1,5 +1,5 @@
 /* Header for coding system handler.
-   Copyright (C) 2004  Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005  Free Software Foundation, Inc.
    Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN.
    Licensed to the Free Software Foundation.
 
@@ -591,9 +591,8 @@
       ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 0) \
       : name))
 
-#ifdef WINDOWSNT
 /* Encode the string STR using the specified coding system
-   for w32 system functions, if any.  */
+   for system functions, if any.  */
 #define ENCODE_SYSTEM(str)						   \
   (! NILP (Vlocale_coding_system)					   \
    && !EQ (Vlocale_coding_system, make_number (0))			   \
@@ -601,20 +600,13 @@
    : str)
 
 /* Decode the string STR using the specified coding system
-   for w32 system functions, if any.  */
+   for system functions, if any.  */
 #define DECODE_SYSTEM(name)						   \
   (! NILP (Vlocale_coding_system)					   \
    && !EQ (Vlocale_coding_system, make_number (0))			   \
    ? code_convert_string_norecord (str, Vlocale_coding_system, 0)	   \
    : str)
 
-#else /* WINDOWSNT */
-
-#define ENCODE_SYSTEM(str) string_make_unibyte(str)
-#define DECODE_SYSTEM(name) name
-
-#endif /* !WINDOWSNT */
-
 #define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 1)
 
 /* Extern declarations.  */
--- a/src/dispnew.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/dispnew.c	Sat Mar 19 17:55:13 2005 +0000
@@ -3153,7 +3153,7 @@
 		  struct glyph_matrix *m2;
 		  int m2_from;
 
-		  w2 = frame_row_to_window (root, frame_to);
+		  w2 = frame_row_to_window (root, frame_from);
 		  m2 = w2->current_matrix;
 		  m2_from = frame_from - m2->matrix_y;
 		  copy_row_except_pointers (m->rows + window_to,
--- a/src/emacs.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/emacs.c	Sat Mar 19 17:55:13 2005 +0000
@@ -2056,7 +2056,7 @@
 
   exit (INTEGERP (arg) ? XINT (arg) : EXIT_SUCCESS);
   /* NOTREACHED */
-  return 0;
+  return Qnil;
 }
 
 
--- a/src/fileio.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/fileio.c	Sat Mar 19 17:55:13 2005 +0000
@@ -2380,7 +2380,7 @@
 }
 
 DEFUN ("copy-file", Fcopy_file, Scopy_file, 2, 4,
-       "fCopy file: \nFCopy %s to file: \np\nP",
+       "fCopy file: \nGCopy %s to file: \np\nP",
        doc: /* Copy FILE to NEWNAME.  Both args must be strings.
 If NEWNAME names a directory, copy FILE there.
 Signals a `file-already-exists' error if file NEWNAME already exists,
@@ -2671,7 +2671,7 @@
 }
 
 DEFUN ("rename-file", Frename_file, Srename_file, 2, 3,
-       "fRename file: \nFRename %s to file: \np",
+       "fRename file: \nGRename %s to file: \np",
        doc: /* Rename FILE as NEWNAME.  Both args strings.
 If file has names other than FILE, it continues to have those names.
 Signals a `file-already-exists' error if a file NEWNAME already exists
@@ -2759,7 +2759,7 @@
 }
 
 DEFUN ("add-name-to-file", Fadd_name_to_file, Sadd_name_to_file, 2, 3,
-       "fAdd name to file: \nFName to add to %s: \np",
+       "fAdd name to file: \nGName to add to %s: \np",
        doc: /* Give FILE additional name NEWNAME.  Both args strings.
 Signals a `file-already-exists' error if a file NEWNAME already exists
 unless optional third argument OK-IF-ALREADY-EXISTS is non-nil.
@@ -2826,7 +2826,7 @@
 
 #ifdef S_IFLNK
 DEFUN ("make-symbolic-link", Fmake_symbolic_link, Smake_symbolic_link, 2, 3,
-       "FMake symbolic link to file: \nFMake symbolic link to file %s: \np",
+       "FMake symbolic link to file: \nGMake symbolic link to file %s: \np",
        doc: /* Make a symbolic link to FILENAME, named LINKNAME.  Both args strings.
 Signals a `file-already-exists' error if a file LINKNAME already exists
 unless optional third argument OK-IF-ALREADY-EXISTS is non-nil.
--- a/src/floatfns.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/floatfns.c	Sat Mar 19 17:55:13 2005 +0000
@@ -1,5 +1,5 @@
 /* Primitive operations on floating point for GNU Emacs Lisp interpreter.
-   Copyright (C) 1988, 1993, 1994, 1999, 2003  Free Software Foundation, Inc.
+   Copyright (C) 1988, 1993, 1994, 1999, 2003, 2005  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -861,7 +861,7 @@
 
 DEFUN ("floor", Ffloor, Sfloor, 1, 2, 0,
        doc: /* Return the largest integer no greater than ARG.
-This rounds the value towards +inf.
+This rounds the value towards -inf.
 With optional DIVISOR, return the largest integer no greater than ARG/DIVISOR.  */)
      (arg, divisor)
      Lisp_Object arg, divisor;
--- a/src/frame.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/frame.c	Sat Mar 19 17:55:13 2005 +0000
@@ -1,5 +1,5 @@
 /* Generic frame functions.
-   Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2003, 2004
+   Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2003, 2004, 2005
    Free Software Foundation.
 
 This file is part of GNU Emacs.
@@ -944,11 +944,28 @@
 }
 
 DEFUN ("ignore-event", Fignore_event, Signore_event, 0, 0, "",
-       doc: /* Do nothing, but preserve any prefix argument already specified.
+       doc: /* Do nothing.
 This is a suitable binding for `iconify-frame' and `make-frame-visible'.  */)
      ()
 {
-  current_kboard->Vprefix_arg = Vcurrent_prefix_arg;
+  /* Contrary to `handle-switch-frame', `ignore-event' is used from
+     `special-event-map'.  Commands from that map are run in a special
+     way that automatically preserves the prefix-arg.  Restoring
+     the prefix arg here is not just redundant but harmful:
+     - C-u C-x v =
+     - current-prefix-arg is set to non-nil, prefix-arg is set to nil.
+     - after the first prompt, the exit-minibuffer-hook is run which may
+       iconify a frame and thus push a `iconify-frame' event.
+     - after running exit-minibuffer-hook, current-prefix-arg is
+       restored to the non-nil value it had before the prompt.
+     - we enter the second prompt.
+       current-prefix-arg is non-nil, prefix-arg is nil.
+     - before running the first real event, we run the special iconify-frame
+       event, but we pass the `special' arg to execute-command so
+       current-prefix-arg and prefix-arg are left untouched.
+     - here we foolishly copy the non-nil current-prefix-arg to prefix-arg.
+     - the next key event will have a spuriously non-nil current-prefix-arg.
+  current_kboard->Vprefix_arg = Vcurrent_prefix_arg; */
   return Qnil;
 }
 
--- a/src/keyboard.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/keyboard.c	Sat Mar 19 17:55:13 2005 +0000
@@ -2502,7 +2502,7 @@
 
       c = Faref (Vexecuting_macro, make_number (executing_macro_index));
       if (STRINGP (Vexecuting_macro)
-	  && (XINT (c) & 0x80))
+	  && (XINT (c) & 0x80) && (XUINT (c) <= 0xff))
 	XSETFASTINT (c, CHAR_META | (XINT (c) & ~0x80));
 
       executing_macro_index++;
--- a/src/mac.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/mac.c	Sat Mar 19 17:55:13 2005 +0000
@@ -26,31 +26,15 @@
 #include <errno.h>
 #include <time.h>
 
-#ifdef HAVE_CARBON
-#ifdef MAC_OSX
-#undef mktime
-#undef DEBUG
-#undef free
-#undef malloc
-#undef realloc
-#undef init_process
-#include <Carbon/Carbon.h>
-#undef mktime
-#define mktime emacs_mktime
-#undef free
-#define free unexec_free
-#undef malloc
-#define malloc unexec_malloc
-#undef realloc
-#define realloc unexec_realloc
-#undef init_process
-#define init_process emacs_init_process
-#else  /* not MAC_OSX */
-#undef SIGHUP
-#define OLDP2C 1
-#include <Carbon.h>
-#endif	/* not MAC_OSX */
-#else	/* not HAVE_CARBON */
+#include "lisp.h"
+#include "process.h"
+#include "sysselect.h"
+#include "systime.h"
+#include "blockinput.h"
+
+#include "macterm.h"
+
+#ifndef HAVE_CARBON
 #include <Files.h>
 #include <MacTypes.h>
 #include <TextUtils.h>
@@ -81,12 +65,6 @@
 #include <unistd.h>
 #endif
 
-#include "lisp.h"
-#include "process.h"
-#include "sysselect.h"
-#include "systime.h"
-#include "blockinput.h"
-
 Lisp_Object QCLIPBOARD;
 
 /* An instance of the AppleScript component.  */
@@ -272,7 +250,25 @@
   return 1;
 }
 
+
+/***********************************************************************
+	 Conversion between Lisp and Core Foundation objects
+ ***********************************************************************/
+
 #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
+{
+  Lisp_Object *result;
+  int with_tag, hash_bound;
+};
+
+/* C string to CFString. */
+
 CFStringRef
 cfstring_create_with_utf8_cstring (c_str)
      const char *c_str;
@@ -286,8 +282,824 @@
 
   return str;
 }
+
+
+/* From CFData to a lisp string.  Always returns a unibyte string.  */
+
+Lisp_Object
+cfdata_to_lisp (data)
+     CFDataRef data;
+{
+  CFIndex len = CFDataGetLength (data);
+  Lisp_Object result = make_uninit_string (len);
+  
+  CFDataGetBytes (data, CFRangeMake (0, len), SDATA (result));
+
+  return result;
+}
+
+
+/* From CFString to a lisp string.  Never returns a unibyte string
+   (even if it only contains ASCII characters).
+   This may cause GC during code conversion. */
+
+Lisp_Object
+cfstring_to_lisp (string)
+     CFStringRef string;
+{
+  Lisp_Object result = Qnil;
+  const char *s = CFStringGetCStringPtr (string, kCFStringEncodingUTF8);
+
+  if (s)
+    result = make_unibyte_string (s, strlen (s));
+  else
+    {
+      CFDataRef data =
+	CFStringCreateExternalRepresentation (NULL, string,
+					      kCFStringEncodingUTF8, '?');
+
+      if (data)
+	{
+	  result = cfdata_to_lisp (data);
+	  CFRelease (data);
+	}
+    }
+
+  if (!NILP (result))
+    {
+      result = DECODE_UTF_8 (result);
+      /* This may be superfluous.  Just to make sure that the result
+	 is a multibyte string.  */
+      result = string_to_multibyte (result);
+    }
+
+  return result;
+}
+
+
+/* CFNumber to a lisp integer or a lisp float.  */
+
+Lisp_Object
+cfnumber_to_lisp (number)
+     CFNumberRef number;
+{
+  Lisp_Object result = Qnil;
+#if BITS_PER_EMACS_INT > 32
+  SInt64 int_val;
+  CFNumberType emacs_int_type = kCFNumberSInt64Type;
+#else
+  SInt32 int_val;
+  CFNumberType emacs_int_type = kCFNumberSInt32Type;
 #endif
-
+  double float_val;
+
+  if (CFNumberGetValue (number, emacs_int_type, &int_val)
+      && !FIXNUM_OVERFLOW_P (int_val))
+    result = make_number (int_val);
+  else
+    if (CFNumberGetValue (number, kCFNumberDoubleType, &float_val))
+      result = make_float (float_val);
+  return result;
+}
+
+
+/* CFDate to a list of three integers as in a return value of
+   `current-time'xo.  */
+
+Lisp_Object
+cfdate_to_lisp (date)
+     CFDateRef date;
+{
+  static CFGregorianDate epoch_gdate = {1970, 1, 1, 0, 0, 0.0};
+  static CFAbsoluteTime epoch = 0.0, sec;
+  int high, low;
+
+  if (epoch == 0.0)
+    epoch = CFGregorianDateGetAbsoluteTime (epoch_gdate, NULL);
+
+  sec = CFDateGetAbsoluteTime (date) - epoch;
+  high = sec / 65536.0;
+  low = sec - high * 65536.0;
+
+  return list3 (make_number (high), make_number (low), make_number (0));
+}
+
+
+/* CFBoolean to a lisp symbol, `t' or `nil'.  */
+
+Lisp_Object
+cfboolean_to_lisp (boolean)
+     CFBooleanRef boolean;
+{
+  return CFBooleanGetValue (boolean) ? Qt : Qnil;
+}
+
+
+/* Any Core Foundation object to a (lengthy) lisp string.  */
+
+Lisp_Object
+cfobject_desc_to_lisp (object)
+     CFTypeRef object;
+{
+  Lisp_Object result = Qnil;
+  CFStringRef desc = CFCopyDescription (object);
+
+  if (desc)
+    {
+      result = cfstring_to_lisp (desc);
+      CFRelease (desc);
+    }
+
+  return result;
+}
+
+
+/* Callback functions for cfproperty_list_to_lisp.  */
+
+static void
+cfdictionary_add_to_list (key, value, context)
+     const void *key;
+     const void *value;
+     void *context;
+{
+  struct cfdict_context *cxt = (struct cfdict_context *)context;
+
+  *cxt->result =
+    Fcons (Fcons (cfstring_to_lisp (key),
+		  cfproperty_list_to_lisp (value, cxt->with_tag,
+					   cxt->hash_bound)),
+	   *cxt->result);
+}
+
+static void
+cfdictionary_puthash (key, value, context)
+     const void *key;
+     const void *value;
+     void *context;
+{
+  Lisp_Object lisp_key = cfstring_to_lisp (key);
+  struct cfdict_context *cxt = (struct cfdict_context *)context;
+  struct Lisp_Hash_Table *h = XHASH_TABLE (*(cxt->result));
+  unsigned hash_code;
+
+  hash_lookup (h, lisp_key, &hash_code);
+  hash_put (h, lisp_key,
+	    cfproperty_list_to_lisp (value, cxt->with_tag, cxt->hash_bound),
+	    hash_code);
+}
+
+
+/* Convert CFPropertyList PLIST to a lisp object.  If WITH_TAG is
+   non-zero, a symbol that represents the type of the original Core
+   Foundation object is prepended.  HASH_BOUND specifies which kinds
+   of the lisp objects, alists or hash tables, are used as the targets
+   of the conversion from CFDictionary.  If HASH_BOUND is negative,
+   always generate alists.  If HASH_BOUND >= 0, generate an alist if
+   the number of keys in the dictionary is smaller than HASH_BOUND,
+   and a hash table otherwise.  */
+
+Lisp_Object
+cfproperty_list_to_lisp (plist, with_tag, hash_bound)
+     CFPropertyListRef plist;
+     int with_tag, hash_bound;
+{
+  CFTypeID type_id = CFGetTypeID (plist);
+  Lisp_Object tag = Qnil, result = Qnil;
+  struct gcpro gcpro1, gcpro2;
+
+  GCPRO2 (tag, result);
+
+  if (type_id == CFStringGetTypeID ())
+    {
+      tag = Qstring;
+      result = cfstring_to_lisp (plist);
+    }
+  else if (type_id == CFNumberGetTypeID ())
+    {
+      tag = Qnumber;
+      result = cfnumber_to_lisp (plist);
+    }
+  else if (type_id == CFBooleanGetTypeID ())
+    {
+      tag = Qboolean;
+      result = cfboolean_to_lisp (plist);
+    }
+  else if (type_id == CFDateGetTypeID ())
+    {
+      tag = Qdate;
+      result = cfdate_to_lisp (plist);
+    }
+  else if (type_id == CFDataGetTypeID ())
+    {
+      tag = Qdata;
+      result = cfdata_to_lisp (plist);
+    }
+  else if (type_id == CFArrayGetTypeID ())
+    {
+      CFIndex index, count = CFArrayGetCount (plist);
+
+      tag = Qarray;
+      result = Fmake_vector (make_number (count), Qnil);
+      for (index = 0; index < count; index++)
+	XVECTOR (result)->contents[index] =
+	  cfproperty_list_to_lisp (CFArrayGetValueAtIndex (plist, index),
+				   with_tag, hash_bound);
+    }
+  else if (type_id == CFDictionaryGetTypeID ())
+    {
+      struct cfdict_context context;
+      CFIndex count = CFDictionaryGetCount (plist);
+
+      tag = Qdictionary;
+      context.result  = &result;
+      context.with_tag = with_tag;
+      context.hash_bound = hash_bound;
+      if (hash_bound < 0 || count < hash_bound)
+	{
+	  result = Qnil;
+	  CFDictionaryApplyFunction (plist, cfdictionary_add_to_list,
+				     &context);
+	}
+      else
+	{
+	  result = make_hash_table (Qequal,
+				    make_number (count),
+				    make_float (DEFAULT_REHASH_SIZE),
+				    make_float (DEFAULT_REHASH_THRESHOLD),
+				    Qnil, Qnil, Qnil);
+	  CFDictionaryApplyFunction (plist, cfdictionary_puthash,
+				     &context);
+	}
+    }
+  else
+    abort ();
+
+  UNGCPRO;
+
+  if (with_tag)
+    result = Fcons (tag, result);
+
+  return result;
+}
+#endif
+
+
+/***********************************************************************
+		 Emulation of the X Resource Manager
+ ***********************************************************************/
+
+/* Parser functions for resource lines.  Each function takes an
+   address of a variable whose value points to the head of a string.
+   The value will be advanced so that it points to the next character
+   of the parsed part when the function returns.
+
+   A resource name such as "Emacs*font" is parsed into a non-empty
+   list called `quarks'.  Each element is either a Lisp string that
+   represents a concrete component, a Lisp symbol LOOSE_BINDING
+   (actually Qlambda) that represents any number (>=0) of intervening
+   components, or a Lisp symbol SINGLE_COMPONENT (actually Qquote)
+   that represents as any single component.  */
+
+#define P (*p)
+
+#define LOOSE_BINDING    Qlambda /* '*' ("L"oose) */
+#define SINGLE_COMPONENT Qquote	 /* '?' ("Q"uestion) */
+
+static void
+skip_white_space (p)
+     char **p;
+{
+  /* WhiteSpace = {<space> | <horizontal tab>} */
+  while (*P == ' ' || *P == '\t')
+    P++;
+}
+
+static int
+parse_comment (p)
+     char **p;
+{
+  /* Comment = "!" {<any character except null or newline>} */
+  if (*P == '!')
+    {
+      P++;
+      while (*P)
+	if (*P++ == '\n')
+	  break;
+      return 1;
+    }
+  else
+    return 0;
+}
+
+/* Don't interpret filename.  Just skip until the newline.  */
+static int
+parse_include_file (p)
+     char **p;
+{
+  /* IncludeFile = "#" WhiteSpace "include" WhiteSpace FileName WhiteSpace */
+  if (*P == '#')
+    {
+      P++;
+      while (*P)
+	if (*P++ == '\n')
+	  break;
+      return 1;
+    }
+  else
+    return 0;
+}
+
+static char
+parse_binding (p)
+     char **p;
+{
+  /* Binding = "." | "*"  */
+  if (*P == '.' || *P == '*')
+    {
+      char binding = *P++;
+
+      while (*P == '.' || *P == '*')
+	if (*P++ == '*')
+	  binding = '*';
+      return binding;
+    }
+  else
+    return '\0';
+}
+
+static Lisp_Object
+parse_component (p)
+     char **p;
+{
+  /*  Component = "?" | ComponentName
+      ComponentName = NameChar {NameChar}
+      NameChar = "a"-"z" | "A"-"Z" | "0"-"9" | "_" | "-" */
+  if (*P == '?')
+    {
+      P++;
+      return SINGLE_COMPONENT;
+    }
+  else if (isalnum (*P) || *P == '_' || *P == '-')
+    {
+      char *start = P++;
+
+      while (isalnum (*P) || *P == '_' || *P == '-')
+	P++;
+
+      return make_unibyte_string (start, P - start);
+    }
+  else
+    return Qnil;
+}
+
+static Lisp_Object
+parse_resource_name (p)
+     char **p;
+{
+  Lisp_Object result = Qnil, component;
+  char binding;
+
+  /* ResourceName = [Binding] {Component Binding} ComponentName */
+  if (parse_binding (p) == '*')
+    result = Fcons (LOOSE_BINDING, result);
+
+  component = parse_component (p);
+  if (NILP (component))
+    return Qnil;
+
+  result = Fcons (component, result);
+  while (binding = parse_binding (p))
+    {
+      if (binding == '*')
+	result = Fcons (LOOSE_BINDING, result);
+      component = parse_component (p);
+      if (NILP (component))
+	return Qnil;
+      else
+	result = Fcons (component, result);
+    }
+
+  /* The final component should not be '?'.  */
+  if (EQ (component, SINGLE_COMPONENT))
+    return Qnil;
+
+  return Fnreverse (result);
+}
+
+static Lisp_Object
+parse_value (p)
+     char **p;
+{
+  char *q, *buf;
+  Lisp_Object seq = Qnil, result;
+  int buf_len, total_len = 0, len, continue_p;
+
+  q = strchr (P, '\n');
+  buf_len = q ? q - P : strlen (P);
+  buf = xmalloc (buf_len);
+
+  while (1)
+    {
+      q = buf;
+      continue_p = 0;
+      while (*P)
+	{
+	  if (*P == '\n')
+	    {
+	      P++;
+	      break;
+	    }
+	  else if (*P == '\\')
+	    {
+	      P++;
+	      if (*P == '\0')
+		break;
+	      else if (*P == '\n')
+		{
+		  P++;
+		  continue_p = 1;
+		  break;
+		}
+	      else if (*P == 'n')
+		{
+		  *q++ = '\n';
+		  P++;
+		}
+	      else if ('0' <= P[0] && P[0] <= '7'
+		       && '0' <= P[1] && P[1] <= '7'
+		       && '0' <= P[2] && P[2] <= '7')
+		{
+		  *q++ = (P[0] - '0' << 6) + (P[1] - '0' << 3) + (P[2] - '0');
+		  P += 3;
+		}
+	      else
+		*q++ = *P++;
+	    }
+	  else
+	    *q++ = *P++;
+	}
+      len = q - buf;
+      seq = Fcons (make_unibyte_string (buf, len), seq);
+      total_len += len;
+
+      if (continue_p)
+	{
+	  q = strchr (P, '\n');
+	  len = q ? q - P : strlen (P);
+	  if (len > buf_len)
+	    {
+	      xfree (buf);
+	      buf_len = len;
+	      buf = xmalloc (buf_len);
+	    }
+	}
+      else
+	break;
+    }
+  xfree (buf);
+
+  if (SBYTES (XCAR (seq)) == total_len)
+    return make_string (SDATA (XCAR (seq)), total_len);
+  else
+    {
+      buf = xmalloc (total_len);
+      q = buf + total_len;
+      for (; CONSP (seq); seq = XCDR (seq))
+	{
+	  len = SBYTES (XCAR (seq));
+	  q -= len;
+	  memcpy (q, SDATA (XCAR (seq)), len);
+	}
+      result = make_string (buf, total_len);
+      xfree (buf);
+      return result;
+    }
+}
+
+static Lisp_Object
+parse_resource_line (p)
+     char **p;
+{
+  Lisp_Object quarks, value;
+
+  /* ResourceLine = Comment | IncludeFile | ResourceSpec | <empty line> */
+  if (parse_comment (p) || parse_include_file (p))
+    return Qnil;
+
+  /* ResourceSpec = WhiteSpace ResourceName WhiteSpace ":" WhiteSpace Value */
+  skip_white_space (p);
+  quarks = parse_resource_name (p);
+  if (NILP (quarks))
+    goto cleanup;
+  skip_white_space (p);
+  if (*P != ':')
+    goto cleanup;
+  P++;
+  skip_white_space (p);
+  value = parse_value (p);
+  return Fcons (quarks, value);
+
+ cleanup:
+  /* Skip the remaining data as a dummy value.  */
+  parse_value (p);
+  return Qnil;
+}
+
+#undef P
+
+/* Equivalents of X Resource Manager functions.
+
+   An X Resource Database acts as a collection of resource names and
+   associated values.  It is implemented as a trie on quarks.  Namely,
+   each edge is labeled by either a string, LOOSE_BINDING, or
+   SINGLE_COMPONENT.  Each node has a node id, which is a unique
+   nonnegative integer, and the root node id is 0.  A database is
+   implemented as a hash table that maps a pair (SRC-NODE-ID .
+   EDGE-LABEL) to DEST-NODE-ID.  It also holds a maximum node id used
+   in the table as a value for HASHKEY_MAX_NID.  A value associated to
+   a node is recorded as a value for the node id.  */
+
+#define HASHKEY_MAX_NID (make_number (0))
+
+static XrmDatabase
+xrm_create_database ()
+{
+  XrmDatabase database;
+
+  database = make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE),
+			      make_float (DEFAULT_REHASH_SIZE),
+			      make_float (DEFAULT_REHASH_THRESHOLD),
+			      Qnil, Qnil, Qnil);
+  Fputhash (HASHKEY_MAX_NID, make_number (0), database);
+
+  return database;
+}
+
+static void
+xrm_q_put_resource (database, quarks, value)
+     XrmDatabase database;
+     Lisp_Object quarks, value;
+{
+  struct Lisp_Hash_Table *h = XHASH_TABLE (database);
+  unsigned hash_code;
+  int max_nid, i;
+  Lisp_Object node_id, key;
+
+  max_nid = XINT (Fgethash (HASHKEY_MAX_NID, database, Qnil));
+
+  XSETINT (node_id, 0);
+  for (; CONSP (quarks); quarks = XCDR (quarks))
+    {
+      key = Fcons (node_id, XCAR (quarks));
+      i = hash_lookup (h, key, &hash_code);
+      if (i < 0)
+	{
+	  max_nid++;
+	  XSETINT (node_id, max_nid); 
+	  hash_put (h, key, node_id, hash_code);
+	}
+      else
+	node_id = HASH_VALUE (h, i);
+    }
+  Fputhash (node_id, value, database);
+
+  Fputhash (HASHKEY_MAX_NID, make_number (max_nid), database);
+}
+
+/* Merge multiple resource entries specified by DATA into a resource
+   database DATABASE.  DATA points to the head of a null-terminated
+   string consisting of multiple resource lines.  It's like a
+   combination of XrmGetStringDatabase and XrmMergeDatabases.  */
+
+void
+xrm_merge_string_database (database, data)
+     XrmDatabase database;
+     char *data;
+{
+  Lisp_Object quarks_value;
+
+  while (*data)
+    {
+      quarks_value = parse_resource_line (&data);
+      if (!NILP (quarks_value))
+	xrm_q_put_resource (database,
+			    XCAR (quarks_value), XCDR (quarks_value));
+    }
+}
+
+static Lisp_Object
+xrm_q_get_resource_1 (database, node_id, quark_name, quark_class)
+     XrmDatabase database;
+     Lisp_Object node_id, quark_name, quark_class;
+{
+  struct Lisp_Hash_Table *h = XHASH_TABLE (database);
+  Lisp_Object key, labels[3], value;
+  int i, k;
+
+  if (!CONSP (quark_name))
+    return Fgethash (node_id, database, Qnil);
+
+  /* First, try tight bindings */
+  labels[0] = XCAR (quark_name);
+  labels[1] = XCAR (quark_class);
+  labels[2] = SINGLE_COMPONENT;
+
+  key = Fcons (node_id, Qnil);
+  for (k = 0; k < sizeof (labels) / sizeof (*labels); k++)
+    {
+      XSETCDR (key, labels[k]);
+      i = hash_lookup (h, key, NULL);
+      if (i >= 0)
+	{
+	  value = xrm_q_get_resource_1 (database, HASH_VALUE (h, i),
+					XCDR (quark_name), XCDR (quark_class));
+	  if (!NILP (value))
+	    return value;
+	}
+    }
+
+  /* Then, try loose bindings */
+  XSETCDR (key, LOOSE_BINDING);
+  i = hash_lookup (h, key, NULL);
+  if (i >= 0)
+    {
+      value = xrm_q_get_resource_1 (database, HASH_VALUE (h, i),
+				    quark_name, quark_class);
+      if (!NILP (value))
+	return value;
+      else
+	return xrm_q_get_resource_1 (database, node_id,
+				     XCDR (quark_name), XCDR (quark_class));
+    }
+  else
+    return Qnil;
+}
+
+static Lisp_Object
+xrm_q_get_resource (database, quark_name, quark_class)
+     XrmDatabase database;
+     Lisp_Object quark_name, quark_class;
+{
+  return xrm_q_get_resource_1 (database, make_number (0),
+			       quark_name, quark_class);
+}
+
+/* Retrieve a resource value for the specified NAME and CLASS from the
+   resource database DATABASE.  It corresponds to XrmGetResource.  */
+
+Lisp_Object
+xrm_get_resource (database, name, class)
+     XrmDatabase database;
+     char *name, *class;
+{
+  Lisp_Object quark_name, quark_class, tmp;
+  int nn, nc;
+
+  quark_name = parse_resource_name (&name);
+  if (*name != '\0')
+    return Qnil;
+  for (tmp = quark_name, nn = 0; CONSP (tmp); tmp = XCDR (tmp), nn++)
+    if (!STRINGP (XCAR (tmp)))
+      return Qnil;
+
+  quark_class = parse_resource_name (&class);
+  if (*class != '\0')
+    return Qnil;
+  for (tmp = quark_class, nc = 0; CONSP (tmp); tmp = XCDR (tmp), nc++)
+    if (!STRINGP (XCAR (tmp)))
+      return Qnil;
+
+  if (nn != nc)
+    return Qnil;
+  else
+    return xrm_q_get_resource (database, quark_name, quark_class);
+}
+
+#if TARGET_API_MAC_CARBON
+static Lisp_Object
+xrm_cfproperty_list_to_value (plist)
+     CFPropertyListRef plist;
+{
+  CFTypeID type_id = CFGetTypeID (plist);
+
+  if (type_id == CFStringGetTypeID ())
+      return cfstring_to_lisp (plist);
+  else if (type_id == CFNumberGetTypeID ())
+    {
+      CFStringRef string;
+      Lisp_Object result = Qnil;
+
+      string = CFStringCreateWithFormat (NULL, NULL, CFSTR ("%@"), plist);
+      if (string)
+	{
+	  result = cfstring_to_lisp (string);
+	  CFRelease (string);
+	}
+      return result;
+    }
+  else if (type_id == CFBooleanGetTypeID ())
+    return build_string (CFBooleanGetValue (plist) ? "true" : "false");
+  else if (type_id == CFDataGetTypeID ())
+    return cfdata_to_lisp (plist);
+  else
+    return Qnil;
+}
+#endif
+
+/* Create a new resource database from the preferences for the
+   application APPLICATION.  APPLICATION is either a string that
+   specifies an application ID, or NULL that represents the current
+   application.  */
+
+XrmDatabase
+xrm_get_preference_database (application)
+     char *application;
+{
+#if TARGET_API_MAC_CARBON
+  CFStringRef app_id, *keys, user_doms[2], host_doms[2];
+  CFMutableSetRef key_set = NULL;
+  CFArrayRef key_array;
+  CFIndex index, count;
+  char *res_name;
+  XrmDatabase database;
+  Lisp_Object quarks = Qnil, value = Qnil;
+  CFPropertyListRef plist;
+  int iu, ih;
+  struct gcpro gcpro1, gcpro2, gcpro3;
+
+  user_doms[0] = kCFPreferencesCurrentUser;
+  user_doms[1] = kCFPreferencesAnyUser;
+  host_doms[0] = kCFPreferencesCurrentHost;
+  host_doms[1] = kCFPreferencesAnyHost;
+
+  database = xrm_create_database ();
+
+  GCPRO3 (database, quarks, value);
+
+  BLOCK_INPUT;
+
+  app_id = kCFPreferencesCurrentApplication;
+  if (application)
+    {
+      app_id = cfstring_create_with_utf8_cstring (application);
+      if (app_id == NULL)
+	goto out;
+    }
+
+  key_set = CFSetCreateMutable (NULL, 0, &kCFCopyStringSetCallBacks);
+  if (key_set == NULL)
+    goto out;
+  for (iu = 0; iu < sizeof (user_doms) / sizeof (*user_doms) ; iu++)
+    for (ih = 0; ih < sizeof (host_doms) / sizeof (*host_doms); ih++)
+      {
+	key_array = CFPreferencesCopyKeyList (app_id, user_doms[iu],
+					      host_doms[ih]);
+	if (key_array)
+	  {
+	    count = CFArrayGetCount (key_array);
+	    for (index = 0; index < count; index++)
+	      CFSetAddValue (key_set,
+			     CFArrayGetValueAtIndex (key_array, index));
+	    CFRelease (key_array);
+	  }
+      }
+
+  count = CFSetGetCount (key_set);
+  keys = xmalloc (sizeof (CFStringRef) * count);
+  if (keys == NULL)
+    goto out;
+  CFSetGetValues (key_set, (const void **)keys);
+  for (index = 0; index < count; index++)
+    {
+      res_name = SDATA (cfstring_to_lisp (keys[index]));
+      quarks = parse_resource_name (&res_name);
+      if (!(NILP (quarks) || *res_name))
+	{
+	  plist = CFPreferencesCopyAppValue (keys[index], app_id);
+	  value = xrm_cfproperty_list_to_value (plist);
+	  CFRelease (plist);
+	  if (!NILP (value))
+	    xrm_q_put_resource (database, quarks, value);
+	}
+    }
+
+  xfree (keys);
+ out:
+  if (key_set)
+    CFRelease (key_set);
+  CFRelease (app_id);
+
+  UNBLOCK_INPUT;
+
+  UNGCPRO;
+
+  return database;
+#else
+  return xrm_create_database ();
+#endif
+}
+
+
 #ifndef MAC_OSX
 
 /* The following functions with "sys_" prefix are stubs to Unix
@@ -2825,6 +3637,124 @@
   return Qnil;
 }
 
+#if TARGET_API_MAC_CARBON
+static Lisp_Object Qxml;
+
+DEFUN ("mac-get-preference", Fmac_get_preference, Smac_get_preference, 1, 4, 0,
+       doc: /* Return the application preference value for KEY.
+KEY is either a string specifying a preference key, or a list of key
+strings.  If it is a list, the (i+1)-th element is used as a key for
+the CFDictionary value obtained by the i-th element.  If lookup is
+failed at some stage, nil is returned.
+
+Optional arg APPLICATION is an application ID string.  If omitted or
+nil, that stands for the current application.
+
+Optional arg FORMAT specifies the data format of the return value.  If
+omitted or nil, each Core Foundation object is converted into a
+corresponding Lisp object as follows:
+
+  Core Foundation    Lisp                           Tag
+  ------------------------------------------------------------
+  CFString           Multibyte string               string
+  CFNumber           Integer or float               number
+  CFBoolean          Symbol (t or nil)              boolean
+  CFDate             List of three integers         date
+                       (cf. `current-time')
+  CFData             Unibyte string                 data
+  CFArray            Array                          array
+  CFDictionary       Alist or hash table            dictionary
+                       (depending on HASH-BOUND)
+
+If it is t, a symbol that represents the type of the original Core
+Foundation object is prepended.  If it is `xml', the value is returned
+as an XML representation.
+
+Optional arg HASH-BOUND specifies which kinds of the list objects,
+alists or hash tables, are used as the targets of the conversion from
+CFDictionary.  If HASH-BOUND is a negative integer or nil, always
+generate alists.  If HASH-BOUND >= 0, generate an alist if the number
+of keys in the dictionary is smaller than HASH-BOUND, and a hash table
+otherwise.  */)
+  (key, application, format, hash_bound)
+     Lisp_Object key, application, format, hash_bound;
+{
+  CFStringRef app_id, key_str;
+  CFPropertyListRef app_plist = NULL, plist;
+  Lisp_Object result = Qnil, tmp;
+
+  if (STRINGP (key))
+    key = Fcons (key, Qnil);
+  else
+    {
+      CHECK_CONS (key);
+      for (tmp = key; CONSP (tmp); tmp = XCDR (tmp))
+	CHECK_STRING_CAR (tmp);
+      if (!NILP (tmp))
+	wrong_type_argument (Qlistp, key);
+    }
+  if (!NILP (application))
+    CHECK_STRING (application);
+  CHECK_SYMBOL (format);
+  if (!NILP (hash_bound))
+    CHECK_NUMBER (hash_bound);
+
+  BLOCK_INPUT;
+
+  app_id = kCFPreferencesCurrentApplication;
+  if (!NILP (application))
+    {
+      app_id = cfstring_create_with_utf8_cstring (SDATA (application));
+      if (app_id == NULL)
+	goto out;
+    }
+  key_str = cfstring_create_with_utf8_cstring (SDATA (XCAR (key)));
+  if (key_str == NULL)
+    goto out;
+  app_plist = CFPreferencesCopyAppValue (key_str, app_id);
+  CFRelease (key_str);
+  if (app_plist == NULL)
+    goto out;
+
+  plist = app_plist;
+  for (key = XCDR (key); CONSP (key); key = XCDR (key))
+    {
+      if (CFGetTypeID (plist) != CFDictionaryGetTypeID ())
+	break;
+      key_str = cfstring_create_with_utf8_cstring (SDATA (XCAR (key)));
+      if (key_str == NULL)
+	goto out;
+      plist = CFDictionaryGetValue (plist, key_str);
+      CFRelease (key_str);
+      if (plist == NULL)
+	goto out;
+    }
+
+  if (NILP (key))
+    if (EQ (format, Qxml))
+      {
+	CFDataRef data = CFPropertyListCreateXMLData (NULL, plist);
+	if (data == NULL)
+	  goto out;
+	result = cfdata_to_lisp (data);
+	CFRelease (data);
+      }
+    else
+      result =
+	cfproperty_list_to_lisp (plist, EQ (format, Qt),
+				 NILP (hash_bound) ? -1 : XINT (hash_bound));
+
+ out:
+  if (app_plist)
+    CFRelease (app_plist);
+  CFRelease (app_id);
+
+  UNBLOCK_INPUT;
+
+  return result;
+}
+#endif	/* TARGET_API_MAC_CARBON */
+
 
 DEFUN ("mac-clear-font-name-table", Fmac_clear_font_name_table, Smac_clear_font_name_table, 0, 0, 0,
        doc: /* Clear the font name table.  */)
@@ -3243,9 +4173,38 @@
   QCLIPBOARD = intern ("CLIPBOARD");
   staticpro (&QCLIPBOARD);
 
+#if TARGET_API_MAC_CARBON
+  Qstring = intern ("string");
+  staticpro (&Qstring);
+
+  Qnumber = intern ("number");
+  staticpro (&Qnumber);
+
+  Qboolean = intern ("boolean");
+  staticpro (&Qboolean);
+
+  Qdate = intern ("date");
+  staticpro (&Qdate);
+
+  Qdata = intern ("data");
+  staticpro (&Qdata);
+
+  Qarray = intern ("array");
+  staticpro (&Qarray);
+
+  Qdictionary = intern ("dictionary");
+  staticpro (&Qdictionary);
+
+  Qxml = intern ("xml");
+  staticpro (&Qxml);
+#endif
+
   defsubr (&Smac_paste_function);
   defsubr (&Smac_cut_function);
   defsubr (&Sx_selection_exists_p);
+#if TARGET_API_MAC_CARBON
+  defsubr (&Smac_get_preference);
+#endif
   defsubr (&Smac_clear_font_name_table);
 
   defsubr (&Sdo_applescript);
--- a/src/macfns.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/macfns.c	Sat Mar 19 17:55:13 2005 +0000
@@ -149,13 +149,6 @@
 Lisp_Object Qsuppress_icon;
 Lisp_Object Qundefined_color;
 Lisp_Object Qcancel_timer;
-Lisp_Object Qhyper;
-Lisp_Object Qsuper;
-Lisp_Object Qmeta;
-Lisp_Object Qalt;
-Lisp_Object Qctrl;
-Lisp_Object Qcontrol;
-Lisp_Object Qshift;
 
 extern Lisp_Object Vwindow_system_version;
 
@@ -1453,148 +1446,99 @@
      struct frame *f;
      Lisp_Object arg, oldval;
 {
+  struct x_output *x = f->output_data.x;
+  Display *dpy = FRAME_MAC_DISPLAY (f);
   Cursor cursor, nontext_cursor, mode_cursor, hand_cursor;
-  int count;
-  int mask_color;
-
-  if (!EQ (Qnil, arg))
-    f->output_data.mac->mouse_pixel
-      = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
-  mask_color = FRAME_BACKGROUND_PIXEL (f);
+  Cursor hourglass_cursor, horizontal_drag_cursor;
+  unsigned long pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
+  unsigned long mask_color = x->background_pixel;
 
   /* Don't let pointers be invisible.  */
-  if (mask_color == f->output_data.mac->mouse_pixel
-	&& mask_color == FRAME_BACKGROUND_PIXEL (f))
-    f->output_data.mac->mouse_pixel = FRAME_FOREGROUND_PIXEL (f);
-
-#if 0 /* MAC_TODO : cursor changes */
-  BLOCK_INPUT;
-
-  /* It's not okay to crash if the user selects a screwy cursor.  */
-  count = x_catch_errors (FRAME_W32_DISPLAY (f));
-
-  if (!EQ (Qnil, Vx_pointer_shape))
+  if (mask_color == pixel)
+    pixel = x->foreground_pixel;
+
+  f->output_data.mac->mouse_pixel = pixel;
+
+  if (!NILP (Vx_pointer_shape))
     {
       CHECK_NUMBER (Vx_pointer_shape);
-      cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XINT (Vx_pointer_shape));
+      cursor = XINT (Vx_pointer_shape);
     }
   else
-    cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_xterm);
-  x_check_errors (FRAME_W32_DISPLAY (f), "bad text pointer cursor: %s");
-
-  if (!EQ (Qnil, Vx_nontext_pointer_shape))
+    cursor = kThemeIBeamCursor;
+
+  if (!NILP (Vx_nontext_pointer_shape))
     {
       CHECK_NUMBER (Vx_nontext_pointer_shape);
-      nontext_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f),
-					  XINT (Vx_nontext_pointer_shape));
+      nontext_cursor = XINT (Vx_nontext_pointer_shape);
     }
   else
-    nontext_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_left_ptr);
-  x_check_errors (FRAME_W32_DISPLAY (f), "bad nontext pointer cursor: %s");
-
-  if (!EQ (Qnil, Vx_hourglass_pointer_shape))
+    nontext_cursor = kThemeArrowCursor;
+
+  if (!NILP (Vx_hourglass_pointer_shape))
     {
       CHECK_NUMBER (Vx_hourglass_pointer_shape);
-      hourglass_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f),
-					    XINT (Vx_hourglass_pointer_shape));
+      hourglass_cursor = XINT (Vx_hourglass_pointer_shape);
     }
   else
-    hourglass_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_watch);
-  x_check_errors (FRAME_W32_DISPLAY (f), "bad busy pointer cursor: %s");
-
-  x_check_errors (FRAME_W32_DISPLAY (f), "bad nontext pointer cursor: %s");
-  if (!EQ (Qnil, Vx_mode_pointer_shape))
+    hourglass_cursor = kThemeWatchCursor;
+
+  if (!NILP (Vx_mode_pointer_shape))
     {
       CHECK_NUMBER (Vx_mode_pointer_shape);
-      mode_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f),
-				       XINT (Vx_mode_pointer_shape));
+      mode_cursor = XINT (Vx_mode_pointer_shape);
     }
   else
-    mode_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_xterm);
-  x_check_errors (FRAME_W32_DISPLAY (f), "bad modeline pointer cursor: %s");
-
-  if (!EQ (Qnil, Vx_sensitive_text_pointer_shape))
+    mode_cursor = kThemeArrowCursor;
+
+  if (!NILP (Vx_sensitive_text_pointer_shape))
     {
       CHECK_NUMBER (Vx_sensitive_text_pointer_shape);
-      hand_cursor
-	= XCreateFontCursor (FRAME_W32_DISPLAY (f),
-			     XINT (Vx_sensitive_text_pointer_shape));
+      hand_cursor = XINT (Vx_sensitive_text_pointer_shape);
     }
   else
-    hand_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_crosshair);
+    hand_cursor = kThemePointingHandCursor;
 
   if (!NILP (Vx_window_horizontal_drag_shape))
     {
       CHECK_NUMBER (Vx_window_horizontal_drag_shape);
-      horizontal_drag_cursor
-	= XCreateFontCursor (FRAME_W32_DISPLAY (f),
-			     XINT (Vx_window_horizontal_drag_shape));
+      horizontal_drag_cursor = XINT (Vx_window_horizontal_drag_shape);
     }
   else
-    horizontal_drag_cursor
-      = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_sb_h_double_arrow);
-
-  /* Check and report errors with the above calls.  */
-  x_check_errors (FRAME_W32_DISPLAY (f), "can't set cursor shape: %s");
-  x_uncatch_errors (FRAME_W32_DISPLAY (f), count);
-
+    horizontal_drag_cursor = kThemeResizeLeftRightCursor;
+
+#if 0 /* MAC_TODO: cursor color changes */
   {
     XColor fore_color, back_color;
 
-    fore_color.pixel = f->output_data.w32->mouse_pixel;
+    fore_color.pixel = f->output_data.mac->mouse_pixel;
+    x_query_color (f, &fore_color);
     back_color.pixel = mask_color;
-    XQueryColor (FRAME_W32_DISPLAY (f),
-		 DefaultColormap (FRAME_W32_DISPLAY (f),
-				  DefaultScreen (FRAME_W32_DISPLAY (f))),
-		 &fore_color);
-    XQueryColor (FRAME_W32_DISPLAY (f),
-		 DefaultColormap (FRAME_W32_DISPLAY (f),
-				  DefaultScreen (FRAME_W32_DISPLAY (f))),
-		 &back_color);
-    XRecolorCursor (FRAME_W32_DISPLAY (f), cursor,
-		    &fore_color, &back_color);
-    XRecolorCursor (FRAME_W32_DISPLAY (f), nontext_cursor,
-		    &fore_color, &back_color);
-    XRecolorCursor (FRAME_W32_DISPLAY (f), mode_cursor,
-		    &fore_color, &back_color);
-    XRecolorCursor (FRAME_W32_DISPLAY (f), hand_cursor,
-                    &fore_color, &back_color);
-    XRecolorCursor (FRAME_W32_DISPLAY (f), hourglass_cursor,
-                    &fore_color, &back_color);
+    x_query_color (f, &back_color);
+
+    XRecolorCursor (dpy, cursor, &fore_color, &back_color);
+    XRecolorCursor (dpy, nontext_cursor, &fore_color, &back_color);
+    XRecolorCursor (dpy, mode_cursor, &fore_color, &back_color);
+    XRecolorCursor (dpy, hand_cursor, &fore_color, &back_color);
+    XRecolorCursor (dpy, hourglass_cursor, &fore_color, &back_color);
+    XRecolorCursor (dpy, horizontal_drag_cursor, &fore_color, &back_color);
   }
-
-  if (FRAME_W32_WINDOW (f) != 0)
-    XDefineCursor (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), cursor);
-
-  if (cursor != f->output_data.w32->text_cursor && f->output_data.w32->text_cursor != 0)
-    XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->text_cursor);
-  f->output_data.w32->text_cursor = cursor;
-
-  if (nontext_cursor != f->output_data.w32->nontext_cursor
-      && f->output_data.w32->nontext_cursor != 0)
-    XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->nontext_cursor);
-  f->output_data.w32->nontext_cursor = nontext_cursor;
-
-  if (hourglass_cursor != f->output_data.w32->hourglass_cursor
-      && f->output_data.w32->hourglass_cursor != 0)
-    XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->hourglass_cursor);
-  f->output_data.w32->hourglass_cursor = hourglass_cursor;
-
-  if (mode_cursor != f->output_data.w32->modeline_cursor
-      && f->output_data.w32->modeline_cursor != 0)
-    XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->modeline_cursor);
-  f->output_data.w32->modeline_cursor = mode_cursor;
-
-  if (hand_cursor != f->output_data.w32->hand_cursor
-      && f->output_data.w32->hand_cursor != 0)
-    XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->hand_cursor);
-  f->output_data.w32->hand_cursor = hand_cursor;
-
-  XFlush (FRAME_W32_DISPLAY (f));
+#endif
+
+  BLOCK_INPUT;
+
+  rif->define_frame_cursor (f, cursor);
+
+  f->output_data.mac->text_cursor = cursor;
+  f->output_data.mac->nontext_cursor = nontext_cursor;
+  f->output_data.mac->hourglass_cursor = hourglass_cursor;
+  f->output_data.mac->modeline_cursor = mode_cursor;
+  f->output_data.mac->hand_cursor = hand_cursor;
+  f->output_data.mac->horizontal_drag_cursor = horizontal_drag_cursor;
+
   UNBLOCK_INPUT;
 
   update_face_from_frame_parameter (f, Qmouse_color, arg);
-#endif /* MAC_TODO */
 }
 
 void
@@ -2086,49 +2030,24 @@
 
 /* Subroutines of creating a frame.  */
 
-static char *
-mac_get_rdb_resource (rdb, resource)
-     char *rdb;
-     char *resource;
-{
-  char *value = rdb;
-  int len = strlen (resource);
-
-  while (*value)
-    {
-      if ((strncmp (value, resource, len) == 0) && (value[len] == ':'))
-        return xstrdup (&value[len + 1]);
-
-      value = strchr (value, '\0') + 1;
-    }
-
-  return NULL;
-}
-
 /* Retrieve the string resource specified by NAME with CLASS from
-   database RDB. */
+   database RDB.
+
+   The return value points to the contents of a Lisp string.  So it
+   will not be valid after the next GC where string compaction will
+   occur.  */
 
 char *
 x_get_string_resource (rdb, name, class)
      XrmDatabase rdb;
      char *name, *class;
 {
-  if (rdb)
-    {
-      char *resource;
-
-      if (resource = mac_get_rdb_resource (rdb, name))
-        return resource;
-      if (resource = mac_get_rdb_resource (rdb, class))
-        return resource;
-    }
-
-  /* MAC_TODO: implement resource strings.  (Maybe Property Lists?)  */
-#if 0
-  return mac_get_string_resource (name, class);
-#else
-  return (char *)0;
-#endif
+  Lisp_Object value = xrm_get_resource (rdb, name, class);
+
+  if (STRINGP (value))
+    return SDATA (value);
+  else
+    return NULL;
 }
 
 /* Return the value of parameter PARAM.
@@ -2327,6 +2246,18 @@
   /* so that update events can find this mac_output struct */
   f->output_data.mac->mFP = f;  /* point back to emacs frame */
 
+#ifndef MAC_OSX
+  if (FRAME_MAC_WINDOW (f))
+    {
+      ControlRef root_control;
+
+      if (CreateRootControl (FRAME_MAC_WINDOW (f), &root_control) != noErr)
+	{
+	  DisposeWindow (FRAME_MAC_WINDOW (f));
+	  FRAME_MAC_WINDOW (f) = NULL;
+	}
+    }
+#endif
   if (FRAME_MAC_WINDOW (f))
     XSetWindowBackground (FRAME_MAC_DISPLAY(f), FRAME_MAC_WINDOW (f),
 			  FRAME_BACKGROUND_PIXEL (f));
@@ -2775,22 +2706,6 @@
 
   f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
 
-#if TARGET_API_MAC_CARBON
-  f->output_data.mac->text_cursor = kThemeIBeamCursor;
-  f->output_data.mac->nontext_cursor = kThemeArrowCursor;
-  f->output_data.mac->modeline_cursor = kThemeArrowCursor;
-  f->output_data.mac->hand_cursor = kThemePointingHandCursor;
-  f->output_data.mac->hourglass_cursor = kThemeWatchCursor;
-  f->output_data.mac->horizontal_drag_cursor = kThemeResizeLeftRightCursor;
-#else
-  f->output_data.mac->text_cursor = GetCursor (iBeamCursor);
-  f->output_data.mac->nontext_cursor = &arrow_cursor;
-  f->output_data.mac->modeline_cursor = &arrow_cursor;
-  f->output_data.mac->hand_cursor = &arrow_cursor;
-  f->output_data.mac->hourglass_cursor = GetCursor (watchCursor);
-  f->output_data.mac->horizontal_drag_cursor = &arrow_cursor;
-#endif
-
   /* Compute the size of the window.  */
   window_prompting = x_figure_window_size (f, parms, 1);
 
@@ -3475,7 +3390,7 @@
 
 
 /***********************************************************************
-				Hourglass cursor
+				Busy cursor
  ***********************************************************************/
 
 /* If non-null, an asynchronous timer that, when it expires, displays
@@ -3501,13 +3416,21 @@
 static void show_hourglass P_ ((struct atimer *));
 static void hide_hourglass P_ ((void));
 
+/* Return non-zero if houglass timer has been started or hourglass is shown.  */
+
+int
+hourglass_started ()
+{
+  return hourglass_shown_p || hourglass_atimer != NULL;
+}
+
 
 /* Cancel a currently active hourglass timer, and start a new one.  */
 
 void
 start_hourglass ()
 {
-#if 0 /* MAC_TODO: cursor shape changes.  */
+#ifdef MAC_OSX
   EMACS_TIME delay;
   int secs, usecs = 0;
 
@@ -3530,16 +3453,17 @@
   EMACS_SET_SECS_USECS (delay, secs, usecs);
   hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
 				     show_hourglass, NULL);
-#endif /* MAC_TODO */
+#endif /* MAC_OSX */
 }
 
 
-/* Cancel the hourglass cursor timer if active, hide an hourglass
-   cursor if shown.  */
+/* Cancel the hourglass cursor timer if active, hide a busy cursor if
+   shown.  */
 
 void
 cancel_hourglass ()
 {
+#ifdef MAC_OSX
   if (hourglass_atimer)
     {
       cancel_atimer (hourglass_atimer);
@@ -3548,22 +3472,22 @@
 
   if (hourglass_shown_p)
     hide_hourglass ();
+#endif /* MAC_OSX */
 }
 
 
 /* Timer function of hourglass_atimer.  TIMER is equal to
    hourglass_atimer.
 
-   Display an hourglass cursor on all frames by mapping the frames'
-   hourglass_window.  Set the hourglass_p flag in the frames'
-   output_data.x structure to indicate that an hourglass cursor is
-   shown on the frames.  */
+   On Mac, busy status is shown by the progress indicator (chasing
+   arrows) at the upper-right corner of each frame instead of the
+   hourglass pointer.  */
 
 static void
 show_hourglass (timer)
      struct atimer *timer;
 {
-#if 0  /* MAC_TODO: cursor shape changes.  */
+#if TARGET_API_MAC_CARBON
   /* The timer implementation will cancel this timer automatically
      after this function has run.  Set hourglass_atimer to null
      so that we know the timer doesn't have to be canceled.  */
@@ -3576,46 +3500,44 @@
       BLOCK_INPUT;
 
       FOR_EACH_FRAME (rest, frame)
-	if (FRAME_W32_P (XFRAME (frame)))
-	  {
-	    struct frame *f = XFRAME (frame);
-
-	    f->output_data.w32->hourglass_p = 1;
-
-	    if (!f->output_data.w32->hourglass_window)
-	      {
-		unsigned long mask = CWCursor;
-		XSetWindowAttributes attrs;
-
-		attrs.cursor = f->output_data.w32->hourglass_cursor;
-
-		f->output_data.w32->hourglass_window
-		  = XCreateWindow (FRAME_X_DISPLAY (f),
-				   FRAME_OUTER_WINDOW (f),
-				   0, 0, 32000, 32000, 0, 0,
-				   InputOnly,
-				   CopyFromParent,
-				   mask, &attrs);
-	      }
-
-	    XMapRaised (FRAME_X_DISPLAY (f),
-			f->output_data.w32->hourglass_window);
-	    XFlush (FRAME_X_DISPLAY (f));
-	  }
+	{
+	  struct frame *f = XFRAME (frame);
+
+	  if (FRAME_LIVE_P (f) && FRAME_MAC_P (f)
+	      && FRAME_MAC_WINDOW (f) != tip_window)
+	    {
+	      if (!f->output_data.mac->hourglass_control)
+		{
+		  Window w = FRAME_MAC_WINDOW (f);
+		  Rect r;
+		  ControlRef c;
+
+		  GetWindowPortBounds (w, &r);
+		  r.left = r.right - HOURGLASS_WIDTH;
+		  r.bottom = r.top + HOURGLASS_HEIGHT;
+		  if (CreateChasingArrowsControl (w, &r, &c) == noErr)
+		    f->output_data.mac->hourglass_control = c;
+		}
+
+	      if (f->output_data.mac->hourglass_control)
+		ShowControl (f->output_data.mac->hourglass_control);
+	    }
+	}
 
       hourglass_shown_p = 1;
       UNBLOCK_INPUT;
     }
-#endif /* MAC_TODO */
+#endif /* TARGET_API_MAC_CARBON */
 }
 
 
-/* Hide the hourglass cursor on all frames, if it is currently shown.  */
+/* Hide the progress indicators on all frames, if it is currently
+   shown.  */
 
 static void
 hide_hourglass ()
 {
-#if 0 /* MAC_TODO: cursor shape changes.  */
+#if TARGET_API_MAC_CARBON
   if (hourglass_shown_p)
     {
       Lisp_Object rest, frame;
@@ -3625,23 +3547,16 @@
 	{
 	  struct frame *f = XFRAME (frame);
 
-	  if (FRAME_W32_P (f)
+	  if (FRAME_MAC_P (f)
 	      /* Watch out for newly created frames.  */
-	      && f->output_data.x->hourglass_window)
-	    {
-	      XUnmapWindow (FRAME_X_DISPLAY (f),
-			    f->output_data.x->hourglass_window);
-	      /* Sync here because XTread_socket looks at the
-		 hourglass_p flag that is reset to zero below.  */
-	      XSync (FRAME_X_DISPLAY (f), False);
-	      f->output_data.x->hourglass_p = 0;
-	    }
+	      && f->output_data.mac->hourglass_control)
+	    HideControl (f->output_data.mac->hourglass_control);
 	}
 
       hourglass_shown_p = 0;
       UNBLOCK_INPUT;
     }
-#endif /* MAC_TODO */
+#endif /* TARGET_API_MAC_CARBON */
 }
 
 
@@ -4487,7 +4402,7 @@
 			    Initialization
  ***********************************************************************/
 
-/* Keep this list in the same order as frame_parms in frame.c. 
+/* Keep this list in the same order as frame_parms in frame.c.
    Use 0 for unsupported frame parameters.  */
 
 frame_parm_handler mac_frame_parm_handlers[] =
@@ -4545,29 +4460,12 @@
   staticpro (&Qundefined_color);
   Qcancel_timer = intern ("cancel-timer");
   staticpro (&Qcancel_timer);
-
-  Qhyper = intern ("hyper");
-  staticpro (&Qhyper);
-  Qsuper = intern ("super");
-  staticpro (&Qsuper);
-  Qmeta = intern ("meta");
-  staticpro (&Qmeta);
-  Qalt = intern ("alt");
-  staticpro (&Qalt);
-  Qctrl = intern ("ctrl");
-  staticpro (&Qctrl);
-  Qcontrol = intern ("control");
-  staticpro (&Qcontrol);
-  Qshift = intern ("shift");
-  staticpro (&Qshift);
   /* This is the end of symbol initialization.  */
 
   /* Text property `display' should be nonsticky by default.  */
   Vtext_property_default_nonsticky
     = Fcons (Fcons (Qdisplay, Qt), Vtext_property_default_nonsticky);
 
-  Qface_set_after_frame_default = intern ("face-set-after-frame-default");
-  staticpro (&Qface_set_after_frame_default);
 
   Fput (Qundefined_color, Qerror_conditions,
 	Fcons (Qundefined_color, Fcons (Qerror, Qnil)));
@@ -4575,39 +4473,58 @@
 	build_string ("Undefined color"));
 
   DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape,
-	       doc: /* The shape of the pointer when over text.
+    doc: /* The shape of the pointer when over text.
 Changing the value does not affect existing frames
 unless you set the mouse color.  */);
   Vx_pointer_shape = Qnil;
 
+#if 0 /* This doesn't really do anything.  */
+  DEFVAR_LISP ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape,
+    doc: /* The shape of the pointer when not over text.
+This variable takes effect when you create a new frame
+or when you set the mouse color.  */);
+#endif
   Vx_nontext_pointer_shape = Qnil;
 
-  Vx_mode_pointer_shape = Qnil;
-
   DEFVAR_LISP ("x-hourglass-pointer-shape", &Vx_hourglass_pointer_shape,
-	       doc: /* The shape of the pointer when Emacs is hourglass.
+    doc: /* The shape of the pointer when Emacs is busy.
 This variable takes effect when you create a new frame
 or when you set the mouse color.  */);
   Vx_hourglass_pointer_shape = Qnil;
 
   DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
-	       doc: /* Non-zero means Emacs displays an hourglass pointer on window systems.  */);
+    doc: /* Non-zero means Emacs displays an hourglass pointer on window systems.  */);
   display_hourglass_p = 1;
 
   DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
-	       doc: /* *Seconds to wait before displaying an hourglass pointer.
+    doc: /* *Seconds to wait before displaying an hourglass pointer.
 Value must be an integer or float.  */);
   Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY);
 
+#if 0 /* This doesn't really do anything.  */
+  DEFVAR_LISP ("x-mode-pointer-shape", &Vx_mode_pointer_shape,
+    doc: /* The shape of the pointer when over the mode line.
+This variable takes effect when you create a new frame
+or when you set the mouse color.  */);
+#endif
+  Vx_mode_pointer_shape = Qnil;
+
   DEFVAR_LISP ("x-sensitive-text-pointer-shape",
-	       &Vx_sensitive_text_pointer_shape,
+	      &Vx_sensitive_text_pointer_shape,
 	       doc: /* The shape of the pointer when over mouse-sensitive text.
 This variable takes effect when you create a new frame
 or when you set the mouse color.  */);
   Vx_sensitive_text_pointer_shape = Qnil;
 
+  DEFVAR_LISP ("x-window-horizontal-drag-cursor",
+	      &Vx_window_horizontal_drag_shape,
+  doc: /* Pointer shape to use for indicating a window can be dragged horizontally.
+This variable takes effect when you create a new frame
+or when you set the mouse color.  */);
+  Vx_window_horizontal_drag_shape = Qnil;
+
   DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel,
-	       doc: /* A string indicating the foreground color of the cursor box.  */);
+    doc: /* A string indicating the foreground color of the cursor box.  */);
   Vx_cursor_fore_pixel = Qnil;
 
   DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size,
@@ -4616,7 +4533,7 @@
   Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
 
   DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
-	       doc: /* Non-nil if no window manager is in use.
+    doc: /* Non-nil if no window manager is in use.
 Emacs doesn't try to figure this out; this is always nil
 unless you set it to something else.  */);
   /* We don't have any way to find this out, so set it to nil
@@ -4625,7 +4542,7 @@
 
   DEFVAR_LISP ("x-pixel-size-width-font-regexp",
 	       &Vx_pixel_size_width_font_regexp,
-	       doc: /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'.
+    doc: /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'.
 
 Since Emacs gets width of a font matching with this regexp from
 PIXEL_SIZE field of the name, font finding mechanism gets faster for
--- a/src/macgui.h	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/macgui.h	Sat Mar 19 17:55:13 2005 +0000
@@ -25,7 +25,7 @@
 
 typedef int Display;  /* fix later */
 
-typedef char * XrmDatabase;  /* fix later */
+typedef Lisp_Object XrmDatabase;
 
 typedef unsigned long Time;
 
@@ -68,22 +68,17 @@
 #else /* not HAVE_CARBON */
 #include <QuickDraw.h>		/* for WindowPtr */
 #include <QDOffscreen.h>	/* for GWorldPtr */
+#include <Appearance.h>		/* for ThemeCursor */
 #include <Windows.h>
+#include <Controls.h>
 #include <Gestalt.h>
 #endif /* not HAVE_CARBON */
 
 typedef WindowPtr Window;
 typedef GWorldPtr Pixmap;
 
-#if TARGET_API_MAC_CARBON
 #define Cursor ThemeCursor
 #define No_Cursor (-1)
-#else
-#define SetPortWindowPort(w) SetPort(w)
-#define Cursor CursHandle
-#define No_Cursor (0)
-extern CursPtr arrow_cursor;
-#endif
 
 #define FACE_DEFAULT (~0)
 
--- a/src/macterm.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/macterm.c	Sat Mar 19 17:55:13 2005 +0000
@@ -129,9 +129,12 @@
 struct x_display_info *x_display_list;
 
 /* This is a list of cons cells, each of the form (NAME
-   . FONT-LIST-CACHE), one for each element of x_display_list and in
-   the same order.  NAME is the name of the frame.  FONT-LIST-CACHE
-   records previous values returned by x-list-fonts.  */
+   FONT-LIST-CACHE . RESOURCE-DATABASE), one for each element of
+   x_display_list and in the same order.  NAME is the name of the
+   frame.  FONT-LIST-CACHE records previous values returned by
+   x-list-fonts.  RESOURCE-DATABASE preserves the X Resource Database
+   equivalent, which is implemented with a Lisp object, for the
+   display. */
 
 Lisp_Object x_display_name_list;
 
@@ -290,9 +293,6 @@
 static void x_update_window_begin P_ ((struct window *));
 static void x_after_update_window_line P_ ((struct glyph_row *));
 
-void activate_scroll_bars (FRAME_PTR);
-void deactivate_scroll_bars (FRAME_PTR);
-
 static int is_emacs_window (WindowPtr);
 
 int x_bitmap_icon (struct frame *, Lisp_Object);
@@ -350,8 +350,12 @@
    commands.  Assume that the graphic port has already been set.  */
 
 static void
-mac_set_colors (GC gc)
-{
+mac_set_colors (gc, bg_save)
+     GC gc;
+     RGBColor *bg_save;
+{
+  if (bg_save)
+    GetBackColor (bg_save);
   mac_set_forecolor (gc->foreground);
   mac_set_backcolor (gc->background);
 }
@@ -365,12 +369,16 @@
      GC gc;
      int x1, y1, x2, y2;
 {
+  RGBColor old_bg;
+
   SetPortWindowPort (w);
 
-  mac_set_colors (gc);
+  mac_set_colors (gc, &old_bg);
 
   MoveTo (x1, y1);
   LineTo (x2, y2);
+
+  RGBBackColor (&old_bg);
 }
 
 void
@@ -386,7 +394,7 @@
   GetGWorld (&old_port, &old_gdh);
   SetGWorld (p, NULL);
 
-  mac_set_colors (gc);
+  mac_set_colors (gc, NULL);
 
   LockPixels (GetGWorldPixMap (p));
   MoveTo (x1, y1);
@@ -409,16 +417,19 @@
   struct mac_output *mwp = (mac_output *) GetWRefCon (w);
   Rect r;
   XGCValues xgc;
+  RGBColor old_bg;
 
   xgc.foreground = mwp->x_compatible.foreground_pixel;
   xgc.background = mwp->x_compatible.background_pixel;
 
   SetPortWindowPort (w);
 
-  mac_set_colors (&xgc);
+  mac_set_colors (&xgc, &old_bg);
   SetRect (&r, x, y, x + width, y + height);
 
   EraseRect (&r);
+
+  RGBBackColor (&old_bg);
 }
 
 /* Mac version of XClearWindow.  */
@@ -436,7 +447,7 @@
 
   SetPortWindowPort (w);
 
-  mac_set_colors (&xgc);
+  mac_set_colors (&xgc, NULL);
 
 #if TARGET_API_MAC_CARBON
   {
@@ -464,6 +475,7 @@
 {
   BitMap bitmap;
   Rect r;
+  RGBColor old_bg;
 
   bitmap.rowBytes = sizeof(unsigned short);
   bitmap.baseAddr = (char *)bits;
@@ -471,7 +483,7 @@
 
   SetPortWindowPort (w);
 
-  mac_set_colors (gc);
+  mac_set_colors (gc, &old_bg);
   SetRect (&r, x, y, x + width, y + height);
 
 #if TARGET_API_MAC_CARBON
@@ -483,6 +495,8 @@
   CopyBits (&bitmap, &(w->portBits), &(bitmap.bounds), &r,
 	    overlay_p ? srcOr : srcCopy, 0);
 #endif /* not TARGET_API_MAC_CARBON */
+
+  RGBBackColor (&old_bg);
 }
 
 
@@ -631,13 +645,16 @@
      unsigned int width, height;
 {
   Rect r;
+  RGBColor old_bg;
 
   SetPortWindowPort (w);
 
-  mac_set_colors (gc);
+  mac_set_colors (gc, &old_bg);
   SetRect (&r, x, y, x + width, y + height);
 
   PaintRect (&r); /* using foreground color of gc */
+
+  RGBBackColor (&old_bg);
 }
 
 
@@ -656,7 +673,7 @@
 
   GetGWorld (&old_port, &old_gdh);
   SetGWorld (p, NULL);
-  mac_set_colors (gc);
+  mac_set_colors (gc, NULL);
   SetRect (&r, x, y, x + width, y + height);
 
   LockPixels (GetGWorldPixMap (p));
@@ -679,13 +696,16 @@
      unsigned int width, height;
 {
   Rect r;
+  RGBColor old_bg;
 
   SetPortWindowPort (w);
 
-  mac_set_colors (gc);
+  mac_set_colors (gc, &old_bg);
   SetRect (&r, x, y, x + width + 1, y + height + 1);
 
   FrameRect (&r); /* using foreground color of gc */
+
+  RGBBackColor (&old_bg);
 }
 
 
@@ -706,7 +726,7 @@
 
   GetGWorld (&old_port, &old_gdh);
   SetGWorld (p, NULL);
-  mac_set_colors (gc);
+  mac_set_colors (gc, NULL);
   SetRect (&r, x, y, x + width + 1, y + height + 1);
 
   LockPixels (GetGWorldPixMap (p));
@@ -728,6 +748,8 @@
      char *buf;
      int nchars, mode, bytes_per_char;
 {
+  RGBColor old_bg;
+
   SetPortWindowPort (w);
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
   UInt32 textFlags, savedFlags;
@@ -737,7 +759,7 @@
   }
 #endif
 
-  mac_set_colors (gc);
+  mac_set_colors (gc, &old_bg);
 
   TextFont (gc->font->mac_fontnum);
   TextSize (gc->font->mac_fontsize);
@@ -746,6 +768,8 @@
 
   MoveTo (x, y);
   DrawText (buf, 0, nchars * bytes_per_char);
+
+  RGBBackColor (&old_bg);
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
   if (!NILP(Vmac_use_core_graphics))
     SwapQDTextFlags(savedFlags);
@@ -933,7 +957,7 @@
 
   SetPort (w);
 #if 0
-  mac_set_colors (gc);
+  mac_set_colors (gc, NULL);
 #endif
 
   SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
@@ -955,7 +979,7 @@
   BackColor (whiteColor);
   CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0);
 
-  mac_set_colors (gc);
+  mac_set_colors (gc, NULL);
 #endif
 #endif /* not TARGET_API_MAC_CARBON */
 }
@@ -1395,13 +1419,6 @@
   FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0;
 
   BLOCK_INPUT;
-  /* Reset the background color of Mac OS Window to that of the frame after
-     update so that it is used by Mac Toolbox to clear the update region before
-     an update event is generated.  */
-  SetPortWindowPort (FRAME_MAC_WINDOW (f));
-
-  mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));
-
 #if TARGET_API_MAC_CARBON
   EnableScreenUpdates ();
 #endif
@@ -4471,50 +4488,6 @@
 }
 
 
-void
-activate_scroll_bars (frame)
-     FRAME_PTR frame;
-{
-  Lisp_Object bar;
-  ControlHandle ch;
-
-  bar = FRAME_SCROLL_BARS (frame);
-  while (! NILP (bar))
-    {
-      ch = SCROLL_BAR_CONTROL_HANDLE (XSCROLL_BAR (bar));
-#if 1 /* TARGET_API_MAC_CARBON */
-      ActivateControl (ch);
-#else
-      SetControlMaximum (ch,
-			 VERTICAL_SCROLL_BAR_TOP_RANGE (frame,
-							XINT (XSCROLL_BAR (bar)
-							      ->height)) - 1);
-#endif
-      bar = XSCROLL_BAR (bar)->next;
-    }
-}
-
-
-void
-deactivate_scroll_bars (frame)
-     FRAME_PTR frame;
-{
-  Lisp_Object bar;
-  ControlHandle ch;
-
-  bar = FRAME_SCROLL_BARS (frame);
-  while (! NILP (bar))
-    {
-      ch = SCROLL_BAR_CONTROL_HANDLE (XSCROLL_BAR (bar));
-#if 1 /* TARGET_API_MAC_CARBON */
-      DeactivateControl (ch);
-#else
-      SetControlMaximum (ch, -1);
-#endif
-      bar = XSCROLL_BAR (bar)->next;
-    }
-}
-
 /* Handle a mouse click on the scroll bar BAR.  If *EMACS_EVENT's kind
    is set to something other than NO_EVENT, it is enqueued.
 
@@ -4845,11 +4818,7 @@
      struct frame *f;
      Cursor cursor;
 {
-#if TARGET_API_MAC_CARBON
   SetThemeCursor (cursor);
-#else
-  SetCursor (*cursor);
-#endif
 }
 
 
@@ -5274,6 +5243,11 @@
   x_wm_set_size_hint (f, (long) 0, 0);
 
   SizeWindow (FRAME_MAC_WINDOW (f), pixelwidth, pixelheight, 0);
+#if TARGET_API_MAC_CARBON
+  if (f->output_data.mac->hourglass_control)
+    MoveControl (f->output_data.mac->hourglass_control,
+		 pixelwidth - HOURGLASS_WIDTH, 0);
+#endif
 
   /* Now, strictly speaking, we can't be sure that this is accurate,
      but the window manager will get around to dealing with the size
@@ -6476,7 +6450,7 @@
 
   if (dpyinfo)
     {
-      tem = XCDR (dpyinfo->name_list_element);
+      tem = XCAR (XCDR (dpyinfo->name_list_element));
       key = Fcons (pattern, make_number (maxnames));
 
       newlist = Fassoc (key, tem);
@@ -6495,9 +6469,9 @@
 
   if (dpyinfo)
     {
-      XSETCDR (dpyinfo->name_list_element,
+      XSETCAR (XCDR (dpyinfo->name_list_element),
 	       Fcons (Fcons (key, newlist),
-		      XCDR (dpyinfo->name_list_element)));
+		      XCAR (XCDR (dpyinfo->name_list_element))));
     }
  label_cached:
 
@@ -7185,11 +7159,6 @@
 
 Point saved_menu_event_location;
 
-#if !TARGET_API_MAC_CARBON
-/* Place holder for the default arrow cursor.  */
-CursPtr arrow_cursor;
-#endif
-
 /* Apple Events */
 static void init_required_apple_events (void);
 static pascal OSErr
@@ -7392,8 +7361,6 @@
   InitCursor ();
 
 #if !TARGET_API_MAC_CARBON
-  arrow_cursor = &qd.arrow;
-
   /* set up some extra stack space for use by emacs */
   SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC));
 
@@ -7454,15 +7421,16 @@
 	    RgnHandle region = NewRgn ();
 
 	    GetPortVisibleRegion (GetWindowPort (win), region);
+	    GetRegionBounds (region, &r);
+	    expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);
 	    UpdateControls (win, region);
-	    GetRegionBounds (region, &r);
 	    DisposeRgn (region);
 	  }
 #else
+	  r = (*win->visRgn)->rgnBBox;
+	  expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);
 	  UpdateControls (win, win->visRgn);
-	  r = (*win->visRgn)->rgnBBox;
-#endif
-	  expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);
+#endif
 
           handling_window_update = 0;
         }
@@ -7955,8 +7923,6 @@
      EventRef event;
      void *data;
 {
-  extern Lisp_Object Qcontrol;
-
   WindowPtr wp;
   OSStatus result;
   UInt32 attributes;
@@ -8226,7 +8192,6 @@
 	  Rect r;
 	  struct frame *f = mac_window_to_frame (window);
 
-	  mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));
 	  GetWindowPortBounds (window, &r);
 	  OffsetRect (&r, -r.left, -r.top);
 	  RectRgn (hilite_rgn, &r);
@@ -8244,7 +8209,6 @@
 	{
 	  struct frame *f = mac_window_to_frame (window);
 
-	  mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));
 	  HideDragHilite (theDrag);
 	  SetThemeCursor (kThemeArrowCursor);
 	}
@@ -8736,12 +8700,9 @@
 		    /* ticks to milliseconds */
 
 		    if (dpyinfo->grabbed && tracked_scroll_bar
-#if TARGET_API_MAC_CARBON
-			|| ch != 0
-#else
-			|| control_part_code != 0
-#endif
-			)
+			/* control_part_code becomes kControlNoPart if
+			   a progress indicator is clicked.  */
+			|| ch != 0 && control_part_code != kControlNoPart)
 		      {
 			struct scroll_bar *bar;
 
@@ -8910,6 +8871,7 @@
 	case activateEvt:
 	  {
 	    WindowPtr window_ptr = (WindowPtr) er.message;
+	    ControlRef root_control;
 
 #if USE_CARBON_EVENTS
 	    if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
@@ -8926,6 +8888,7 @@
 	      break;
 
 	    f = mac_window_to_frame (window_ptr);
+	    GetRootControl (window_ptr, &root_control);
 
 	    if ((er.modifiers & activeFlag) != 0)
 	      {
@@ -8933,7 +8896,7 @@
 		Point mouse_loc = er.where;
 
 		x_new_focus_frame (dpyinfo, f);
-		activate_scroll_bars (f);
+		ActivateControl (root_control);
 
 		SetPortWindowPort (window_ptr);
 		GlobalToLocal (&mouse_loc);
@@ -8950,7 +8913,7 @@
 		if (f == dpyinfo->x_focus_frame)
 		  {
 		    x_new_focus_frame (dpyinfo, 0);
-		    deactivate_scroll_bars (f);
+		    DeactivateControl (root_control);
 		  }
 
 
@@ -9288,21 +9251,12 @@
   f->output_data.mac->mouse_pixel = 0xff00ff;
   f->output_data.mac->cursor_foreground_pixel = 0x0000ff;
 
-#if TARGET_API_MAC_CARBON
   f->output_data.mac->text_cursor = kThemeIBeamCursor;
   f->output_data.mac->nontext_cursor = kThemeArrowCursor;
   f->output_data.mac->modeline_cursor = kThemeArrowCursor;
   f->output_data.mac->hand_cursor = kThemePointingHandCursor;
   f->output_data.mac->hourglass_cursor = kThemeWatchCursor;
   f->output_data.mac->horizontal_drag_cursor = kThemeResizeLeftRightCursor;
-#else
-  f->output_data.mac->text_cursor = GetCursor (iBeamCursor);
-  f->output_data.mac->nontext_cursor = &arrow_cursor;
-  f->output_data.mac->modeline_cursor = &arrow_cursor;
-  f->output_data.mac->hand_cursor = &arrow_cursor;
-  f->output_data.mac->hourglass_cursor = GetCursor (watchCursor);
-  f->output_data.mac->horizontal_drag_cursor = &arrow_cursor;
-#endif
 
   FRAME_FONTSET (f) = -1;
   f->output_data.mac->explicit_parent = 0;
@@ -9420,59 +9374,18 @@
   dpyinfo->mouse_face_hidden = 0;
 }
 
-/* Create an xrdb-style database of resources to supercede registry settings.
-   The database is just a concatenation of C strings, finished by an additional
-   \0.  The string are submitted to some basic normalization, so
-
-     [ *]option[ *]:[ *]value...
-
-   becomes
-
-     option:value...
-
-   but any whitespace following value is not removed.  */
-
-static char *
+
+static XrmDatabase
 mac_make_rdb (xrm_option)
      char *xrm_option;
 {
-  char *buffer = xmalloc (strlen (xrm_option) + 2);
-  char *current = buffer;
-  char ch;
-  int in_option = 1;
-  int before_value = 0;
-
-  do {
-    ch = *xrm_option++;
-
-    if (ch == '\n')
-      {
-        *current++ = '\0';
-        in_option = 1;
-        before_value = 0;
-      }
-    else if (ch != ' ')
-      {
-        *current++ = ch;
-        if (in_option && (ch == ':'))
-          {
-            in_option = 0;
-            before_value = 1;
-          }
-        else if (before_value)
-          {
-            before_value = 0;
-          }
-      }
-    else if (!(in_option || before_value))
-      {
-        *current++ = ch;
-      }
-  } while (ch);
-
-  *current = '\0';
-
-  return buffer;
+  XrmDatabase database;
+
+  database = xrm_get_preference_database (NULL);
+  if (xrm_option)
+    xrm_merge_string_database (database, xrm_option);
+
+  return database;
 }
 
 struct mac_display_info *
@@ -9498,14 +9411,15 @@
 
   dpyinfo = &one_mac_display_info;
 
-  dpyinfo->xrdb = xrm_option ? mac_make_rdb (xrm_option) : NULL;
+  dpyinfo->xrdb = mac_make_rdb (xrm_option);
 
   /* Put this display on the chain.  */
   dpyinfo->next = x_display_list;
   x_display_list = dpyinfo;
 
   /* Put it on x_display_name_list.  */
-  x_display_name_list = Fcons (Fcons (display_name, Qnil),
+  x_display_name_list = Fcons (Fcons (display_name,
+				      Fcons (Qnil, dpyinfo->xrdb)),
                                x_display_name_list);
   dpyinfo->name_list_element = XCAR (x_display_name_list);
 
--- a/src/macterm.h	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/macterm.h	Sat Mar 19 17:55:13 2005 +0000
@@ -355,6 +355,12 @@
 
 #endif
 
+#if TARGET_API_MAC_CARBON
+  /* The Mac control reference for the hourglass (progress indicator)
+     shown at the upper-right corner of the window.  */
+  ControlRef hourglass_control;
+#endif
+
 #if 0
   DWORD dwStyle;
 #endif
@@ -570,6 +576,10 @@
    text from glomming up against the scroll bar */
 #define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0)
 
+/* Size of hourglass controls */
+#define HOURGLASS_WIDTH 16
+#define HOURGLASS_HEIGHT 16
+
 struct frame;
 struct face;
 struct image;
@@ -583,9 +593,6 @@
 EXFUN (Fx_display_planes, 1);
 extern void x_free_gcs P_ ((struct frame *));
 
-void activate_scroll_bars (FRAME_PTR);
-void deactivate_scroll_bars (FRAME_PTR);
-
 /* Defined in macterm.c.  */
 
 extern void x_set_window_size P_ ((struct frame *, int, int, int));
@@ -617,7 +624,17 @@
 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 Lisp_Object cfdata_to_lisp P_ ((CFDataRef));
+extern Lisp_Object cfstring_to_lisp P_ ((CFStringRef));
+extern Lisp_Object cfnumber_to_lisp P_ ((CFNumberRef));
+extern Lisp_Object cfdate_to_lisp P_ ((CFDateRef));
+extern Lisp_Object cfboolean_to_lisp P_ ((CFBooleanRef));
+extern Lisp_Object cfobject_desc_to_lisp P_ ((CFTypeRef));
+extern Lisp_Object cfproperty_list_to_lisp P_ ((CFPropertyListRef, int, int));
 #endif
+extern void xrm_merge_string_database P_ ((XrmDatabase, char *));
+extern Lisp_Object xrm_get_resource P_ ((XrmDatabase, char *, char *));
+extern XrmDatabase xrm_get_preference_database P_ ((char *));
 
 /* arch-tag: 6b4ca125-5bef-476d-8ee8-31ed808b7e79
    (do not change this comment) */
--- a/src/process.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/process.c	Sat Mar 19 17:55:13 2005 +0000
@@ -6703,7 +6703,7 @@
  }
 #endif /* HAVE_SOCKETS */
 
-#ifdef DARWIN
+#if defined (DARWIN) || defined (MAC_OSX)
   /* PTYs are broken on Darwin < 6, but are sometimes useful for interactive 
      processes.  As such, we only change the default value.  */
  if (initialized)
--- a/src/s/darwin.h	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/s/darwin.h	Sat Mar 19 17:55:13 2005 +0000
@@ -37,9 +37,12 @@
 #define BSD_SYSTEM
 /* #define VMS */
 
+#if 0 /* Don't define DARWIN on Mac OS X because CoreFoundation.h uses
+	 it to distinguish Mac OS X from bare Darwin.  */
 #ifndef	DARWIN
 #define	DARWIN 1
 #endif
+#endif
 
 /* MAC_OS is used to conditionally compile code common to both MAC_OS8
    and MAC_OSX.  */
--- a/src/xfaces.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/xfaces.c	Sat Mar 19 17:55:13 2005 +0000
@@ -4695,16 +4695,27 @@
 	{
 #ifdef USE_MOTIF
 	  const char *suffix = "List";
+	  Bool motif = True;
 #else
 	  const char *suffix = "";
+	  Bool motif = False;
+#endif
+#if defined HAVE_X_I18N
+	  extern char *xic_create_fontsetname
+	    P_ ((char *base_fontname, Bool motif));
+	  char *fontsetname = xic_create_fontsetname (face->font_name, motif);
+#else
+	  char *fontsetname = face->font_name;
 #endif
 	  sprintf (line, "%s.pane.menubar*font%s: %s",
-		   myname, suffix, face->font_name);
+		   myname, suffix, fontsetname);
 	  XrmPutLineResource (&rdb, line);
 	  sprintf (line, "%s.%s*font%s: %s",
-		   myname, popup_path, suffix, face->font_name);
+		   myname, popup_path, suffix, fontsetname);
 	  XrmPutLineResource (&rdb, line);
 	  changed_p = 1;
+	  if (fontsetname != face->font_name)
+	    xfree (fontsetname);
 	}
 
       if (changed_p && f->output_data.x->menubar_widget)
@@ -7774,7 +7785,7 @@
 {
   fprintf (stderr, "ID: %d\n", face->id);
 #ifdef HAVE_X_WINDOWS
-  fprintf (stderr, "gc: %d\n", (int) face->gc);
+  fprintf (stderr, "gc: %ld\n", (long) face->gc);
 #endif
   fprintf (stderr, "foreground: 0x%lx (%s)\n",
 	   face->foreground,
--- a/src/xfns.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/xfns.c	Sat Mar 19 17:55:13 2005 +0000
@@ -1971,14 +1971,24 @@
 
 char xic_defaut_fontset[] = "-*-*-*-r-normal--14-*-*-*-*-*-*-*";
 
+/* Create an Xt fontset spec from the name of a base font.
+   If `motif' is True use the Motif syntax.  */
 char *
-xic_create_fontsetname (base_fontname)
+xic_create_fontsetname (base_fontname, motif)
      char *base_fontname;
+     Bool motif;
 {
+  const char *sep = motif ? ";" : ",";
+  char *fontsetname;
+
   /* Make a fontset name from the base font name.  */
   if (xic_defaut_fontset == base_fontname)
-    /* There is no base font name, use the default.  */
-    return base_fontname;
+    { /* There is no base font name, use the default.  */
+      int len = strlen (base_fontname) + 2;
+      fontsetname = xmalloc (len);
+      bzero (fontsetname, len);
+      strcpy (fontsetname, base_fontname);
+    }
   else
     {
       /* Make a fontset name from the base font name.
@@ -1987,30 +1997,31 @@
 	 - the base font where the charset spec is replaced by -*-*.
 	 - the same but with the family also replaced with -*-*-.  */
       char *p = base_fontname;
-      char *fontsetname;
       int i;
-	
+      
       for (i = 0; *p; p++)
 	if (*p == '-') i++;
       if (i != 14)
 	{ /* As the font name doesn't conform to XLFD, we can't
 	     modify it to generalize it to allcs and allfamilies.
 	     Use the specified font plus the default.  */
-	  int len = strlen (base_fontname) + strlen (xic_defaut_fontset) + 2;
+	  int len = strlen (base_fontname) + strlen (xic_defaut_fontset) + 3;
 	  fontsetname = xmalloc (len);
 	  bzero (fontsetname, len);
 	  strcpy (fontsetname, base_fontname);
-	  strcat (fontsetname, ",");
+	  strcat (fontsetname, sep);
 	  strcat (fontsetname, xic_defaut_fontset);
 	}
       else
 	{
 	  int len;
-	  char *p1 = NULL;
+	  char *p1 = NULL, *p2 = NULL;
 	  char *font_allcs = NULL;
 	  char *font_allfamilies = NULL;
+	  char *font_all = NULL;
 	  char *allcs = "*-*-*-*-*-*-*";
 	  char *allfamilies = "-*-*-";
+	  char *all = "*-*-*-*-";
 	  
 	  for (i = 0, p = base_fontname; i < 8; p++)
 	    {
@@ -2019,6 +2030,8 @@
 		  i++;
 		  if (i == 3)
 		    p1 = p + 1;
+		  else if (i == 7)
+		    p2 = p + 1;
 		}
 	    }
 	  /* Build the font spec that matches all charsets.  */
@@ -2033,22 +2046,35 @@
 	  font_allfamilies = (char *) alloca (len);
 	  bzero (font_allfamilies, len);
 	  strcpy (font_allfamilies, allfamilies);
-	  bcopy (p1, font_allfamilies + (strlen (allfamilies)), p - p1);
+	  bcopy (p1, font_allfamilies + strlen (allfamilies), p - p1);
 	  strcat (font_allfamilies, allcs);
 
+	  /* Build the font spec that matches all.  */
+	  len = p - p2 + strlen (allcs) + strlen (all) + strlen (allfamilies) + 1;
+	  font_all = (char *) alloca (len);
+	  bzero (font_all, len);
+	  strcpy (font_all, allfamilies);
+	  strcat (font_all, all);
+	  bcopy (p2, font_all + strlen (all) + strlen (allfamilies), p - p2);
+	  strcat (font_all, allcs);
+
 	  /* Build the actual font set name.  */
 	  len = strlen (base_fontname) + strlen (font_allcs)
-	    + strlen (font_allfamilies) + 3;
+	    + strlen (font_allfamilies) + strlen (font_all) + 5;
 	  fontsetname = xmalloc (len);
 	  bzero (fontsetname, len);
 	  strcpy (fontsetname, base_fontname);
-	  strcat (fontsetname, ",");
+	  strcat (fontsetname, sep);
 	  strcat (fontsetname, font_allcs);
-	  strcat (fontsetname, ",");
+	  strcat (fontsetname, sep);
 	  strcat (fontsetname, font_allfamilies);
+	  strcat (fontsetname, sep);
+	  strcat (fontsetname, font_all);
 	}
-      return fontsetname;
     }
+  if (motif)
+    strcat (fontsetname, ":");
+  return fontsetname;
 }
 
 static XFontSet
@@ -2081,7 +2107,7 @@
 
   if (!xfs)
     {
-      char *fontsetname = xic_create_fontsetname (base_fontname);
+      char *fontsetname = xic_create_fontsetname (base_fontname, False);
 
       /* New fontset.  */
       xfs = XCreateFontSet (FRAME_X_DISPLAY (f),
@@ -2089,8 +2115,7 @@
                             &missing_count, &def_string);
       if (missing_list)
         XFreeStringList (missing_list);
-      if (fontsetname != base_fontname)
-	xfree (fontsetname);
+      xfree (fontsetname);
     }
 
   if (FRAME_XIC_BASE_FONTNAME (f))
@@ -4596,9 +4621,6 @@
 
   check_x ();
 
-  /* 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;
@@ -4613,8 +4635,6 @@
       && !NILP (name))
     error ("Invalid frame name--not a string or nil");
 
-  Vx_resource_name = name;
-
   frame = Qnil;
   GCPRO3 (parms, name, frame);
   f = make_frame (1);
--- a/src/xmenu.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/xmenu.c	Sat Mar 19 17:55:13 2005 +0000
@@ -137,6 +137,8 @@
 #ifdef USE_GTK
 /* gtk just uses utf-8.  */
 # define ENCODE_MENU_STRING(str) ENCODE_UTF_8 (str)
+#elif defined HAVE_X_I18N
+# define ENCODE_MENU_STRING(str) ENCODE_SYSTEM (str)
 #else
 # define ENCODE_MENU_STRING(str) string_make_unibyte (str)
 #endif
--- a/src/xrdb.c	Wed Mar 16 16:06:45 2005 +0000
+++ b/src/xrdb.c	Sat Mar 19 17:55:13 2005 +0000
@@ -527,7 +527,11 @@
   XrmDatabase rdb;
   XrmDatabase db;
   char line[256];
+#ifdef HAVE_X_I18N
+  char *helv = "-*-helvetica-medium-r-*--*-120-*-*-*-*,*";
+#else
   char *helv = "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1";
+#endif
 #ifdef USE_MOTIF
   char *courier = "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1";
   extern Lisp_Object Vdouble_click_time;