changeset 88120:3996a7930718

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 865) - Update from CVS Revision: emacs@sv.gnu.org/emacs--multi-tty--0--patch-45
author Miles Bader <miles@gnu.org>
date Thu, 30 Aug 2007 02:03:47 +0000
parents 6fc3e91581c3 (current diff) ed8435ec5652 (diff)
children 74dbf77e41be
files lisp/ChangeLog lisp/simple.el lisp/term/x-win.el src/ChangeLog src/dispextern.h src/gtkutil.c src/keyboard.c
diffstat 17 files changed, 875 insertions(+), 345 deletions(-) [+]
line wrap: on
line diff
--- a/etc/ChangeLog	Wed Aug 29 04:01:43 2007 +0000
+++ b/etc/ChangeLog	Thu Aug 30 02:03:47 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	Thu Aug 30 02:03:47 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.
 
 
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	Thu Aug 30 02:03:47 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/lisp/ChangeLog	Wed Aug 29 04:01:43 2007 +0000
+++ b/lisp/ChangeLog	Thu Aug 30 02:03:47 2007 +0000
@@ -1,3 +1,58 @@
+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/image-mode.el	Wed Aug 29 04:01:43 2007 +0000
+++ b/lisp/image-mode.el	Thu Aug 30 02:03:47 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	Thu Aug 30 02:03:47 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	Thu Aug 30 02:03:47 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	Thu Aug 30 02:03:47 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	Thu Aug 30 02:03:47 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	Thu Aug 30 02:03:47 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	Thu Aug 30 02:03:47 2007 +0000
@@ -1,3 +1,13 @@
+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/display.texi	Wed Aug 29 04:01:43 2007 +0000
+++ b/lispref/display.texi	Thu Aug 30 02:03:47 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/src/ChangeLog	Wed Aug 29 04:01:43 2007 +0000
+++ b/src/ChangeLog	Thu Aug 30 02:03:47 2007 +0000
@@ -1,3 +1,18 @@
+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/dispextern.h	Wed Aug 29 04:01:43 2007 +0000
+++ b/src/dispextern.h	Thu Aug 30 02:03:47 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	Thu Aug 30 02:03:47 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	Thu Aug 30 02:03:47 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;