changeset 83716:a73440d2f146 merge-multi-tty-to-trunk

Merge multi-tty branch Revision: emacs@sv.gnu.org/emacs--devo--0--patch-866
author Miles Bader <miles@gnu.org>
date Wed, 29 Aug 2007 05:28:10 +0000
parents ed8435ec5652 (diff) 6fc3e91581c3 (current diff)
children 0ee0c5be8e9a
files lib-src/ChangeLog lisp/ChangeLog lisp/simple.el lisp/term/x-win.el lispref/ChangeLog lwlib/ChangeLog mac/ChangeLog src/ChangeLog src/dispextern.h src/gtkutil.c src/keyboard.c src/puresize.h
diffstat 29 files changed, 2605 insertions(+), 1684 deletions(-) [+]
line wrap: on
line diff
--- a/admin/notes/BRANCH	Wed Aug 29 04:01:43 2007 +0000
+++ b/admin/notes/BRANCH	Wed Aug 29 05:28:10 2007 +0000
@@ -1,27 +1,18 @@
-This file describes the Arch branch in which it is maintained.
+This file describes the CVS branch in which it is maintained.
 Everything below the line is branch-specific.
 ________________________________________________________________________
 
-This is the "multi-tty" branch.  It contains a version of Emacs that
-is able to create frames on multiple display devices and display
-types, including multiple tty devices and tty+X combined sessions.
-The branch has an enhanced version of emacsclient that is capable of
-opening a new Emacs frame on the terminal it runs on.
-
-Commit access to the multi-tty branch is only available to its
-maintainer, Károly LĹ‘rentey (lorentey@elte.hu).  The best way to
-contribute to the project is to create your own public Arch branch,
-and publish your changes there.  (I will then be able to easily "pull"
-your changes into the multi-tty branch.)
+This is the "HEAD" branch, otherwise known as the "trunk".  Its primary
+purpose is to accumulate changes that are not yet partitioned into a
+specific (versioned) release.  When people say "use CVS emacs", this is
+the branch they are talking about.  Likewise, a "cvs checkout" without
+the "-r" option results in this branch.
 
-The branch is scheduled for inclusion in the next major release of
-Emacs, version 22.
-
-Please read the file README.multi-tty in the base directory for
-details.
+The plans for this branch are not specified; Emacs hackers add to it
+relatively free of constraint (aside from proper legal / accounting
+practices), although sometimes there is related discussion on the
+emacs-devel mailing list.
 
-
-
-Local Variables:
-coding: utf-8
-End:
+The closure process for this branch is undocumented; concepts such as
+"freeze", "release", or "integration with the trunk" are not applicable
+to this branch.
--- a/etc/ChangeLog	Wed Aug 29 04:01:43 2007 +0000
+++ b/etc/ChangeLog	Wed Aug 29 05:28:10 2007 +0000
@@ -1,3 +1,8 @@
+2007-08-28  Werner LEMBERG  <wl@gnu.org>
+
+	* refcards/de-refcard.tex, refcards/de-refcard.pdf: Use `C-M-%'
+	instead of `M-x query-replace-regexp'.
+
 2007-08-27  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
 	* PROBLEMS (Mac OS X): Add alternative workaround for QuickTime
--- a/etc/NEWS	Wed Aug 29 04:01:43 2007 +0000
+++ b/etc/NEWS	Wed Aug 29 05:28:10 2007 +0000
@@ -63,6 +63,9 @@
 called with a prefix, and the default directory is a remote file name.
 This is because some file name handler (like ange-ftp) are not able to
 run processes remotely.
+
+** The new command `display-time-world' starts an updating time display
+using several time zones, in a buffer.
 
 * Startup Changes in Emacs 23.1
 
@@ -91,6 +94,8 @@
 
 * New Modes and Packages in Emacs 23.1
 
+** A new game called `bubble' has been added
+
 ** minibuffer-indicate-depth-mode shows the minibuffer depth in the prompt.
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/refcards/Makefile	Wed Aug 29 05:28:10 2007 +0000
@@ -0,0 +1,143 @@
+### Makefile for Emacs refcards
+
+## Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004, 2005, 2006,
+##   2007 Free Software Foundation, Inc.
+
+## 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 3, 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., 51 Franklin Street, Fifth Floor,
+## Boston, MA 02110-1301, USA.
+
+
+## Top-level targets.
+
+## PDF files that are included with Emacs.
+all: refcards_pdf dired-refcards_pdf misc-refcards_pdf
+
+REFCARDS_PDF = refcard.pdf cs-refcard.pdf de-refcard.pdf fr-refcard.pdf \
+            pl-refcard.pdf pt-br-refcard.pdf ru-refcard.pdf sk-refcard.pdf
+refcards_pdf: ${REFCARDS_PDF}
+refcards_ps: ${REFCARDS_PDF:.pdf=.ps}
+
+DIRED-REFCARDS_PDF = dired-ref.pdf cs-dired-ref.pdf fr-dired-ref.pdf \
+		sk-dired-ref.pdf
+dired-refcards_pdf: ${DIRED-REFCARDS_PDF}
+dired-refcards_ps: ${DIRED-REFCARDS_PDF:.pdf=.ps}
+
+MISC-REFCARDS_PDF = calccard.pdf gnus-booklet.pdf gnus-refcard.pdf orgcard.pdf
+misc-refcards_pdf: ${MISC-REFCARDS_PDF}
+misc-refcards_ps: ${MISC-REFCARDS_PDF:.pdf=.ps}
+
+
+## The following files are not included with Emacs.
+SURVIVAL-CARDS_PDF = survival.pdf cs-survival.pdf sk-survival.pdf
+survival-cards_pdf: ${SURVIVAL-CARDS_PDF}
+survival-cards_ps: ${SURVIVAL-CARDS_PDF:.pdf=.ps}
+
+VIPER-CARDS_PDF = vipcard.pdf viperCard.pdf
+viper-cards_pdf: ${VIPER-CARDS_PDF}
+viper-cards_ps: ${VIPER-CARDS_PDF:.pdf=.ps}
+
+
+## PDF files.
+
+## The page layouts (a4/letter) are written directly in the .tex files.
+
+cs-refcard.pdf cs-dired-ref.pdf cs-survival.pdf sk-refcard.pdf \
+sk-dired-ref.pdf sk-survival.pdf: %.pdf:	%.tex
+	csplain "\pdfoutput=1\input $<"
+
+pl-refcard.pdf: %.pdf: %.tex
+	if ! kpsewhich -format=fmt mex > /dev/null; then \
+	  echo "No mex format found."; false; \
+	fi
+	pdftex $<
+
+ru-refcard.pdf: %.pdf: %.tex
+	pdflatex $<
+
+gnus-logo.pdf: %.pdf: %.eps
+	ps2pdf $<
+
+gnus-refcard.pdf: %.pdf: %.tex gnus-logo.pdf 
+	pdflatex $<
+
+gnus-booklet.pdf: gnus-refcard.tex gnus-logo.pdf
+	pdflatex '\def\booklettrue{}\def\letterpapertrue{}\input{gnus-refcard}'
+	mv gnus-refcard.pdf $@
+
+## Everything not explicitly listed above.
+%.pdf: %.tex
+	pdftex $<
+
+
+
+## dvi files.
+
+cs-refcard.dvi cs-dired-ref.dvi cs-survival.dvi sk-refcard.dvi \
+sk-dired-ref.dvi sk-survival.dvi: %.dvi:	%.tex
+	csplain $<
+
+pl-refcard.dvi: %.dvi: %.tex
+	if ! kpsewhich -format=fmt mex > /dev/null; then \
+	  echo "No mex format found."; false; \
+	fi
+	tex $<
+
+ru-refcard.dvi gnus-refcard.dvi: %.dvi: %.tex
+	latex $<
+
+gnus-booklet.dvi: gnus-refcard.tex
+	latex '\def\booklettrue{}\def\letterpapertrue{}\input{gnus-refcard}'
+	mv gnus-refcard.dvi $@
+
+## Everything not explicitly listed above.
+%.dvi: %.tex
+	tex $<
+
+
+## PostScript files.
+
+## Note that some of the tex files (refcard, de-refcard, fr-refcard,
+## pt-br-refcard) have settings for letter or a4 paper. Following are
+## the default paper sizes (letter for English, A4 for translations).
+## FIXME orgcard.ps does not fit on letter (see orgcard.tex).
+
+## A4, landscape.
+de-refcard.ps fr-refcard.ps pt-br-refcard.ps orgcard.ps: %.ps: %.dvi
+	dvips -t a4 -t landscape $< -o $@
+
+## A4, portrait.
+cs-dired-ref.ps cs-refcard.ps cs-survival.ps fr-dired-ref.ps \
+pl-refcard.ps ru-refcard.ps \
+sk-dired-ref.ps sk-refcard.ps sk-survival.ps: %.ps: %.dvi
+	dvips -t a4 $< -o $@
+
+## letter, landscape.
+calccard.ps refcard.ps: %.ps: %.dvi
+	dvips -t letter -t landscape $< -o $@
+
+## letter, portrait.
+dired-ref.ps gnus-booklet.ps gnus-refcard.ps survival.ps vipcard.ps \
+viperCard.ps: %.ps: %.dvi
+	dvips -t letter $< -o $@
+
+
+.PHONY: clean
+
+clean:
+	-rm -f *.dvi *.log
+
+### Makefile ends here
Binary file etc/refcards/de-refcard.pdf has changed
--- a/etc/refcards/de-refcard.tex	Wed Aug 29 04:01:43 2007 +0000
+++ b/etc/refcards/de-refcard.tex	Wed Aug 29 05:28:10 2007 +0000
@@ -394,7 +394,7 @@
 \section{Interaktives Ersetzen}
 
 \key{Zeichenkette interaktiv ersetzen}{M-\%}
-\metax{mit regul\"aren Ausdr\"ucken}{M-x query-replace-regexp}
+\key{mit regul\"aren Ausdr\"ucken}{C-M-\%}
 
 M\"ogliche Antworten in diesem Modus:
 
--- a/info/COPYING	Wed Aug 29 04:01:43 2007 +0000
+++ b/info/COPYING	Wed Aug 29 05:28:10 2007 +0000
@@ -1,285 +1,626 @@
-		    GNU GENERAL PUBLIC LICENSE
-		       Version 2, June 1991
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
 
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
 
-			    Preamble
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
 
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it.  (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.)  You can apply it to
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
 your programs, too.
 
   When we speak of free software, we are referring to freedom, not
 price.  Our General Public Licenses are designed to make sure that you
 have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
 
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
 
   For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must show them these terms so they know their
-rights.
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
 
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
 
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
 
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary.  To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
 
   The precise terms and conditions for copying, distribution and
 modification follow.
 
-		    GNU GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
 
-  0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License.  The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language.  (Hereinafter, translation is included without limitation in
-the term "modification".)  Each licensee is addressed as "you".
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
 
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
 
-  1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
 
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
 
-  2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
 
-    a) You must cause the modified files to carry prominent notices
-    stating that you changed the files and the date of any change.
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
 
-    b) You must cause any work that you distribute or publish, that in
-    whole or in part contains or is derived from the Program or any
-    part thereof, to be licensed as a whole at no charge to all third
-    parties under the terms of this License.
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
 
-    c) If the modified program normally reads commands interactively
-    when run, you must cause it, when started running for such
-    interactive use in the most ordinary way, to print or display an
-    announcement including an appropriate copyright notice and a
-    notice that there is no warranty (or else, saying that you provide
-    a warranty) and that users may redistribute the program under
-    these conditions, and telling the user how to view a copy of this
-    License.  (Exception: if the Program itself is interactive but
-    does not normally print such an announcement, your work based on
-    the Program is not required to print an announcement.)
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
 
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
 
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
 
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
 
-  3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
 
-    a) Accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of Sections
-    1 and 2 above on a medium customarily used for software interchange; or,
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
 
-    b) Accompany it with a written offer, valid for at least three
-    years, to give any third party, for a charge no more than your
-    cost of physically performing source distribution, a complete
-    machine-readable copy of the corresponding source code, to be
-    distributed under the terms of Sections 1 and 2 above on a medium
-    customarily used for software interchange; or,
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
 
-    c) Accompany it with the information you received as to the offer
-    to distribute corresponding source code.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form with such
-    an offer, in accord with Subsection b above.)
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
 
-The source code for a work means the preferred form of the work for
-making modifications to it.  For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable.  However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
 
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
 
-  4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License.  Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
 
-  5. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Program or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
 
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
 this License.
 
-  7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
 
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
 
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
 
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
 
-  8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
 
-  9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
 be similar in spirit to the present version, but may differ in detail to
 address new problems or concerns.
 
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
 
-  10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
 
-			    NO WARRANTY
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
 
-  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
 
-  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
 
-		     END OF TERMS AND CONDITIONS
+  17. Interpretation of Sections 15 and 16.
 
-	    How to Apply These Terms to Your New Programs
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
 
   If you develop a new program, and you want it to be of the greatest
 possible use to the public, the best way to achieve this is to make it
@@ -287,15 +628,15 @@
 
   To do so, attach the following notices to the program.  It is safest
 to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
+state the exclusion of warranty; and each file should have at least
 the "copyright" line and a pointer to where the full notice is found.
 
     <one line to give the program's name and a brief idea of what it does.>
     Copyright (C) <year>  <name of author>
 
-    This program is free software; you can redistribute it and/or modify
+    This program 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 of the License, or
+    the Free Software Foundation, either version 3 of the License, or
     (at your option) any later version.
 
     This program is distributed in the hope that it will be useful,
@@ -303,37 +644,31 @@
     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 this program; if not, write to the Free Software Foundation, Inc.,
-    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 Also add information on how to contact you by electronic and paper mail.
 
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
 
-    Gnomovision version 69, Copyright (C) year name of author
-    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
     This is free software, and you are welcome to redistribute it
     under certain conditions; type `show c' for details.
 
 The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary.  Here is a sample; alter the names:
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
 
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
-  `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
-  <signature of Ty Coon>, 1 April 1989
-  Ty Coon, President of Vice
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
 
-This General Public License does not permit incorporating your program into
-proprietary programs.  If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library.  If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
--- a/lib-src/ChangeLog	Wed Aug 29 04:01:43 2007 +0000
+++ b/lib-src/ChangeLog	Wed Aug 29 05:28:10 2007 +0000
@@ -1,3 +1,57 @@
+2007-08-29  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* emacsclient.c (w32_execvp): Move definition before use.
+	(decode_options): Don't use a tty on mac carbon or windows.
+
+2007-08-29  Jason Rumney  <jasonr@gnu.org>
+
+	* emacsclient.c (SEND_STRING, SEND_QUOTED): Remove obfuscation
+	macros.
+	(quote_argument, set_tcp_socket, handle_sigcont, handle_sigtstp):
+	(main): Expand removed macros inline.
+	(main) [WINDOWSNT]: Don't call ttyname.  Don't recognize -suspend
+	option.
+	(main) [NO_SOCKETS_IN_FILE_SYSTEM]: Don't call init_signals.
+
+2007-08-29  Karoly Lorentey  <lorentey@elte.hu>
+
+	* emacsclient.c (signal.h): New include.
+	(sys/stat.h, errno.h): Always include, even on WINDOWSNT.
+	(DIRECTORY_SEP, IS_DIRECTORY_SEP, IS_DEVICE_SEP, IS_ANY_SEP): Copy
+	definitions here from src/lisp.h.
+	(main_argc, main_argv, current_frame, window_system, tty): New
+	variables.
+	(longopts): Add tty, current-frame.
+	(xmalloc, xstrdup): New functions.
+	(get_current_dir_name): New function, copied from src/sysdep.c.
+	(decode_options): Set display from environment.  Add tty and
+	current_frame options.  Make --no-wait imply --current-frame,
+	except when it is the only option given.  Make sure no frame is
+	opened when --current-frame is set.
+	(print_help_and_exit): Document tty and current-frame options.
+	(fail): Change arguments to void.
+	(main): When sockets are not defined, set main_argc, main_argv,
+	and call fail() with no arguments.
+	(emacs_socket): New variable (moved out from main `s').
+	(quote_file_name): Rename to quote_argument.
+	(quote_argument): New name for old quote_file_name.
+	(unquote_argument, strprefix, pass_signal_to_emacs)
+	(handle_sigcont, handle_sigtstp, init_signals): New functions.
+	(set_local_socket): Initialize saved_errno to 0.  If socket-name
+	is too long, call `fail' rather than `exit'.
+	(main): Doc update.  Set main_argc, main_argv.  New var `str'.
+	Don't need a filename or argument if tty or window_system set.
+	Call fail with no arguments.  Use get_current_dir_name to send
+	over the current directory.  Send version number to Emacs for
+	verification.  If tty is set, check TERM, and pass name and type
+	to Emacs.  Pass window_system to Emacs.  Move sending of eval to
+	optind loop.  Send -position, -file to Emacs.  Call fsync after
+	fflush.  Check for a client/server version match. Handle
+	-emacs-pid, -window-system-unsupported, -print, -error, -suspend
+	commands.  Don't exit prematurely on --no-wait, let Emacs close
+	the connection for us.  When creating a new frame, send
+	environment and pwd to Emacs.  Send current-frame to Emacs.
+
 2007-08-25  Eli Zaretskii  <eliz@gnu.org>
 
 	* Makefile.in (rcs2log, rcs-checkin, grep-changelog, vcdiff):
--- a/lib-src/ChangeLog.multi-tty	Wed Aug 29 04:01:43 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-0000-00-00  Dan Nicolaescu  <dann@ics.uci.edu>
-
-	* emacsclient.c (w32_execvp): Move definition before use.
-	(decode_options): Don't use a tty on mac carbon or windows.
-
-0000-00-00  Jason Rumney  <jasonr@gnu.org>
-
-	* emacsclient.c (SEND_STRING, SEND_QUOTED): Remove obfuscation
-	macros.
-	(quote_argument, set_tcp_socket, handle_sigcont, handle_sigtstp):
-	(main): Expand removed macros inline.
-	(main) [WINDOWSNT]: Don't call ttyname.  Don't recognize -suspend
-	option.
-	(main) [NO_SOCKETS_IN_FILE_SYSTEM]: Don't call init_signals.
-
-0000-00-00  Karoly Lorentey  <lorentey@elte.hu>
-
-	* emacsclient.c (signal.h): New include.
-	(sys/stat.h, errno.h): Always include, even on WINDOWSNT.
-	(DIRECTORY_SEP, IS_DIRECTORY_SEP, IS_DEVICE_SEP, IS_ANY_SEP): Copy
-	definitions here from src/lisp.h.
-	(main_argc, main_argv, current_frame, window_system, tty): New
-	variables.
-	(longopts): Add tty, current-frame.
-	(xmalloc, xstrdup): New functions.
-	(get_current_dir_name): New function, copied from src/sysdep.c.
-	(decode_options): Set display from environment.  Add tty and
-	current_frame options.  Make --no-wait imply --current-frame,
-	except when it is the only option given.  Make sure no frame is
-	opened when --current-frame is set.
-	(print_help_and_exit): Document tty and current-frame options.
-	(fail): Change arguments to void.
-	(main): When sockets are not defined, set main_argc, main_argv,
-	and call fail() with no arguments.
-	(emacs_socket): New variable (moved out from main `s').
-	(quote_file_name): Rename to quote_argument.
-	(quote_argument): New name for old quote_file_name.
-	(unquote_argument, strprefix, pass_signal_to_emacs)
-	(handle_sigcont, handle_sigtstp, init_signals): New functions.
-	(set_local_socket): Initialize saved_errno to 0.  If socket-name
-	is too long, call `fail' rather than `exit'.
-	(main): Doc update.  Set main_argc, main_argv.  New var `str'.
-	Don't need a filename or argument if tty or window_system set.
-	Call fail with no arguments.  Use get_current_dir_name to send
-	over the current directory.  Send version number to Emacs for
-	verification.  If tty is set, check TERM, and pass name and type
-	to Emacs.  Pass window_system to Emacs.  Move sending of eval to
-	optind loop.  Send -position, -file to Emacs.  Call fsync after
-	fflush.  Check for a client/server version match. Handle
-	-emacs-pid, -window-system-unsupported, -print, -error, -suspend
-	commands.  Don't exit prematurely on --no-wait, let Emacs close
-	the connection for us.  When creating a new frame, send
-	environment and pwd to Emacs.  Send current-frame to Emacs.
-
-;; Local Variables:
-;; coding: iso-2022-7bit
-;; add-log-time-zone-rule: t
-;; End:
-
-    Copyright (C) 2007 Free Software Foundation, Inc.
-
-  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., 51 Franklin Street, Fifth Floor,
-  Boston, MA 02110-1301, USA.
-
-;; arch-tag: 7080ff76-36b5-4471-8135-2813915e91cc
--- a/lisp/ChangeLog	Wed Aug 29 04:01:43 2007 +0000
+++ b/lisp/ChangeLog	Wed Aug 29 05:28:10 2007 +0000
@@ -1,3 +1,367 @@
+2007-08-29  Juri Linkov  <juri@jurta.org>
+
+	* loadup.el: Add "button" loading after "faces" and move "startup"
+	to load after "button".
+
+2007-08-29  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* loadup.el: Load term/mac-win on a Mac using Carbon.
+
+	* term/mac-win.el: Provide mac-win.
+	(mac-initialized): New variable.
+	(mac-initialize-window-system): New function.  Move global setup
+	here.
+	(handle-args-function-alist, frame-creation-function-alist):
+	(window-system-initialization-alist): Add mac entries.
+	(x-setup-function-keys): New function containing all the
+	top level function key definitions.
+
+	* term/x-win.el (x-menu-bar-open): Use accelerate-menu.
+
+        * env.el (read-envvar-name): Don't consider the environment frame
+        param.
+
+        * env.el (setenv):
+        * frame.el (frame-initialize, make-frame):
+        * faces.el (tty-set-up-initial-frame-faces):
+        * server.el (server-process-filter):  Set
+	display-environment-variable and term-environment-variable.
+
+	* server.el (server-process-filter): Set COLORFGBG and COLORTERM.
+
+2007-08-29  Jason Rumney  <jasonr@gnu.org>
+
+	* loadup.el: Only load term/x-win when X is compiled in.
+	Load term/w32-win and dependencies on windows-nt.
+
+	* term/w32-win.el: Reorder to match x-win.el more closely.
+	Provide w32-win.  Don't throw error when global window-system not
+	w32.
+	(internal-face-interactive): Remove obsolete function.
+	(x-setup-function-keys): Use local-function-key-map.
+	(w32-initialized): New variable.
+	(w32-initialize-window-system): Set it.
+	Move more global setup here.
+	(x-setup-function-keys): New function.
+	(w32-initialize-window-system): Move non function key global setup
+	here.
+	(x-cut-buffer-max): Remove.
+	(w32-initialize-window-system): New function.
+	(handle-args-function-alist, frame-creation-function-alist):
+	(window-system-initialization-alist): Add w32 entries.
+
+2007-08-29  David Kastrup  <dak@gnu.org>
+
+	* env.el (getenv): Pass frame to getenv-internal.
+
+2007-08-29  Karoly Lorentey  <lorentey@elte.hu>
+
+	* loadup.el: Delay loading env; mule-conf gets confused by cl
+	during bootstrap.  Also load termdev and term/x-win.
+
+	* bindings.el (mode-line-client): New variable.
+	(help-echo): Add it to the default mode-line format.
+
+	* cus-start.el: Remove bogus window-system reference from GTK test.
+
+	* ebrowse.el (ebrowse-electric-list-mode-map)
+	(ebrowse-electric-position-mode-map):
+	* ebuff-menu.el (electric-buffer-menu-mode-map):
+	* echistory.el (electric-history-map): Bind C-z to `suspend-frame',
+	not `suspend-emacs'.
+
+	* ediff-wind.el (ediff-setup-windows-automatic): New function.
+	(ediff-window-setup-function): Use it as default.
+
+	* files.el (save-buffers-kill-terminal): New function.
+	(ctl-x-map): Change binding of C-x C-c to save-buffers-kill-terminal.
+
+	* font-lock.el (lisp-font-lock-keywords-2): Add `let-environment'
+	and `with-selected-frame'.
+
+	* help-fns.el (describe-variable): Describe frame-local variables
+	correctly.
+
+	* simple.el (normal-erase-is-backspace-mode): Rewrite for multiple
+	display support.
+	(normal-erase-is-backspace-setup-frame): New function.
+
+	* subr.el (with-selected-frame): New function.
+	(read-quoted-char): Use terminal-local binding of
+	local-function-key-map instead of function-key-map.
+
+	* talk.el (talk): New function.
+	(talk-handle-delete-frame): New function.
+	(talk-add-display): Open a new frame only if FRAME was not a frame.
+
+	* termdev.el: New file.
+
+	* menu-bar.el (menu-bar-open): New function.  Bind it to f10.
+	* term/x-win.el: Don't bind f10.
+	* tmm.el: Remove autoload binding for f10.
+
+	* international/encoded-kb.el (encoded-kbd-setup-display): Use
+	`set-input-meta-mode'.  Fix broken condition before set-input-mode.
+	Store the saved input method as a terminal parameter.  Add keymap
+	parameter.  Use it instead of changing key-translation-map directly.
+	(saved-key-translation-map, encoded-kbd-mode, saved-input-mode):
+	Remove.
+	(encoded-kbd-setup-display): New function.
+
+	* international/mule-cmds.el (set-locale-environment): Fix getenv
+	call.  Use save-buffers-kill-terminal.  Ignore window-system; always
+	set the keyboard coding system.  Add DISPLAY parameter.
+	(set-display-table-and-terminal-coding-system): Add DISPLAY
+	parameter.  Pass it to set-terminal-coding-system.
+
+	* international/mule.el (keyboard-coding-system): Test for
+	encoded-kbd-setup-display, not encoded-kbd-mode.
+	(set-terminal-coding-system, set-keyboard-coding-system): Add
+	DISPLAY parameter.
+	(set-keyboard-coding-system): Use encoded-kbd-setup-display.
+
+	* term/README: Update.
+
+	* term/linux.el (terminal-init-linux): Use `set-input-meta-mode'.
+
+	* term/x-win.el (x-setup-function-keys): New function.  Move
+	function-key-map tweaks here.  Protect against multiple calls on
+	the same terminal.  Use terminal-local binding of
+	local-function-key-map instead of function-key-map.
+	(x-initialize-window-system): Make a copy of pure list.  Pass a
+	frame getenv.
+
+	* term/vt200.el, term/vt201.el, term/vt220.el, term/vt240.el:
+	* term/vt300.el, term/vt320.el, term/vt400.el, term/vt420.el:
+	* term/AT386.el, term/internal.el, term/iris-ansi.el, term/lk201.el:
+	* term/mac-win.el, term/news.el, term/rxvt.el, term/sun.el:
+	* term/tvi970.el, term/wyse50.el: Use terminal-local binding of
+	local-function-key-map instead of function-key-map.
+
+	* term/rxvt.el, term/xterm.el: Speed up load time by protecting
+	`substitute-key-definition' and `define-key' calls against
+	multiple execution.  Use terminal-local binding of
+	local-function-key-map instead of function-key-map.  Pass a frame
+	to getenv.
+
+	* edmacro.el (edmacro-format-keys):
+	* emulation/cua-base.el (cua--pre-command-handler):
+	* isearch.el (isearch-other-meta-char):
+	* xt-mouse.el: Use terminal-local binding of
+	local-function-key-map instead of function-key-map.
+
+	* fringe.el (set-fringe-mode): Simplify and fix using
+	`modify-all-frames-parameters'.
+	* scroll-bar.el (set-scroll-bar-mode): Ditto.
+	* tool-bar.el (tool-bar-mode): Ditto.  Remove 'tool-bar-map length
+	check before calling `tool-bar-setup'.
+	(tool-bar-setup): New variable.
+	(tool-bar-setup): Use it to guard against multiple calls.  Add
+	optional frame parameter, and select that frame before adding items.
+	(toggle-tool-bar-mode-from-frame): New function.
+
+	* menu-bar.el (toggle-menu-bar-mode-from-frame): New function.
+	(menu-bar-showhide-menu): Use toggle-menu-bar-mode-from-frame and
+	toggle-tool-bar-mode-from-frame to change "Menu-bar" and
+	"Tool-bar" toggles to reflect the state of the current frame.
+	(menu-bar-mode): Simplify and fix using `modify-all-frames-parameters'.
+
+	* env.el Require cl for byte compilation (for `block' and `return').
+	(environment, setenv-internal): New functions.
+	(let-environment): New macro.
+	(setenv, getenv): Add optional terminal parameter.  Update docs.
+	(setenv): Use setenv-internal.  Always set process-environment.
+	Handle `local-environment-variables'.
+	(read-envvar-name, setenv, getenv): Use frame parameters
+	to store the local environment, not terminal parameters.  Include
+	`process-environment' as well.
+
+	* faces.el (tty-run-terminal-initialization): New function.
+	(tty-create-frame-with-faces): Use it.  Set up faces and
+	background mode only after the terminal has been initialized.
+	Call terminal-init-*.  Don't load the initialization file more
+	than once.  Call set-locale-environment.
+	(frame-set-background-mode): Handle the 'background-mode terminal
+	parameter.
+	(tty-find-type): New function.
+	(x-create-frame-with-faces): Remove bogus check for
+	first frame.  Call `tool-bar-setup'.  Don't make frame visible
+	until we are done setting up all its parameters.  Call
+	x-setup-function-keys.
+
+	* frame.el (make-frame): Always inherit 'environment and 'client
+	parameters.  Set up the 'environment frame parameter, when needed.
+	Also inherit 'client parameter.  Don't override explicitly
+	specified values with inherited ones.  Add 'terminal frame
+	parameter.  Append window-system-default-frame-alist to parameters
+	before calling frame-creation-function.
+	(frame-initialize): Copy the environment from the initial frame.
+	(window-system-default-frame-alist): Enhance doc string.
+	(frame-notice-user-settings): Don't put 'tool-bar-lines in
+	`default-frame-alist' when initial frame is on a tty.
+	(modify-all-frames-parameters): Simplify using `assq-delete-all'.
+	Remove specified parameters from `window-system-default-frame-alist'.
+	(make-frame-on-tty, framep-on-display, suspend-frame):
+	Extend doc string, update parameter names.
+	(frames-on-display-list): Use terminal-id to get the display id.
+	(frame-notice-user-settings): Extend to apply
+	settings in `window-system-default-frame-alist' as well.
+	(terminal-id, terminal-parameters, terminal-parameter)
+	(set-terminal-parameter, terminal-handle-delete-frame): New functions.
+	(delete-frame-functions): Add to `delete-frame-functions' hook.
+	(blink-cursor-mode): Adapt blink-cursor-mode default
+	value from startup.el.
+	(make-frame-on-display): Protect condition on x-initialized when
+	x-win.el is not loaded.  Update doc.
+	(suspend-frame): Use display-controlling-tty-p to decide between
+	suspend-emacs and suspend-tty.
+	(frames-on-display-list): Update for display ids.
+	(framep-on-display): Ditto.
+	(suspend-frame): Use display-name, not frame-tty-name.
+	(selected-terminal): New function.
+
+	* server.el: Use `device' instead of `display' or `display-id' in
+	variable and client parameter names.
+	(server-select-display): Remove (unused).
+	(server-tty-live-p, server-handle-delete-tty): Remove.
+	(server-unquote-arg, server-quote-arg, server-buffer-clients):
+	Update docs.
+	(server-getenv-from, server-with-environment, server-send-string)
+	(server-save-buffers-kill-terminal): New functions.
+	(server-delete-client): Handle quits in kill-buffer.  Don't kill
+	modified buffers.  Add extra logging.  Delete frames after
+	deleting the tty.  Clear 'client parameter before deleting a frame.
+	Use delete-display, not delete-tty.
+	(server-visit-files): Don't set `server-existing-buffer' if the
+	buffer already has other clients.  Return list of buffers
+	created.  Update doc.  Don't set client-record when nowait.
+	(server-handle-delete-frame): Delete the client if this was its
+	last frame.  Check that the frame is alive.  Remove bogus comment.
+	Add note on possible race condition.  Delete tty clients, if needed.
+	(server-handle-suspend-tty): Use server-send-string.  Kill the
+	client in case of errors from process-send-string.  Use the display
+	parameter.
+	(server-unload-hook): Remove obsolete delete-tty hook.
+	(server-start): Ask before restarting if the old server still has
+	clients.  Add feedback messages.  Remove obsolete delete-tty hook.
+	(server-process-filter): Use server-send-string.  Accept `-dir'
+	command.  Switch to *scratch* immediately after creating the frame,
+	before evaluating any -evals.  Protect `display-splash-screen'
+	call in a condition-case.  Explain why.  Call
+	`display-startup-echo-area-message' before
+	`display-splash-screen'.  Don't display the splash screen when no
+	frame was created.  Show the Emacs splash screen and startup echo
+	area message.  Display the *scratch* buffer by default.  Store the
+	local environment in a frame (not terminal) parameter.  Do not try
+	to decode environment strings.  Fix reference to the 'display
+	frame parameter.  Change syntax of environment variables.  Put
+	environment into terminal parameters, not client parameters.  Use
+	a dummy client with --no-wait's X frames.  In `-position LINE'
+	handler, don't ruin the request string until the line number is
+	extracted.  Log opened files.  Handle -current-frame command.
+	Don't create frames when it is given.  Don't bind X frames to the
+	client when we are in -no-wait mode.  Set locale environment
+	variables from client while creating tty frames.  Disable call to
+	configure-display-for-locale.  When processing -position command,
+	don't change the request string until the parameters are
+	extracted.  Don't try to create an X frame when Emacs does not
+	support it.  Improve logging.  Temporarily set ncurses-related
+	environment variables to those of the client while creating a new
+	tty frame.  Select buffers opened by nowait clients, don't leave
+	them buried under others.  Set the display parameter, and use it
+	when appropriate.
+
+	* startup.el (display-startup-echo-area-message): Handle
+	`inhibit-startup-echo-area-message' here.
+	(command-line-1): Moved from here.
+	(fancy-splash-screens): Use `overriding-local-map' instead of
+	`overriding-terminal-local-map' for now; the latter doesn't work
+	right, it looses keypresses to another terminal.  Use
+	`overriding-terminal-local-map' to set up keymap.  Install a
+	`delete-frame-functions' hook to catch `delete-frame' events.
+	Ignore `select-window' events to cope better with
+	`focus-follows-mouse'.  Don't switch back to the original buffer
+	if the splash frame has been killed.  Restore previous buffer, even
+	if it's *scratch*.
+	(normal-splash-screen): Don't let-bind `mode-line-format'; it
+	changes the global binding - setq it instead.  Use
+	`save-buffers-kill-terminal'.
+	(display-splash-screen): Don't do anything if the splash screen is
+	already displayed elsewhere.
+	(fancy-splash-exit, fancy-splash-delete-frame): New functions.
+	(command-line): Replace duplicated code with a call to
+	tty-run-terminal-initialization.  Don't load the terminal
+	initialization file more than once.  Remove call to nonexistent
+	function `set-locale-translation-file-name'.
+
+	* xt-mouse.el (xterm-mouse-x, xterm-mouse-y): Convert to terminal
+	parameters.
+	(xterm-mouse-position-function, xterm-mouse-event): Update.
+	(xterm-mouse-mode): Don't depend on current value of window-system.
+	(turn-on-xterm-mouse-tracking, turn-off-xterm-mouse-tracking):
+	Update for multi-tty.
+	(turn-on-xterm-mouse-tracking-on-terminal)
+	(turn-off-xterm-mouse-tracking-on-terminal)
+	(xterm-mouse-handle-delete-frame): New functions.
+	(delete-frame-functions, after-make-frame-functions)
+	(suspend-tty-functions, resume-tty-functions): Install extra hooks
+	for multi-tty.
+
+2007-08-29  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* simple.el (invisible-p): Remove: implemented in C now.
+	(line-move-invisible-p): Remove obsolete alias.
+
+2007-08-28  Juri Linkov  <juri@jurta.org>
+
+	* image-mode.el (image-type): New variable.
+	(image-mode): Set default major mode name to "Image[text]".
+	(image-minor-mode): Change LIGHTER to display image-type in the
+	mode line.
+	(image-minor-mode): Set default image-type to "text".
+	(image-toggle-display): After switching to text mode, set
+	image-type to "text" and major mode name to "Image[text]".
+	After switching to image mode, set image-type to actual image
+	type, and add image type to major mode name.  Let-bind the same
+	variable names as arguments of `image-type' and `create-image'.
+	Bind `type' to the result of `image-type' and use it as arg
+	of `create-image' to not determine the image type twice.
+
+2007-08-28  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-handle-set-file-times): Flush the file
+	properties.
+	(tramp-set-file-uid-gid, tramp-get-local-uid)
+	(tramp-get-local-gid): New defuns.
+	(tramp-handle-copy-file): Handle new parameter PRESERVE-UID-GID.
+	(tramp-do-copy-or-rename-file): New parameter PRESERVE-UID-GID.
+	Improve fast track.
+	(tramp-do-copy-or-rename-file-directly): Sync parameter list with
+	the other tramp-do-copy-or-rename-file-* functions.  Major rewrite.
+	(tramp-handle-file-local-copy, tramp-handle-insert-file-contents)
+	(tramp-handle-write-region): Improve fast track.
+	(tramp-handle-file-remote-p): IDENTIFICATION can also be `localname'.
+	(tramp-maybe-open-connection): Let `process-adaptive-read-buffering'
+	be nil.
+
+2007-08-28  Ivan Kanis  <apple@kanis.eu>
+
+	* time.el: New feature to display several time zones in a buffer.
+	(display-time-world-mode, display-time-world-display)
+	(display-time-world, display-time-world-timer): New functions.
+	(display-time-world-list, display-time-world-time-format)
+	(display-time-world-buffer-name, display-time-world-timer-enable)
+	(display-time-world-timer-second, display-time-world-mode-map):
+	New variables.
+
+2007-08-28  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* term/x-win.el (x-gtk-stock-map): New variable.
+	(x-gtk-map-stock): New function.
+
+	* info.el (info-tool-bar-map): Add :rtl keyword to right/left-arrow and
+	prev/next-node.
+
 2007-08-28  Johan Bockg,Ae(Brd  <bojohan@dd.chalmers.se>  (tiny change)
 
 	* play/gamegrid.el (gamegrid-init): Set line-spacing to 0.
--- a/lisp/ChangeLog.multi-tty	Wed Aug 29 04:01:43 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,334 +0,0 @@
-0000-00-00  Juri Linkov  <juri@jurta.org>
-
-	* loadup.el: Add "button" loading after "faces" and move "startup"
-	to load after "button".
-
-0000-00-00  Dan Nicolaescu  <dann@ics.uci.edu>
-
-	* loadup.el: Load term/mac-win on a Mac using Carbon.
-
-	* term/mac-win.el: Provide mac-win.
-	(mac-initialized): New variable.
-	(mac-initialize-window-system): New function.  Move global setup
-	here.
-	(handle-args-function-alist, frame-creation-function-alist):
-	(window-system-initialization-alist): Add mac entries.
-	(x-setup-function-keys): New function containing all the
-	top level function key definitions.
-
-	* term/x-win.el (x-menu-bar-open): Use accelerate-menu.
-
-        * env.el (read-envvar-name): Don't consider the environment frame
-        param.
-
-        * env.el (setenv):
-        * frame.el (frame-initialize, make-frame):
-        * faces.el (tty-set-up-initial-frame-faces):
-        * server.el (server-process-filter):  Set
-	display-environment-variable and term-environment-variable.
-
-	* server.el (server-process-filter): Set COLORFGBG and COLORTERM.
-
-0000-00-00  Jason Rumney  <jasonr@gnu.org>
-
-	* loadup.el: Only load term/x-win when X is compiled in.
-	Load term/w32-win and dependencies on windows-nt.
-
-	* term/w32-win.el: Reorder to match x-win.el more closely.
-	Provide w32-win.  Don't throw error when global window-system not
-	w32.
-	(internal-face-interactive): Remove obsolete function.
-	(x-setup-function-keys): Use local-function-key-map.
-	(w32-initialized): New variable.
-	(w32-initialize-window-system): Set it.
-	Move more global setup here.
-	(x-setup-function-keys): New function.
-	(w32-initialize-window-system): Move non function key global setup
-	here.
-	(x-cut-buffer-max): Remove.
-	(w32-initialize-window-system): New function.
-	(handle-args-function-alist, frame-creation-function-alist):
-	(window-system-initialization-alist): Add w32 entries.
-
-0000-00-00  David Kastrup  <dak@gnu.org>
-
-	* env.el (getenv): Pass frame to getenv-internal.
-
-0000-00-00  Karoly Lorentey  <lorentey@elte.hu>
-
-	* loadup.el: Delay loading env; mule-conf gets confused by cl
-	during bootstrap.  Also load termdev and term/x-win.
-
-	* bindings.el (mode-line-client): New variable.
-	(help-echo): Add it to the default mode-line format.
-
-	* cus-start.el: Remove bogus window-system reference from GTK test.
-
-	* ebrowse.el (ebrowse-electric-list-mode-map)
-	(ebrowse-electric-position-mode-map):
-	* ebuff-menu.el (electric-buffer-menu-mode-map):
-	* echistory.el (electric-history-map): Bind C-z to `suspend-frame',
-	not `suspend-emacs'.
-
-	* ediff-wind.el (ediff-setup-windows-automatic): New function.
-	(ediff-window-setup-function): Use it as default.
-
-	* files.el (save-buffers-kill-terminal): New function.
-	(ctl-x-map): Change binding of C-x C-c to save-buffers-kill-terminal.
-
-	* font-lock.el (lisp-font-lock-keywords-2): Add `let-environment'
-	and `with-selected-frame'.
-
-	* help-fns.el (describe-variable): Describe frame-local variables
-	correctly.
-
-	* simple.el (normal-erase-is-backspace-mode): Rewrite for multiple
-	display support.
-	(normal-erase-is-backspace-setup-frame): New function.
-
-	* subr.el (with-selected-frame): New function.
-	(read-quoted-char): Use terminal-local binding of
-	local-function-key-map instead of function-key-map.
-
-	* talk.el (talk): New function.
-	(talk-handle-delete-frame): New function.
-	(talk-add-display): Open a new frame only if FRAME was not a frame.
-
-	* termdev.el: New file.
-
-	* menu-bar.el (menu-bar-open): New function.  Bind it to f10.
-	* term/x-win.el: Don't bind f10.
-	* tmm.el: Remove autoload binding for f10.
-
-	* international/encoded-kb.el (encoded-kbd-setup-display): Use
-	`set-input-meta-mode'.  Fix broken condition before set-input-mode.
-	Store the saved input method as a terminal parameter.  Add keymap
-	parameter.  Use it instead of changing key-translation-map directly.
-	(saved-key-translation-map, encoded-kbd-mode, saved-input-mode):
-	Remove.
-	(encoded-kbd-setup-display): New function.
-
-	* international/mule-cmds.el (set-locale-environment): Fix getenv
-	call.  Use save-buffers-kill-terminal.  Ignore window-system; always
-	set the keyboard coding system.  Add DISPLAY parameter.
-	(set-display-table-and-terminal-coding-system): Add DISPLAY
-	parameter.  Pass it to set-terminal-coding-system.
-
-	* international/mule.el (keyboard-coding-system): Test for
-	encoded-kbd-setup-display, not encoded-kbd-mode.
-	(set-terminal-coding-system, set-keyboard-coding-system): Add
-	DISPLAY parameter.
-	(set-keyboard-coding-system): Use encoded-kbd-setup-display.
-
-	* term/README: Update.
-
-	* term/linux.el (terminal-init-linux): Use `set-input-meta-mode'.
-
-	* term/x-win.el (x-setup-function-keys): New function.  Move
-	function-key-map tweaks here.  Protect against multiple calls on
-	the same terminal.  Use terminal-local binding of
-	local-function-key-map instead of function-key-map.
-	(x-initialize-window-system): Make a copy of pure list.  Pass a
-	frame getenv.
-
-	* term/vt200.el, term/vt201.el, term/vt220.el, term/vt240.el:
-	* term/vt300.el, term/vt320.el, term/vt400.el, term/vt420.el:
-	* term/AT386.el, term/internal.el, term/iris-ansi.el, term/lk201.el:
-	* term/mac-win.el, term/news.el, term/rxvt.el, term/sun.el:
-	* term/tvi970.el, term/wyse50.el: Use terminal-local binding of
-	local-function-key-map instead of function-key-map.
-
-	* term/rxvt.el, term/xterm.el: Speed up load time by protecting
-	`substitute-key-definition' and `define-key' calls against
-	multiple execution.  Use terminal-local binding of
-	local-function-key-map instead of function-key-map.  Pass a frame
-	to getenv.
-
-	* edmacro.el (edmacro-format-keys):
-	* emulation/cua-base.el (cua--pre-command-handler):
-	* isearch.el (isearch-other-meta-char):
-	* xt-mouse.el: Use terminal-local binding of
-	local-function-key-map instead of function-key-map.
-
-	* fringe.el (set-fringe-mode): Simplify and fix using
-	`modify-all-frames-parameters'.
-	* scroll-bar.el (set-scroll-bar-mode): Ditto.
-	* tool-bar.el (tool-bar-mode): Ditto.  Remove 'tool-bar-map length
-	check before calling `tool-bar-setup'.
-	(tool-bar-setup): New variable.
-	(tool-bar-setup): Use it to guard against multiple calls.  Add
-	optional frame parameter, and select that frame before adding items.
-	(toggle-tool-bar-mode-from-frame): New function.
-
-	* menu-bar.el (toggle-menu-bar-mode-from-frame): New function.
-	(menu-bar-showhide-menu): Use toggle-menu-bar-mode-from-frame and
-	toggle-tool-bar-mode-from-frame to change "Menu-bar" and
-	"Tool-bar" toggles to reflect the state of the current frame.
-	(menu-bar-mode): Simplify and fix using `modify-all-frames-parameters'.
-
-	* env.el Require cl for byte compilation (for `block' and `return').
-	(environment, setenv-internal): New functions.
-	(let-environment): New macro.
-	(setenv, getenv): Add optional terminal parameter.  Update docs.
-	(setenv): Use setenv-internal.  Always set process-environment.
-	Handle `local-environment-variables'.
-	(read-envvar-name, setenv, getenv): Use frame parameters
-	to store the local environment, not terminal parameters.  Include
-	`process-environment' as well.
-
-	* faces.el (tty-run-terminal-initialization): New function.
-	(tty-create-frame-with-faces): Use it.  Set up faces and
-	background mode only after the terminal has been initialized.
-	Call terminal-init-*.  Don't load the initialization file more
-	than once.  Call set-locale-environment.
-	(frame-set-background-mode): Handle the 'background-mode terminal
-	parameter.
-	(tty-find-type): New function.
-	(x-create-frame-with-faces): Remove bogus check for
-	first frame.  Call `tool-bar-setup'.  Don't make frame visible
-	until we are done setting up all its parameters.  Call
-	x-setup-function-keys.
-
-	* frame.el (make-frame): Always inherit 'environment and 'client
-	parameters.  Set up the 'environment frame parameter, when needed.
-	Also inherit 'client parameter.  Don't override explicitly
-	specified values with inherited ones.  Add 'terminal frame
-	parameter.  Append window-system-default-frame-alist to parameters
-	before calling frame-creation-function.
-	(frame-initialize): Copy the environment from the initial frame.
-	(window-system-default-frame-alist): Enhance doc string.
-	(frame-notice-user-settings): Don't put 'tool-bar-lines in
-	`default-frame-alist' when initial frame is on a tty.
-	(modify-all-frames-parameters): Simplify using `assq-delete-all'.
-	Remove specified parameters from `window-system-default-frame-alist'.
-	(make-frame-on-tty, framep-on-display, suspend-frame):
-	Extend doc string, update parameter names.
-	(frames-on-display-list): Use terminal-id to get the display id.
-	(frame-notice-user-settings): Extend to apply
-	settings in `window-system-default-frame-alist' as well.
-	(terminal-id, terminal-parameters, terminal-parameter)
-	(set-terminal-parameter, terminal-handle-delete-frame): New functions.
-	(delete-frame-functions): Add to `delete-frame-functions' hook.
-	(blink-cursor-mode): Adapt blink-cursor-mode default
-	value from startup.el.
-	(make-frame-on-display): Protect condition on x-initialized when
-	x-win.el is not loaded.  Update doc.
-	(suspend-frame): Use display-controlling-tty-p to decide between
-	suspend-emacs and suspend-tty.
-	(frames-on-display-list): Update for display ids.
-	(framep-on-display): Ditto.
-	(suspend-frame): Use display-name, not frame-tty-name.
-	(selected-terminal): New function.
-
-	* server.el: Use `device' instead of `display' or `display-id' in
-	variable and client parameter names.
-	(server-select-display): Remove (unused).
-	(server-tty-live-p, server-handle-delete-tty): Remove.
-	(server-unquote-arg, server-quote-arg, server-buffer-clients):
-	Update docs.
-	(server-getenv-from, server-with-environment, server-send-string)
-	(server-save-buffers-kill-terminal): New functions.
-	(server-delete-client): Handle quits in kill-buffer.  Don't kill
-	modified buffers.  Add extra logging.  Delete frames after
-	deleting the tty.  Clear 'client parameter before deleting a frame.
-	Use delete-display, not delete-tty.
-	(server-visit-files): Don't set `server-existing-buffer' if the
-	buffer already has other clients.  Return list of buffers
-	created.  Update doc.  Don't set client-record when nowait.
-	(server-handle-delete-frame): Delete the client if this was its
-	last frame.  Check that the frame is alive.  Remove bogus comment.
-	Add note on possible race condition.  Delete tty clients, if needed.
-	(server-handle-suspend-tty): Use server-send-string.  Kill the
-	client in case of errors from process-send-string.  Use the display
-	parameter.
-	(server-unload-hook): Remove obsolete delete-tty hook.
-	(server-start): Ask before restarting if the old server still has
-	clients.  Add feedback messages.  Remove obsolete delete-tty hook.
-	(server-process-filter): Use server-send-string.  Accept `-dir'
-	command.  Switch to *scratch* immediately after creating the frame,
-	before evaluating any -evals.  Protect `display-splash-screen'
-	call in a condition-case.  Explain why.  Call
-	`display-startup-echo-area-message' before
-	`display-splash-screen'.  Don't display the splash screen when no
-	frame was created.  Show the Emacs splash screen and startup echo
-	area message.  Display the *scratch* buffer by default.  Store the
-	local environment in a frame (not terminal) parameter.  Do not try
-	to decode environment strings.  Fix reference to the 'display
-	frame parameter.  Change syntax of environment variables.  Put
-	environment into terminal parameters, not client parameters.  Use
-	a dummy client with --no-wait's X frames.  In `-position LINE'
-	handler, don't ruin the request string until the line number is
-	extracted.  Log opened files.  Handle -current-frame command.
-	Don't create frames when it is given.  Don't bind X frames to the
-	client when we are in -no-wait mode.  Set locale environment
-	variables from client while creating tty frames.  Disable call to
-	configure-display-for-locale.  When processing -position command,
-	don't change the request string until the parameters are
-	extracted.  Don't try to create an X frame when Emacs does not
-	support it.  Improve logging.  Temporarily set ncurses-related
-	environment variables to those of the client while creating a new
-	tty frame.  Select buffers opened by nowait clients, don't leave
-	them buried under others.  Set the display parameter, and use it
-	when appropriate.
-
-	* startup.el (display-startup-echo-area-message): Handle
-	`inhibit-startup-echo-area-message' here.
-	(command-line-1): Moved from here.
-	(fancy-splash-screens): Use `overriding-local-map' instead of
-	`overriding-terminal-local-map' for now; the latter doesn't work
-	right, it looses keypresses to another terminal.  Use
-	`overriding-terminal-local-map' to set up keymap.  Install a
-	`delete-frame-functions' hook to catch `delete-frame' events.
-	Ignore `select-window' events to cope better with
-	`focus-follows-mouse'.  Don't switch back to the original buffer
-	if the splash frame has been killed.  Restore previous buffer, even
-	if it's *scratch*.
-	(normal-splash-screen): Don't let-bind `mode-line-format'; it
-	changes the global binding - setq it instead.  Use
-	`save-buffers-kill-terminal'.
-	(display-splash-screen): Don't do anything if the splash screen is
-	already displayed elsewhere.
-	(fancy-splash-exit, fancy-splash-delete-frame): New functions.
-	(command-line): Replace duplicated code with a call to
-	tty-run-terminal-initialization.  Don't load the terminal
-	initialization file more than once.  Remove call to nonexistent
-	function `set-locale-translation-file-name'.
-
-	* xt-mouse.el (xterm-mouse-x, xterm-mouse-y): Convert to terminal
-	parameters.
-	(xterm-mouse-position-function, xterm-mouse-event): Update.
-	(xterm-mouse-mode): Don't depend on current value of window-system.
-	(turn-on-xterm-mouse-tracking, turn-off-xterm-mouse-tracking):
-	Update for multi-tty.
-	(turn-on-xterm-mouse-tracking-on-terminal)
-	(turn-off-xterm-mouse-tracking-on-terminal)
-	(xterm-mouse-handle-delete-frame): New functions.
-	(delete-frame-functions, after-make-frame-functions)
-	(suspend-tty-functions, resume-tty-functions): Install extra hooks
-	for multi-tty.
-
-;; Local Variables:
-;; coding: iso-2022-7bit
-;; add-log-time-zone-rule: t
-;; End:
-
-    Copyright (C) 2007 Free Software Foundation, Inc.
-
-  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., 51 Franklin Street, Fifth Floor,
-  Boston, MA 02110-1301, USA.
-
-;;; arch-tag: 58312fd6-033a-11dc-a0fb-00114368b55b
--- a/lisp/image-mode.el	Wed Aug 29 04:01:43 2007 +0000
+++ b/lisp/image-mode.el	Wed Aug 29 05:28:10 2007 +0000
@@ -183,6 +183,11 @@
 
 ;;; Image Mode setup
 
+(defvar image-type nil
+  "Current image type.
+This variable is used to display the current image type in the mode line.")
+(make-variable-buffer-local 'image-type)
+
 (defvar image-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map "\C-c\C-c" 'image-toggle-display)
@@ -212,7 +217,7 @@
 to toggle between display as an image and display as text."
   (interactive)
   (kill-all-local-variables)
-  (setq mode-name "Image")
+  (setq mode-name "Image[text]")
   (setq major-mode 'image-mode)
   (add-hook 'change-major-mode-hook 'image-toggle-display-text nil t)
   (if (and (display-images-p)
@@ -235,13 +240,14 @@
   "Toggle Image minor mode.
 With arg, turn Image minor mode on if arg is positive, off otherwise.
 See the command `image-mode' for more information on this mode."
-  nil " Image" image-mode-text-map
+  nil (:eval (format " Image[%s]" image-type)) image-mode-text-map
   :group 'image
   :version "22.1"
   (if (not image-minor-mode)
       (image-toggle-display-text)
     (if (get-text-property (point-min) 'display)
-	(setq cursor-type nil truncate-lines t))
+	(setq cursor-type nil truncate-lines t)
+      (setq image-type "text"))
     (add-hook 'change-major-mode-hook (lambda () (image-minor-mode -1)) nil t)
     (message "%s" (concat (substitute-command-keys
 		      "Type \\[image-toggle-display] to view the image as ")
@@ -298,25 +304,28 @@
 	(kill-local-variable 'truncate-lines)
 	(kill-local-variable 'auto-hscroll-mode)
 	(use-local-map image-mode-text-map)
+	(setq image-type "text")
+	(if (eq major-mode 'image-mode)
+	    (setq mode-name "Image[text]"))
 	(if (called-interactively-p)
 	    (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* ((filename (buffer-file-name))
-	   (image
-	    (if (and filename
-		     (file-readable-p filename)
-		     (not (file-remote-p filename))
-		     (not (buffer-modified-p))
-		     (not (and (boundp 'archive-superior-buffer)
-			       archive-superior-buffer))
-		     (not (and (boundp 'tar-superior-buffer)
-			       tar-superior-buffer)))
-		(create-image filename)
-	      (create-image
-	       (string-make-unibyte
-		(buffer-substring-no-properties (point-min) (point-max)))
-	       nil t)))
+	   (data-p (not (and filename
+			     (file-readable-p filename)
+			     (not (file-remote-p filename))
+			     (not (buffer-modified-p))
+			     (not (and (boundp 'archive-superior-buffer)
+				       archive-superior-buffer))
+			     (not (and (boundp 'tar-superior-buffer)
+				       tar-superior-buffer)))))
+	   (file-or-data (if data-p
+			     (string-make-unibyte
+			      (buffer-substring-no-properties (point-min) (point-max)))
+			   filename))
+	   (type (image-type file-or-data nil data-p))
+	   (image (create-image file-or-data type data-p))
 	   (props
 	    `(display ,image
 	      intangible ,image
@@ -337,6 +346,9 @@
       ;; Allow navigation of large images
       (set (make-local-variable 'auto-hscroll-mode) nil)
       (use-local-map image-mode-map)
+      (setq image-type type)
+      (if (eq major-mode 'image-mode)
+	  (setq mode-name (format "Image[%s]" type)))
       (if (called-interactively-p)
 	  (message "Repeat this command to go back to displaying the file as text")))))
 
--- a/lisp/info.el	Wed Aug 29 04:01:43 2007 +0000
+++ b/lisp/info.el	Wed Aug 29 05:28:10 2007 +0000
@@ -3262,10 +3262,14 @@
 (defvar info-tool-bar-map
   (if (display-graphic-p)
       (let ((map (make-sparse-keymap)))
-	(tool-bar-local-item-from-menu 'Info-history-back "left-arrow" map Info-mode-map)
-	(tool-bar-local-item-from-menu 'Info-history-forward "right-arrow" map Info-mode-map)
-	(tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map)
-	(tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map)
+	(tool-bar-local-item-from-menu 'Info-history-back "left-arrow" map Info-mode-map
+				       :rtl "right-arrow")
+	(tool-bar-local-item-from-menu 'Info-history-forward "right-arrow" map Info-mode-map
+				       :rtl "left-arrow")
+	(tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map
+				       :rtl "next-node")
+	(tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map
+				       :rtl "prev-node")
 	(tool-bar-local-item-from-menu 'Info-up "up-node" map Info-mode-map)
 	(tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map)
 	(tool-bar-local-item-from-menu 'Info-goto-node "jump-to" map Info-mode-map)
--- a/lisp/net/tramp.el	Wed Aug 29 04:01:43 2007 +0000
+++ b/lisp/net/tramp.el	Wed Aug 29 05:28:10 2007 +0000
@@ -2506,6 +2506,7 @@
   (zerop
    (if (file-remote-p filename)
        (with-parsed-tramp-file-name filename nil
+	 (tramp-flush-file-property v localname)
 	 (let ((time (if (or (null time) (equal time '(0 0)))
 			 (current-time)
 		       time))
@@ -2527,6 +2528,7 @@
 			  (format-time-string "%Y%m%d%H%M.%S" time t)
 			(format-time-string "%Y%m%d%H%M.%S" time))
 		      (tramp-shell-quote-argument localname)))))
+
      ;; We handle also the local part, because in older Emacsen,
      ;; without `set-file-times', this function is an alias for this.
      ;; We are local, so we don't need the UTC settings.
@@ -2535,6 +2537,34 @@
       (format-time-string "%Y%m%d%H%M.%S" time)
       (tramp-shell-quote-argument filename)))))
 
+(defun tramp-set-file-uid-gid (filename &optional uid gid)
+  "Set the ownership for FILENAME.
+If UID and GID are provided, these values are used; otherwise uid
+and gid of the corresponding user is taken.  Both parameters must be integers."
+  ;; CCC: Modern Unices allow chown only for root.  So we might need
+  ;;      another implementation, see `dired-do-chown'.  OTOH, it is
+  ;;      mostly working with su(do)? when it is needed, so it shall
+  ;;      succeed in the majority of cases.
+  (if (file-remote-p filename)
+      (with-parsed-tramp-file-name filename nil
+	(let ((uid (or (and (integerp uid) uid)
+		       (tramp-get-remote-uid v 'integer)))
+	      (gid (or (and (integerp gid) gid)
+		       (tramp-get-remote-gid v 'integer))))
+	  (tramp-send-command
+	   v (format
+	      "chown %d:%d %s" uid gid
+	      (tramp-shell-quote-argument localname)))))
+
+    ;; We handle also the local part, because there doesn't exist
+    ;; `set-file-uid-gid'.
+    (let ((uid (or (and (integerp uid) uid) (tramp-get-local-uid 'integer)))
+	  (gid (or (and (integerp gid) gid) (tramp-get-local-uid 'integer)))
+	  (default-directory (tramp-temporary-file-directory)))
+      (call-process
+       "chown" nil nil nil
+       (format "%d:%d" uid gid) (tramp-shell-quote-argument filename)))))
+
 ;; Simple functions using the `test' command.
 
 (defun tramp-handle-file-executable-p (filename)
@@ -2840,7 +2870,7 @@
 	 (buffer-name))))))
 
 (defun tramp-handle-copy-file
-  (filename newname &optional ok-if-already-exists keep-date)
+  (filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
   "Like `copy-file' for Tramp files."
   ;; Check if both files are local -- invoke normal copy-file.
   ;; Otherwise, use tramp from local system.
@@ -2850,9 +2880,10 @@
   (if (or (tramp-tramp-file-p filename)
           (tramp-tramp-file-p newname))
       (tramp-do-copy-or-rename-file
-       'copy filename newname ok-if-already-exists keep-date)
+       'copy filename newname ok-if-already-exists keep-date preserve-uid-gid)
     (tramp-run-real-handler
-     'copy-file (list filename newname ok-if-already-exists keep-date))))
+     'copy-file
+     (list filename newname ok-if-already-exists keep-date preserve-uid-gid))))
 
 (defun tramp-handle-rename-file
   (filename newname &optional ok-if-already-exists)
@@ -2865,19 +2896,20 @@
   (if (or (tramp-tramp-file-p filename)
           (tramp-tramp-file-p newname))
       (tramp-do-copy-or-rename-file
-       'rename filename newname ok-if-already-exists t)
+       'rename filename newname ok-if-already-exists t t)
     (tramp-run-real-handler
      'rename-file (list filename newname ok-if-already-exists))))
 
 (defun tramp-do-copy-or-rename-file
-  (op filename newname &optional ok-if-already-exists keep-date)
+  (op filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
   "Copy or rename a remote file.
 OP must be `copy' or `rename' and indicates the operation to perform.
 FILENAME specifies the file to copy or rename, NEWNAME is the name of
 the new file (for copy) or the new name of the file (for rename).
 OK-IF-ALREADY-EXISTS means don't barf if NEWNAME exists already.
 KEEP-DATE means to make sure that NEWNAME has the same timestamp
-as FILENAME.
+as FILENAME.  PRESERVE-UID-GID, when non-nil, instructs to keep
+the uid and gid if both files are on the same host.
 
 This function is invoked by `tramp-handle-copy-file' and
 `tramp-handle-rename-file'.  It is an error if OP is neither of `copy'
@@ -2905,7 +2937,9 @@
 	       ;; directly.
 	       ((tramp-equal-remote filename newname)
 		(tramp-do-copy-or-rename-file-directly
-		 op v1 v1-localname v2-localname keep-date))
+		 op filename newname
+		 ok-if-already-exists keep-date preserve-uid-gid))
+
 	       ;; If both source and target are Tramp files,
 	       ;; both are using the same copy-program, then we
 	       ;; can invoke rcp directly.  Note that
@@ -2917,6 +2951,7 @@
 			tramp-copy-size-limit))
 		(tramp-do-copy-or-rename-file-out-of-band
 		 op filename newname keep-date))
+
 	       ;; No shortcut was possible.  So we copy the
 	       ;; file first.  If the operation was `rename', we go
 	       ;; back and delete the original file (if the copy was
@@ -2933,20 +2968,29 @@
 	 ;; One file is a Tramp file, the other one is local.
 	 ((or t1 t2)
 	  (with-parsed-tramp-file-name (if t1 filename newname) nil
-	    ;; If the Tramp file has an out-of-band method, the corresponding
-	    ;; copy-program can be invoked.
-	    (if (and (tramp-method-out-of-band-p v)
-		     (> (nth 7 (file-attributes filename))
-			tramp-copy-size-limit))
-		(tramp-do-copy-or-rename-file-out-of-band
-		 op filename newname keep-date)
-	      ;; Use the generic method via a Tramp buffer.
-	      (tramp-do-copy-or-rename-file-via-buffer
-	       op filename newname keep-date))))
+	    (cond
+	     ;; Fast track on local machine.
+	     ((tramp-local-host-p v)
+	      (tramp-do-copy-or-rename-file-directly
+	       op filename newname
+	       ok-if-already-exists keep-date preserve-uid-gid))
+
+	     ;; If the Tramp file has an out-of-band method, the corresponding
+	     ;; copy-program can be invoked.
+	     ((and (tramp-method-out-of-band-p v)
+		   (> (nth 7 (file-attributes filename))
+		      tramp-copy-size-limit))
+	      (tramp-do-copy-or-rename-file-out-of-band
+	       op filename newname keep-date))
+
+	     ;; Use the inline method via a Tramp buffer.
+	     (t (tramp-do-copy-or-rename-file-via-buffer
+		 op filename newname keep-date)))))
 
 	 (t
 	  ;; One of them must be a Tramp file.
 	  (error "Tramp implementation says this cannot happen")))
+
       ;; When newname did exist, we have wrong cached values.
       (when t2
 	(with-parsed-tramp-file-name newname nil
@@ -2977,53 +3021,132 @@
       (delete-file filename))))
 
 (defun tramp-do-copy-or-rename-file-directly
-  (op vec localname1 localname2 keep-date)
+ (op filename newname ok-if-already-exists keep-date preserve-uid-gid)
   "Invokes `cp' or `mv' on the remote system.
 OP must be one of `copy' or `rename', indicating `cp' or `mv',
-respectively.  VEC specifies the connection.  LOCALNAME1 and
-LOCALNAME2 specify the two arguments of `cp' or `mv'.  If
-KEEP-DATE is non-nil, preserve the time stamp when copying."
-  ;; CCC: What happens to the timestamp when renaming?
-  (let ((cmd (cond ((and (eq op 'copy) keep-date) "cp -f -p")
-                   ((eq op 'copy) "cp -f")
-                   ((eq op 'rename) "mv -f")
-                   (t (tramp-error
-		       vec 'file-error
-                       "Unknown operation `%s', must be `copy' or `rename'"
-                       op)))))
-    (tramp-send-command
-     vec
-     (format "%s %s %s"
-	     cmd
-	     (tramp-shell-quote-argument localname1)
-	     (tramp-shell-quote-argument localname2)))
-    (with-current-buffer (tramp-get-buffer vec)
-      (goto-char (point-min))
-      (unless
-	  (or
-	   (and (eq op 'copy) keep-date
-		;; Mask cp -f error.
-		(re-search-forward tramp-operation-not-permitted-regexp nil t))
-	   (zerop (tramp-send-command-and-check vec nil)))
-	(tramp-error-with-buffer
-	 nil vec 'file-error
-	 "Copying directly failed, see buffer `%s' for details."
-	 (buffer-name))))
-    ;; Set the mode.
-    ;; CCC: Maybe `chmod --reference=localname1 localname2' could be used
-    ;;      where available?
-    (unless (or (eq op 'rename) keep-date)
-      (set-file-modes
-       (tramp-make-tramp-file-name
-	(tramp-file-name-method vec)
-	(tramp-file-name-user vec)
-	(tramp-file-name-host vec)
-	localname2)
-       (file-modes (tramp-make-tramp-file-name
-		    (tramp-file-name-method vec)
-		    (tramp-file-name-user vec)
-		    (tramp-file-name-host vec)
-		    localname1))))))
+respectively.  FILENAME specifies the file to copy or rename,
+NEWNAME is the name of the new file (for copy) or the new name of
+the file (for rename).  Both files must reside on the same host.
+KEEP-DATE means to make sure that NEWNAME has the same timestamp
+as FILENAME.  PRESERVE-UID-GID, when non-nil, instructs to keep
+the uid and gid from FILENAME."
+  (with-parsed-tramp-file-name (if t1 filename newname) nil
+    (let* ((cmd (cond ((and (eq op 'copy) preserve-uid-gid) "cp -f -p")
+		      ((eq op 'copy) "cp -f")
+		      ((eq op 'rename) "mv -f")
+		      (t (tramp-error
+			  vec 'file-error
+			  "Unknown operation `%s', must be `copy' or `rename'"
+			  op))))
+	   (t1 (tramp-tramp-file-p filename))
+	   (t2 (tramp-tramp-file-p newname))
+	   (localname1
+	    (if t1 (tramp-handle-file-remote-p filename 'localname) filename))
+	   (localname2
+	    (if t2 (tramp-handle-file-remote-p newname 'localname) newname))
+	   (prefix (tramp-handle-file-remote-p (if t1 filename newname)))
+	   (tmpfile (tramp-make-temp-file localname1)))
+
+      (cond
+       ;; Both files are on a remote host, with same user.
+       ((and t1 t2)
+	(tramp-send-command
+	 v
+	 (format "%s %s %s" cmd
+		 (tramp-shell-quote-argument localname1)
+		 (tramp-shell-quote-argument localname2)))
+	(with-current-buffer (tramp-get-buffer v)
+	  (goto-char (point-min))
+	  (unless
+	      (or
+	       (and keep-date
+		    ;; Mask cp -f error.
+		    (re-search-forward
+		     tramp-operation-not-permitted-regexp nil t))
+	       (zerop (tramp-send-command-and-check v nil)))
+	    (tramp-error-with-buffer
+	     nil v 'file-error
+	     "Copying directly failed, see buffer `%s' for details."
+	     (buffer-name)))))
+
+       ;; We are on the local host.
+       ((or t1 t2)
+	(cond
+	 ;; We can do it directly.
+	 ((and (file-readable-p localname1)
+	       (file-writable-p (file-name-directory localname2)))
+	  (if (eq op 'copy)
+	      (copy-file
+	       localname1 localname2 ok-if-already-exists
+	       keep-date preserve-uid-gid)
+	    (rename-file localname1 localname2 ok-if-already-exists)))
+
+	 ;; We can do it directly with `tramp-send-command'
+	 ((and (file-readable-p (concat prefix localname1))
+	       (file-writable-p
+		(file-name-directory (concat prefix localname2))))
+	  (tramp-do-copy-or-rename-file-directly
+	   op (concat prefix localname1) (concat prefix localname2)
+	   ok-if-already-exists keep-date t)
+	  ;; We must change the ownership to the local user.
+	  (tramp-set-file-uid-gid
+	   (concat prefix localname2)
+	   (tramp-get-local-uid 'integer)
+	   (tramp-get-local-gid 'integer)))
+
+	 ;; We need a temporary file in between.
+	 (t
+	  ;; Create the temporary file.
+	  (cond
+	   (t1
+	    (tramp-send-command
+	     v (format
+		"%s %s %s" cmd
+		(tramp-shell-quote-argument localname1)
+		(tramp-shell-quote-argument tmpfile)))
+	    ;; We must change the ownership as remote user.
+	    (tramp-set-file-uid-gid
+	     (concat prefix tmpfile)
+	     (tramp-get-local-uid 'integer)
+	     (tramp-get-local-gid 'integer)))
+	   (t2
+	    (if (eq op 'copy)
+		(copy-file
+		 localname1 tmpfile ok-if-already-exists
+		 keep-date preserve-uid-gid)
+	      (rename-file localname1 tmpfile ok-if-already-exists))
+	    ;; We must change the ownership as local user.
+	    (tramp-set-file-uid-gid
+	     tmpfile
+	     (tramp-get-remote-uid v 'integer)
+	     (tramp-get-remote-gid v 'integer))))
+
+	  ;; Move the temporary file to its destination.
+	  (cond
+	   (t2
+	    (tramp-send-command
+	     v (format
+		"%s %s %s" cmd
+		(tramp-shell-quote-argument tmpfile)
+		(tramp-shell-quote-argument localname2))))
+	   (t1
+	    (if (eq op 'copy)
+		(copy-file
+		 tmpfile localname2 ok-if-already-exists
+		 keep-date preserve-uid-gid)
+	      (rename-file tmpfile localname2 ok-if-already-exists))))
+
+	  ;; Remove temporary file.
+	  (when (eq op 'copy) (delete-file tmpfile))))))
+
+      ;; Set the time and mode. Mask possible errors.
+      ;; Won't be applied for 'rename.
+      (condition-case nil
+	  (when (and keep-date (not preserve-uid-gid))
+	    (set-file-times newname (nth 5 (file-attributes filename)))
+	    (set-file-modes newname (file-modes filename)))
+	(error)))))
+
 
 (defun tramp-do-copy-or-rename-file-out-of-band (op filename newname keep-date)
   "Invoke rcp program to copy.
@@ -3669,22 +3792,17 @@
   (with-parsed-tramp-file-name filename nil
     (let ((rem-enc (tramp-get-remote-coding v "remote-encoding"))
 	  (loc-dec (tramp-get-local-coding v "local-decoding"))
-	  tmpfil)
+	  (tmpfil (tramp-make-temp-file filename)))
       (unless (file-exists-p filename)
 	(tramp-error
 	 v 'file-error
 	 "Cannot make local copy of non-existing file `%s'" filename))
-      (setq tmpfil (tramp-make-temp-file filename))
 
       (cond
-       ;; Fast track on local machine.
-       ((tramp-local-host-p v)
-	(tramp-do-copy-or-rename-file-directly 'copy v localname tmpfil t)
-	(tramp-send-command v (format "chown %s %s" (user-login-name) tmpfil)))
-
-       ;; `copy-file' handles out-of-band methods.
-       ((and (tramp-method-out-of-band-p v)
-	     (> (nth 7 (file-attributes filename)) tramp-copy-size-limit))
+       ;; `copy-file' handles direct copy and out-of-band methods.
+       ((or (tramp-local-host-p v)
+	    (and (tramp-method-out-of-band-p v)
+		 (> (nth 7 (file-attributes filename)) tramp-copy-size-limit)))
 	(copy-file filename tmpfil t t))
 
        ;; Use inline encoding for file transfer.
@@ -3723,7 +3841,9 @@
 	      (delete-file tmpfil2)))
 	  (tramp-message v 5 "Decoding remote file %s...done" filename)
 	  ;; Set proper permissions.
-	  (set-file-modes tmpfil (file-modes filename))))
+	  (set-file-modes tmpfil (file-modes filename))
+	  ;; Set local user ownership.
+	  (tramp-set-file-uid-gid tmpfil)))
 
        ;; Oops, I don't know what to do.
        (t (tramp-error
@@ -3743,6 +3863,7 @@
 	    ((eq identification 'method) method)
 	    ((eq identification 'user) user)
 	    ((eq identification 'host) host)
+	    ((eq identification 'localname) localname)
 	    (t (tramp-make-tramp-file-name method user host "")))))))
 
 (defun tramp-handle-insert-file-contents
@@ -3750,43 +3871,51 @@
   "Like `insert-file-contents' for Tramp files."
   (barf-if-buffer-read-only)
   (setq filename (expand-file-name filename))
-  (with-parsed-tramp-file-name filename nil
-    (if (not (file-exists-p filename))
-	(progn
-	  (when visit
-	    (setq buffer-file-name filename)
-	    (set-visited-file-modtime)
-	    (set-buffer-modified-p nil))
-	  (tramp-error
-	   v 'file-error "File %s not found on remote host" filename)
-	  (list (expand-file-name filename) 0))
-      ;; `insert-file-contents-literally' takes care to avoid calling
-      ;; jka-compr.  By let-binding inhibit-file-name-operation, we
-      ;; propagate that care to the file-local-copy operation.
-      (let ((local-copy
-	     (let ((inhibit-file-name-operation
-		    (when (eq inhibit-file-name-operation
-			      'insert-file-contents)
-		      'file-local-copy)))
-	       (file-local-copy filename)))
-	    coding-system-used result)
-	(tramp-message v 4 "Inserting local temp file `%s'..." local-copy)
-	(setq result (insert-file-contents local-copy nil beg end replace))
+  (let (coding-system-used result)
+    (with-parsed-tramp-file-name filename nil
+
+      (if (not (file-exists-p filename))
+	  (progn
+	    (when visit
+	      (setq buffer-file-name filename)
+	      (set-visited-file-modtime)
+	      (set-buffer-modified-p nil))
+	    (tramp-error
+	     v 'file-error "File %s not found on remote host" filename)
+	    (list (expand-file-name filename) 0))
+
+	(if (and (tramp-local-host-p v)
+		 (file-readable-p localname))
+	    ;; Short track: if we are on the local host, we can run directly.
+	  (insert-file-contents localname visit beg end replace)
+
+	  ;; `insert-file-contents-literally' takes care to avoid calling
+	  ;; jka-compr.  By let-binding inhibit-file-name-operation, we
+	  ;; propagate that care to the file-local-copy operation.
+	  (let ((local-copy
+		 (let ((inhibit-file-name-operation
+			(when (eq inhibit-file-name-operation
+				  'insert-file-contents)
+			  'file-local-copy)))
+		   (file-local-copy filename))))
+	    (tramp-message v 4 "Inserting local temp file `%s'..." local-copy)
+	    (setq result (insert-file-contents local-copy nil beg end replace))
+	    ;; Now `last-coding-system-used' has right value.  Remember it.
+	    (when (boundp 'last-coding-system-used)
+	      (setq coding-system-used (symbol-value 'last-coding-system-used)))
+	    (tramp-message v 4 "Inserting local temp file `%s'...done" local-copy)
+	    (delete-file local-copy)
+	    (when (boundp 'last-coding-system-used)
+	      (set 'last-coding-system-used coding-system-used))))
+
 	(when visit
+	  (setq buffer-read-only (file-writable-p filename))
 	  (setq buffer-file-name filename)
 	  (set-visited-file-modtime)
 	  (set-buffer-modified-p nil))
-	;; Now `last-coding-system-used' has right value.  Remember it.
-	(when (boundp 'last-coding-system-used)
-	  (setq coding-system-used (symbol-value 'last-coding-system-used)))
-	(tramp-message v 4 "Inserting local temp file `%s'...done" local-copy)
-	(delete-file local-copy)
-	(when (boundp 'last-coding-system-used)
-	  (set 'last-coding-system-used coding-system-used))
 	(list (expand-file-name filename)
 	      (cadr result))))))
 
-
 (defun tramp-handle-find-backup-file-name (filename)
   "Like `find-backup-file-name' for Tramp files."
   (with-parsed-tramp-file-name filename nil
@@ -3892,10 +4021,12 @@
     ;;              (string= lockname filename))
     ;;    (error
     ;;     "tramp-handle-write-region: LOCKNAME must be nil or equal FILENAME"))
+
     ;; XEmacs takes a coding system as the seventh argument, not `confirm'
     (when (and (not (featurep 'xemacs)) confirm (file-exists-p filename))
       (unless (y-or-n-p (format "File %s exists; overwrite anyway? " filename))
 	(tramp-error v 'file-error "File not overwritten")))
+
     (let ((rem-dec (tramp-get-remote-coding v "remote-decoding"))
 	  (loc-enc (tramp-get-local-coding v "local-encoding"))
 	  (modes (save-excursion (file-modes filename)))
@@ -3910,146 +4041,148 @@
 	  ;; use an encoding function, but currently we use it always
 	  ;; because this makes the logic simpler.
 	  (tmpfil (tramp-make-temp-file filename)))
-      ;; We say `no-message' here because we don't want the visited file
-      ;; modtime data to be clobbered from the temp file.  We call
-      ;; `set-visited-file-modtime' ourselves later on.
-      (tramp-run-real-handler
-       'write-region
-       (if confirm ; don't pass this arg unless defined for backward compat.
-	   (list start end tmpfil append 'no-message lockname confirm)
-	 (list start end tmpfil append 'no-message lockname)))
-      ;; Now, `last-coding-system-used' has the right value.  Remember it.
-      (when (boundp 'last-coding-system-used)
-	(setq coding-system-used (symbol-value 'last-coding-system-used)))
-      ;; The permissions of the temporary file should be set.  If
-      ;; filename does not exist (eq modes nil) it has been renamed to
-      ;; the backup file.  This case `save-buffer' handles
-      ;; permissions.
-      (when modes (set-file-modes tmpfil modes))
-
-      ;; This is a bit lengthy due to the different methods possible for
-      ;; file transfer.  First, we check whether the method uses an rcp
-      ;; program.  If so, we call it.  Otherwise, both encoding and
-      ;; decoding command must be specified.  However, if the method
-      ;; _also_ specifies an encoding function, then that is used for
-      ;; encoding the contents of the tmp file.
-      (cond ;; Fast track on local machine.
-            ((tramp-local-host-p v)
-	     (tramp-do-copy-or-rename-file-directly
-	      'rename v tmpfil localname t))
-
-	    ;; `copy-file' handles out-of-band methods
-	    ((and (tramp-method-out-of-band-p v)
-		  (integerp start)
-		  (> (- end start) tramp-copy-size-limit))
-	     (rename-file tmpfil filename t))
-
-	    ;; Use inline file transfer
-	    (rem-dec
-	     ;; Encode tmpfil
-	     (tramp-message v 5 "Encoding region...")
-	     (unwind-protect
-		 (with-temp-buffer
-		   ;; Use encoding function or command.
-		   (if (and (symbolp loc-enc) (fboundp loc-enc))
-		       (progn
-			 (tramp-message
-			  v 5 "Encoding region using function `%s'..."
-			  (symbol-name loc-enc))
-			 (let ((coding-system-for-read 'binary))
-			   (insert-file-contents-literally tmpfil))
-			 ;; CCC.  The following `let' is a workaround for
-			 ;; the base64.el that comes with pgnus-0.84.  If
-			 ;; both of the following conditions are
-			 ;; satisfied, it tries to write to a local file
-			 ;; in default-directory, but at this point,
-			 ;; default-directory is remote.
-			 ;; (CALL-PROCESS-REGION can't write to remote
-			 ;; files, it seems.)  The file in question is a
-			 ;; tmp file anyway.
-			 (let ((default-directory
-				 (tramp-temporary-file-directory)))
-			   (funcall loc-enc (point-min) (point-max))))
-
-		     (tramp-message
-		      v 5 "Encoding region using command `%s'..." loc-enc)
-		     (unless (equal 0 (tramp-call-local-coding-command
-				       loc-enc tmpfil t))
-		       (tramp-error
-			v 'file-error
-			(concat "Cannot write to `%s', local encoding"
-				" command `%s' failed")
-			filename loc-enc)))
-
-		   ;; Send buffer into remote decoding command which
-		   ;; writes to remote file.  Because this happens on the
-		   ;; remote host, we cannot use the function.
-		   (goto-char (point-max))
-		   (unless (bolp) (newline))
-		   (tramp-message
-		    v 5 "Decoding region into remote file %s..." filename)
-		   (tramp-send-command
-		    v
-		    (format
-		     "%s >%s <<'EOF'\n%sEOF"
-		     rem-dec
-		     (tramp-shell-quote-argument localname)
-		     (buffer-string)))
-		   (tramp-barf-unless-okay
-		    v nil
+
+      (if (and (tramp-local-host-p v)
+	       (file-writable-p (file-name-directory localname)))
+	  ;; Short track: if we are on the local host, we can run directly.
+	  (if confirm
+	      (write-region
+	       start end localname append 'no-message lockname confirm)
+	    (write-region start end localname append 'no-message lockname))
+
+	;; We say `no-message' here because we don't want the visited file
+	;; modtime data to be clobbered from the temp file.  We call
+	;; `set-visited-file-modtime' ourselves later on.
+	(tramp-run-real-handler
+	 'write-region
+	 (if confirm ; don't pass this arg unless defined for backward compat.
+	     (list start end tmpfil append 'no-message lockname confirm)
+	   (list start end tmpfil append 'no-message lockname)))
+	;; Now, `last-coding-system-used' has the right value.  Remember it.
+	(when (boundp 'last-coding-system-used)
+	  (setq coding-system-used (symbol-value 'last-coding-system-used)))
+	;; The permissions of the temporary file should be set.  If
+	;; filename does not exist (eq modes nil) it has been renamed to
+	;; the backup file.  This case `save-buffer' handles
+	;; permissions.
+	(when modes (set-file-modes tmpfil modes))
+
+	;; This is a bit lengthy due to the different methods possible for
+	;; file transfer.  First, we check whether the method uses an rcp
+	;; program.  If so, we call it.  Otherwise, both encoding and
+	;; decoding command must be specified.  However, if the method
+	;; _also_ specifies an encoding function, then that is used for
+	;; encoding the contents of the tmp file.
+	(cond
+	 ;; `rename-file' handles direct copy and out-of-band methods.
+	 ((or (tramp-local-host-p v)
+	      (and (tramp-method-out-of-band-p v)
+		   (integerp start)
+		   (> (- end start) tramp-copy-size-limit)))
+	  (rename-file tmpfil filename t))
+
+	 ;; Use inline file transfer
+	 (rem-dec
+	  ;; Encode tmpfil
+	  (tramp-message v 5 "Encoding region...")
+	  (unwind-protect
+	      (with-temp-buffer
+		;; Use encoding function or command.
+		(if (and (symbolp loc-enc) (fboundp loc-enc))
+		    (progn
+		      (tramp-message
+		       v 5 "Encoding region using function `%s'..."
+		       (symbol-name loc-enc))
+		      (let ((coding-system-for-read 'binary))
+			(insert-file-contents-literally tmpfil))
+		      ;; CCC.  The following `let' is a workaround for
+		      ;; the base64.el that comes with pgnus-0.84.  If
+		      ;; both of the following conditions are
+		      ;; satisfied, it tries to write to a local file
+		      ;; in default-directory, but at this point,
+		      ;; default-directory is remote.
+		      ;; (CALL-PROCESS-REGION can't write to remote
+		      ;; files, it seems.)  The file in question is a
+		      ;; tmp file anyway.
+		      (let ((default-directory
+			      (tramp-temporary-file-directory)))
+			(funcall loc-enc (point-min) (point-max))))
+
+		  (tramp-message
+		   v 5 "Encoding region using command `%s'..." loc-enc)
+		  (unless (equal 0 (tramp-call-local-coding-command
+				    loc-enc tmpfil t))
+		    (tramp-error
+		     v 'file-error
+		     "Cannot write to `%s', local encoding command `%s' failed"
+		     filename loc-enc)))
+
+		;; Send buffer into remote decoding command which
+		;; writes to remote file.  Because this happens on the
+		;; remote host, we cannot use the function.
+		(goto-char (point-max))
+		(unless (bolp) (newline))
+		(tramp-message
+		 v 5 "Decoding region into remote file %s..." filename)
+		(tramp-send-command
+		 v
+		 (format
+		  "%s >%s <<'EOF'\n%sEOF"
+		  rem-dec
+		  (tramp-shell-quote-argument localname)
+		  (buffer-string)))
+		(tramp-barf-unless-okay
+		 v nil
+		 "Couldn't write region to `%s', decode using `%s' failed"
+		 filename rem-dec)
+		;; When `file-precious-flag' is set, the region is
+		;; written to a temporary file.  Check that the
+		;; checksum is equal to that from the local tmpfil.
+		(when file-precious-flag
+		  (erase-buffer)
+		  (and
+		   ;; cksum runs locally
+		   (let ((default-directory (tramp-temporary-file-directory)))
+		     (zerop (call-process "cksum" tmpfil t)))
+		   ;; cksum runs remotely
+		   (zerop
+		    (tramp-send-command-and-check
+		     v
+		     (format "cksum <%s" (tramp-shell-quote-argument localname))))
+		   ;; ... they are different
+		   (not
+		    (string-equal
+		     (buffer-string)
+		     (with-current-buffer (tramp-get-buffer v) (buffer-string))))
+		   (tramp-error
+		    v 'file-error
 		    (concat "Couldn't write region to `%s',"
 			    " decode using `%s' failed")
-		    filename rem-dec)
-		   ;; When `file-precious-flag' is set, the region is
-		   ;; written to a temporary file.  Check that the
-		   ;; checksum is equal to that from the local tmpfil.
-		   (when file-precious-flag
- 		     (erase-buffer)
-		     (and
-		      ;; cksum runs locally
-		      (let ((default-directory
-			      (tramp-temporary-file-directory)))
-			(zerop (call-process "cksum" tmpfil t)))
-		      ;; cksum runs remotely
-		      (zerop
-		       (tramp-send-command-and-check
-			v
-			(format
-			 "cksum <%s"
-			 (tramp-shell-quote-argument localname))))
-		      ;; ... they are different
-		      (not
-		       (string-equal
-			(buffer-string)
-			(with-current-buffer (tramp-get-buffer v)
-			  (buffer-string))))
-		      (tramp-error
-		       v 'file-error
-		       (concat "Couldn't write region to `%s',"
-			       " decode using `%s' failed")
-		       filename rem-dec)))
-		   (tramp-message
-		    v 5 "Decoding region into remote file %s...done" filename)
-		   (tramp-flush-file-property v localname))
-
-	       ;; Save exit.
-	       (delete-file tmpfil)))
-
-	    ;; That's not expected.
-	    (t
-	     (tramp-error
-	      v 'file-error
-	      (concat "Method `%s' should specify both encoding and "
-		      "decoding command or an rcp program")
-	      method)))
+		    filename rem-dec)))
+		(tramp-message
+		 v 5 "Decoding region into remote file %s...done" filename)
+		(tramp-flush-file-property v localname))
+
+	    ;; Save exit.
+	    (delete-file tmpfil)))
+
+	 ;; That's not expected.
+	 (t
+	  (tramp-error
+	   v 'file-error
+	   (concat "Method `%s' should specify both encoding and "
+		   "decoding command or an rcp program")
+	   method))))
 
       (when (or (eq visit t) (stringp visit))
 	(set-visited-file-modtime
 	 ;; We must pass modtime explicitely, because filename can be different
 	 ;; from (buffer-file-name), f.e. if `file-precious-flag' is set.
 	 (nth 5 (file-attributes filename))))
+      ;; Set the ownership.
+      (tramp-set-file-uid-gid filename)
       ;; Make `last-coding-system-used' have the right value.
-      (when (boundp 'last-coding-system-used)
+      (when coding-system-used
 	(set 'last-coding-system-used coding-system-used))
       (when (or (eq visit t) (null visit) (stringp visit))
 	(tramp-message v 0 "Wrote %s" filename))
@@ -5917,6 +6050,7 @@
       (let* ((target-alist (tramp-compute-multi-hops vec))
 	     (process-environment (copy-sequence process-environment))
 	     (process-connection-type tramp-process-connection-type)
+	     (process-adaptive-read-buffering nil)
 	     (coding-system-for-read nil)
 	     ;; This must be done in order to avoid our file name handler.
 	     (p (let ((default-directory (tramp-temporary-file-directory)))
@@ -6705,6 +6839,12 @@
       ;; The command might not always return a number.
       (if (and (equal id-format 'integer) (not (integerp res))) -1 res))))
 
+(defun tramp-get-local-uid (id-format)
+  (if (equal id-format 'integer) (user-uid) (user-login-name)))
+
+(defun tramp-get-local-gid (id-format)
+  (nth 3 (file-attributes "~/" id-format)))
+
 ;; Some predefined connection properties.
 (defun tramp-get-remote-coding (vec prop)
   ;; Local coding handles properties like remote coding.  So we could
--- a/lisp/simple.el	Wed Aug 29 04:01:43 2007 +0000
+++ b/lisp/simple.el	Wed Aug 29 05:28:10 2007 +0000
@@ -3631,16 +3631,6 @@
   :type 'boolean
   :group 'editing-basics)
 
-(defun invisible-p (pos)
-  "Return non-nil if the character after POS is currently invisible."
-  (let ((prop
-	 (get-char-property pos 'invisible)))
-    (if (eq buffer-invisibility-spec t)
-	prop
-      (or (memq prop buffer-invisibility-spec)
-	  (assq prop buffer-invisibility-spec)))))
-(define-obsolete-function-alias 'line-move-invisible-p 'invisible-p)
-
 ;; Returns non-nil if partial move was done.
 (defun line-move-partial (arg noerror to-end)
   (if (< arg 0)
--- a/lisp/term/x-win.el	Wed Aug 29 04:01:43 2007 +0000
+++ b/lisp/term/x-win.el	Wed Aug 29 05:28:10 2007 +0000
@@ -2566,5 +2566,52 @@
 (add-hook 'after-make-frame-functions 'x-dnd-init-frame)
 (define-key special-event-map [drag-n-drop] 'x-dnd-handle-drag-n-drop-event)
 
+;; Let F10 do menu bar navigation.
+(defun x-menu-bar-open (&optional frame)
+  "Open the menu bar if `menu-bar-mode' is on. otherwise call `tmm-menubar'."
+  (interactive "i")
+  (if menu-bar-mode (menu-bar-open frame)
+    (tmm-menubar)))
+		   
+(and (fboundp 'menu-bar-open)
+     (global-set-key [f10] 'x-menu-bar-open))
+
+(defcustom x-gtk-stock-map
+  '(
+    ("new" . "gtk-new")
+    ("open" . "gtk-open")
+    ("diropen" . "gtk-directory")
+    ("close" . "gtk-close")
+    ("save" . "gtk-save")
+    ("saveas" . "gtk-save-as")
+    ("undo" . "gtk-undo")
+    ("cut" . "gtk-cut")
+    ("copy" . "gtk-copy")
+    ("paste" . "gtk-paste")
+    ("search" . "gtk-find")
+    ("print" . "gtk-print")
+    ("preferences" . "gtk-preferences")
+    ("help" . "gtk-help")
+    ("left-arrow" . "gtk-go-back")
+    ("right-arrow" . "gtk-go-forward")
+    ("home" . "gtk-home")
+    ("jump-to" . "gtk-jump-to")
+    ("index" . "gtk-index")
+    ("search" . "gtk-find")
+    ("exit" . "gtk-quit"))
+  "How icons for tool bars are mapped to Gtk+ stock items.
+Emacs must be compiled with the Gtk+ toolkit for this to have any effect."
+  :version "23.0"
+  :type 'alist
+  :group 'x)
+
+(defun x-gtk-map-stock (file)
+  "Map icon with file name FILE to a Gtk+ stock name, using `x-gtk-stock-map'."
+  (let ((value (and file
+		    (assoc-string (file-name-sans-extension 
+				   (file-name-nondirectory file))
+				  x-gtk-stock-map))))
+    (and value (cdr value))))
+
 ;; arch-tag: f1501302-db8b-4d95-88e3-116697d89f78
 ;;; x-win.el ends here
--- a/lisp/time.el	Wed Aug 29 04:01:43 2007 +0000
+++ b/lisp/time.el	Wed Aug 29 05:28:10 2007 +0000
@@ -25,7 +25,10 @@
 ;;; Commentary:
 
 ;; Facilities to display current time/date and a new-mail indicator
-;; in the Emacs mode line.  The single entry point is `display-time'.
+;; in the Emacs mode line.  The entry point is `display-time'.
+
+;; Display time world in a buffer, the entry point is
+;; `display-time-world'.
 
 ;;; Code:
 
@@ -109,6 +112,51 @@
    "Time when mail file's file system was recorded to be down.
 If that file system seems to be up, the value is nil.")
 
+(defcustom display-time-world-list
+  '(("America/Los_Angeles" "Seattle")
+    ("America/New_York" "New York")
+    ("Europe/London" "London")
+    ("Europe/Paris" "Paris")
+    ("Asia/Calcutta" "Bangalore")
+    ("Asia/Tokyo" "Tokyo"))
+  "Alist specifying time zones and places for `display-time-world'.
+Each element has the form (TIMEZONE LABEL).
+TIMEZONE should be a valid argument for `set-time-zone-rule'.
+LABEL is a string to display to label that zone's time."
+  :group 'display-time
+  :type '(repeat (list string string))
+  :version "23.1")
+
+(defcustom display-time-world-time-format "%A %m %B %R %Z"
+  "Format of the time displayed, see `format-time-string'."
+  :group 'display-time
+  :type 'string
+  :version "23.1")
+
+(defcustom display-time-world-buffer-name "*wclock*"
+  "Name of the wclock buffer."
+  :group 'display-time
+  :type 'string
+  :version "23.1")
+
+(defcustom display-time-world-timer-enable t
+  "If non-nil, a timer will update the world clock."
+  :group 'display-time
+  :type 'boolean
+  :version "23.1")
+
+(defcustom display-time-world-timer-second 60
+  "Interval in seconds for updating the world clock."
+  :group 'display-time
+  :type 'integer
+  :version "23.1")
+
+(defvar display-time-world-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "q" 'kill-this-buffer)
+    map)
+  "Keymap of Display Time World mode")
+
 ;;;###autoload
 (defun display-time ()
   "Enable display of time, load level, and mail flag in mode lines.
@@ -393,6 +441,69 @@
     (remove-hook 'rmail-after-get-new-mail-hook
 		 'display-time-event-handler)))
 
+
+(defun display-time-world-mode ()
+  "Major mode for buffer that displays times in various time zones.
+See `display-time-world'."
+  (interactive)
+  (kill-all-local-variables)
+  (setq
+   major-mode 'display-time-world-mode
+   mode-name "World clock")
+  (use-local-map display-time-world-mode-map))
+
+(defun display-time-world-display (alist)
+  "Replace current buffer text with times in various zones, based on ALIST."
+  (let ((inhibit-read-only t)
+	(buffer-undo-list t))
+    (erase-buffer)
+    (let ((max-width 0)
+	  (result ()))
+      (unwind-protect
+	  (dolist (zone alist)
+	    (let* ((label (cadr zone))
+		   (width (string-width label)))
+	      (set-time-zone-rule (car zone))
+	      (setq result
+		    (append result
+			    (list
+			     label width
+			     (format-time-string display-time-world-time-format))))
+	      (when (> width max-width)
+		(setq max-width width))))
+	(set-time-zone-rule nil))
+      (while result
+	(insert (pop result)
+		(make-string (1+ (- max-width (pop result))) ?\s)
+		(pop result) "\n")))
+    (delete-backward-char 1)))
+
+;;;###autoload
+(defun display-time-world ()
+  "Enable updating display of times in various time zones.
+`display-time-world-list' specifies the zones.
+To turn off the world time display, go to that window and type `q'."
+  (interactive)
+  (when (and display-time-world-timer-enable
+             (not (get-buffer display-time-world-buffer-name)))
+    (run-at-time t display-time-world-timer-second 'display-time-world-timer))
+  (with-current-buffer (get-buffer-create display-time-world-buffer-name)
+    (display-time-world-display display-time-world-list))
+  (pop-to-buffer display-time-world-buffer-name)
+  (fit-window-to-buffer)
+  (display-time-world-mode))
+
+(defun display-time-world-timer ()
+  (if (get-buffer display-time-world-buffer-name)
+      (with-current-buffer (get-buffer display-time-world-buffer-name)
+        (display-time-world-display display-time-world-list))
+    ;; cancel timer
+    (let ((list timer-list))
+      (while list
+        (let ((elt (pop list)))
+          (when (equal (symbol-name (aref elt 5)) "display-time-world-timer")
+            (cancel-timer elt)))))))
+
 (provide 'time)
 
 ;;; arch-tag: b9c1623f-b5cb-48e4-b650-482a4d23c5a6
--- a/lispref/ChangeLog	Wed Aug 29 04:01:43 2007 +0000
+++ b/lispref/ChangeLog	Wed Aug 29 05:28:10 2007 +0000
@@ -1,3 +1,18 @@
+2007-08-29  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* frames.texi (Basic Parameters): Add display-environment-variable
+	and term-environment-variable.
+
+2007-08-28  Juri Linkov  <juri@jurta.org>
+
+	* display.texi (Image Formats, Other Image Types): Add SVG.
+
+2007-08-28  Juri Linkov  <juri@jurta.org>
+
+	* display.texi (Images): Move formats-related text to new node
+	"Image Formats".
+	(Image Formats): New node.
+
 2007-08-25  Richard Stallman  <rms@gnu.org>
 
 	* display.texi (Images): Delete redundant @findex.
--- a/lispref/ChangeLog.multi-tty	Wed Aug 29 04:01:43 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-0000-00-00  Dan Nicolaescu  <dann@ics.uci.edu>
-
-	* frames.texi (Basic Parameters): Add display-environment-variable
-	and term-environment-variable.
-
-;; arch-tag: 95766b84-1e41-49e3-9841-4b8c2f9be2d7
--- a/lispref/display.texi	Wed Aug 29 04:01:43 2007 +0000
+++ b/lispref/display.texi	Wed Aug 29 05:28:10 2007 +0000
@@ -3603,6 +3603,24 @@
 @code{display-images-p} to determine if images can in principle be
 displayed (@pxref{Display Feature Testing}).
 
+@menu
+* Image Formats::       Supported image formats.
+* Image Descriptors::   How to specify an image for use in @code{:display}.
+* XBM Images::          Special features for XBM format.
+* XPM Images::          Special features for XPM format.
+* GIF Images::          Special features for GIF format.
+* PostScript Images::   Special features for PostScript format.
+* Other Image Types::   Various other formats are supported.
+* Defining Images::     Convenient ways to define an image for later use.
+* Showing Images::      Convenient ways to display an image once it is defined.
+* Image Cache::         Internal mechanisms of image display.
+@end menu
+
+@node Image Formats
+@subsection Image Formats
+@cindex image formats
+@cindex image types
+
   Emacs can display a number of different image formats; some of them
 are supported only if particular support libraries are installed on
 your machine.  In some environments, Emacs can load image
@@ -3614,11 +3632,12 @@
 libraries @code{libXpm} version 3.4k and @code{libz}), GIF (requiring
 @code{libungif} 4.1.0), PostScript, PBM, JPEG (requiring the
 @code{libjpeg} library version v6a), TIFF (requiring @code{libtiff}
-v3.4), and PNG (requiring @code{libpng} 1.0.2).
+v3.4), PNG (requiring @code{libpng} 1.0.2), and SVG (requiring
+@code{librsvg} 2.0.0).
 
   You specify one of these formats with an image type symbol.  The image
 type symbols are @code{xbm}, @code{xpm}, @code{gif}, @code{postscript},
-@code{pbm}, @code{jpeg}, @code{tiff}, and @code{png}.
+@code{pbm}, @code{jpeg}, @code{tiff}, @code{png}, and @code{svg}.
 
 @defvar image-types
 This variable contains a list of those image type symbols that are
@@ -3660,18 +3679,6 @@
 @code{t} if the dynamic library could be loaded, @code{nil} otherwise.
 @end defun
 
-@menu
-* Image Descriptors::   How to specify an image for use in @code{:display}.
-* XBM Images::          Special features for XBM format.
-* XPM Images::          Special features for XPM format.
-* GIF Images::          Special features for GIF format.
-* PostScript Images::   Special features for PostScript format.
-* Other Image Types::   Various other formats are supported.
-* Defining Images::     Convenient ways to define an image for later use.
-* Showing Images::      Convenient ways to display an image once it is defined.
-* Image Cache::         Internal mechanisms of image display.
-@end menu
-
 @node Image Descriptors
 @subsection Image Descriptors
 @cindex image descriptor
@@ -4046,6 +4053,8 @@
 
   For PNG images, specify image type @code{png}.
 
+  For SVG images, specify image type @code{svg}.
+
 @node Defining Images
 @subsection Defining Images
 
--- a/lwlib/ChangeLog	Wed Aug 29 04:01:43 2007 +0000
+++ b/lwlib/ChangeLog	Wed Aug 29 05:28:10 2007 +0000
@@ -1,3 +1,8 @@
+2007-08-29  Karoly Lorentey  <lorentey@elte.hu>
+
+	* xlwmenu.c (XlwMenuRealize): Ignore X errors while setting up
+	cursor shape.
+
 2007-07-25  Glenn Morris  <rgm@gnu.org>
 
 	* Relicense all FSF files to GPLv3 or later.
--- a/lwlib/ChangeLog.multi-tty	Wed Aug 29 04:01:43 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-0000-00-00  Karoly Lorentey  <lorentey@elte.hu>
-
-	* xlwmenu.c (XlwMenuRealize): Ignore X errors while setting up
-	cursor shape.
-
-;; arch-tag: bee9b967-809c-4221-906c-50446a308c77
--- a/mac/ChangeLog	Wed Aug 29 04:01:43 2007 +0000
+++ b/mac/ChangeLog	Wed Aug 29 05:28:10 2007 +0000
@@ -1,3 +1,10 @@
+2007-08-29  Karoly Lorentey  <lorentey@elte.hu>
+
+	* makefile.MPW (EmacsObjects): Add terminal.c.x.
+	(callproc.c.x): Add dependencies frame.h, termhooks.h.
+	({Src}terminal.c.x): New.
+	(shortlisp): Add server.elc and termdev.elc.
+
 2007-07-25  Glenn Morris  <rgm@gnu.org>
 
 	* Relicense all FSF files to GPLv3 or later.
--- a/mac/ChangeLog.multi-tty	Wed Aug 29 04:01:43 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-0000-00-00  Karoly Lorentey  <lorentey@elte.hu>
-
-	* makefile.MPW (EmacsObjects): Add terminal.c.x.
-	(callproc.c.x): Add dependencies frame.h, termhooks.h.
-	({Src}terminal.c.x): New.
-	(shortlisp): Add server.elc and termdev.elc.
-
-;; arch-tag: f3b2ce5d-5476-47dd-a18b-4b481c737a25
--- a/src/ChangeLog	Wed Aug 29 04:01:43 2007 +0000
+++ b/src/ChangeLog	Wed Aug 29 05:28:10 2007 +0000
@@ -1,3 +1,624 @@
+2007-08-29  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* callproc.c (child_setup, getenv_internal): Use the
+	display-environment-variable and term-environment-variable frame
+	params.
+	(set_initial_environment): Initialise Vprocess_environment.
+
+	* config.in: Disable multi-keyboard support on a mac.
+
+	* frame.c (Qterm_environment_variable)
+	(Qdisplay_environment_variable): New variables.
+	(syms_of_frame): Intern and staticpro them.
+	(Fmake_terminal_frame): Disable output method test.
+
+	* frame.h: Declare them here.
+
+	* macfns.c (x_set_mouse_color): Get rif from the frame.
+	(x_set_tool_bar_lines): Don't use updating_frame.
+	(mac_window): Add 2 new parameters for consistency with other systems.
+	(Fx_create_frame): Fix doc string.  Rename the parameter.  Set the
+	frame parameters following what is done in X11 and w32.  Don't use
+	FRAME_MAC_DISPLAY_INFO.
+	(Fx_open_connection, start_hourglass): Remove window-system check.
+	(x_create_tip_frame): Get the keyboard from the terminal.
+
+	* macmenu.c: Reorder includes.
+	(Fx_popup_menu): Use terminal specific mouse_position_hook.
+
+	* macterm.c (XTset_terminal_modes, XTreset_terminal_modes): Add a
+	terminal parameter.
+	(x_clear_frame): Add a frame parameter.
+	(note_mouse_movement): Get rif from the frame.
+	(mac_term_init): Initialize the terminal.
+	(mac_initialize): Make static and move terminal initialization ...
+	(mac_create_terminal): ... to this new function.
+
+	* macterm.h (struct mac_display_info): Add terminal.
+
+	* puresize.h (BASE_PURESIZE): Increase base value to 1158000.
+
+	* sysdep.c: Comment out text after #endif.
+
+	* term.c (init_tty): Only use terminal->kboard when MULTI_KBOARD
+	is defined.  Better initialize ttys in windows.  Use terminal
+	specific mouse_position_hook.
+
+	* termhooks.h (union display_info): Add mac_display_info.
+
+	* w32fns.c (Fx_create_frame): Use kboard from the terminal.  Set
+	the default minibuffer frame, window_system and the rest of the
+	frame parameters following what is done in X11.
+
+	* w32term.c (w32_initialize): Make static.
+
+	* xselect.c (x_handle_selection_clear): Only access
+	terminal->kboard when MULTI_KBOARD is defined.
+
+	* s/darwin.h (SYSTEM_PURESIZE_EXTRA): Define here.
+	(SYSTEM_PURESIZE_EXTRA): Only define on Carbon.
+
+2007-08-29  Jason Rumney  <jasonr@gnu.org>
+
+	* frame.c (Fdelete_frame): Only get kboard when MULTI_KBOARD defined.
+	(make_terminal_frame) [WINDOWSNT]: Initialize terminal.
+
+	* fringe.c (w32_init_fringe w32_reset_fringes) [HAVE_NTGUI]:
+	(mac_init_fringe) [MAC_OS]: Get rif from selected_frame.
+
+	* keyboard.c (restore_kboard_configuration): Only define when
+	MULTI_KBOARD defined.
+
+	* makefile.w32-in: Update dependancies from Makefile.in
+	(OBJ1): Add terminal.$(O)
+
+	* term.c (dissociate_if_controlling_tty) [WINDOWSNT]: Don't
+	define function body.
+	(init_tty) [WINDOWSNT]: Use selected_frame for initializing.
+
+	* termhooks.h (display_info) [WINDOWSNT]: Add w32.
+
+	* w32.c (request_sigio, unrequest_sigio): Remove.
+
+	* w32console.c (w32con_move_cursor, w32con_clear_to_end)
+	(w32con_clear_frame, w32con_clear_end_of_line)
+	(w32con_ins_del_lines, w32con_insert_glyphs, w32con_write_glyphs)
+	(w32con_delete_glyphs, w32con_set_terminal_window)
+	(scroll_line, w32_sys_ring_bell): Add frame arg.
+	(w32con_set_terminal_modes, w32con_reset_terminal_modes): Add
+	terminal arg.
+	(PICK_FRAME): Remove.
+	(w32con_write_glyphs): Use frame specific terminal coding.
+	(one_and_only_w32cons): New global variable.
+	(initialize_w32_display): Use it for storing hooks.
+	(create_w32cons_output): New function.
+
+	* w32inevt.c, w32inevt.h (w32_console_read_socket): Make first
+	arg a frame.
+
+	* w32fns.c (x_create_tip_frame): Set terminal and ref count.  Set
+	window_system.
+	(x_set_tool_bar_lines): Don't use updating_frame.
+	(Fx_create_frame): Set terminal and ref count.
+	(Fx_open_connection): Remove window-system check.
+
+	* w32menu.c (Fx_popup_menu): Use terminal specific mouse_position_hook.
+
+	* w32term.c (w32_term_init): Call add_keyboard_wait_descriptor.
+	(w32_set_terminal_modes, w32_reset_terminal_modes): Add terminal arg.
+	(x_clear_frame, x_delete_glyphs, w32_ring_bell, x_ins_del_lines):
+	Add frame arg.
+	(x_delete_terminal, w32_create_terminal): New functions.
+	(w32_term_init): Create a terminal.
+	(w32_initialize): Move terminal specific initialization to
+	w32_create_terminal.
+
+	* w32term.h (x_output): Remove foreground_pixel and
+	background_pixel.
+	(w32_clear_rect, w32_clear_area): Use background from frame.
+	(w32_display_info): Add terminal.
+	(w32_sys_ring_bell, x_delete_display): Declare here.
+
+	* xdisp.c (display_menu_bar) [HAVE_NTGUI]: Check frame type.
+
+	* s/ms-w32.h (SYSTEM_PURESIZE_EXTRA): Bump to 50k.
+
+2007-08-29  Kalle Olavi Niemitalo  <kon@iki.fi>  (tiny change)
+
+	* keyboard.c (interrupt_signal, handle_interrupt, Fset_quit_char):
+	Fix get_named_tty calls for the controlling tty.
+
+2007-08-29  ARISAWA Akihiro  <ari@mbf.ocn.ne.jp>  (tiny change)
+
+	* term.c (dissociate_if_controlling_tty)[USG]: Fix parse error.
+
+2007-08-29  Yoshiaki Kasahara  <kasahara@nc.kyushu-u.ac.jp>  (tiny change)
+
+	* term.c (tty_insert_glyphs): Add missing first parameter.
+
+2007-08-29  Karoly Lorentey  <karoly@lorentey.hu>
+
+	* buffer.c (Fbuffer_list, Fbury_buffer): Take
+	frame->buried_buffer_list into account.
+
+	* cm.c (current_tty): New variable, for cmputc().
+	(cmputc): Use it.
+	(cmcheckmagic): Add tty parameter, look up terminal streams there.
+	(calccost): Add tty parameter.  Use emacs_tputs() instead of tputs().
+	(cmgoto): Add tty parameter.  Pass it on to calccost().  Use
+	emacs_tputs() instead of tputs().
+
+	* cm.h (emacs_tputs): New macro to set current_tty, and then call
+	tputs().
+	(current_tty): New variable, for cmputc().
+	(cmcheckmagic, cmputc, cmgoto): Add prototypes.
+
+	* eval.c (unwind_to_catch): Don't call x_fully_uncatch_errors.
+	(internal_condition_case, internal_condition_case_1)
+	(internal_condition_case_2): Don't abort when x_catching_errors.
+
+	* fns.c (Fyes_or_no_p): Don't try to open an X dialog on tty terminals.
+	(Fy_or_n_p): Likewise.  Use temporarily_switch_to_single_kboard to
+	prevent crashes caused by bogus longjmps in read_char.
+
+	* keymap.h (Fset_keymap_parent): Add EXFUN.
+
+	* macterm.h (FRAME_FOREGROUND_PIXEL, FRAME_BACKGROUND_PIXEL)
+	* w32term.h (FRAME_FOREGROUND_PIXEL, FRAME_BACKGROUND_PIXEL):
+	Remove redundant definition.
+
+	* macfns.c (x_set_mouse_color,x_make_gc): Use
+	FRAME_BACKGROUND_PIXEL and FRAME_FOREGROUND_PIXEL.
+
+	* w32term.c (x_free_frame_resources): Use
+	FRAME_BACKGROUND_PIXEL and FRAME_FOREGROUND_PIXEL.
+	(w32_initialize): Use the accessor macros for terminal characteristics.
+
+	* macterm.c (mac_initialize): Use Fset_input_interrupt_mode.
+	Use the accessor macros for terminal characteristics.
+	* msdos.c (internal_terminal_init): Use the accessor macros for
+	terminal characteristics.
+	(ScreenVisualBell,internal_terminal_init): Use
+	FRAME_BACKGROUND_PIXEL and FRAME_FOREGROUND_PIXEL.
+
+	* termopts.h (no_redraw_on_reenter): Declare.
+
+	* alloc.c (emacs_blocked_malloc): Disable mallopt call.
+	(mark_terminals,mark_ttys): Declare.
+	(Fgarbage_collect): Call them.
+	(mark_object): Mark buried_buffer_list;
+
+	* prefix-args.c: Include stdlib.h for exit.
+
+	* syssignal.h: Add comment.
+
+	* indent.c: Include stdio.h.
+
+	* window.h (Vinitial_window_system): Declare.
+	(Vwindow_system): Delete declaration.
+
+	* fontset.c (Finternal_char_font): Use FRAME_RIF.
+
+	* image.c (lookup_image): Don't initialize `c' until the xasserts
+	have been run.
+
+	* gtkutil.c (xg_create_frame_widgets): Use FRAME_BACKGROUND_PIXEL and
+	FRAME_FOREGROUND_PIXEL.
+
+	* print.c (print_preprocess): Don't lose print_depth levels while
+	iterating.
+
+	* widget.c (update_from_various_frame_slots): Use
+	FRAME_BACKGROUND_PIXEL and FRAME_FOREGROUND_PIXEL.
+
+	* window.c (set_window_buffer): Don't call clear_mouse_face on tty
+	frames.
+	(window_internal_height): Remove bogus make_number call.
+	(init_window_once): Call make_terminal_frame with two zero
+	parameters.
+
+	* fileio.c (Fread_file_name): Update comment.
+
+	* callint.c (Fcall_interactively): Use
+	temporarily_switch_to_single_kboard instead of single_kboard_state.
+	Make sure it is correctly unwound.
+
+	* xsmfns.c (x_session_close): New function.
+
+	* coding.h (terminal_coding,safe_terminal_coding,keyboard_coding):
+	Delete declarations.
+
+	* xterm.h: Remove declaration for x_fully_uncatch_errors.
+	(x_output): Remove background_pixel and foreground_pixel fields.
+	(x_display_info): Add new field TERMINAL. Remove KBOARD field.
+	(x_delete_device):
+	(x_session_close): Declare.
+
+	* lread.c: Include setjmp.h.  Update declaration of `read_char'.
+	(read_filtered_event): Call `read_char' with a local
+	`wrong_kboard_jmpbuf'.
+
+	* minibuf.c (read_minibuf): Call
+	temporarily_switch_to_single_kboard. Don't call
+	single_kboard_state. Use FRAME_RIF.
+
+	* process.c (Fmake_network_process): Don't unrequest_sigio on modern
+	systems.
+
+	* lisp.h (set_process_environment): Rename to
+	`set_global_environment'.
+	(Fframe_with_environment,Fset_input_meta_mode)
+	(Fset_quit_char): EXFUN.
+	(x_create_device,tty_output,terminal,tty_display_info): Declare.
+	(init_sys_modes, reset_sys_modes): Update prototypes.
+	(init_all_sys_modes, reset_all_sys_modes): New prototypes.
+
+	* keyboard.h (struct kboard): Add new fields:
+	Vlocal_function_key_map, Vlocal_key_translation_map,
+	Vkeyboard_translate_table.
+	(Vfunction_key_map,Vkeyboard_translate_table,single_kboard_state):
+	Delete declarations.
+	(Vfunction_key_map,Vkey_translation_map,push_kboard,pop_kboard)
+	(temporarily_switch_to_single_kboard,tty_read_avail_input):
+	New declarations.
+
+	* emacs.c (main): Don't call init_sys_modes(), the new term_init()
+	already does that during init_display().  Call syms_of_keymap
+	before syms_of_keyboard.  Call `syms_of_terminal'.  Call
+	set_initial_environment, not set_process_environment.
+	(shut_down_emacs): Call reset_all_sys_modes() instead of
+	reset_sys_modes().
+
+	* xfaces.c (x_free_gc): Protect xassert with GLYPH_DEBUG.
+	(internal_resolve_face_name, resolve_face_name_error): New
+	functions.
+	(resolve_face_name): Protect against loops and errors thrown by
+	Fget.
+	(realize_default_face): Don't use FRAME_FONT unless frame is an X
+	frame.
+	(Ftty_supports_face_attributes_p): Update tty_capable_p call.
+
+	* scroll.c: Replace CURTTY() with local variables throughout the
+	file (where applicable).
+	(calculate_scrolling, calculate_direct_scrolling)
+	(scrolling_1, scroll_cost): Use the accessor macros for terminal
+	characteristics.
+
+	* keymap.c (Vfunction_key_map): Remove.
+	(Fdescribe_buffer_bindings): Update references to
+	Vfunction_key_map.
+	(syms_of_keymap): Remove DEFVAR for Vfunction_key_map.
+	(Vkey_translation_map): Remove.
+	(syms_of_keymap): Remove DEFVAR for key-translation-map.
+	(Fdescribe_buffer_bindings):
+	(read_key_sequence, init_kboard, syms_of_keyboard, mark_kboards):
+	Update for terminal-local key-translation-map.
+
+	* Makefile.in (callproc.o): Update dependencies.
+	(lisp, shortlisp): Add termdev.elc.
+	(obj): Add terminal.o.
+	(terminal.o): Add dependencies.
+	[HAVE_CARBON]: Make terminal.o depend on macgui.h.
+	(data.o, fns.o): Add termhooks.h dependency.
+	(SOME_MACHINE_LISP): Add dnd.elc.
+	(minibuf.o): Fix typo.
+	Update dependencies.
+
+	* data.c (do_symval_forwarding, store_symval_forwarding)
+	(find_symbol_value): Use the selected frame's keyboard, not
+	current_kboard.
+
+	* .gdbinit (init_sys_modes): Use Vinitial_window_system instead of
+	Vwindow_system.
+
+	* xmenu.c (Fx_menu_bar_open) [USE_X_TOOLKIT, USE_GTK]: Rename from
+	Fmenu_bar_open.
+	(syms_of_xmenu): Update defsubr.
+	(mouse_position_for_popup, Fx_popup_menu)
+	(Fx_popup_dialog, x_activate_menubar, update_frame_menubar)
+	(set_frame_menubar, free_frame_menubar)
+	(create_and_show_popup_menu, xmenu_show, )
+	(create_and_show_dialog, xdialog_show, xmenu_show): Abort if not
+	an X frame.
+
+	* xselect.c (x_own_selection): Abort if not an X frame.
+	(some_frame_on_display): Check if it is an X frame.
+	(x_handle_selection_clear): Deal with MULTI_KBOARD.
+
+	* coding.c: Include frame.h and termhooks.h.
+	(terminal_coding,keyboard_coding): Delete.
+	(Fset_terminal_coding_system_internal):
+	(Fset_keyboard_coding_system_internal):
+	(Fkeyboard_coding_system):
+	(Fterminal_coding_system): Add a terminal parameter. Get
+	terminal_coding from the terminal.
+	(init_coding_once): Don't call setup_coding_system here.
+
+	* dispextern.h (set_scroll_region, turn_off_insert)
+	(turn_off_highlight, background_highlight, clear_end_of_line_raw)
+	(tty_clear_end_of_line, tty_setup_colors)
+	(delete_tty,updating_frame)
+	(produce_special_glyphs, produce_glyphs, write_glyphs)
+	(insert_glyphs): Remove.
+	(raw_cursor_to, clear_to_end, tty_turn_off_insert)
+	(tty_turn_off_highlight,get_tty_size): Add declaration.
+	(tabs_safe_p, init_baud_rate, get_tty_terminal): Update
+	prototypes.
+
+	* frame.h (enum output_method): Add output_initial.
+	(struct x_output): Delete.
+	(FRAME_FOREGROUND_PIXEL, FRAME_BACKGROUND_PIXEL): Access
+	foreground_pixel and background_pixel directly from the frame.
+	(tty_display): Delete.
+	(struct frame): Add buried_buffer_list, foreground_pixel,
+	background_pixel and terminal. Delete kboard
+	(union output_data): Add tty.
+	(FRAME_KBOARD): Get the kboard from the terminal.
+	(FRAME_INITIAL_P): New macro.
+	(Qtty, Qtty_type, Qterminal, Qterminal_live_p, Qenvironment)
+	(Qterm_environment_variable, Qdisplay_environment_variable)
+	(make_terminal_frame, Qburied_buffer_list, Qwindow_system): New
+	declarations.
+
+	* termchar.h (tty_output, tty_display_info): New structures.
+	(tty_list): Declare.
+	(FRAME_TTY, CURTTY): New macros.
+	(must_write_spaces, min_padding_speed, fast_clear_end_of_line)
+	(line_ins_del_ok, char_ins_del_ok, scroll_region_ok)
+	(scroll_region_cost, memory_below_frame, fast_clear_end_of_line)
+	(dont_calculate_costs, no_redraw_on_reenter): Remove declarations.
+
+	* callproc.c: Include frame.h and termhooks.h, for terminal
+	parameters.
+	(add_env): New function.
+	(child_setup): Use it.
+	(child_setup, getenv_internal): Handle the new
+	Vprocess_environment.
+	(getenv_internal): Fix get_terminal_param call.
+	(Fgetenv_internal, egetenv): Update doc.
+	(syms_of_callproc): Initialize Vprocess_environment to nil.
+	Register and initialize them. Remove obsolete defvars. Update doc
+	strings.
+	(child_setup): Handle Vlocal_environment_variables.
+	(getenv_internal): Add terminal parameter.  Handle
+	Vlocal_environment_variables.
+	(Fgetenv_internal): Add terminal parameter.
+	(child_setup, getenv_internal, Fgetenv_internal): Store the local
+	environment in a frame (not terminal) parameter.  Update doc
+	strings.
+	(set_initial_environment): Rename from set_global_environment.
+	Store Emacs environment in initial frame parameter.
+
+	* xdisp.c (redisplay_internal): Update references to
+	`previous_terminal_frame'.
+	(display_mode_line, Fformat_mode_line): Replace calls to
+	`push_frame_kboard' with `push_kboard'.
+	(get_glyph_string_clip_rects): Add extra parentheses and
+	braces to prevent compiler warnings.
+	(calc_pixel_width_or_height): Add xassert to check that the
+	frame is alive.  Don't call `lookup_image' on a termcap frame.
+	(message2_nolog, message3_nolog, redisplay_internal)
+	(set_vertical_scroll_bar, redisplay_window, check_x_display_info)
+	(x_set_scroll_bar_foreground, x_set_scroll_bar_background)
+	(Fx_create_frame, Fxw_display_color_p, Fx_display_grayscale_p)
+	(Fx_display_pixel_width, Fx_display_pixel_height)
+	(Fx_display_planes, Fx_display_color_cells)
+	(Fx_server_max_request_size, Fx_server_vendor, Fx_server_version)
+	(Fx_display_screens, Fx_display_mm_height, Fx_display_mm_width)
+	(Fx_display_backing_store, Fx_display_visual_class)
+	(Fx_display_save_under, Fx_close_connection, x_create_tip_frame):
+	Use FRAME_TERMINAL_P, FRAME_WINDOW_P,  FRAME_TTY and FRAME_RIF.
+
+	* xfns.c (x_set_foreground_color x_set_background_color)
+	(x_set_mouse_color, x_set_cursor_color, x_make_gc): Use
+	FRAME_BACKGROUND_PIXEL and FRAME_FOREGROUND_PIXEL.
+	(Fx_create_frame, x_create_tip_frame, build_string, x_window)
+	(Fx_create_frame, x_create_tip_frame): Don't create frames on a
+	terminal that is being deleted.
+	(Fx_create_frame): Use `store_frame_param' to set `window-system'
+	frame parameter, and make sure it overrides any user-supplied
+	setting.
+	(Fx_close_connection, Fx_synchronize): Unify argument names with
+	the rest of the DEFUNs.
+
+	* dispnew.c (Fsend_string_to_terminal): Update call to
+	`get_tty_terminal'.
+	(Fredraw_frame, Fsend_string_to_terminal)
+	(Fsend_string_to_terminal, init_display): User FRAME_RIF,
+	FRAME_TERMCAP_P and FRAME_TTY.
+	(window_change_signal): Don't believe width/height values that are
+	impossibly small.
+	(Vinitial_window_system): Rename from Vwindow_system.
+	(termscript, Wcm, rif): Delete.
+
+	* termhooks.h (struct terminal): New struct containing the
+	previously global text display hooks and new members NAME,
+	DELETED and PARAM_ALIST.
+	(FRAME_TERMINAL, TERMINAL_TERMINAL_CODING)
+	(TERMINAL_KEYBOARD_CODING, TERMINAL_ACTIVE_P, FRAME_WINDOW_P)
+	(FRAME_RIF): New macros.
+	(get_terminal_param, get_device): New declarations.
+	(termscript): Delete declaration.
+
+	* xterm.c (x_initialize): Use Fset_input_interrupt_mode.
+	(XTflash, x_free_frame_resources, x_scroll_bar_create)
+	(x_scroll_bar_set_handle): Use FRAME_BACKGROUND_PIXEL and
+	FRAME_FOREGROUND_PIXEL.
+	(x_fully_uncatch_errors): Disable definition.
+	(x_scroll_bar_expose): Fix reference to foreground pixel.
+	(XTread_socket): Disable loop on all X displays.
+	(x_delete_terminal): Don't set terminal->deleted and let
+	delete_terminal delete the frames on the terminal.
+	(x_delete_display): Doc update to reflect changes in
+	delete_terminal.
+	(x_display_info) <terminal>: Move member earlier in the struct.
+	(x_delete_terminal): Use terminal->deleted.  Delete all frames on
+	the display explicitly.
+	(deleting_tty): Remove old variable.
+	(Fsuspend_tty): Call clear_tty_hooks.
+	(Fresume_tty, init_tty): Call set_tty_hooks.
+	(clear_tty_hooks, set_tty_hooks): New functions.
+	(Ftty_display_color_p, Ftty_display_color_cells): Don't throw
+	errors on X frames.
+	(x_catch_errors_unwind): Abort if x_error_message is NULL.
+	(handle_one_xevent): Initialize `f' to NULL.
+	(x_delete_device, x_create_device): New functions.
+	(XTset_terminal_modes, XTreset_terminal_modes)
+	(XTread_socket, x_connection_closed, x_term_init)
+	(x_term_init, x_delete_display): Add terminal parameter.
+	(x_term_init) [!HAVE_GTK_MULTIDISPLAY]: Refuse to create secondary
+	X connections.
+
+	* frame.c (Fframep): Deal with output_initial.
+	(Qbuffer_predicate, Qbuffer_list, Qburied_buffer_list, Qtty)
+	(Qtty_type, Qwindow_system, Qenvironment)
+	(Qterm_environment_variable, Qdisplay_environment_variable): New
+	variables.
+	(x_set_screen_gamma, store_frame_param): Fix compilation errors.
+	(make_terminal_frame): Don't create frames on a terminal that is
+	being deleted.
+	(make_terminal_frame): Use FRAME_BACKGROUND_PIXEL and
+	FRAME_FOREGROUND_PIXEL.
+	(store_frame_param): Check for found_for_frame before calling
+	XFRAME.
+	(Fmake_terminal_frame): Handle NULL tty names correctly.
+	(syms_of_frame): Enhance doc string of `default-frame-alist'.
+	(Fdelete_frame): Remove unused variable `count'.
+	(Qenvironment): New variable.
+	(Fdelete_frame): Don't allow other frames to refer to a deleted
+	frame in their 'environment parameter.
+	(Fframe_with_environment): New function.
+	(syms_of_frame): Defsubr it.  Initialize and staticpro
+	Qenvironment.
+	(get_future_frame_param): New function.
+	(Fmake_terminal_frame): Use it.
+
+	* sysdep.c (init_sys_modes, reset_sys_modes): Update for renames.
+	* sysdep.c (reset_sys_modes): Update for renames.
+
+	* keyboard.c (tty_read_avail_input): New function.
+	(Fset_input_interrupt_mode,Fset_output_flow_control): New
+	functions.
+	(syms_of_keyboard): Defsubr them.
+	(Fset_input_meta_mode, Fset_quit_char): New functions.
+	(Fset_input_mode): Split to above functions.
+
+	(read_char_minibuf_menu_prompt): Add wrong_kboard_jmpbuf
+	parameter.  Use it in call to `read_char'.
+	(read_char): Declare.  Update call to
+	`read_char_minibuf_menu_prompt'.  Set wrong_kboard_jmpbuf
+	correctly in recursive calls.  Use current_kboard to access
+	Vkeyboard_translate_table.  Enhance comment before extra longjmp
+	to wrong_kboard_jmpbuf.  Add wrong_kboard_jmpbuf parameter to
+	allow for recursive calls.  Update longjmp invocations.  Remember
+	the original current_kboard, and longjmp to `wrong_kboard_jmpbuf'
+	when a filter, timer or sentinel changes it.  Comment out
+	unnecessary calls to `record_single_kboard_state' and
+	`any_kboard_state'.  Update recursive calls.
+	(wrong_kboard_jmpbuf): Remove global variable.
+	(read_key_sequence): Remove unused variable wrong_kboard_jmpbuf.
+	Handle deleted interrupted_kboards correctly; that is a legal
+	case.  Add `wrong_kboard_jmpbuf' local variable.  Update setjmp
+	and read_char calls.  Abort if interrupted_kboard died in
+	read_char.
+	(any_kboard_state, single_kboard_state)
+	(push_frame_kboard): Remove function.
+	(pop_kboard): Switch out of single_kboard mode if the kboard has
+	been deleted. Remove unused variable. Help debugging by not
+	changing current_kboard unnecessarily. Set current_kboard to the
+	kboard of the selected frame when the stored kboard object has
+	been deleted before pop_kboard.
+	(temporarily_switch_to_single_kboard): Change first parameter to a
+	frame pointer.  Throw an error when caller wants to change kboards
+	while in single_kboard mode.  Don't push_kboard if we weren't in
+	single kboard state.  Don't pop_kboard if we popped into any
+	kboard state.
+	(restore_kboard_configuration): Abort if pop_kboard changed the
+	kboard in single_kboard mode. Call pop_kboard only after setting
+	up single_kboard mode.
+	(Frecursive_edit): Switch to single_kboard mode only in nested
+	command loops.
+	(cmd_error, command_loop, command_loop_1, timer_check): Comment
+	out unnecessary call to `any_kboard_state' and
+	`record_single_kboard_state'.
+	(delete_kboard): Exit single_kboard mode if we have just deleted
+	that kboard. Use FRAME_KBOARD.
+	(interrupt_signal): Use `Fkill_emacs' to exit Emacs, not
+	`fatal_error_signal'.
+	(record_single_kboard_state): Don't push_kboard if we weren't in
+	single kboard state.  Don't pop_kboard if we popped into any
+	kboard state.
+	(push_frame_kboard): Rename to push_kboard.
+	(kbd_buffer_get_event): Use FRAME_TERMINAL.
+	(read_avail_input): Read input from all terminals.
+	(mark_kboards): Also mark Vkeyboard_translate_table.
+	(kbd_buffer_store_event_hold): Simplify condition.
+	(read_key_sequence): Reinitialize fkey and keytran at each replay.
+	(Vkeyboard_translate_table): Move to struct kboard.
+	(init_kboard): Initialize Vkeyboard_translate_table.
+	(syms_of_keyboard): Use DEFVAR_KBOARD to define
+	Vkeyboard_translate_table.  Update doc strings.  Update docs of
+	local-function-key-map and function-key-map.
+
+	* terminal.c: New file.
+
+	* term.c: Include errno.h.
+	(Vring_bell_function, device_list, initial_device)
+	(next_device_id, ring_bell, update_begin, update_end)
+	(set_terminal_window, cursor_to, raw_cursor_to)
+	(clear_to_end, clear_frame, clear_end_of_line)
+	(write_glyphs, insert_glyphs, delete_glyphs, ins_del_lines)
+	(Fdisplay_name, create_device, delete_device): Move to terminal.c.
+	(syms_of_term): Move their initialization to terminal.c.
+	(get_tty_terminal, Fdisplay_tty_type, Ftty_display_color_p)
+	(Ftty_display_color_cells)
+	(Ftty_no_underline, Fsuspend_tty, Fresume_tty, create_tty_output)
+	(init_tty, maybe_fatal): New functions.
+	(Ftty_type): Return nil if terminal is not on a tty instead of
+	throwing an error.  Doc update.
+	(syms_of_term) <Vsuspend_tty_functions, Vresume_tty_functions>:
+	Doc update. Initialize new subrs and variables.
+	(delete_tty): Use terminal->deleted.
+	(tty_set_terminal_modes): Rename from set_terminal_modes.
+	(tty_reset_terminal_modes): Rename from reset_terminal_modes.
+	(set_scroll_region): Rename to `tty_set_scroll_region'.
+	(turn_on_insert): Rename to `tty_turn_on_insert'.
+	(turn_off_insert): Rename to `tty_turn_off_insert'.
+	(turn_off_highlight): Rename to `tty_turn_off_highlight'.
+	(turn_on_highlight): Rename to `tty_turn_on_highlight'.
+	(toggle_highligh): Rename to `tty_toggle_highlight'.
+	(background_highlight): Rename to `tty_background_highlight'.
+	(highlight_if_desired): Rename to `tty_highlight_if_desired'.
+	(tty_ring_bell, tty_update_end, tty_set_terminal_window)
+	(tty_set_scroll_region, tty_background_highlight)
+	(tty_cursor_to, tty_raw_cursor_to, tty_clear_to_end)
+	(tty_clear_frame, tty_clear_end_of_line, tty_write_glyphs)
+	(tty_insert_glyphs, tty_delete_glyphs, tty_ins_del_lines)
+	(term_get_fkeys, tty_setup_colors, dissociate_if_controlling_tty):
+	Add static modifier.
+	(tty_reset_terminal_modes, tty_set_terminal_window)
+	(tty_set_scroll_region, tty_background_highlight)
+	(tty_highlight_if_desired, tty_cursor_to)
+	(tty_raw_cursor_to, tty_clear_to_end, tty_clear_frame)
+	(tty_clear_end_of_line, tty_write_glyphs, tty_insert_glyphs)
+	(tty_delete_glyphs, tty_ins_del_lines, turn_on_face): Update for
+	renames.
+
+2007-08-28  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* keyboard.c: Qrtl is new.
+	(parse_tool_bar_item): Handle :rtl keyword.
+	(syms_of_keyboard): Intern :rtl keyword.
+
+	* dispextern.h (enum tool_bar_item_idx): Add TOOL_BAR_ITEM_RTL_IMAGE.
+
+	* gtkutil.c (xg_tool_bar_expose_callback): Just do SET_FRAME_GARBAGED
+	so no Lisp code is executed.
+	(file_for_image, find_rtl_image): New functions.
+	(xg_get_image_for_pixmap): Use file_for_image
+	(update_frame_tool_bar): If direction is RTL, use RTL image if
+	defined.  Use Gtk stock images if defined.
+
 2007-08-27  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
 	* macterm.c (x_draw_composite_glyph_string_foreground): Draw rectangle
--- a/src/ChangeLog.multi-tty	Wed Aug 29 04:01:43 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,631 +0,0 @@
-0000-00-00  Dan Nicolaescu  <dann@ics.uci.edu>
-
-	* callproc.c (child_setup, getenv_internal): Use the
-	display-environment-variable and term-environment-variable frame
-	params.
-	(set_initial_environment): Initialise Vprocess_environment.
-
-	* config.in: Disable multi-keyboard support on a mac.
-
-	* frame.c (Qterm_environment_variable)
-	(Qdisplay_environment_variable): New variables.
-	(syms_of_frame): Intern and staticpro them.
-	(Fmake_terminal_frame): Disable output method test.
-
-	* frame.h: Declare them here.
-
-	* macfns.c (x_set_mouse_color): Get rif from the frame.
-	(x_set_tool_bar_lines): Don't use updating_frame.
-	(mac_window): Add 2 new parameters for consistency with other systems.
-	(Fx_create_frame): Fix doc string.  Rename the parameter.  Set the
-	frame parameters following what is done in X11 and w32.  Don't use
-	FRAME_MAC_DISPLAY_INFO.
-	(Fx_open_connection, start_hourglass): Remove window-system check.
-	(x_create_tip_frame): Get the keyboard from the terminal.
-
-	* macmenu.c: Reorder includes.
-	(Fx_popup_menu): Use terminal specific mouse_position_hook.
-
-	* macterm.c (XTset_terminal_modes, XTreset_terminal_modes): Add a
-	terminal parameter.
-	(x_clear_frame): Add a frame parameter.
-	(note_mouse_movement): Get rif from the frame.
-	(mac_term_init): Initialize the terminal.
-	(mac_initialize): Make static and move terminal initialization ...
-	(mac_create_terminal): ... to this new function.
-
-	* macterm.h (struct mac_display_info): Add terminal.
-
-	* puresize.h (BASE_PURESIZE): Increase base value to 1158000.
-
-	* sysdep.c: Comment out text after #endif.
-
-	* term.c (init_tty): Only use terminal->kboard when MULTI_KBOARD
-	is defined.  Better initialize ttys in windows.  Use terminal
-	specific mouse_position_hook.
-
-	* termhooks.h (union display_info): Add mac_display_info.
-
-	* w32fns.c (Fx_create_frame): Use kboard from the terminal.  Set
-	the default minibuffer frame, window_system and the rest of the
-	frame parameters following what is done in X11.
-
-	* w32term.c (w32_initialize): Make static.
-
-	* xselect.c (x_handle_selection_clear): Only access
-	terminal->kboard when MULTI_KBOARD is defined.
-
-	* s/darwin.h (SYSTEM_PURESIZE_EXTRA): Define here.
-	(SYSTEM_PURESIZE_EXTRA): Only define on Carbon.
-
-0000-00-00  Jason Rumney  <jasonr@gnu.org>
-
-	* frame.c (Fdelete_frame): Only get kboard when MULTI_KBOARD defined.
-	(make_terminal_frame) [WINDOWSNT]: Initialize terminal.
-
-	* fringe.c (w32_init_fringe w32_reset_fringes) [HAVE_NTGUI]:
-	(mac_init_fringe) [MAC_OS]: Get rif from selected_frame.
-
-	* keyboard.c (restore_kboard_configuration): Only define when
-	MULTI_KBOARD defined.
-
-	* makefile.w32-in: Update dependancies from Makefile.in
-	(OBJ1): Add terminal.$(O)
-
-	* term.c (dissociate_if_controlling_tty) [WINDOWSNT]: Don't
-	define function body.
-	(init_tty) [WINDOWSNT]: Use selected_frame for initializing.
-
-	* termhooks.h (display_info) [WINDOWSNT]: Add w32.
-
-	* w32.c (request_sigio, unrequest_sigio): Remove.
-
-	* w32console.c (w32con_move_cursor, w32con_clear_to_end)
-	(w32con_clear_frame, w32con_clear_end_of_line)
-	(w32con_ins_del_lines, w32con_insert_glyphs, w32con_write_glyphs)
-	(w32con_delete_glyphs, w32con_set_terminal_window)
-	(scroll_line, w32_sys_ring_bell): Add frame arg.
-	(w32con_set_terminal_modes, w32con_reset_terminal_modes): Add
-	terminal arg.
-	(PICK_FRAME): Remove.
-	(w32con_write_glyphs): Use frame specific terminal coding.
-	(one_and_only_w32cons): New global variable.
-	(initialize_w32_display): Use it for storing hooks.
-	(create_w32cons_output): New function.
-
-	* w32inevt.c, w32inevt.h (w32_console_read_socket): Make first
-	arg a frame.
-
-	* w32fns.c (x_create_tip_frame): Set terminal and ref count.  Set
-	window_system.
-	(x_set_tool_bar_lines): Don't use updating_frame.
-	(Fx_create_frame): Set terminal and ref count.
-	(Fx_open_connection): Remove window-system check.
-
-	* w32menu.c (Fx_popup_menu): Use terminal specific mouse_position_hook.
-
-	* w32term.c (w32_term_init): Call add_keyboard_wait_descriptor.
-	(w32_set_terminal_modes, w32_reset_terminal_modes): Add terminal arg.
-	(x_clear_frame, x_delete_glyphs, w32_ring_bell, x_ins_del_lines):
-	Add frame arg.
-	(x_delete_terminal, w32_create_terminal): New functions.
-	(w32_term_init): Create a terminal.
-	(w32_initialize): Move terminal specific initialization to
-	w32_create_terminal.
-
-	* w32term.h (x_output): Remove foreground_pixel and
-	background_pixel.
-	(w32_clear_rect, w32_clear_area): Use background from frame.
-	(w32_display_info): Add terminal.
-	(w32_sys_ring_bell, x_delete_display): Declare here.
-
-	* xdisp.c (display_menu_bar) [HAVE_NTGUI]: Check frame type.
-
-	* s/ms-w32.h (SYSTEM_PURESIZE_EXTRA): Bump to 50k.
-
-0000-00-00  Kalle Olavi Niemitalo  <kon@iki.fi>  (tiny change)
-
-	* keyboard.c (interrupt_signal, handle_interrupt, Fset_quit_char):
-	Fix get_named_tty calls for the controlling tty.
-
-0000-00-00  ARISAWA Akihiro  <ari@mbf.ocn.ne.jp>  (tiny change)
-
-	* term.c (dissociate_if_controlling_tty)[USG]: Fix parse error.
-
-0000-00-00  Yoshiaki Kasahara  <kasahara@nc.kyushu-u.ac.jp>  (tiny change)
-
-	* term.c (tty_insert_glyphs): Add missing first parameter.
-
-0000-00-00  Karoly Lorentey  <karoly@lorentey.hu>
-
-	* buffer.c (Fbuffer_list, Fbury_buffer): Take
-	frame->buried_buffer_list into account.
-
-	* cm.c (current_tty): New variable, for cmputc().
-	(cmputc): Use it.
-	(cmcheckmagic): Add tty parameter, look up terminal streams there.
-	(calccost): Add tty parameter.  Use emacs_tputs() instead of tputs().
-	(cmgoto): Add tty parameter.  Pass it on to calccost().  Use
-	emacs_tputs() instead of tputs().
-
-	* cm.h (emacs_tputs): New macro to set current_tty, and then call
-	tputs().
-	(current_tty): New variable, for cmputc().
-	(cmcheckmagic, cmputc, cmgoto): Add prototypes.
-
-	* eval.c (unwind_to_catch): Don't call x_fully_uncatch_errors.
-	(internal_condition_case, internal_condition_case_1)
-	(internal_condition_case_2): Don't abort when x_catching_errors.
-
-	* fns.c (Fyes_or_no_p): Don't try to open an X dialog on tty terminals.
-	(Fy_or_n_p): Likewise.  Use temporarily_switch_to_single_kboard to
-	prevent crashes caused by bogus longjmps in read_char.
-
-	* keymap.h (Fset_keymap_parent): Add EXFUN.
-
-	* macterm.h (FRAME_FOREGROUND_PIXEL, FRAME_BACKGROUND_PIXEL)
-	* w32term.h (FRAME_FOREGROUND_PIXEL, FRAME_BACKGROUND_PIXEL):
-	Remove redundant definition.
-
-	* macfns.c (x_set_mouse_color,x_make_gc): Use
-	FRAME_BACKGROUND_PIXEL and FRAME_FOREGROUND_PIXEL.
-
-	* w32term.c (x_free_frame_resources): Use
-	FRAME_BACKGROUND_PIXEL and FRAME_FOREGROUND_PIXEL.
-	(w32_initialize): Use the accessor macros for terminal characteristics.
-
-	* macterm.c (mac_initialize): Use Fset_input_interrupt_mode.
-	Use the accessor macros for terminal characteristics.
-	* msdos.c (internal_terminal_init): Use the accessor macros for
-	terminal characteristics.
-	(ScreenVisualBell,internal_terminal_init): Use
-	FRAME_BACKGROUND_PIXEL and FRAME_FOREGROUND_PIXEL.
-
-	* termopts.h (no_redraw_on_reenter): Declare.
-
-	* alloc.c (emacs_blocked_malloc): Disable mallopt call.
-	(mark_terminals,mark_ttys): Declare.
-	(Fgarbage_collect): Call them.
-	(mark_object): Mark buried_buffer_list;
-
-	* prefix-args.c: Include stdlib.h for exit.
-
-	* syssignal.h: Add comment.
-
-	* indent.c: Include stdio.h.
-
-	* window.h (Vinitial_window_system): Declare.
-	(Vwindow_system): Delete declaration.
-
-	* fontset.c (Finternal_char_font): Use FRAME_RIF.
-
-	* image.c (lookup_image): Don't initialize `c' until the xasserts
-	have been run.
-
-	* gtkutil.c (xg_create_frame_widgets): Use FRAME_BACKGROUND_PIXEL and
-	FRAME_FOREGROUND_PIXEL.
-
-	* print.c (print_preprocess): Don't lose print_depth levels while
-	iterating.
-
-	* widget.c (update_from_various_frame_slots): Use
-	FRAME_BACKGROUND_PIXEL and FRAME_FOREGROUND_PIXEL.
-
-	* window.c (set_window_buffer): Don't call clear_mouse_face on tty
-	frames.
-	(window_internal_height): Remove bogus make_number call.
-	(init_window_once): Call make_terminal_frame with two zero
-	parameters.
-
-	* fileio.c (Fread_file_name): Update comment.
-
-	* callint.c (Fcall_interactively): Use
-	temporarily_switch_to_single_kboard instead of single_kboard_state.
-	Make sure it is correctly unwound.
-
-	* xsmfns.c (x_session_close): New function.
-
-	* coding.h (terminal_coding,safe_terminal_coding,keyboard_coding):
-	Delete declarations.
-
-	* xterm.h: Remove declaration for x_fully_uncatch_errors.
-	(x_output): Remove background_pixel and foreground_pixel fields.
-	(x_display_info): Add new field TERMINAL. Remove KBOARD field.
-	(x_delete_device):
-	(x_session_close): Declare.
-
-	* lread.c: Include setjmp.h.  Update declaration of `read_char'.
-	(read_filtered_event): Call `read_char' with a local
-	`wrong_kboard_jmpbuf'.
-
-	* minibuf.c (read_minibuf): Call
-	temporarily_switch_to_single_kboard. Don't call
-	single_kboard_state. Use FRAME_RIF.
-
-	* process.c (Fmake_network_process): Don't unrequest_sigio on modern
-	systems.
-
-	* lisp.h (set_process_environment): Rename to
-	`set_global_environment'.
-	(Fframe_with_environment,Fset_input_meta_mode)
-	(Fset_quit_char): EXFUN.
-	(x_create_device,tty_output,terminal,tty_display_info): Declare.
-	(init_sys_modes, reset_sys_modes): Update prototypes.
-	(init_all_sys_modes, reset_all_sys_modes): New prototypes.
-
-	* keyboard.h (struct kboard): Add new fields:
-	Vlocal_function_key_map, Vlocal_key_translation_map,
-	Vkeyboard_translate_table.
-	(Vfunction_key_map,Vkeyboard_translate_table,single_kboard_state):
-	Delete declarations.
-	(Vfunction_key_map,Vkey_translation_map,push_kboard,pop_kboard)
-	(temporarily_switch_to_single_kboard,tty_read_avail_input):
-	New declarations.
-
-	* emacs.c (main): Don't call init_sys_modes(), the new term_init()
-	already does that during init_display().  Call syms_of_keymap
-	before syms_of_keyboard.  Call `syms_of_terminal'.  Call
-	set_initial_environment, not set_process_environment.
-	(shut_down_emacs): Call reset_all_sys_modes() instead of
-	reset_sys_modes().
-
-	* xfaces.c (x_free_gc): Protect xassert with GLYPH_DEBUG.
-	(internal_resolve_face_name, resolve_face_name_error): New
-	functions.
-	(resolve_face_name): Protect against loops and errors thrown by
-	Fget.
-	(realize_default_face): Don't use FRAME_FONT unless frame is an X
-	frame.
-	(Ftty_supports_face_attributes_p): Update tty_capable_p call.
-
-	* scroll.c: Replace CURTTY() with local variables throughout the
-	file (where applicable).
-	(calculate_scrolling, calculate_direct_scrolling)
-	(scrolling_1, scroll_cost): Use the accessor macros for terminal
-	characteristics.
-
-	* keymap.c (Vfunction_key_map): Remove.
-	(Fdescribe_buffer_bindings): Update references to
-	Vfunction_key_map.
-	(syms_of_keymap): Remove DEFVAR for Vfunction_key_map.
-	(Vkey_translation_map): Remove.
-	(syms_of_keymap): Remove DEFVAR for key-translation-map.
-	(Fdescribe_buffer_bindings):
-	(read_key_sequence, init_kboard, syms_of_keyboard, mark_kboards):
-	Update for terminal-local key-translation-map.
-
-	* Makefile.in (callproc.o): Update dependencies.
-	(lisp, shortlisp): Add termdev.elc.
-	(obj): Add terminal.o.
-	(terminal.o): Add dependencies.
-	[HAVE_CARBON]: Make terminal.o depend on macgui.h.
-	(data.o, fns.o): Add termhooks.h dependency.
-	(SOME_MACHINE_LISP): Add dnd.elc.
-	(minibuf.o): Fix typo.
-	Update dependencies.
-
-	* data.c (do_symval_forwarding, store_symval_forwarding)
-	(find_symbol_value): Use the selected frame's keyboard, not
-	current_kboard.
-
-	* .gdbinit (init_sys_modes): Use Vinitial_window_system instead of
-	Vwindow_system.
-
-	* xmenu.c (Fx_menu_bar_open) [USE_X_TOOLKIT, USE_GTK]: Rename from
-	Fmenu_bar_open.
-	(syms_of_xmenu): Update defsubr.
-	(mouse_position_for_popup, Fx_popup_menu)
-	(Fx_popup_dialog, x_activate_menubar, update_frame_menubar)
-	(set_frame_menubar, free_frame_menubar)
-	(create_and_show_popup_menu, xmenu_show, )
-	(create_and_show_dialog, xdialog_show, xmenu_show): Abort if not
-	an X frame.
-
-	* xselect.c (x_own_selection): Abort if not an X frame.
-	(some_frame_on_display): Check if it is an X frame.
-	(x_handle_selection_clear): Deal with MULTI_KBOARD.
-
-	* coding.c: Include frame.h and termhooks.h.
-	(terminal_coding,keyboard_coding): Delete.
-	(Fset_terminal_coding_system_internal):
-	(Fset_keyboard_coding_system_internal):
-	(Fkeyboard_coding_system):
-	(Fterminal_coding_system): Add a terminal parameter. Get
-	terminal_coding from the terminal.
-	(init_coding_once): Don't call setup_coding_system here.
-
-	* dispextern.h (set_scroll_region, turn_off_insert)
-	(turn_off_highlight, background_highlight, clear_end_of_line_raw)
-	(tty_clear_end_of_line, tty_setup_colors)
-	(delete_tty,updating_frame)
-	(produce_special_glyphs, produce_glyphs, write_glyphs)
-	(insert_glyphs): Remove.
-	(raw_cursor_to, clear_to_end, tty_turn_off_insert)
-	(tty_turn_off_highlight,get_tty_size): Add declaration.
-	(tabs_safe_p, init_baud_rate, get_tty_terminal): Update
-	prototypes.
-
-	* frame.h (enum output_method): Add output_initial.
-	(struct x_output): Delete.
-	(FRAME_FOREGROUND_PIXEL, FRAME_BACKGROUND_PIXEL): Access
-	foreground_pixel and background_pixel directly from the frame.
-	(tty_display): Delete.
-	(struct frame): Add buried_buffer_list, foreground_pixel,
-	background_pixel and terminal. Delete kboard
-	(union output_data): Add tty.
-	(FRAME_KBOARD): Get the kboard from the terminal.
-	(FRAME_INITIAL_P): New macro.
-	(Qtty, Qtty_type, Qterminal, Qterminal_live_p, Qenvironment)
-	(Qterm_environment_variable, Qdisplay_environment_variable)
-	(make_terminal_frame, Qburied_buffer_list, Qwindow_system): New
-	declarations.
-
-	* termchar.h (tty_output, tty_display_info): New structures.
-	(tty_list): Declare.
-	(FRAME_TTY, CURTTY): New macros.
-	(must_write_spaces, min_padding_speed, fast_clear_end_of_line)
-	(line_ins_del_ok, char_ins_del_ok, scroll_region_ok)
-	(scroll_region_cost, memory_below_frame, fast_clear_end_of_line)
-	(dont_calculate_costs, no_redraw_on_reenter): Remove declarations.
-
-	* callproc.c: Include frame.h and termhooks.h, for terminal
-	parameters.
-	(add_env): New function.
-	(child_setup): Use it.
-	(child_setup, getenv_internal): Handle the new
-	Vprocess_environment.
-	(getenv_internal): Fix get_terminal_param call.
-	(Fgetenv_internal, egetenv): Update doc.
-	(syms_of_callproc): Initialize Vprocess_environment to nil.
-	Register and initialize them. Remove obsolete defvars. Update doc
-	strings.
-	(child_setup): Handle Vlocal_environment_variables.
-	(getenv_internal): Add terminal parameter.  Handle
-	Vlocal_environment_variables.
-	(Fgetenv_internal): Add terminal parameter.
-	(child_setup, getenv_internal, Fgetenv_internal): Store the local
-	environment in a frame (not terminal) parameter.  Update doc
-	strings.
-	(set_initial_environment): Rename from set_global_environment.
-	Store Emacs environment in initial frame parameter.
-
-	* xdisp.c (redisplay_internal): Update references to
-	`previous_terminal_frame'.
-	(display_mode_line, Fformat_mode_line): Replace calls to
-	`push_frame_kboard' with `push_kboard'.
-	(get_glyph_string_clip_rects): Add extra parentheses and
-	braces to prevent compiler warnings.
-	(calc_pixel_width_or_height): Add xassert to check that the
-	frame is alive.  Don't call `lookup_image' on a termcap frame.
-	(message2_nolog, message3_nolog, redisplay_internal)
-	(set_vertical_scroll_bar, redisplay_window, check_x_display_info)
-	(x_set_scroll_bar_foreground, x_set_scroll_bar_background)
-	(Fx_create_frame, Fxw_display_color_p, Fx_display_grayscale_p)
-	(Fx_display_pixel_width, Fx_display_pixel_height)
-	(Fx_display_planes, Fx_display_color_cells)
-	(Fx_server_max_request_size, Fx_server_vendor, Fx_server_version)
-	(Fx_display_screens, Fx_display_mm_height, Fx_display_mm_width)
-	(Fx_display_backing_store, Fx_display_visual_class)
-	(Fx_display_save_under, Fx_close_connection, x_create_tip_frame):
-	Use FRAME_TERMINAL_P, FRAME_WINDOW_P,  FRAME_TTY and FRAME_RIF.
-
-	* xfns.c (x_set_foreground_color x_set_background_color)
-	(x_set_mouse_color, x_set_cursor_color, x_make_gc): Use
-	FRAME_BACKGROUND_PIXEL and FRAME_FOREGROUND_PIXEL.
-	(Fx_create_frame, x_create_tip_frame, build_string, x_window)
-	(Fx_create_frame, x_create_tip_frame): Don't create frames on a
-	terminal that is being deleted.
-	(Fx_create_frame): Use `store_frame_param' to set `window-system'
-	frame parameter, and make sure it overrides any user-supplied
-	setting.
-	(Fx_close_connection, Fx_synchronize): Unify argument names with
-	the rest of the DEFUNs.
-
-	* dispnew.c (Fsend_string_to_terminal): Update call to
-	`get_tty_terminal'.
-	(Fredraw_frame, Fsend_string_to_terminal)
-	(Fsend_string_to_terminal, init_display): User FRAME_RIF,
-	FRAME_TERMCAP_P and FRAME_TTY.
-	(window_change_signal): Don't believe width/height values that are
-	impossibly small.
-	(Vinitial_window_system): Rename from Vwindow_system.
-	(termscript, Wcm, rif): Delete.
-
-	* termhooks.h (struct terminal): New struct containing the
-	previously global text display hooks and new members NAME,
-	DELETED and PARAM_ALIST.
-	(FRAME_TERMINAL, TERMINAL_TERMINAL_CODING)
-	(TERMINAL_KEYBOARD_CODING, TERMINAL_ACTIVE_P, FRAME_WINDOW_P)
-	(FRAME_RIF): New macros.
-	(get_terminal_param, get_device): New declarations.
-	(termscript): Delete declaration.
-
-	* xterm.c (x_initialize): Use Fset_input_interrupt_mode.
-	(XTflash, x_free_frame_resources, x_scroll_bar_create)
-	(x_scroll_bar_set_handle): Use FRAME_BACKGROUND_PIXEL and
-	FRAME_FOREGROUND_PIXEL.
-	(x_fully_uncatch_errors): Disable definition.
-	(x_scroll_bar_expose): Fix reference to foreground pixel.
-	(XTread_socket): Disable loop on all X displays.
-	(x_delete_terminal): Don't set terminal->deleted and let
-	delete_terminal delete the frames on the terminal.
-	(x_delete_display): Doc update to reflect changes in
-	delete_terminal.
-	(x_display_info) <terminal>: Move member earlier in the struct.
-	(x_delete_terminal): Use terminal->deleted.  Delete all frames on
-	the display explicitly.
-	(deleting_tty): Remove old variable.
-	(Fsuspend_tty): Call clear_tty_hooks.
-	(Fresume_tty, init_tty): Call set_tty_hooks.
-	(clear_tty_hooks, set_tty_hooks): New functions.
-	(Ftty_display_color_p, Ftty_display_color_cells): Don't throw
-	errors on X frames.
-	(x_catch_errors_unwind): Abort if x_error_message is NULL.
-	(handle_one_xevent): Initialize `f' to NULL.
-	(x_delete_device, x_create_device): New functions.
-	(XTset_terminal_modes, XTreset_terminal_modes)
-	(XTread_socket, x_connection_closed, x_term_init)
-	(x_term_init, x_delete_display): Add terminal parameter.
-	(x_term_init) [!HAVE_GTK_MULTIDISPLAY]: Refuse to create secondary
-	X connections.
-
-	* frame.c (Fframep): Deal with output_initial.
-	(Qbuffer_predicate, Qbuffer_list, Qburied_buffer_list, Qtty)
-	(Qtty_type, Qwindow_system, Qenvironment)
-	(Qterm_environment_variable, Qdisplay_environment_variable): New
-	variables.
-	(x_set_screen_gamma, store_frame_param): Fix compilation errors.
-	(make_terminal_frame): Don't create frames on a terminal that is
-	being deleted.
-	(make_terminal_frame): Use FRAME_BACKGROUND_PIXEL and
-	FRAME_FOREGROUND_PIXEL.
-	(store_frame_param): Check for found_for_frame before calling
-	XFRAME.
-	(Fmake_terminal_frame): Handle NULL tty names correctly.
-	(syms_of_frame): Enhance doc string of `default-frame-alist'.
-	(Fdelete_frame): Remove unused variable `count'.
-	(Qenvironment): New variable.
-	(Fdelete_frame): Don't allow other frames to refer to a deleted
-	frame in their 'environment parameter.
-	(Fframe_with_environment): New function.
-	(syms_of_frame): Defsubr it.  Initialize and staticpro
-	Qenvironment.
-	(get_future_frame_param): New function.
-	(Fmake_terminal_frame): Use it.
-
-	* sysdep.c (init_sys_modes, reset_sys_modes): Update for renames.
-	* sysdep.c (reset_sys_modes): Update for renames.
-
-	* keyboard.c (tty_read_avail_input): New function.
-	(Fset_input_interrupt_mode,Fset_output_flow_control): New
-	functions.
-	(syms_of_keyboard): Defsubr them.
-	(Fset_input_meta_mode, Fset_quit_char): New functions.
-	(Fset_input_mode): Split to above functions.
-
-	(read_char_minibuf_menu_prompt): Add wrong_kboard_jmpbuf
-	parameter.  Use it in call to `read_char'.
-	(read_char): Declare.  Update call to
-	`read_char_minibuf_menu_prompt'.  Set wrong_kboard_jmpbuf
-	correctly in recursive calls.  Use current_kboard to access
-	Vkeyboard_translate_table.  Enhance comment before extra longjmp
-	to wrong_kboard_jmpbuf.  Add wrong_kboard_jmpbuf parameter to
-	allow for recursive calls.  Update longjmp invocations.  Remember
-	the original current_kboard, and longjmp to `wrong_kboard_jmpbuf'
-	when a filter, timer or sentinel changes it.  Comment out
-	unnecessary calls to `record_single_kboard_state' and
-	`any_kboard_state'.  Update recursive calls.
-	(wrong_kboard_jmpbuf): Remove global variable.
-	(read_key_sequence): Remove unused variable wrong_kboard_jmpbuf.
-	Handle deleted interrupted_kboards correctly; that is a legal
-	case.  Add `wrong_kboard_jmpbuf' local variable.  Update setjmp
-	and read_char calls.  Abort if interrupted_kboard died in
-	read_char.
-	(any_kboard_state, single_kboard_state)
-	(push_frame_kboard): Remove function.
-	(pop_kboard): Switch out of single_kboard mode if the kboard has
-	been deleted. Remove unused variable. Help debugging by not
-	changing current_kboard unnecessarily. Set current_kboard to the
-	kboard of the selected frame when the stored kboard object has
-	been deleted before pop_kboard.
-	(temporarily_switch_to_single_kboard): Change first parameter to a
-	frame pointer.  Throw an error when caller wants to change kboards
-	while in single_kboard mode.  Don't push_kboard if we weren't in
-	single kboard state.  Don't pop_kboard if we popped into any
-	kboard state.
-	(restore_kboard_configuration): Abort if pop_kboard changed the
-	kboard in single_kboard mode. Call pop_kboard only after setting
-	up single_kboard mode.
-	(Frecursive_edit): Switch to single_kboard mode only in nested
-	command loops.
-	(cmd_error, command_loop, command_loop_1, timer_check): Comment
-	out unnecessary call to `any_kboard_state' and
-	`record_single_kboard_state'.
-	(delete_kboard): Exit single_kboard mode if we have just deleted
-	that kboard. Use FRAME_KBOARD.
-	(interrupt_signal): Use `Fkill_emacs' to exit Emacs, not
-	`fatal_error_signal'.
-	(record_single_kboard_state): Don't push_kboard if we weren't in
-	single kboard state.  Don't pop_kboard if we popped into any
-	kboard state.
-	(push_frame_kboard): Rename to push_kboard.
-	(kbd_buffer_get_event): Use FRAME_TERMINAL.
-	(read_avail_input): Read input from all terminals.
-	(mark_kboards): Also mark Vkeyboard_translate_table.
-	(kbd_buffer_store_event_hold): Simplify condition.
-	(read_key_sequence): Reinitialize fkey and keytran at each replay.
-	(Vkeyboard_translate_table): Move to struct kboard.
-	(init_kboard): Initialize Vkeyboard_translate_table.
-	(syms_of_keyboard): Use DEFVAR_KBOARD to define
-	Vkeyboard_translate_table.  Update doc strings.  Update docs of
-	local-function-key-map and function-key-map.
-
-	* terminal.c: New file.
-
-	* term.c: Include errno.h.
-	(Vring_bell_function, device_list, initial_device)
-	(next_device_id, ring_bell, update_begin, update_end)
-	(set_terminal_window, cursor_to, raw_cursor_to)
-	(clear_to_end, clear_frame, clear_end_of_line)
-	(write_glyphs, insert_glyphs, delete_glyphs, ins_del_lines)
-	(Fdisplay_name, create_device, delete_device): Move to terminal.c.
-	(syms_of_term): Move their initialization to terminal.c.
-	(get_tty_terminal, Fdisplay_tty_type, Ftty_display_color_p)
-	(Ftty_display_color_cells)
-	(Ftty_no_underline, Fsuspend_tty, Fresume_tty, create_tty_output)
-	(init_tty, maybe_fatal): New functions.
-	(Ftty_type): Return nil if terminal is not on a tty instead of
-	throwing an error.  Doc update.
-	(syms_of_term) <Vsuspend_tty_functions, Vresume_tty_functions>:
-	Doc update. Initialize new subrs and variables.
-	(delete_tty): Use terminal->deleted.
-	(tty_set_terminal_modes): Rename from set_terminal_modes.
-	(tty_reset_terminal_modes): Rename from reset_terminal_modes.
-	(set_scroll_region): Rename to `tty_set_scroll_region'.
-	(turn_on_insert): Rename to `tty_turn_on_insert'.
-	(turn_off_insert): Rename to `tty_turn_off_insert'.
-	(turn_off_highlight): Rename to `tty_turn_off_highlight'.
-	(turn_on_highlight): Rename to `tty_turn_on_highlight'.
-	(toggle_highligh): Rename to `tty_toggle_highlight'.
-	(background_highlight): Rename to `tty_background_highlight'.
-	(highlight_if_desired): Rename to `tty_highlight_if_desired'.
-	(tty_ring_bell, tty_update_end, tty_set_terminal_window)
-	(tty_set_scroll_region, tty_background_highlight)
-	(tty_cursor_to, tty_raw_cursor_to, tty_clear_to_end)
-	(tty_clear_frame, tty_clear_end_of_line, tty_write_glyphs)
-	(tty_insert_glyphs, tty_delete_glyphs, tty_ins_del_lines)
-	(term_get_fkeys, tty_setup_colors, dissociate_if_controlling_tty):
-	Add static modifier.
-	(tty_reset_terminal_modes, tty_set_terminal_window)
-	(tty_set_scroll_region, tty_background_highlight)
-	(tty_highlight_if_desired, tty_cursor_to)
-	(tty_raw_cursor_to, tty_clear_to_end, tty_clear_frame)
-	(tty_clear_end_of_line, tty_write_glyphs, tty_insert_glyphs)
-	(tty_delete_glyphs, tty_ins_del_lines, turn_on_face): Update for
-	renames.
-
-;; Local Variables:
-;; coding: iso-2022-7bit
-;; add-log-time-zone-rule: t
-;; End:
-
-    Copyright (C) 2007 Free Software Foundation, Inc.
-
-  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., 51 Franklin Street, Fifth Floor,
-  Boston, MA 02110-1301, USA.
-
-;;; arch-tag: 4015a0e0-033e-11dc-807c-00114368b55b
--- a/src/dispextern.h	Wed Aug 29 04:01:43 2007 +0000
+++ b/src/dispextern.h	Wed Aug 29 05:28:10 2007 +0000
@@ -2570,6 +2570,9 @@
   /* Help string.  */
   TOOL_BAR_ITEM_HELP,
 
+  /* Icon file name of right to left image when an RTL locale is used.  */
+  TOOL_BAR_ITEM_RTL_IMAGE,
+
   /* Sentinel = number of slots in tool_bar_items occupied by one
      tool-bar item.  */
   TOOL_BAR_ITEM_NSLOTS
--- a/src/gtkutil.c	Wed Aug 29 04:01:43 2007 +0000
+++ b/src/gtkutil.c	Wed Aug 29 05:28:10 2007 +0000
@@ -298,6 +298,23 @@
   return icon_buf;
 }
 
+static Lisp_Object
+file_for_image(image)
+     Lisp_Object image;
+{
+  Lisp_Object specified_file = Qnil;
+  Lisp_Object tail;
+  extern Lisp_Object QCfile;
+
+  for (tail = XCDR (image);
+       NILP (specified_file) && CONSP (tail) && CONSP (XCDR (tail));
+       tail = XCDR (XCDR (tail)))
+    if (EQ (XCAR (tail), QCfile))
+      specified_file = XCAR (XCDR (tail));
+
+  return specified_file;
+}
+
 /* For the image defined in IMG, make and return a GtkImage.  For displays with
    8 planes or less we must make a GdkPixbuf and apply the mask manually.
    Otherwise the highlightning and dimming the tool bar code in GTK does
@@ -323,16 +340,8 @@
   /* If we have a file, let GTK do all the image handling.
      This seems to be the only way to make insensitive and activated icons
      look good in all cases.  */
-  Lisp_Object specified_file = Qnil;
-  Lisp_Object tail;
+  Lisp_Object specified_file = file_for_image (img->spec);
   Lisp_Object file;
-  extern Lisp_Object QCfile;
-
-  for (tail = XCDR (img->spec);
-       NILP (specified_file) && CONSP (tail) && CONSP (XCDR (tail));
-       tail = XCDR (XCDR (tail)))
-    if (EQ (XCAR (tail), QCfile))
-      specified_file = XCAR (XCDR (tail));
 
   /* We already loaded the image once before calling this
      function, so this only fails if the image file has been removed.
@@ -3332,6 +3341,16 @@
 /* The key for storing the button widget in its proxy menu item. */
 #define XG_TOOL_BAR_PROXY_BUTTON "emacs-tool-bar-proxy-button"
 
+/* The key for the data we put in the GtkImage widgets.  The data is
+   the stock name used by Emacs.  We use this to see if we need to update
+   the GtkImage with a new image.  */
+#define XG_TOOL_BAR_STOCK_NAME "emacs-tool-bar-stock-name"
+
+/* Callback function invoked when a tool bar item is pressed.
+   W is the button widget in the tool bar that got pressed,
+   CLIENT_DATA is an integer that is the index of the button in the
+   tool bar.  0 is the first button.  */
+
 static gboolean
 xg_tool_bar_button_cb (widget, event, user_data)
     GtkWidget      *widget;
@@ -3614,8 +3633,10 @@
   return FALSE;
 }
 
+#define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX))
+
 /* This callback is called when a tool bar shall be redrawn.
-   We need to update the tool bar from here in case the image cache
+   We need to update the images in case the image cache
    has deleted the pixmaps used in the tool bar.
    W is the GtkToolbar to be redrawn.
    EVENT is the expose event for W.
@@ -3629,7 +3650,8 @@
      GdkEventExpose *event;
      gpointer client_data;
 {
-  update_frame_tool_bar ((FRAME_PTR) client_data);
+  FRAME_PTR f = (FRAME_PTR) client_data;
+  SET_FRAME_GARBAGED (f);
   return FALSE;
 }
 
@@ -3690,6 +3712,40 @@
   SET_FRAME_GARBAGED (f);
 }
 
+/* Find the right-to-left image named by RTL in the tool bar images for F.
+   Returns IMAGE if RTL is not found.  */
+
+static Lisp_Object
+find_rtl_image (f, image, rtl)
+     FRAME_PTR f;
+     Lisp_Object image;
+     Lisp_Object rtl;
+{
+  int i;
+  Lisp_Object file, rtl_name;
+  struct gcpro gcpro1, gcpro2;
+  GCPRO2 (file, rtl_name);
+
+  rtl_name = Ffile_name_nondirectory (rtl);
+
+  for (i = 0; i < f->n_tool_bar_items; ++i)
+    {
+      Lisp_Object rtl_image = PROP (TOOL_BAR_ITEM_IMAGES);
+      if (!NILP (file = file_for_image (rtl_image))) 
+        {
+          file = call1 (intern ("file-name-sans-extension"),
+                       Ffile_name_nondirectory (file));
+          if (EQ (Fequal (file, rtl_name), Qt))
+            {
+              image = rtl_image;
+              break;
+            }
+        }
+    }
+
+  return image;
+}
+
 /* Update the tool bar for frame F.  Add new buttons and remove old.  */
 
 void
@@ -3700,7 +3756,9 @@
   GtkRequisition old_req, new_req;
   struct x_output *x = f->output_data.x;
   int hmargin = 0, vmargin = 0;
+  GtkToolbar *wtoolbar;
   GtkToolItem *ti;
+  GtkTextDirection dir;
 
   if (! FRAME_GTK_WIDGET (f))
     return;
@@ -3734,20 +3792,27 @@
   if (! x->toolbar_widget)
     xg_create_tool_bar (f);
 
-  gtk_widget_size_request (x->toolbar_widget, &old_req);
+  wtoolbar = GTK_TOOLBAR (x->toolbar_widget);
+  gtk_widget_size_request (GTK_WIDGET (wtoolbar), &old_req);
+  dir = gtk_widget_get_direction (x->toolbar_widget);
 
   for (i = 0; i < f->n_tool_bar_items; ++i)
     {
-#define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX))
 
       int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P));
       int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P));
       int idx;
       int img_id;
-      struct image *img;
+      int icon_size = 0;
+      struct image *img = NULL;
       Lisp_Object image;
+      Lisp_Object stock;
+      GtkStockItem stock_item;
+      char *stock_name = NULL;
+      Lisp_Object rtl;
       GtkWidget *wbutton;
       GtkWidget *weventbox;
+      Lisp_Object func = intern ("x-gtk-map-stock");
 
       ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (x->toolbar_widget), i);
 
@@ -3757,59 +3822,98 @@
           wbutton = gtk_bin_get_child (GTK_BIN (weventbox));
         }
 
-      /* If image is a vector, choose the image according to the
-	 button state.  */
       image = PROP (TOOL_BAR_ITEM_IMAGES);
-      if (VECTORP (image))
-	{
-	  if (enabled_p)
-	    idx = (selected_p
-		   ? TOOL_BAR_IMAGE_ENABLED_SELECTED
-		   : TOOL_BAR_IMAGE_ENABLED_DESELECTED);
-	  else
-	    idx = (selected_p
-		   ? TOOL_BAR_IMAGE_DISABLED_SELECTED
-		   : TOOL_BAR_IMAGE_DISABLED_DESELECTED);
-
-	  xassert (ASIZE (image) >= idx);
-	  image = AREF (image, idx);
-	}
-      else
-	idx = -1;
 
       /* Ignore invalid image specifications.  */
       if (!valid_image_p (image))
         {
-          if (ti) gtk_widget_hide_all (GTK_WIDGET (ti));
+          if (wbutton) gtk_widget_hide (wbutton);
           continue;
         }
 
-      img_id = lookup_image (f, image);
-      img = IMAGE_FROM_ID (f, img_id);
-      prepare_image_for_display (f, img);
-
-      if (img->load_failed_p || img->pixmap == None)
+      if (EQ (Qt, Ffboundp (func))) 
+        stock = call1 (func, file_for_image (image));
+
+      if (! NILP (stock) && STRINGP (stock)
+          && gtk_stock_lookup (SSDATA (stock), &stock_item))
+        {
+          stock_name = SSDATA (stock);
+          icon_size = gtk_toolbar_get_icon_size (wtoolbar);
+        }
+      else
         {
-          if (ti)
-	    gtk_widget_hide_all (GTK_WIDGET (ti));
-	  else
+          /* No stock image, or stock item not known.  Try regular image.  */
+
+          /* If image is a vector, choose the image according to the
+             button state.  */
+          if (dir == GTK_TEXT_DIR_RTL
+              && !NILP (rtl = PROP (TOOL_BAR_ITEM_RTL_IMAGE))
+              && STRINGP (rtl))
+            {
+              image = find_rtl_image (f, image, rtl);
+            }
+
+          if (VECTORP (image))
             {
-              /* Insert an empty (non-image) button */
-              weventbox = gtk_event_box_new ();
-              wbutton = gtk_button_new ();
-              gtk_button_set_focus_on_click (GTK_BUTTON (wbutton), FALSE);
-              gtk_button_set_relief (GTK_BUTTON (wbutton), GTK_RELIEF_NONE);
-              gtk_container_add (GTK_CONTAINER (weventbox), wbutton);
-              ti = gtk_tool_item_new ();
-              gtk_container_add (GTK_CONTAINER (ti), weventbox);
-              gtk_toolbar_insert (GTK_TOOLBAR (x->toolbar_widget), ti, -1);
+              if (enabled_p)
+                idx = (selected_p
+                       ? TOOL_BAR_IMAGE_ENABLED_SELECTED
+                       : TOOL_BAR_IMAGE_ENABLED_DESELECTED);
+              else
+                idx = (selected_p
+                       ? TOOL_BAR_IMAGE_DISABLED_SELECTED
+                       : TOOL_BAR_IMAGE_DISABLED_DESELECTED);
+
+              xassert (ASIZE (image) >= idx);
+              image = AREF (image, idx);
             }
-          continue;
+          else
+            idx = -1;
+
+          img_id = lookup_image (f, image);
+          img = IMAGE_FROM_ID (f, img_id);
+          prepare_image_for_display (f, img);
+      
+          if (img->load_failed_p || img->pixmap == None)
+            {
+                if (ti)
+                    gtk_widget_hide_all (GTK_WIDGET (ti));
+                else
+                {
+                    /* Insert an empty (non-image) button */
+                    weventbox = gtk_event_box_new ();
+                    wbutton = gtk_button_new ();
+                    gtk_button_set_focus_on_click (GTK_BUTTON (wbutton), FALSE);
+                    gtk_button_set_relief (GTK_BUTTON (wbutton),
+                                           GTK_RELIEF_NONE);
+                    gtk_container_add (GTK_CONTAINER (weventbox), wbutton);
+                    ti = gtk_tool_item_new ();
+                    gtk_container_add (GTK_CONTAINER (ti), weventbox);
+                    gtk_toolbar_insert (GTK_TOOLBAR (x->toolbar_widget), ti, -1);
+                }
+                continue;
+            }
         }
 
       if (ti == NULL)
         {
-          GtkWidget *w = xg_get_image_for_pixmap (f, img, x->widget, NULL);
+          GtkWidget *w;
+          if (stock_name)
+            {
+              w = gtk_image_new_from_stock (stock_name, icon_size);
+              g_object_set_data_full (G_OBJECT (w), XG_TOOL_BAR_STOCK_NAME,
+                                      (gpointer) xstrdup (stock_name),
+                                      (GDestroyNotify) xfree);
+            }
+          else
+            {
+              w = xg_get_image_for_pixmap (f, img, x->widget, NULL);
+              /* Save the image so we can see if an update is needed when
+                 this function is called again.  */
+              g_object_set_data (G_OBJECT (w), XG_TOOL_BAR_IMAGE_DATA,
+                                 (gpointer)img->pixmap);
+            }
+
           gtk_misc_set_padding (GTK_MISC (w), hmargin, vmargin);
           wbutton = gtk_button_new ();
           gtk_button_set_focus_on_click (GTK_BUTTON (wbutton), FALSE);
@@ -3833,10 +3937,6 @@
 
           gtk_widget_show_all (GTK_WIDGET (ti));
 
-          /* Save the image so we can see if an update is needed when
-             this function is called again.  */
-          g_object_set_data (G_OBJECT (w), XG_TOOL_BAR_IMAGE_DATA,
-                             (gpointer)img->pixmap);
 
           g_object_set_data (G_OBJECT (weventbox), XG_FRAME_DATA, (gpointer)f);
 
@@ -3878,14 +3978,31 @@
           GtkWidget *wimage = gtk_bin_get_child (GTK_BIN (wbutton));
           Pixmap old_img = (Pixmap)g_object_get_data (G_OBJECT (wimage),
                                                       XG_TOOL_BAR_IMAGE_DATA);
+          gpointer old_stock_name = g_object_get_data (G_OBJECT (wimage),
+                                                       XG_TOOL_BAR_STOCK_NAME);
+          if (stock_name &&
+              (! old_stock_name || strcmp (old_stock_name, stock_name) != 0))
+            {
+              gtk_image_set_from_stock (GTK_IMAGE (wimage),
+                                        stock_name, icon_size);
+              g_object_set_data_full (G_OBJECT (wimage), XG_TOOL_BAR_STOCK_NAME,
+                                      (gpointer) xstrdup (stock_name),
+                                      (GDestroyNotify) xfree);
+              g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA,
+                                 NULL);
+            }
+          else if (img && old_img != img->pixmap)
+            {
+              (void) xg_get_image_for_pixmap (f, img, x->widget, wimage);
+              g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA,
+                                 (gpointer)img->pixmap);
+
+              g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_STOCK_NAME,
+                                 NULL);
+            }
+
           gtk_misc_set_padding (GTK_MISC (wimage), hmargin, vmargin);
 
-          if (old_img != img->pixmap)
-            (void) xg_get_image_for_pixmap (f, img, x->widget, wimage);
-
-          g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA,
-                             (gpointer)img->pixmap);
-
           gtk_widget_set_sensitive (wbutton, enabled_p);
           gtk_widget_show_all (GTK_WIDGET (ti));
        }
@@ -3901,7 +4018,7 @@
       if (ti) gtk_widget_hide_all (GTK_WIDGET (ti));
     } while (ti != NULL);
 
-  gtk_widget_size_request (x->toolbar_widget, &new_req);
+  gtk_widget_size_request (GTK_WIDGET (wtoolbar), &new_req);
   if (old_req.height != new_req.height
       && ! FRAME_X_OUTPUT (f)->toolbar_detached)
     {
--- a/src/keyboard.c	Wed Aug 29 04:01:43 2007 +0000
+++ b/src/keyboard.c	Wed Aug 29 05:28:10 2007 +0000
@@ -8096,10 +8096,11 @@
 
 static int ntool_bar_items;
 
-/* The symbols `tool-bar', and `:image'.  */
+/* The symbols `tool-bar', `:image' and `:rtl'.  */
 
 extern Lisp_Object Qtool_bar;
 Lisp_Object QCimage;
+Lisp_Object Qrtl;
 
 /* Function prototypes.  */
 
@@ -8385,6 +8386,9 @@
 	/* Value is either a single image specification or a vector
 	   of 4 such specifications for the different button states.  */
 	PROP (TOOL_BAR_ITEM_IMAGES) = value;
+      else if (EQ (key, Qrtl))
+        /* ':rtl STRING' */
+	PROP (TOOL_BAR_ITEM_RTL_IMAGE) = value;
     }
 
   /* If got a filter apply it on binding.  */
@@ -11624,6 +11628,9 @@
   staticpro (&Qhelp_echo);
   Qhelp_echo = intern ("help-echo");
 
+  staticpro (&Qrtl);
+  Qrtl = intern (":rtl");
+
   staticpro (&item_properties);
   item_properties = Qnil;