changeset 83119:6c46628776bc

Merged in changes from CVS trunk. Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-287 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-288 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-289 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-159
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 08 May 2004 20:22:26 +0000
parents 7652900ea029 (current diff) 3f07e8295d4a (diff)
children b2b85b22b20e
files lisp/ChangeLog lisp/simple.el src/macterm.c
diffstat 28 files changed, 1087 insertions(+), 551 deletions(-) [+]
line wrap: on
line diff
--- a/admin/ChangeLog	Sat May 08 16:20:28 2004 +0000
+++ b/admin/ChangeLog	Sat May 08 20:22:26 2004 +0000
@@ -1,3 +1,7 @@
+2004-05-08  Thien-Thi Nguyen  <ttn@gnu.org>
+
+	* notes/BRANCH: New file, to be maintained per CVS branch.
+
 2003-10-01  Miles Bader  <miles@gnu.org>
 
 	* quick-install-emacs: Don't use "function" keyword when defining
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/admin/notes/BRANCH	Sat May 08 20:22:26 2004 +0000
@@ -0,0 +1,18 @@
+This file describes the CVS branch in which it is maintained.
+Everything below the line is branch-specific.
+________________________________________________________________________
+
+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 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.
+
+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/leim/ChangeLog	Sat May 08 16:20:28 2004 +0000
+++ b/leim/ChangeLog	Sat May 08 20:22:26 2004 +0000
@@ -1,3 +1,7 @@
+2004-05-07  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* quail/latin-ltx.el ("TeX"): Fix typo.
+
 2004-05-06  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* quail/latin-ltx.el: Use utf-8 coding.
--- a/leim/quail/latin-ltx.el	Sat May 08 16:20:28 2004 +0000
+++ b/leim/quail/latin-ltx.el	Sat May 08 20:22:26 2004 +0000
@@ -953,12 +953,12 @@
  ;; From Karl Eichwalder.
  ("\\glq"  ?‚)
  ("\\grq"  ?‘)
- ("\\glqq"  ?„) ("\"`"  ?„)
- ("\\grqq"  ?“) ("\"'"  ?“)
+ ("\\glqq"  ?„) ("\\\"`"  ?„)
+ ("\\grqq"  ?“) ("\\\"'"  ?“)
  ("\\flq" ?‹)
  ("\\frq" ?›)
- ("\\flqq" ?«) ("\"<" ?«)
- ("\\frqq" ?») ("\">" ?»)
+ ("\\flqq" ?\«) ("\\\"<" ?\«)
+ ("\\frqq" ?\») ("\\\">" ?\»)
  )
 
 ;; arch-tag: 3daae613-2c53-446e-a0a1-ee2e1ebed15f
--- a/lib-src/ChangeLog	Sat May 08 16:20:28 2004 +0000
+++ b/lib-src/ChangeLog	Sat May 08 20:22:26 2004 +0000
@@ -1,3 +1,11 @@
+2004-05-07  Thien-Thi Nguyen  <ttn@gnu.org>
+
+	* b2m.c (GOOD, BAD): Delete macros.  Throughout,
+	replace w/ `EXIT_SUCCESS' and `EXIT_FAILURE', respectively.
+	(main): Use `EXIT_SUCCESS' or `EXIT_FAILURE' for return value.
+
+	* etags.c: Likewise.
+
 2004-05-03  Jason Rumney  <jasonr@gnu.org>
 
 	* makefile.nt: Remove.
--- a/lib-src/b2m.c	Sat May 08 16:20:28 2004 +0000
+++ b/lib-src/b2m.c	Sat May 08 20:22:26 2004 +0000
@@ -39,15 +39,6 @@
 #undef FALSE
 #define FALSE	0
 
-/* Exit codes for success and failure.  */
-#ifdef VMS
-#define	GOOD	1
-#define BAD	0
-#else
-#define	GOOD	0
-#define	BAD	1
-#endif
-
 #define streq(s,t)	(strcmp (s, t) == 0)
 #define strneq(s,t,n)	(strncmp (s, t, n) == 0)
 
@@ -124,18 +115,18 @@
 	case 'V':
 	  printf ("%s (GNU Emacs %s)\n", "b2m", VERSION);
 	  puts ("b2m is in the public domain.");
-	  exit (GOOD);
+	  exit (EXIT_SUCCESS);
 
 	case 'h':
 	  fprintf (stderr, "Usage: %s <babylmailbox >unixmailbox\n", progname);
-	  exit (GOOD);
+	  exit (EXIT_SUCCESS);
 	}
     }
 
   if (optind != argc)
     {
       fprintf (stderr, "Usage: %s <babylmailbox >unixmailbox\n", progname);
-      exit (GOOD);
+      exit (EXIT_SUCCESS);
     }
 
   labels_saved = printing = header = FALSE;
@@ -191,7 +182,7 @@
 	puts (data.buffer);
     }
 
-  return 0;
+  return EXIT_SUCCESS;
 }
 
 
@@ -298,8 +289,10 @@
      char *message;
 {
   fprintf (stderr, "%s: %s\n", progname, message);
-  exit (BAD);
+  exit (EXIT_FAILURE);
 }
 
 /* arch-tag: 5a3ad2af-a802-408f-83cc-e7cf5e98653e
    (do not change this comment) */
+
+/* b2m.c ends here */
--- a/lib-src/etags.c	Sat May 08 16:20:28 2004 +0000
+++ b/lib-src/etags.c	Sat May 08 20:22:26 2004 +0000
@@ -177,15 +177,6 @@
 # define CTAGS FALSE
 #endif
 
-/* Exit codes for success and failure.  */
-#ifdef VMS
-# define	GOOD	1
-# define	BAD	0
-#else
-# define	GOOD	0
-# define	BAD	1
-#endif
-
 #define streq(s,t)	(assert((s)!=NULL || (t)!=NULL), !strcmp (s, t))
 #define strcaseeq(s,t)	(assert((s)!=NULL && (t)!=NULL), !etags_strcasecmp (s, t))
 #define strneq(s,t,n)	(assert((s)!=NULL || (t)!=NULL), !strncmp (s, t, n))
@@ -830,7 +821,7 @@
   puts ("Copyright (C) 2002 Free Software Foundation, Inc. and Ken Arnold");
   puts ("This program is distributed under the same terms as Emacs");
 
-  exit (GOOD);
+  exit (EXIT_SUCCESS);
 }
 
 static void
@@ -849,7 +840,7 @@
       }
 
   if (help_for_lang)
-    exit (GOOD);
+    exit (EXIT_SUCCESS);
 
   printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\
 \n\
@@ -990,7 +981,7 @@
   puts ("");
   puts ("Report bugs to bug-gnu-emacs@gnu.org");
 
-  exit (GOOD);
+  exit (EXIT_SUCCESS);
 }
 
 
@@ -1413,7 +1404,7 @@
 
       if (fclose (tagf) == EOF)
 	pfatal (tagfile);
-      exit (GOOD);
+      exit (EXIT_SUCCESS);
     }
 
   if (update)
@@ -1432,7 +1423,7 @@
 	  sprintf (cmd,
 		   "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS",
 		   tagfile, argbuffer[i].what, tagfile);
-	  if (system (cmd) != GOOD)
+	  if (system (cmd) != EXIT_SUCCESS)
 	    fatal ("failed to execute shell command", (char *)NULL);
 	}
       append_to_tagfile = TRUE;
@@ -1453,7 +1444,7 @@
       sprintf (cmd, "sort -o %.*s %.*s", BUFSIZ, tagfile, BUFSIZ, tagfile);
       exit (system (cmd));
     }
-  return GOOD;
+  return EXIT_SUCCESS;
 }
 
 
@@ -6470,7 +6461,7 @@
      char *s1, *s2;
 {
   error (s1, s2);
-  exit (BAD);
+  exit (EXIT_FAILURE);
 }
 
 static void
@@ -6478,7 +6469,7 @@
      char *s1;
 {
   perror (s1);
-  exit (BAD);
+  exit (EXIT_FAILURE);
 }
 
 static void
@@ -6492,7 +6483,7 @@
 fprintf (stderr, "\tTry `%s %s' for a complete list of options.\n",
 	 progname, "-h");
 #endif
-  exit (BAD);
+  exit (EXIT_FAILURE);
 }
 
 /* Print error message.  `s1' is printf control string, `s2' is arg for it. */
@@ -6788,3 +6779,5 @@
 
 /* arch-tag: 8a9b748d-390c-4922-99db-2eeefa921051
    (do not change this comment) */
+
+/* etags.c ends here */
--- a/lisp/ChangeLog	Sat May 08 16:20:28 2004 +0000
+++ b/lisp/ChangeLog	Sat May 08 20:22:26 2004 +0000
@@ -1,9 +1,85 @@
-
+2004-05-08  Juanma Barranquero  <lektu@terra.es>
+
+	* help-fns.el (help-do-arg-highlight): Temporarily set ?\- to be a
+	word constituent so FOO-ARG is not recognized as an arg.
+	(help-highlight-arguments): Don't skip lists in mandatory
+	arguments.
+
+	* simple.el (next-error): Fix typo in docstring.
+	(open-line): Make argument names match their use in docstring.
+	(split-line): Fix docstring.
+
+2004-05-07  Kai Grossjohann  <kai@emptydomain.de>
+
+	Version 2.0.40 of Tramp released.
+
+	* net/tramp.el (tramp-completion-mode, tramp-md5-function): Use
+	symbol-function to invoke functions only known on some Emacs
+	flavors.  This avoids byte-compiler warnings.  Reported by Kevin
+	Scaldeferri <kevin@scaldeferri.com>.
+	(tramp-do-copy-or-rename-file-via-buffer): Renamed from
+	tramp-do-copy-or-rename-via-buffer (without `file'), to make it
+	consistent with the other tramp-do-* functions.
+	(tramp-do-copy-or-rename-file): Calls adjusted.
+	(tramp-process-initial-commands): Avoid liveness check on shell --
+	we know that it must be alive since we're opening a connection at
+	this moment.
+	(tramp-last-cmd): New internal variable.
+	(tramp-process-echoes): New tunable.
+	(tramp-send-command): Set tramp-last-cmd.
+	(tramp-wait-for-output): Delete echo, if applicable.
+	(tramp-read-passwd): Construct the key for the password cache in a
+	way that works for multi methods, too.
+	(tramp-bug): Add backup-directory-alist and
+	bkup-backup-directory-info to bug reports, with Tramp
+	counterparts.
+
+2004-05-07  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp*.el: Suppress byte-compiler warnings where possible.
+
+	* net/tramp.el (tramp-out-of-band-prompt-regexp)
+	(tramp-actions-copy-out-of-band): New defcustoms.
+	(tramp-do-copy-or-rename-file-out-of-band): Asynchronous process
+	used instead of a synchronous one.  Allows password entering.
+	(tramp-action-out-of-band): New defun.
+	(tramp-open-connection-rsh, tramp-method-out-of-band-p): Remove
+	restriction with password from doc string.
+	(tramp-bug): Add variables `tramp-terminal-prompt-regexp',
+	`tramp-out-of-band-prompt-regexp',
+	`tramp-actions-copy-out-of-band', `password-cache' and
+	`password-cache-expiry'.
+	(toplevel): Remove todo item wrt ssh-agent.  Obsolete due to
+	password caching.
+	(tramp-touch): FILE can be a local file, too.
+	(TODO): Remove items done.
+	(tramp-handle-insert-directory): Properly quote file name also if
+	not full-directory-p.  Handle wildcard case.  Reported by Andreas
+	Schwab <schwab@suse.de>.
+	(tramp-do-copy-or-rename-file-via-buffer): Set permissions of the
+	new file.
+	(tramp-handle-file-local-copy, tramp-handle-write-region): The
+	permissions of the temporary file are set if filename exists.
+	Reported by Ted Stern <stern@cray.com>.
+	(tramp-backup-directory-alist)
+	(tramp-bkup-backup-directory-info): New defcustoms.
+	(tramp-file-name-handler-alist): Add entry for
+	`find-backup-file-name'.
+	(tramp-handle-find-backup-file-name): New function.  Implements
+	Tramp's find-backup-file-name.
+
+	* net/tramp-smb.el (tramp-smb-file-name-handler-alist): Add entry
+	for `find-backup-file-name'.
+
+	* net/tramp-vc.el (tramp-vc-workfile-unchanged-p): Correct typo
+	("file" -> "filename").  Reported by Kim F. Storm <storm@cua.dk>.
+
+2004-05-07  Lars Hansen  <larsh@math.ku.dk>
+
+	* desktop.el (desktop-buffer-mode-handlers): Fix docstring.
+
 2004-05-07  Juanma Barranquero  <lektu@terra.es>
 
-	* emacs-lisp/byte-run.el (make-obsolete, make-obsolete-variable):
-	Make argument names match their use in docstring.
-
 	* subr.el (lambda): Add arglist description to docstring.
 	(declare): Fix typo in docstring.
 	(open-network-stream): Fix docstring.
@@ -14,6 +90,9 @@
 	(insert-buffer-substring-as-yank): Likewise.
 	(split-string): Fix docstring.
 
+	* emacs-lisp/byte-run.el (make-obsolete, make-obsolete-variable):
+	Make argument names match their use in docstring.
+
 	* emacs-lisp/re-builder.el (reb-auto-update): Fix typo in docstring.
 
 2004-05-06  Nick Roberts  <nickrob@gnu.org>
--- a/lisp/desktop.el	Sat May 08 16:20:28 2004 +0000
+++ b/lisp/desktop.el	Sat May 08 20:22:26 2004 +0000
@@ -289,16 +289,14 @@
   (Info-mode . Info-restore-desktop-buffer))
   "Alist of major mode specific functions to restore a desktop buffer.
 Functions are called by `desktop-read'. List elements must have the form
-\(MAJOR-MODE . FUNCTION).
+\(MAJOR-MODE . RESTORE-BUFFER-FUNCTION).
 
 Buffers with a major mode not specified here, are restored by the default
 handler `desktop-restore-file-buffer'.
 
-Handlers are called with parameters
+Handlers are called with argument list
 
-   desktop-buffer-file-name
-   desktop-buffer-name
-   desktop-buffer-misc
+   (DESKTOP-BUFFER-FILE-NAME DESKTOP-BUFFER-NAME DESKTOP-BUFFER-MISC)
 
 Furthermore, they may use the following variables:
 
--- a/lisp/gnus/ChangeLog	Sat May 08 16:20:28 2004 +0000
+++ b/lisp/gnus/ChangeLog	Sat May 08 20:22:26 2004 +0000
@@ -1,3 +1,8 @@
+2004-05-07  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* rfc2047.el (rfc2047-encode-message-header): Don't encode non-address
+	headers as address headers (which breaks if subject has a single ").
+
 2004-05-06  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* nnimap.el (nnimap-demule): Avoid string-as-multibyte.
--- a/lisp/gnus/rfc2047.el	Sat May 08 16:20:28 2004 +0000
+++ b/lisp/gnus/rfc2047.el	Sat May 08 20:22:26 2004 +0000
@@ -1,5 +1,5 @@
 ;;; rfc2047.el --- functions for encoding and decoding rfc2047 messages
-;; Copyright (C) 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 1998,1999,2000,02,03,2004  Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;;	MORIOKA Tomohiko <morioka@jaist.ac.jp>
@@ -169,7 +169,7 @@
 	     ((eq method 'address-mime)
 	      (rfc2047-encode-region (point) (point-max)))
 	     ((eq method 'mime)
-	      (let (rfc2047-encoding-type)
+	      (let ((rfc2047-encoding-type method))
 		(rfc2047-encode-region (point) (point-max))))
 	     ((eq method 'default)
 	      (if (and (featurep 'mule)
--- a/lisp/help-fns.el	Sat May 08 16:20:28 2004 +0000
+++ b/lisp/help-fns.el	Sat May 08 20:22:26 2004 +0000
@@ -241,28 +241,32 @@
   "Face to highlight function arguments in docstrings.")
 
 (defun help-do-arg-highlight (doc args)
-  (while args
-    (let ((arg (prog1 (car args) (setq args (cdr args)))))
-      (setq doc (replace-regexp-in-string
-                 (concat "\\<\\(" arg "\\)\\(?:es\\|s\\|th\\)?\\>")
-                 (propertize arg 'face 'help-argument-name)
-                 doc t t 1))))
-  doc)
+  (with-syntax-table (make-syntax-table emacs-lisp-mode-syntax-table)
+    (modify-syntax-entry ?\- "w")
+    (while args
+      (let ((arg (prog1 (car args) (setq args (cdr args)))))
+        (setq doc (replace-regexp-in-string
+                   (concat "\\<\\(" arg "\\)\\(?:es\\|s\\|th\\)?\\>")
+                   (propertize arg 'face 'help-argument-name)
+                   doc t t 1))))
+    doc))
 
 (defun help-highlight-arguments (usage doc &rest args)
   (when usage
     (let ((case-fold-search nil)
-          (next (not args)))
+          (next (not args))
+          (opt nil))
       ;; Make a list of all arguments
       (with-temp-buffer
         (insert usage)
         (goto-char (point-min))
         ;; Make a list of all arguments
         (while next
+          (or opt (not (looking-at " &")) (setq opt t))
           (if (not (re-search-forward " \\([\\[(]?\\)\\([^] &)\.]+\\)" nil t))
               (setq next nil)
             (setq args (cons (match-string 2) args))
-            (when (string= (match-string 1) "(")
+            (when (and opt (string= (match-string 1) "("))
               ;; A pesky CL-style optional argument with default value,
               ;; so let's skip over it
               (search-backward "(")
--- a/lisp/net/tramp-smb.el	Sat May 08 16:20:28 2004 +0000
+++ b/lisp/net/tramp-smb.el	Sat May 08 20:22:26 2004 +0000
@@ -38,6 +38,19 @@
   (or (>= emacs-major-version 20)
       (load "cl-seq")))
 
+;; Avoid byte-compiler warnings if the byte-compiler supports this.
+;; Currently, XEmacs supports this.
+(eval-when-compile
+  (when (fboundp 'byte-compiler-options)
+    (let (unused-vars) ; Pacify Emacs byte-compiler
+      (defalias 'warnings 'identity) ; Pacify Emacs byte-compiler
+      (byte-compiler-options (warnings (- unused-vars))))))
+
+;; XEmacs byte-compiler raises warning abouts `last-coding-system-used'.
+(eval-when-compile
+  (unless (boundp 'last-coding-system-used)
+    (defvar last-coding-system-used nil)))
+
 ;; Define SMB method ...
 (defcustom tramp-smb-method "smb"
   "*Method to connect SAMBA and M$ SMB servers."
@@ -145,7 +158,7 @@
     (file-symlink-p . tramp-smb-not-handled)
     ;; `file-truename' performed by default handler
     (file-writable-p . tramp-smb-handle-file-writable-p)
-    ;; `find-backup-file-name' performed by default handler
+    (find-backup-file-name . tramp-handle-find-backup-file-name)
     ;; `find-file-noselect' performed by default handler
     ;; `get-file-buffer' performed by default handler
     (insert-directory . tramp-smb-handle-insert-directory)
--- a/lisp/net/tramp-vc.el	Sat May 08 16:20:28 2004 +0000
+++ b/lisp/net/tramp-vc.el	Sat May 08 20:22:26 2004 +0000
@@ -1,6 +1,6 @@
 ;;; tramp-vc.el --- Version control integration for TRAMP.el
 
-;; Copyright (C) 2000 by Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2001, 2002, 2003, 2004 by Free Software Foundation, Inc.
 
 ;; Author: Daniel Pittman <daniel@danann.net>
 ;; Keywords: comm, processes
@@ -38,6 +38,14 @@
   (require 'vc-rcs))
 (require 'tramp)
 
+;; Avoid byte-compiler warnings if the byte-compiler supports this.
+;; Currently, XEmacs supports this.
+(eval-when-compile
+  (when (fboundp 'byte-compiler-options)
+    (let (unused-vars) ; Pacify Emacs byte-compiler
+      (defalias 'warnings 'identity) ; Pacify Emacs byte-compiler
+      (byte-compiler-options (warnings (- unused-vars))))))
+
 ;; -- vc --
 
 ;; This used to blow away the file-name-handler-alist and reinstall
@@ -163,7 +171,9 @@
   (if vc-command-messages
       (message "Running %s on %s..." command file))
   (save-current-buffer
-    (unless (eq buffer t) (vc-setup-buffer buffer))
+    (unless (eq buffer t)
+      ; Pacify byte-compiler
+      (funcall (symbol-function 'vc-setup-buffer) buffer))
     (let ((squeezed nil)
 	  (inhibit-read-only t)
 	  (status 0))
@@ -192,9 +202,10 @@
                  (if (integerp status) (format "status %d" status) status))))
       (if vc-command-messages
           (message "Running %s...OK" command))
-      (vc-exec-after
-       `(run-hook-with-args
-         'vc-post-command-functions ',command ',localname ',flags))
+      ; Pacify byte-compiler
+      (funcall (symbol-function 'vc-exec-after)
+	       `(run-hook-with-args
+		 'vc-post-command-functions ',command ',localname ',flags))
       status))))
 
 
@@ -325,7 +336,8 @@
                              (not want-differences-if-changed))))
         (zerop status))
     ;; New VC.  Call `vc-default-workfile-unchanged-p'.
-    (vc-default-workfile-unchanged-p (vc-backend file) filename)))
+      (funcall (symbol-function 'vc-default-workfile-unchanged-p)
+	       (vc-backend filename) filename)))
 
 (defadvice vc-workfile-unchanged-p
   (around tramp-advice-vc-workfile-unchanged-p
@@ -391,14 +403,15 @@
   ;; Pacify byte-compiler; this symbol is bound in the calling
   ;; function.  CCC: Maybe it would be better to move the
   ;; boundness-checking into this function?
-  (let ((file (symbol-value 'file))
-	(remote-uid
-	 ;; With Emacs 21.4, `file-attributes' has got an optional parameter
-	 ;; ID-FORMAT. Handle this case backwards compatible.
-	 (if (and (functionp 'subr-arity)
-		  (= 2 (cdr (subr-arity (symbol-function 'file-attributes)))))
-	     (nth 2 (file-attributes file 'integer))
-	   (nth 2 (file-attributes file)))))
+  (let* ((file (symbol-value 'file))
+	 (remote-uid
+	  ;; With Emacs 21.4, `file-attributes' has got an optional parameter
+	  ;; ID-FORMAT. Handle this case backwards compatible.
+	  (if (and (functionp 'subr-arity)
+		   (= 2 (cdr (funcall (symbol-function 'subr-arity)
+				      (symbol-function 'file-attributes)))))
+	      (nth 2 (file-attributes file 'integer))
+	    (nth 2 (file-attributes file)))))
     (if (and uid (/= uid remote-uid))
 	(error "tramp-handle-vc-user-login-name cannot map a uid to a name")
       (let* ((v (tramp-dissect-file-name (tramp-handle-expand-file-name file)))
--- a/lisp/net/tramp.el	Sat May 08 16:20:28 2004 +0000
+++ b/lisp/net/tramp.el	Sat May 08 20:22:26 2004 +0000
@@ -135,11 +135,25 @@
 (unless (boundp 'custom-print-functions)
   (defvar custom-print-functions nil))	; not autoloaded before Emacs 20.4
 
-;; Avoid bytecompiler warnings if the byte-compiler supports this.
+;; Avoid byte-compiler warnings if the byte-compiler supports this.
 ;; Currently, XEmacs supports this.
 (eval-when-compile
   (when (fboundp 'byte-compiler-options)
-    (byte-compiler-options (warnings (- unused-vars)))))
+    (let (unused-vars) ; Pacify Emacs byte-compiler
+      (defalias 'warnings 'identity) ; Pacify Emacs byte-compiler
+      (byte-compiler-options (warnings (- unused-vars))))))
+
+;; `directory-sep-char' is an obsolete variable in Emacs.  But it is
+;; used in XEmacs, so we set it here and there.  The following is needed
+;; to pacify Emacs byte-compiler.
+(eval-when-compile
+  (when (boundp 'byte-compile-not-obsolete-var)
+    (setq byte-compile-not-obsolete-var 'directory-sep-char)))
+
+;; XEmacs byte-compiler raises warning abouts `last-coding-system-used'.
+(eval-when-compile
+  (unless (boundp 'last-coding-system-used)
+    (defvar last-coding-system-used nil)))
 
 ;;; User Customizable Internal Variables:
 
@@ -157,6 +171,49 @@
   :group 'tramp
   :type 'boolean)
 
+;; Emacs case
+(eval-and-compile
+  (when (boundp 'backup-directory-alist)
+    (defcustom tramp-backup-directory-alist nil
+      "Alist of filename patterns and backup directory names.
+Each element looks like (REGEXP . DIRECTORY), with the same meaning like
+in `backup-directory-alist'.  If a Tramp file is backed up, and DIRECTORY
+is a local file name, the backup directory is prepended with Tramp file
+name prefix \(multi-method, method, user, host\) of file.
+
+\(setq tramp-backup-directory-alist backup-directory-alist\)
+
+gives the same backup policy for Tramp files on their hosts like the
+policy for local files."
+      :group 'tramp
+      :type '(repeat (cons (regexp :tag "Regexp matching filename")
+			   (directory :tag "Backup directory name"))))))
+
+;; XEmacs case.  We cannot check for `bkup-backup-directory-info', because
+;; the package "backup-dir" might not be loaded yet.
+(eval-and-compile
+  (when (featurep 'xemacs)
+    (defcustom tramp-bkup-backup-directory-info nil
+      "*Alist of (FILE-REGEXP BACKUP-DIR OPTIONS ...))
+It has the same meaning like `bkup-backup-directory-info' from package
+`backup-dir'.  If a Tramp file is backed up, and BACKUP-DIR is a local
+file name, the backup directory is prepended with Tramp file name prefix
+\(multi-method, method, user, host\) of file.
+
+\(setq tramp-bkup-backup-directory-info bkup-backup-directory-info\)
+
+gives the same backup policy for Tramp files on their hosts like the
+policy for local files."
+      :type '(repeat 
+	      (list (regexp :tag "File regexp")
+		    (string :tag "Backup Dir")
+		    (set :inline t
+			 (const ok-create)
+			 (const full-path)
+			 (const prepend-name)
+			 (const search-upward))))
+      :group 'tramp)))
+
 (defcustom tramp-auto-save-directory nil
   "*Put auto-save files in this directory, if set.
 The idea is to use a local directory so that auto-saving is faster."
@@ -854,6 +911,15 @@
   :group 'tramp
   :type 'regexp)
 
+(defcustom tramp-out-of-band-prompt-regexp
+  ""
+  "Regular expression indicating an out-of-band copy has finished.
+In fact this expression is empty by intention, it will be used only to
+check regularly the status of the associated process.
+The answer will be provided by `tramp-action-out-of-band', which see."
+  :group 'tramp
+  :type 'regexp)
+
 (defcustom tramp-temp-name-prefix "tramp."
   "*Prefix to use for temporary files.
 If this is a relative file name (such as \"tramp.\"), it is considered
@@ -1237,6 +1303,16 @@
   :group 'tramp
   :type '(repeat (list variable function)))
 
+(defcustom tramp-actions-copy-out-of-band
+  '((tramp-password-prompt-regexp tramp-action-password)
+    (tramp-wrong-passwd-regexp tramp-action-permission-denied)
+    (tramp-out-of-band-prompt-regexp tramp-action-out-of-band))
+  "List of pattern/action pairs.
+This list is used for copying/renaming with out-of-band methods.
+See `tramp-actions-before-shell' for more info."
+  :group 'tramp
+  :type '(repeat (list variable function)))
+
 (defcustom tramp-multi-actions
   '((tramp-password-prompt-regexp tramp-multi-action-password)
     (tramp-login-prompt-regexp tramp-multi-action-login)
@@ -1326,7 +1402,8 @@
 (defvar tramp-md5-function
   (cond ((and (require 'md5) (fboundp 'md5)) 'md5)
 	((fboundp 'md5-encode)
-	 (lambda (x) (base64-encode-string (md5-encode x))))
+	 (lambda (x) (base64-encode-string
+		      (funcall (symbol-function 'md5-encode) x))))
 	(t (error "Coulnd't find an `md5' function")))
   "Function to call for running the MD5 algorithm.")
 
@@ -1464,7 +1541,7 @@
 ;; The device number is returned as "-1", because there will be a virtual
 ;; device number set in `tramp-handle-file-attributes'
 (defconst tramp-perl-file-attributes "\
-($f, $n) = @ARGV;
+\($f, $n) = @ARGV;
 @s = lstat($f);
 if (($s[2] & 0170000) == 0120000) { $l = readlink($f); $l = \"\\\"$l\\\"\"; }
 elsif (($s[2] & 0170000) == 040000) { $l = \"t\"; }
@@ -1628,6 +1705,14 @@
     'undecided-dos)
   "Some Emacsen know the `dos' coding system, others need `undecided-dos'.")
 
+(defvar tramp-last-cmd nil
+  "Internal Tramp variable recording the last command sent.
+This variable is buffer-local in every buffer.")
+(make-variable-buffer-local 'tramp-last-cmd)
+
+(defvar tramp-process-echoes nil
+  "Whether to process echoes from the remote shell.")
+
 (defvar tramp-last-cmd-time nil
   "Internal Tramp variable recording the time when the last cmd was sent.
 This variable is buffer-local in every buffer.")
@@ -1638,7 +1723,8 @@
 (defvar tramp-feature-write-region-fix
   (when (fboundp 'find-operation-coding-system)
     (let ((file-coding-system-alist '(("test" emacs-mule))))
-      (find-operation-coding-system 'write-region 0 0 "" nil "test")))
+      (funcall (symbol-function 'find-operation-coding-system)
+	       'write-region 0 0 "" nil "test")))
     "Internal variable to say if `write-region' chooses the right coding.
 Older versions of Emacs chose the coding system for `write-region' based
 on the FILENAME argument, even if VISIT was a string.")
@@ -1684,6 +1770,7 @@
     (file-local-copy . tramp-handle-file-local-copy)
     (insert-file-contents . tramp-handle-insert-file-contents)
     (write-region . tramp-handle-write-region)
+    (find-backup-file-name . tramp-handle-find-backup-file-name)
     (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory)
     (dired-compress-file . tramp-handle-dired-compress-file)
     (dired-call-process . tramp-handle-dired-call-process)
@@ -1756,8 +1843,8 @@
 Calls `line-end-position' or `point-at-eol' if defined, else
 own implementation."
   (cond
-   ((fboundp 'line-end-position) (funcall 'line-end-position))
-   ((fboundp 'point-at-eol) 	 (funcall 'point-at-eol))
+   ((fboundp 'line-end-position) (funcall (symbol-function 'line-end-position)))
+   ((fboundp 'point-at-eol) 	 (funcall (symbol-function 'point-at-eol)))
    (t (save-excursion (end-of-line) (point)))))
 
 (defmacro with-parsed-tramp-file-name (filename var &rest body)
@@ -1790,6 +1877,8 @@
      ,@body))
 
 (put 'with-parsed-tramp-file-name 'lisp-indent-function 2)
+;; To be activated for debugging containing this macro
+(def-edebug-spec with-parsed-tramp-file-name t)
 
 ;;; Config Manipulation Functions:
 
@@ -2711,7 +2800,7 @@
        ;; matter which filename handlers are used for the
        ;; source and target file.
        (t
-	(tramp-do-copy-or-rename-via-buffer
+	(tramp-do-copy-or-rename-file-via-buffer
 	 op filename newname keep-date))))
 
      ;; One file is a Tramp file, the other one is local.
@@ -2727,14 +2816,14 @@
 	  (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-via-buffer op filename newname keep-date)))
+	(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")))))
 
-;; CCC: implement keep-date if possible -- via touch?
-(defun tramp-do-copy-or-rename-via-buffer (op filename newname keep-date)
+(defun tramp-do-copy-or-rename-file-via-buffer (op filename newname keep-date)
   "Use an Emacs buffer to copy or rename a file.
 First arg OP is either `copy' or `rename' and indicates the operation.
 FILENAME is the source file, NEWNAME the target file.
@@ -2754,10 +2843,11 @@
 	    (jka-compr-inhibit t))
 	(write-region (point-min) (point-max) newname))
       ;; KEEP-DATE handling.
-      (when (and keep-date 
-		 (not (null modtime))
-		 (not (equal modtime '(0 0))))
-	(tramp-touch newname modtime)))
+      (when keep-date
+	(when (and (not (null modtime))
+		   (not (equal modtime '(0 0))))
+	  (tramp-touch newname modtime))
+	(set-file-modes newname (file-modes filename))))
     ;; If the operation was `rename', delete the original file.
     (unless (eq op 'copy)
       (delete-file filename))))
@@ -2791,12 +2881,12 @@
   "Invoke rcp program to copy.
 One of FILENAME and NEWNAME must be a Tramp name, the other must
 be a local filename.  The method used must be an out-of-band method."
-  (let ((trampbuf (get-buffer-create "*tramp output*"))
-	(t1 (tramp-tramp-file-p filename))
+  (let ((t1 (tramp-tramp-file-p filename))
 	(t2 (tramp-tramp-file-p newname))
 	v1-multi-method v1-method v1-user v1-host v1-localname
 	v2-multi-method v2-method v2-user v2-host v2-localname
-	method copy-program copy-args source target)
+	multi-method method user host copy-program copy-args
+	source target trampbuf)
 
     ;; Check which ones of source and target are Tramp files.
     ;; We cannot invoke `with-parsed-tramp-file-name';
@@ -2808,8 +2898,11 @@
 		v1-user l-user
 		v1-host l-host
 		v1-localname l-localname
+		multi-method l-multi-method
 		method (tramp-find-method
 			v1-multi-method v1-method v1-user v1-host)
+		user l-user
+		host l-host
 		copy-program (tramp-get-method-parameter
 			      v1-multi-method method
 			      v1-user v1-host 'tramp-copy-program)
@@ -2825,8 +2918,11 @@
 		v2-user l-user
 		v2-host l-host
 		v2-localname l-localname
+		multi-method l-multi-method
 		method (tramp-find-method
 			v2-multi-method v2-method v2-user v2-host)
+		user l-user
+		host l-host
 		copy-program (tramp-get-method-parameter
 			      v2-multi-method method
 			      v2-user v2-host 'tramp-copy-program)
@@ -2871,24 +2967,29 @@
 		     v2-user v2-host 'tramp-copy-keep-date-arg)
 		    copy-args))))
 
-    (setq copy-args (append copy-args (list source target)))
-
-    ;; Use rcp-like program for file transfer.
-    (tramp-message
-     5 "Transferring %s to file %s..." filename newname)
-    (save-excursion (set-buffer trampbuf) (erase-buffer))
-    (unless (equal
-	     0
-	     (apply #'call-process copy-program
-		    nil trampbuf nil copy-args))
-      (pop-to-buffer trampbuf)
-      (error
-       (concat
-	"tramp-do-copy-or-rename-file-out-of-band: `%s' didn't work, "
-	"see buffer `%s' for details")
-       copy-program trampbuf))
-    (tramp-message
-     5 "Transferring %s to file %s...done" filename newname)
+    (setq copy-args (append copy-args (list source target))
+	  trampbuf (generate-new-buffer
+		    (tramp-buffer-name multi-method method user host)))
+
+    ;; Use an asynchronous process.  By this, password can be handled.
+    (save-excursion
+      (set-buffer trampbuf)
+      (setq tramp-current-multi-method multi-method
+	    tramp-current-method method
+	    tramp-current-user user
+	    tramp-current-host host)
+      (tramp-message
+       5 "Transferring %s to file %s..." filename newname)
+
+      ;; Use rcp-like program for file transfer.
+      (let ((p (apply 'start-process (buffer-name trampbuf) trampbuf
+		      copy-program copy-args)))
+	(process-kill-without-query p)
+	(tramp-process-actions p multi-method method user host
+			       tramp-actions-copy-out-of-band))
+      (kill-buffer trampbuf)
+      (tramp-message
+       5 "Transferring %s to file %s...done" filename newname))
 
     ;; If the operation was `rename', delete the original file.
     (unless (eq op 'copy)
@@ -3012,7 +3113,8 @@
 			     multi-method method user host
 			     (concat (nth 2 suffix) " " localname)))
 		 (message "Uncompressing %s...done" file)
-		 (dired-remove-file file)
+		 ;; `dired-remove-file' is not defined in XEmacs
+		 (funcall (symbol-function 'dired-remove-file) file)
 		 (string-match (car suffix) file)
 		 (concat (substring file 0 (match-beginning 0)))))
 	      (t
@@ -3023,7 +3125,8 @@
 			     multi-method method user host
 			     (concat "gzip -f " localname)))
 		 (message "Compressing %s...done" file)
-		 (dired-remove-file file)
+		 ;; `dired-remove-file' is not defined in XEmacs
+		 (funcall (symbol-function 'dired-remove-file) file)
 		 (cond ((file-exists-p (concat file ".gz"))
 			(concat file ".gz"))
 		       ((file-exists-p (concat file ".z"))
@@ -3091,12 +3194,10 @@
 	 (format "%s %s %s"
 		 (tramp-get-ls-command multi-method method user host)
 		 switches
-		 (if full-directory-p
-		     ;; Add "/." to make sure we got complete dir
-		     ;; listing for symlinks, too.
-		     (concat (file-name-as-directory
-			      (file-name-nondirectory localname)) ".")
-		   (file-name-nondirectory localname)))))
+		 (if wildcard
+		     localname
+		   (tramp-shell-quote-argument
+		    (file-name-nondirectory localname))))))
       (sit-for 1)			;needed for rsh but not ssh?
       (tramp-wait-for-output))
     ;; The following let-binding is used by code that's commented
@@ -3361,7 +3462,6 @@
 	       filename))
       (setq tmpfil (tramp-make-temp-file))
 
-
       (cond ((tramp-method-out-of-band-p multi-method method user host)
 	     ;; `copy-file' handles out-of-band methods
 	     (copy-file filename tmpfil t t))
@@ -3418,7 +3518,9 @@
 		   (delete-file tmpfil2)))
 	       (tramp-message-for-buffer
 		multi-method method user host
-		5 "Decoding remote file %s...done" filename)))
+		5 "Decoding remote file %s...done" filename)
+	       ;; Set proper permissions.
+	       (set-file-modes tmpfil (file-modes filename))))
 
 	    (t (error "Wrong method specification for `%s'" method)))
       tmpfil)))
@@ -3470,6 +3572,49 @@
 	(list (expand-file-name filename)
 	      (second result))))))
 
+
+(defun tramp-handle-find-backup-file-name (filename)
+  "Like `find-backup-file-name' for tramp files."
+
+  (if (or (and (not (featurep 'xemacs))
+	       (not (boundp 'tramp-backup-directory-alist)))
+	  (and (featurep 'xemacs)
+	       (not (boundp 'tramp-bkup-backup-directory-info))))
+
+      ;; No tramp backup directory alist defined, or nil
+      (tramp-run-real-handler 'find-backup-file-name (list filename))
+
+    (with-parsed-tramp-file-name filename nil
+      (let* ((backup-var
+	      (copy-tree
+	       (if (featurep 'xemacs)
+		   ;; XEmacs case
+		   (symbol-value 'tramp-bkup-backup-directory-info)
+		 ;; Emacs case
+		 (symbol-value 'tramp-backup-directory-alist))))
+
+	     ;; We set both variables. It doesn't matter whether it is
+	     ;; Emacs or XEmacs
+	     (backup-directory-alist backup-var)
+	     (bkup-backup-directory-info backup-var))
+
+	(mapcar
+	 '(lambda (x)
+	    (let ((dir (if (consp (cdr x)) (car (cdr x)) (cdr x))))
+	      (when (and (stringp dir)
+			 (file-name-absolute-p dir)
+			 (not (tramp-file-name-p dir)))
+		;; Prepend absolute directory names with tramp prefix
+		(if (consp (cdr x))
+		    (setcar (cdr x)
+			    (tramp-make-tramp-file-name
+			     multi-method method user host dir))
+		  (setcdr x (tramp-make-tramp-file-name
+			     multi-method method user host dir))))))
+	 backup-var)
+
+	(tramp-run-real-handler 'find-backup-file-name (list filename))))))
+
 ;; CCC grok APPEND, LOCKNAME, CONFIRM
 (defun tramp-handle-write-region
   (start end filename &optional append visit lockname confirm)
@@ -3499,6 +3644,7 @@
 	  (loc-enc (tramp-get-local-encoding multi-method method user host))
 	  (loc-dec (tramp-get-local-decoding multi-method method user host))
 	  (trampbuf (get-buffer-create "*tramp output*"))
+	  (modes (file-modes filename))
 	  ;; We use this to save the value of `last-coding-system-used'
 	  ;; after writing the tmp file.  At the end of the function,
 	  ;; we set `last-coding-system-used' to this saved value.
@@ -3519,6 +3665,11 @@
        (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)))
+      ;; 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))
       ;; Now, `last-coding-system-used' has the right value.  Remember it.
       (when (boundp 'last-coding-system-used)
 	(setq coding-system-used last-coding-system-used))
@@ -3885,7 +4036,7 @@
 	(list (tramp-handle-expand-file-name name))))))
 
 ;; Check for complete.el and override PC-expand-many-files if appropriate.
-(eval-when-compile
+(eval-and-compile
   (defun tramp-save-PC-expand-many-files (name))); avoid compiler warning
 
 (defun tramp-setup-complete ()
@@ -3936,11 +4087,14 @@
 	(and (featurep 'xemacs)
 	     (not (event-modifiers last-input-event))
 	     (or (char-equal
-		  (funcall 'event-to-character last-input-event) ?\?)
+		  (funcall (symbol-function 'event-to-character)
+			   last-input-event) ?\?)
 		 (char-equal
-		  (funcall 'event-to-character last-input-event) ?\t)
+		  (funcall (symbol-function 'event-to-character)
+			   last-input-event) ?\t)
 		 (char-equal
-		  (funcall 'event-to-character last-input-event) ?\ ))))
+		  (funcall (symbol-function 'event-to-character)
+			   last-input-event) ?\ ))))
     t)))
 
 (defun tramp-completion-handle-file-exists-p (filename)
@@ -4478,17 +4632,24 @@
   "Set the last-modified timestamp of the given file.
 TIME is an Emacs internal time value as returned by `current-time'."
   (let ((touch-time (format-time-string "%Y%m%d%H%M.%S" time)))
-    (with-parsed-tramp-file-name file nil
-      (let ((buf (tramp-get-buffer multi-method method user host)))
-	(unless (zerop (tramp-send-command-and-check
-			multi-method method user host
-			(format "touch -t %s %s"
-				touch-time
-				localname)))
-	  (pop-to-buffer buf)
-	  (error "tramp-touch: touch failed, see buffer `%s' for details"
-		 buf))))))
-
+    (if (tramp-tramp-file-p file)
+	(with-parsed-tramp-file-name file nil
+	  (let ((buf (tramp-get-buffer multi-method method user host)))
+	    (unless (zerop (tramp-send-command-and-check
+			    multi-method method user host
+			    (format "touch -t %s %s"
+				    touch-time
+				    localname)))
+	      (pop-to-buffer buf)
+	      (error "tramp-touch: touch failed, see buffer `%s' for details"
+		     buf))))
+      ;; It's a local file
+      (with-temp-buffer
+	(unless (zerop (call-process
+			"touch" nil (current-buffer) nil "-t" touch-time file))
+	      (pop-to-buffer (current-buffer))
+	      (error "tramp-touch: touch failed"))))))
+ 
 (defun tramp-buffer-name (multi-method method user host)
   "A name for the connection buffer for USER at HOST using METHOD."
   (if multi-method
@@ -4815,6 +4976,19 @@
   (process-send-string nil (concat tramp-terminal-type
 				   tramp-rsh-end-of-line)))
 
+(defun tramp-action-out-of-band (p multi-method method user host)
+  "Check whether an out-of-band copy has finished."
+  (cond ((and (memq (process-status p) '(stop exit))
+	      (zerop (process-exit-status p)))
+	 (tramp-message 9 "Process has finished.")
+	 (throw 'tramp-action 'ok))
+	((or (and (memq (process-status p) '(stop exit))
+		  (not (zerop (process-exit-status p))))
+	     (memq (process-status p) '(signal)))
+	 (tramp-message 9 "Process has died.")
+	 (throw 'tramp-action 'process-died))
+	(t nil)))
+
 ;; The following functions are specifically for multi connections.
 
 (defun tramp-multi-action-login (p method user host)
@@ -4931,7 +5105,7 @@
       (erase-buffer)
       (tramp-message 10 "Sending command to remote shell: %s"
 		     cmd)
-      (tramp-send-command multi-method method user host cmd)
+      (tramp-send-command multi-method method user host cmd nil t)
       (tramp-barf-if-no-shell-prompt
        p 60 "Remote shell command failed: %s" cmd))
     (erase-buffer)))
@@ -5014,12 +5188,6 @@
 `shell-prompt-pattern' and `tramp-shell-prompt-pattern' which must be
 set up correctly.
 
-Please note that it is NOT possible to use this connection method with
-an out-of-band transfer method if this function asks the user for a
-password!  You must use an inline transfer method in this case.
-Sadly, the transfer method cannot be switched on the fly, instead you
-must specify the right method in the file name.
-
 Kludgy feature: if HOST has the form \"xx#yy\", then yy is assumed to
 be a port number for ssh, and \"-p yy\" will be added to the list of
 arguments, and xx will be used as the host name to connect to.
@@ -5412,6 +5580,10 @@
   (tramp-send-command-internal multi-method method user host
 			       "stty -inlcr -echo kill '^U'")
   (erase-buffer)
+  ;; Ignore garbage after stty command.
+  (tramp-send-command-internal multi-method method user host
+			       "echo foo")
+  (erase-buffer)
   (tramp-send-command-internal multi-method method user host
 			       "TERM=dumb; export TERM")
   ;; Try to set up the coding system correctly.
@@ -5858,6 +6030,7 @@
   (or neveropen
       (tramp-maybe-open-connection multi-method method user host))
   (setq tramp-last-cmd-time (current-time))
+  (setq tramp-last-cmd command)
   (when tramp-debug-buffer
     (save-excursion
       (set-buffer (tramp-get-debug-buffer multi-method method user host))
@@ -5886,6 +6059,7 @@
   (let ((proc (get-buffer-process (current-buffer)))
         (found nil)
         (start-time (current-time))
+	(start-point (point))
         (end-of-output (concat "^"
                                (regexp-quote tramp-end-of-output)
                                "\r?$")))
@@ -5920,6 +6094,12 @@
       (goto-char (point-max))
       (forward-line -2)
       (delete-region (point) (point-max)))
+    ;; If processing echoes, look for it in the first line and delete.
+    (when tramp-process-echoes
+      (save-excursion
+	(goto-char start-point)
+	(when (looking-at (regexp-quote tramp-last-cmd))
+	  (delete-region (point) (forward-line 1)))))
     ;; Add output to debug buffer if appropriate.
     (when tramp-debug-buffer
       (append-to-buffer
@@ -6325,9 +6505,7 @@
     (format "%s:%s" host localname)))
 
 (defun tramp-method-out-of-band-p (multi-method method user host)
-  "Return t if this is an out-of-band method, nil otherwise.
-It is important to check for this condition, since it is not possible
-to enter a password for the `tramp-copy-program'."
+  "Return t if this is an out-of-band method, nil otherwise."
   (tramp-get-method-parameter
    multi-method
    (tramp-find-method multi-method method user host)
@@ -6502,7 +6680,10 @@
   (if (functionp 'password-read)
       (let* ((user (or tramp-current-user (user-login-name)))
 	     (host (or tramp-current-host (system-name)))
-	     (key (concat user "@" host))
+	     (key (if (and (stringp user) (stringp host))
+		      (concat user "@" host)
+		    (concat "[" (mapconcat 'identity user "/") "]@["
+			    (mapconcat 'identity host "/") "]")))
 	     (password (apply #'password-read (list prompt key))))
 	(apply #'password-cache-add (list key password))
 	password)
@@ -6714,6 +6895,8 @@
        tramp-wrong-passwd-regexp
        tramp-yesno-prompt-regexp
        tramp-yn-prompt-regexp
+       tramp-terminal-prompt-regexp
+       tramp-out-of-band-prompt-regexp
        tramp-temp-name-prefix
        tramp-file-name-structure
        tramp-file-name-regexp
@@ -6725,10 +6908,15 @@
        tramp-end-of-output
        tramp-coding-commands
        tramp-actions-before-shell
+       tramp-actions-copy-out-of-band
        tramp-multi-actions
        tramp-terminal-type
        tramp-shell-prompt-pattern
        tramp-chunksize
+       ,(when (boundp 'tramp-backup-directory-alist)
+	  'tramp-backup-directory-alist)
+       ,(when (boundp 'tramp-bkup-backup-directory-info)
+	  'tramp-bkup-backup-directory-info)
 
        ;; Non-tramp variables of interest
        shell-prompt-pattern
@@ -6737,6 +6925,14 @@
        backup-by-copying-when-mismatch
        ,(when (boundp 'backup-by-copying-when-privileged-mismatch)
           'backup-by-copying-when-privileged-mismatch)
+       ,(when (boundp 'password-cache)
+          'password-cache)
+       ,(when (boundp 'password-cache-expiry)
+          'password-cache-expiry)
+       ,(when (boundp 'backup-directory-alist)
+	  'backup-directory-alist)
+       ,(when (boundp 'bkup-backup-directory-info)
+	  'bkup-backup-directory-info)
        file-name-handler-alist)
      nil				; pre-hook
      nil				; post-hook
@@ -6799,7 +6995,6 @@
 ;; * Rewrite `tramp-shell-quote-argument' to abstain from using
 ;;   `shell-quote-argument'.
 ;; * Completion gets confused when you leave out the method name.
-;; * Support `dired-compress-file' filename handler.
 ;; * In Emacs 21, `insert-directory' shows total number of bytes used
 ;;   by the files in that directory.  Add this here.
 ;; * Avoid screen blanking when hitting `g' in dired.  (Eli Tziperman)
@@ -6820,19 +7015,12 @@
 ;;   if it does show files when run locally.
 ;; * Allow correction of passwords, if the remote end allows this.
 ;;   (Mark Hershberger)
-;; * Make sure permissions of tmp file are good.
-;;   (Nelson Minar <nelson@media.mit.edu>)
-;; * Grok passwd prompts with scp?  (David Winter
-;;   <winter@nevis1.nevis.columbia.edu>).  Maybe just do `ssh -l user
-;;   host', then wait a while for the passwd or passphrase prompt.  If
-;;   there is one, remember the passwd/phrase.
 ;; * How to deal with MULE in `insert-file-contents' and `write-region'?
 ;; * Do asynchronous `shell-command's.
 ;; * Grok `append' parameter for `write-region'.
 ;; * Test remote ksh or bash for tilde expansion in `tramp-find-shell'?
 ;; * abbreviate-file-name
 ;; * grok ~ in tramp-remote-path  (Henrik Holm <henrikh@tele.ntnu.no>)
-;; * `C' in dired gives error `not tramp file name'.
 ;; * Also allow to omit user names when doing multi-hop.  Not sure yet
 ;;   what the user names should default to, though.
 ;; * better error checking.  At least whenever we see something
@@ -6848,9 +7036,7 @@
 ;;   (Francesco Potort,Al(B)
 ;; * Should we set PATH ourselves or should we rely on the remote end
 ;;   to do it?
-;; * Do the autoconf thing.
 ;; * Make it work for XEmacs 20, which is missing `with-timeout'.
-;; * Allow non-Unix remote systems.  (More a long-term thing.)
 ;; * Make it work for different encodings, and for different file name
 ;;   encodings, too.  (Daniel Pittman)
 ;; * Change applicable functions to pass a struct tramp-file-name rather
@@ -6865,13 +7051,6 @@
 ;; * When editing a remote CVS controlled file as a different user, VC
 ;;   gets confused about the file locking status.  Try to find out why
 ;;   the workaround doesn't work.
-;; * When user is running ssh-agent, it would be useful to add the
-;;   passwords typed by the user to that agent.  This way, the next time
-;;   round, the users don't have to type all this in again.
-;;   This would be especially useful for start-process, I think.
-;;   An easy way to implement start-process is to open a second shell
-;;   connection which is inconvenient if the user has to reenter
-;;   passwords.
 ;; * Change `copy-file' to grok the case where the filename handler
 ;;   for the source and the target file are different.  Right now,
 ;;   it looks at the source file and then calls that handler, if
@@ -6895,17 +7074,10 @@
 
 ;; Functions for file-name-handler-alist:
 ;; diff-latest-backup-file -- in diff.el
-;; dired-compress-file
 ;; dired-uncache -- this will be needed when we do insert-directory caching
 ;; file-name-as-directory -- use primitive?
-;; file-name-directory -- use primitive?
-;; file-name-nondirectory -- use primitive?
 ;; file-name-sans-versions -- use primitive?
-;; file-newer-than-file-p
-;; find-backup-file-name
 ;; get-file-buffer -- use primitive
-;; load
-;; unhandled-file-name-directory
 ;; vc-registered
 
 ;;; arch-tag: 3a21a994-182b-48fa-b0cd-c1d9fede424a
--- a/lisp/simple.el	Sat May 08 16:20:28 2004 +0000
+++ b/lisp/simple.el	Sat May 08 20:22:26 2004 +0000
@@ -133,7 +133,7 @@
 Just \\[universal-argument] as a prefix means reparse the error message buffer
 and start at the first error.
 
-The RESET argument specifies that we should restart from the beginning
+The RESET argument specifies that we should restart from the beginning.
 
 \\[next-error] normally uses the most recently started
 compilation, grep, or occur buffer.  It can also operate on any
@@ -294,7 +294,7 @@
 	(put-text-property from (point) 'rear-nonsticky
 			   (cons 'hard sticky)))))
 
-(defun open-line (arg)
+(defun open-line (n)
   "Insert a newline and leave point before it.
 If there is a fill prefix and/or a left-margin, insert them on the new line
 if the line would have been blank.
@@ -305,23 +305,23 @@
 	 (loc (point))
 	 ;; Don't expand an abbrev before point.
 	 (abbrev-mode nil))
-    (newline arg)
+    (newline n)
     (goto-char loc)
-    (while (> arg 0)
+    (while (> n 0)
       (cond ((bolp)
 	     (if do-left-margin (indent-to (current-left-margin)))
 	     (if do-fill-prefix (insert-and-inherit fill-prefix))))
       (forward-line 1)
-      (setq arg (1- arg)))
+      (setq n (1- n)))
     (goto-char loc)
     (end-of-line)))
 
 (defun split-line (&optional arg)
   "Split current line, moving portion beyond point vertically down.
 If the current line starts with `fill-prefix', insert it on the new
-line as well.  With prefix arg, don't insert fill-prefix on new line.
-
-When called from Lisp code, the arg may be a prefix string to copy."
+line as well.  With prefix ARG, don't insert fill-prefix on new line.
+
+When called from Lisp code, ARG may be a prefix string to copy."
   (interactive "*P")
   (skip-chars-forward " \t")
   (let* ((col (current-column))
--- a/lispref/ChangeLog	Sat May 08 16:20:28 2004 +0000
+++ b/lispref/ChangeLog	Sat May 08 20:22:26 2004 +0000
@@ -1,3 +1,13 @@
+2004-05-07  Lars Hansen  <larsh@math.ku.dk>
+
+	* modes.texi (Desktop Save Mode): Add.
+	(Modes): Add menu entry Desktop Save Mode.
+
+	* hooks.texi: Add desktop-after-read-hook,
+	desktop-no-desktop-file-hook and desktop-save-hook.
+
+	* locals.texi: Add desktop-save-buffer.
+
 2004-04-30  Jesper Harder  <harder@ifa.au.dk>
 
 	* display.texi: emacs -> Emacs.
--- a/lispref/hooks.texi	Sat May 08 16:20:28 2004 +0000
+++ b/lispref/hooks.texi	Sat May 08 20:22:26 2004 +0000
@@ -58,6 +58,9 @@
 @item comment-indent-function
 @item custom-define-hook
 @item deactivate-mark-hook
+@item desktop-after-read-hook
+@item desktop-no-desktop-file-hook
+@item desktop-save-hook
 @item diary-display-hook
 @item diary-hook
 @item dired-mode-hook
--- a/lispref/locals.texi	Sat May 08 16:20:28 2004 +0000
+++ b/lispref/locals.texi	Sat May 08 20:22:26 2004 +0000
@@ -84,6 +84,9 @@
 @item defun-prompt-regexp
 @xref{List Motion}.
 
+@item desktop-save-buffer
+@xref{Desktop Save Mode}.
+
 @item enable-multibyte-characters
 @ref{Non-ASCII Characters}.
 
--- a/lispref/modes.texi	Sat May 08 16:20:28 2004 +0000
+++ b/lispref/modes.texi	Sat May 08 20:22:26 2004 +0000
@@ -26,6 +26,8 @@
 * Imenu::              How a mode can provide a menu
                          of definitions in the buffer.
 * Font Lock Mode::     How modes can highlight text according to syntax.
+* Desktop Save Mode::  How modes can have buffer state saved between
+                         Emacs sessions.
 * Hooks::              How to use hooks; how to write code that provides hooks.
 @end menu
 
@@ -2426,6 +2428,59 @@
 
 @end defvar
 
+@node Desktop Save Mode
+@section Desktop Save Mode
+@cindex desktop save mode
+
+@dfn{Desktop Save Mode} is a feature to save the state of Emacs from
+one session to another.  The user-level commands for using Desktop
+Save Mode are described in the GNU Emacs Manual (@pxref{Saving Emacs
+Sessions,,, emacs, the GNU Emacs Manual}).  Modes whose buffers visit
+a file, don't have to do anything to use this feature.
+
+For buffers not visiting a file to have their state saved, the major
+mode must bind the buffer local variable @code{desktop-save-buffer} to
+a non-nil value.
+
+@defvar desktop-save-buffer
+If this buffer-local variable is non-@code{nil}, the buffer will have
+its state saved in the desktop file at desktop save.  If the value is
+a function, it is called at desktop save with argument
+@var{desktop-dirname}, and its value is saved in the desktop file along
+with the state of the buffer for which it was called.  When file names
+are returned as part of the auxiliary information, they should be
+formatted using the call
+
+@example
+(desktop-file-name @var{file-name} @var{desktop-dirname})
+@end example
+
+@end defvar
+
+For buffers not visiting a file to be restored, the major mode must
+define a function to do the job, and that function must be listed in
+the alist @code{desktop-buffer-mode-handlers}.
+
+@defvar desktop-buffer-mode-handlers
+Alist with elements
+
+@example
+(@var{major-mode} . @var{restore-buffer-function})
+@end example
+
+The function @var{restore-buffer-function} will be called with
+argument list
+
+@example
+(@var{buffer-file-name} @var{buffer-name} @var{desktop-buffer-misc})
+@end example
+
+and it should return the restored buffer.
+Here @var{desktop-buffer-misc} is the value returned by the function
+optionally bound to @code{desktop-save-buffer}.
+
+@end defvar
+
 @node Hooks
 @section Hooks
 @cindex hooks
--- a/man/ChangeLog	Sat May 08 16:20:28 2004 +0000
+++ b/man/ChangeLog	Sat May 08 20:22:26 2004 +0000
@@ -1,3 +1,29 @@
+2004-05-07  Kai Grossjohann  <kai@emptydomain.de>
+
+	Version 2.0.40 of Tramp released.
+
+2004-04-25  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	Complete rework, based on review by Karl Berry <karl@gnu.org>.
+
+	* tramp.texi (Auto-save and Backup): Explain exploitation of new
+	variables `tramp-backup-directory-alist' and
+	`tramp-bkup-backup-directory-info'. (Overview, Connection types)
+	(External transfer methods, Default Method)
+	(Windows setup hints): Remove restriction of password entering
+	with external methods.
+	(Auto-save and Backup): Make file name example
+	(X)Emacs neutral. In case of XEmacs, `bkup-backup-directory-info'
+	and `auto-save-directory' must be used.
+	(Frequently Asked Questions): Use "MS Windows NT/2000/XP" (not
+	only "NT").  Remove doubled entry "What kinds of systems does
+	@tramp{} work on".
+	(tramp): Macro removed.
+	(Obtaining Tramp): Flag removed from title.
+	(all): "tramp-" and "-" removed from flag names.  Flags `tramp'
+	and `trampver' used properly.  Flag `tramp-inst' replaced by
+	`installchapter'.  Installation related text adapted.
+
 2004-05-04  Jason Rumney  <jasonr@gnu.org>
 
 	* makefile.w32-in: Revert last change
--- a/man/tramp.texi	Sat May 08 16:20:28 2004 +0000
+++ b/man/tramp.texi	Sat May 08 20:22:26 2004 +0000
@@ -17,16 +17,11 @@
 
 @include trampver.texi
 
-@c Macro to make formatting of the tramp program name consistent.
-@macro tramp
-@sc{tramp}
-@end macro
-
 @c Macros for formatting a filename.
 @c trampfn is for a full filename, trampfnmhp means method, host, localname
 @c were given, and so on.
 @macro trampfn(method, user, host, localname)
-@value{tramp-prefix}@value{method}@value{user}@@@value{host}@value{tramp-postfix}@value{localname}
+@value{prefix}@value{method}@value{user}@@@value{host}@value{postfix}@value{localname}
 @end macro
 
 @copying
@@ -54,16 +49,16 @@
 @end copying
 
 @c Entries for @command{install-info} to use
-@dircategory @value{emacs-name}
+@dircategory @value{emacsname}
 @direntry
 * TRAMP: (tramp).                Transparent Remote Access, Multiple Protocol
-                                 @value{emacs-name} remote file access via rsh and rcp.
+                                 @value{emacsname} remote file access via rsh and rcp.
 @end direntry
 
 @tex
 
 @titlepage
-@title @tramp{} version @trampver{} User Manual
+@title @value{tramp} version @value{trampver} User Manual
 
 @author by Daniel Pittman
 @author based on documentation by Kai Gro@ss{}johann
@@ -78,17 +73,17 @@
 
 @ifnottex
 @node Top, Overview, (dir), (dir)
-@top @tramp{} version @trampver{} User Manual
-
-This file documents @tramp{} version @trampver{}, a remote file
-editing package for @value{emacs-name}.
-
-@tramp{} stands for `Transparent Remote (file) Access, Multiple
+@top @value{tramp} version @value{trampver} User Manual
+
+This file documents @value{tramp} version @value{trampver}, a remote file
+editing package for @value{emacsname}.
+
+@value{tramp} stands for `Transparent Remote (file) Access, Multiple
 Protocol'.  This package provides remote file editing, similar to
-@value{ftp-package-name}.
-
-The difference is that @value{ftp-package-name} uses FTP to transfer
-files between the local and the remote host, whereas @tramp{} uses a
+@value{ftppackagename}.
+
+The difference is that @value{ftppackagename} uses FTP to transfer
+files between the local and the remote host, whereas @value{tramp} uses a
 combination of @command{rsh} and @command{rcp} or other work-alike
 programs, such as @command{ssh}/@command{scp}.
 
@@ -96,27 +91,35 @@
 @uref{http://www.freesoftware.fsf.org/tramp/}.
 
 @c Pointer to the other Emacs flavor is necessary only in case of
-@c standalone installation.  Text taken from trampinst.texi.
-@ifset tramp-inst
-@otherflavor{}
+@c standalone installation.
+@ifset installchapter
+The manual has been generated for @value{emacsname}.
+@ifinfo
+If you want to read the info pages for @value{emacsothername}, you
+should read in @ref{Installation} how to create them.
+@end ifinfo
+@ifhtml
+If you're using the other Emacs flavour, you should read the
+@uref{@value{emacsotherfilename}, @value{emacsothername}} pages.
+@end ifhtml
 @end ifset
 
 @ifhtml
 @ifset jamanual
-This manual is also available as a @uref{@value{japanese-manual},
+This manual is also available as a @uref{@value{japanesemanual},
 Japanese translation}.
 @end ifset
 
-The latest release of @tramp{} is available for
-@uref{http://savannah.nongnu.org/download/tramp/,
-download}, or you may see @ref{Obtaining @tramp{}} for more details,
-including the CVS server details.
-
-@tramp{} also has a @uref{http://savannah.nongnu.org/projects/tramp/,
+The latest release of @value{tramp} is available for
+@uref{http://savannah.nongnu.org/download/tramp/, download}, or you
+may see @ref{Obtaining Tramp} for more details, including the CVS
+server details.
+
+@value{tramp} also has a @uref{http://savannah.nongnu.org/projects/tramp/,
 Savannah Project Page}.
 @end ifhtml
 
-There is a mailing list for @tramp{}, available at
+There is a mailing list for @value{tramp}, available at
 @email{tramp-devel@@mail.freesoftware.fsf.org}, and archived at
 @uref{http://savannah.nongnu.org/mail/?group=tramp, Savannah Mail
 Archive}.
@@ -135,17 +138,17 @@
 @end ifnottex
 
 @menu
-* Overview::                    What @tramp{} can and cannot do.
+* Overview::                    What @value{tramp} can and cannot do.
 
 For the end user:
 
-* Obtaining @tramp{}::             How to obtain @tramp{}.
-* History::                     History of @tramp{}.
-@ifset tramp-inst
-* Installation::                Installing @tramp{} with your @value{emacs-name}.
+* Obtaining Tramp::             How to obtain @value{tramp}.
+* History::                     History of @value{tramp}.
+@ifset installchapter
+* Installation::                Installing @value{tramp} with your @value{emacsname}.
 @end ifset
-* Configuration::               Configuring @tramp{} for use.
-* Usage::                       An overview of the operation of @tramp{}.
+* Configuration::               Configuring @value{tramp} for use.
+* Usage::                       An overview of the operation of @value{tramp}.
 * Bug Reports::                 Reporting Bugs and Problems.
 * Frequently Asked Questions::  Questions and answers from the mailing list.
 * Concept Index::               An item for each concept.
@@ -159,16 +162,16 @@
 @detailmenu
  --- The Detailed Node Listing ---
 @c
-@ifset tramp-inst
-Installing @tramp{} with your @value{emacs-name}
+@ifset installchapter
+Installing @value{tramp} with your @value{emacsname}
 
 * Installation parameters::     Parameters in order to control installation.
-* Load paths::                  How to plug-in @tramp{} into your environment.
+* Load paths::                  How to plug-in @value{tramp} into your environment.
 * Japanese manual::             Japanese manual.
 
 @end ifset
 
-Configuring @tramp{} for use
+Configuring @value{tramp} for use
 
 * Connection types::            Types of connections made to remote machines.
 * Inline methods::              Inline methods.
@@ -178,14 +181,14 @@
 * Customizing Methods::         Using Non-Standard Methods.
 * Customizing Completion::      Selecting config files for user/host name completion.
 * Password caching::            Reusing passwords for several connections.
-* Remote Programs::             How @tramp{} finds and uses programs on the remote machine.
+* Remote Programs::             How @value{tramp} finds and uses programs on the remote machine.
 * Remote shell setup::          Remote shell setup hints.
 * Windows setup hints::         Issues with Cygwin ssh.
 * Auto-save and Backup::        Auto-save and Backup.
 
-Using @tramp{}
-
-* Filename Syntax::             @tramp{} filename conventions.
+Using @value{tramp}
+
+* Filename Syntax::             @value{tramp} filename conventions.
 * Multi-hop filename syntax::   Multi-hop filename conventions.
 * Filename completion::         Filename completion.
 * Dired::                       Dired.
@@ -211,10 +214,10 @@
 @end menu
 
 @node Overview
-@chapter An overview of @tramp{}
+@chapter An overview of @value{tramp}
 @cindex overview
 
-After the installation of @tramp{} into your @value{emacs-name}, you
+After the installation of @value{tramp} into your @value{emacsname}, you
 will be able to access files on remote machines as though they were
 local.  Access to the remote file system for editing files, version
 control, and @command{dired} are transparently enabled.
@@ -229,27 +232,26 @@
 relatively secure access to machines, especially if @command{ftp}
 access is disabled.
 
-The majority of activity carried out by @tramp{} requires only that
+The majority of activity carried out by @value{tramp} requires only that
 the remote login is possible and is carried out at the terminal.  In
-order to access remote files @tramp{} needs to transfer their content
+order to access remote files @value{tramp} needs to transfer their content
 to the local machine temporarily.
 
-@tramp{} can transfer files between the machines in a variety of ways.
+@value{tramp} can transfer files between the machines in a variety of ways.
 The details are easy to select, depending on your needs and the
 machines in question.
 
 The fastest transfer methods (for large files) rely on a remote file
 transfer package such as @command{rcp}, @command{scp} or
-@command{rsync}.  The use of these methods is only possible if the
-file copy command does not ask for a password for the remote machine.
-
-If the remote copy methods are not suitable for you, @tramp{} also
+@command{rsync}.
+
+If the remote copy methods are not suitable for you, @value{tramp} also
 supports the use of encoded transfers directly through the shell.
 This requires that the @command{mimencode} or @command{uuencode} tools
 are available on the remote machine.  These methods are generally
 faster for small files.
 
-Within these limitations, @tramp{} is quite powerful.  It is worth
+Within these limitations, @value{tramp} is quite powerful.  It is worth
 noting that, as of the time of writing, it is far from a polished
 end-user product.  For a while yet you should expect to run into rough
 edges and problems with the code now and then.
@@ -258,8 +260,8 @@
 the installation and setup can be a little difficult to master, as can
 the terminology.
 
-@tramp{} is still under active development and any problems you encounter,
-trivial or major, should be reported to the @tramp{} developers.
+@value{tramp} is still under active development and any problems you encounter,
+trivial or major, should be reported to the @value{tramp} developers.
 @xref{Bug Reports}.
 
 
@@ -269,65 +271,65 @@
 @cindex how it works
 
 This section tries to explain what goes on behind the scenes when you
-access a remote file through @tramp{}.
-
-Suppose you type @kbd{C-x C-f} and enter part of an @tramp{} file name,
+access a remote file through @value{tramp}.
+
+Suppose you type @kbd{C-x C-f} and enter part of an @value{tramp} file name,
 then hit @kbd{@key{TAB}} for completion.  Suppose further that this is
-the first time that @tramp{} is invoked for the host in question.  Here's
+the first time that @value{tramp} is invoked for the host in question.  Here's
 what happens:
 
 @itemize
 @item
-@tramp{} discovers that it needs a connection to the host.  So it
+@value{tramp} discovers that it needs a connection to the host.  So it
 invokes @samp{telnet @var{host}} or @samp{rsh @var{host} -l
 @var{user}} or a similar tool to connect to the remote host.
 Communication with this process happens through an
-@value{emacs-name} buffer, that is, the output from the remote end
+@value{emacsname} buffer, that is, the output from the remote end
 goes into a buffer.
 
 @item
 The remote host may prompt for a login name (for @command{telnet}).  The
-login name is given in the file name, so @tramp{} sends the login name and
+login name is given in the file name, so @value{tramp} sends the login name and
 a newline.
 
 @item
 The remote host may prompt for a password or pass phrase (for
 @command{rsh} or for @command{telnet} after sending the login name).
-@tramp{} displays the prompt in the minibuffer, asking you for the
+@value{tramp} displays the prompt in the minibuffer, asking you for the
 password or pass phrase.
 
-You enter the password or pass phrase.  @tramp{} sends it to the remote
+You enter the password or pass phrase.  @value{tramp} sends it to the remote
 host, followed by a newline.
 
 @item
-@tramp{} now waits for the shell prompt or for a message that the login
+@value{tramp} now waits for the shell prompt or for a message that the login
 failed.
 
-If @tramp{} sees neither of them after a certain period of time (a minute,
+If @value{tramp} sees neither of them after a certain period of time (a minute,
 say), then it issues an error message saying that it couldn't find the
 remote shell prompt and shows you what the remote host has sent.
 
-If @tramp{} sees a @samp{login failed} message, it tells you so,
+If @value{tramp} sees a @samp{login failed} message, it tells you so,
 aborts the login attempt and allows you to try again.
 
 @item
-Suppose that the login was successful and @tramp{} sees the shell prompt
-from the remote host.  Now @tramp{} invokes @command{/bin/sh} because
+Suppose that the login was successful and @value{tramp} sees the shell prompt
+from the remote host.  Now @value{tramp} invokes @command{/bin/sh} because
 Bourne shells and C shells have different command
 syntaxes.@footnote{Invoking @command{/bin/sh} will fail if your login
 shell doesn't recognize @samp{exec /bin/sh} as a valid command.
 Maybe you use the Scheme shell @command{scsh}@dots{}}
 
-After the Bourne shell has come up, @tramp{} sends a few commands to
+After the Bourne shell has come up, @value{tramp} sends a few commands to
 ensure a good working environment.  It turns off echoing, it sets the
 shell prompt, and a few other things.
 
 @item
 Now the remote shell is up and it good working order.  Remember, what
-was supposed to happen is that @tramp{} tries to find out what files exist
+was supposed to happen is that @value{tramp} tries to find out what files exist
 on the remote host so that it can do filename completion.
 
-So, @tramp{} basically issues @command{cd} and @command{ls} commands and
+So, @value{tramp} basically issues @command{cd} and @command{ls} commands and
 also sometimes @command{echo} with globbing.  Another command that is
 often used is @command{test} to find out whether a file is writable or a
 directory or the like.  The output of each command is parsed for the
@@ -339,14 +341,14 @@
 transfer the file contents from the remote host to the local host so
 that you can edit them.
 
-See above for an explanation of how @tramp{} transfers the file contents.
-
-For inline transfers, @tramp{} issues a command like @samp{mimencode -b
+See above for an explanation of how @value{tramp} transfers the file contents.
+
+For inline transfers, @value{tramp} issues a command like @samp{mimencode -b
 /path/to/remote/file}, waits until the output has accumulated in the
 buffer that's used for communication, then decodes that output to
 produce the file contents.
 
-For out-of-band transfers, @tramp{} issues a command like the following:
+For out-of-band transfers, @value{tramp} issues a command like the following:
 @example
 rcp user@@host:/path/to/remote/file /tmp/tramp.4711
 @end example
@@ -359,35 +361,35 @@
 you are finished, you type @kbd{C-x C-s} to save the buffer.
 
 @item
-Again, @tramp{} transfers the file contents to the remote host either
+Again, @value{tramp} transfers the file contents to the remote host either
 inline or out-of-band.  This is the reverse of what happens when reading
 the file.
 
 @end itemize
 
 I hope this has provided you with a basic overview of what happens
-behind the scenes when you open a file with @tramp{}.
+behind the scenes when you open a file with @value{tramp}.
 
 
 @c For the end user
-@node Obtaining @tramp{}
-@chapter Obtaining @tramp{}.
-@cindex obtaining @tramp{}
-
-@tramp{} is freely available on the Internet and the latest release
+@node Obtaining Tramp
+@chapter Obtaining Tramp.
+@cindex obtaining Tramp
+
+@value{tramp} is freely available on the Internet and the latest release
 may be downloaded from
 @uref{http://savannah.nongnu.org/download/tramp/}. This
-release includes the full documentation and code for @tramp{},
+release includes the full documentation and code for @value{tramp},
 suitable for installation.  But Emacs (21.4 or later) includes
-@tramp{} already, and there is a @tramp{} package for XEmacs, as well.
+@value{tramp} already, and there is a @value{tramp} package for XEmacs, as well.
 So maybe it is easier to just use those.  But if you want the bleeding
 edge, read on@dots{...}
 
-For the especially brave, @tramp{} is available from CVS.  The CVS
+For the especially brave, @value{tramp} is available from CVS.  The CVS
 version is the latest version of the code and may contain incomplete
 features or new issues. Use these versions at your own risk.
 
-Instructions for obtaining the latest development version of @tramp{}
+Instructions for obtaining the latest development version of @value{tramp}
 from CVS can be found by going to the Savannah project page at the
 following URL and then clicking on the CVS link in the navigation bar
 at the top.
@@ -399,18 +401,18 @@
 Or follow the example session below:
 
 @example
-] @strong{cd ~/@value{emacs-dir}}
+] @strong{cd ~/@value{emacsdir}}
 ] @strong{export CVS_RSH="ssh"}
 ] @strong{cvs -z3 -d:ext:anoncvs@@savannah.nongnu.org:/cvsroot/tramp co tramp}
 @end example
 
 @noindent
-You should now have a directory @file{~/@value{emacs-dir}/tramp}
-containing the latest version of @tramp{}. You can fetch the latest
+You should now have a directory @file{~/@value{emacsdir}/tramp}
+containing the latest version of @value{tramp}. You can fetch the latest
 updates from the repository by issuing the command:
 
 @example
-] @strong{cd ~/@value{emacs-dir}/tramp}
+] @strong{cd ~/@value{emacsdir}/tramp}
 ] @strong{export CVS_RSH="ssh"}
 ] @strong{cvs update -d}
 @end example
@@ -421,13 +423,13 @@
 script:
 
 @example
-] @strong{cd ~/@value{emacs-dir}/tramp}
+] @strong{cd ~/@value{emacsdir}/tramp}
 ] @strong{autoconf}
 @end example
 
 
 @node History
-@chapter History of @tramp{}
+@chapter History of @value{tramp}
 @cindex history
 @cindex development history
 
@@ -435,31 +437,31 @@
 @file{rssh.el}, back then.  It only provided one method to access a
 file, using @command{ssh} to log in to a remote host and using
 @command{scp} to transfer the file contents.  After a while, the name
-was changed to @file{rcp.el}, and now it's @tramp{}.  Along the way,
+was changed to @file{rcp.el}, and now it's @value{tramp}.  Along the way,
 many more methods for getting a remote shell and for transferring the
 file contents were added.  Support for VC was added.
 
 The most recent addition of major features were the multi-hop methods
-added in April 2000 and the unification of @tramp{} and Ange-FTP
+added in April 2000 and the unification of @value{tramp} and Ange-FTP
 filenames in July 2002.
 
 @c Installation chapter is necessary only in case of standalone
 @c installation.  Text taken from trampinst.texi.
-@ifset tramp-inst
-@installationchapter{}
+@ifset installchapter
+@include trampinst.texi
 @end ifset
 
 @node Configuration
-@chapter Configuring @tramp{} for use
+@chapter Configuring @value{tramp} for use
 @cindex configuration
 
 @cindex default configuration
-@tramp{} is (normally) fully functional when it is initially installed.
+@value{tramp} is (normally) fully functional when it is initially installed.
 It is initially configured to use the @command{ssh} program to connect
 to the remote host and to use base64 or uu encoding to transfer the
 files through that shell connection.  So in the easiest case, you just
 type @kbd{C-x C-f} and then enter the filename
-@file{@value{tramp-prefix}@var{user}@@@var{machine}@value{tramp-postfix}@var{/path/to.file}}.
+@file{@value{prefix}@var{user}@@@var{machine}@value{postfix}@var{/path/to.file}}.
 
 On some hosts, there are problems with opening a connection.  These are
 related to the behavior of the remote shell.  See @xref{Remote shell
@@ -467,7 +469,7 @@
 
 If you do not wish to use these commands to connect to the remote
 host, you should change the default connection and transfer method
-that @tramp{} uses.  There are several different methods that @tramp{}
+that @value{tramp} uses.  There are several different methods that @value{tramp}
 can use to connect to remote machines and transfer files
 (@pxref{Connection types}).
 
@@ -487,7 +489,7 @@
 * Customizing Methods::         Using Non-Standard Methods.
 * Customizing Completion::      Selecting config files for user/host name completion.
 * Password caching::            Reusing passwords for several connections.
-* Remote Programs::             How @tramp{} finds and uses programs on the remote machine.
+* Remote Programs::             How @value{tramp} finds and uses programs on the remote machine.
 * Remote shell setup::          Remote shell setup hints.
 * Windows setup hints::         Issues with Cygwin ssh.
 * Auto-save and Backup::        Auto-save and Backup.
@@ -503,7 +505,7 @@
 remote shell access program such as @command{rsh}, @command{ssh} or
 @command{telnet} to connect to the remote machine.
 
-This connection is used to perform many of the operations that @tramp{}
+This connection is used to perform many of the operations that @value{tramp}
 requires to make the remote file system transparently accessible from
 the local machine. It is only when visiting files that the methods
 differ.
@@ -534,10 +536,10 @@
 transferring files, the overhead of the cryptographic negotiation at
 startup may drown out the improvement in file transfer times.
 
-External transfer methods do require that the remote copy command is not
-interactive --- that is, the command does not prompt you for a password.
-If you cannot perform remote copies without a password, you will need to
-use an inline transfer method to work with @tramp{}.
+External transfer methods should be configured such a way that they
+don't require a password (with @command{ssh-agent}, or such alike).
+If it isn't possible, you should consider @ref{Password caching},
+otherwise you will be prompted for a password every copy action.
 
 @cindex multi-hop methods
 @cindex methods, multi-hop
@@ -553,7 +555,7 @@
 @cindex inline methods
 @cindex methods, inline
 
-The inline methods in @tramp{} are quite powerful and can work in
+The inline methods in @value{tramp} are quite powerful and can work in
 situations where you cannot use an external transfer program to connect.
 Inline methods are the only methods that work when connecting to the
 remote machine via telnet.  (There are also strange inline methods which
@@ -561,20 +563,20 @@
 hosts, see below.)
 
 These methods depend on the existence of a suitable encoding and
-decoding command on remote machine.  Locally, @tramp{} may be able to
-use features of @value{emacs-name} to decode and encode the files or
+decoding command on remote machine.  Locally, @value{tramp} may be able to
+use features of @value{emacsname} to decode and encode the files or
 it may require access to external commands to perform that task.
 
 @cindex uuencode
 @cindex mimencode
 @cindex base-64 encoding
-@tramp{} checks the availability and usability of commands like
+@value{tramp} checks the availability and usability of commands like
 @command{mimencode} (part of the @command{metamail} package) or
 @command{uuencode} on the remote host.  The first reliable command
 will be used.  The search path can be customized, see @ref{Remote
 Programs}.
 
-If both commands aren't available on the remote host, @tramp{}
+If both commands aren't available on the remote host, @value{tramp}
 transfers a small piece of Perl code to the remote host, and tries to
 apply it for encoding and decoding.
 
@@ -658,20 +660,20 @@
 @var{user} /bin/sh} to open a connection.  This is useful for users
 where the normal login shell is set up to ask them a number of
 questions when logging in.  This procedure avoids these questions, and
-just gives @tramp{} a more-or-less `standard' login shell to work
+just gives @value{tramp} a more-or-less `standard' login shell to work
 with.
 
 Note that this procedure does not eliminate questions asked by
 @command{ssh} itself.  For example, @command{ssh} might ask ``Are you
 sure you want to continue connecting?'' if the host key of the remote
-host is not known.  @tramp{} does not know how to deal with such a
+host is not known.  @value{tramp} does not know how to deal with such a
 question (yet), therefore you will need to make sure that you can log
 in without such questions.
 
 This is also useful for Windows users where @command{ssh}, when
-invoked from an @value{emacs-name} buffer, tells them that it is not
+invoked from an @value{emacsname} buffer, tells them that it is not
 allocating a pseudo tty.  When this happens, the login shell is wont
-to not print any shell prompt, which confuses @tramp{} mightily.  For
+to not print any shell prompt, which confuses @value{tramp} mightily.  For
 reasons unknown, some Windows ports for @command{ssh} (maybe the
 Cygwin one) require the doubled @samp{-t} option.
 
@@ -702,7 +704,7 @@
 CCC: Do we have to connect to the remote host once from the command
 line to accept the SSH key?  Maybe this can be made automatic?
 
-CCC: Does @command{plink} support the @samp{-p} option?  @tramp{} will
+CCC: Does @command{plink} support the @samp{-p} option?  @value{tramp} will
 support that, anyway.
 
 @end table
@@ -723,8 +725,8 @@
 This saves the overhead of encoding and decoding that multiplexing the
 transfer through the one connection has with the inline methods.
 
-If you want to use an external transfer method you @emph{must} be able
-to execute the transfer utility to copy files to and from the remote
+If you want to use an external transfer method you should be able to
+execute the transfer utility to copy files to and from the remote
 machine without any interaction.
 
 @cindex ssh-agent
@@ -735,9 +737,8 @@
 If you use @command{rsync} via @command{ssh} then the same rule must
 apply to that connection.
 
-If you cannot get @command{scp} to run without asking for a password but
-would still like to use @command{ssh} to secure your connection, have a
-look at the @command{ssh} based inline methods.
+If you cannot get an external method to run without asking for a
+password you should consider @ref{Password caching}.
 
 
 @table @asis
@@ -785,7 +786,7 @@
 
 All the @command{ssh} based methods support the kludgy @samp{-p}
 feature where you can specify a port number to connect to in the host
-name.  For example, the host name @file{host#42} tells @tramp{} to
+name.  For example, the host name @file{host#42} tells @value{tramp} to
 specify @samp{-p 42} in the argument list for @command{ssh}.
 
 
@@ -823,13 +824,13 @@
 @var{user} /bin/sh} to open a connection.  This is useful for users
 where the normal login shell is set up to ask them a number of
 questions when logging in.  This procedure avoids these questions, and
-just gives @tramp{} a more-or-less `standard' login shell to work
+just gives @value{tramp} a more-or-less `standard' login shell to work
 with.
 
 This is also useful for Windows users where @command{ssh}, when
-invoked from an @value{emacs-name} buffer, tells them that it is not
+invoked from an @value{emacsname} buffer, tells them that it is not
 allocating a pseudo tty.  When this happens, the login shell is wont
-to not print any shell prompt, which confuses @tramp{} mightily.
+to not print any shell prompt, which confuses @value{tramp} mightily.
 Maybe this applies to the Cygwin port of SSH.
 
 This method supports the @samp{-p} hack.
@@ -873,7 +874,7 @@
 @cindex fsh method
 
 There is no inline method using @command{fsh} as the multiplexing
-provided by the program is not very useful in our context.  @tramp{}
+provided by the program is not very useful in our context.  @value{tramp}
 opens just one connection to the remote host and then keeps it open,
 anyway.
 
@@ -882,8 +883,8 @@
 @cindex method ftp
 @cindex ftp method
 
-This is not a native @tramp{} method. Instead of, it forwards all
-requests to @value{ftp-package-name}.
+This is not a native @value{tramp} method. Instead of, it forwards all
+requests to @value{ftppackagename}.
 @ifset xemacs
 This works only for unified filenames, see @ref{Issues}.
 @end ifset
@@ -893,7 +894,7 @@
 @cindex method smb
 @cindex smb method
 
-This is another not natural @tramp{} method.  It uses the
+This is another not natural @value{tramp} method.  It uses the
 @command{smbclient} command on different Unices in order to connect to
 an SMB server.  An SMB server might be a Samba (or CIFS) server on
 another UNIX host or, more interesting, a host running MS Windows.  So
@@ -911,22 +912,22 @@
 This can be suppressed by @ref{Password caching}.
 
 MS Windows uses for authorization both a user name and a domain name.
-Because of this, the @tramp{} syntax has been extended: you can
+Because of this, the @value{tramp} syntax has been extended: you can
 specify a user name which looks like @code{user%domain} (the real user
 name, then a percent sign, then the domain name).  So, to connect to
 the machine @code{melancholia} as user @code{daniel} of the domain
 @code{BIZARRE}, and edit @file{.emacs} in the home directory (share
 @code{daniel$}) I would specify the filename
-@file{@value{tramp-prefix}smb@value{tramp-postfix-single-hop}daniel%BIZARRE@@melancholia@value{tramp-postfix}/daniel$$/.emacs}.
+@file{@value{prefix}smb@value{postfixsinglehop}daniel%BIZARRE@@melancholia@value{postfix}/daniel$$/.emacs}.
 
 The domain name as well as the user name are optional.  If no user
 name is specified at all, the anonymous user (without password
-prompting) is assumed.  This is different from all other @tramp{}
+prompting) is assumed.  This is different from all other @value{tramp}
 methods, where in such a case the local user name is taken.
 
 The @option{smb} method supports the @samp{-p} hack.
 
-@strong{Please note:} If @value{emacs-name} runs locally under MS
+@strong{Please note:} If @value{emacsname} runs locally under MS
 Windows, this method isn't available.  Instead of, you can use UNC
 file names like @file{//melancholia/daniel$$/.emacs}.  The only
 disadvantage is that there's no possibility to specify another user
@@ -945,7 +946,7 @@
 to a `bastion host' first before you can connect to the outside world.
 Of course, the target host may also require a bastion host.  The format
 of multi-hop filenames is slightly different than the format of normal
-@tramp{} methods.
+@value{tramp} methods.
 
 @cindex method multi
 @cindex multi method
@@ -1014,7 +1015,7 @@
 maybe they have to use a nonstandard port.  This can be accomplished
 by putting a stanza in @file{~/.ssh/config} for the account which
 specifies a different port number for a certain host name.  But it can
-also be accomplished within @tramp{}, by adding a multi-hop method.
+also be accomplished within @value{tramp}, by adding a multi-hop method.
 For example:
 
 @lisp
@@ -1035,7 +1036,7 @@
 When you select an appropriate transfer method for your typical usage
 you should set the variable @code{tramp-default-method} to reflect that
 choice.  This variable controls which method will be used when a method
-is not specified in the @tramp{} file name.  For example:
+is not specified in the @value{tramp} file name.  For example:
 
 @lisp
 (setq tramp-default-method "scp")
@@ -1062,8 +1063,7 @@
 @code{tramp-default-method-alist} for more details.
 
 External transfer methods are normally preferable to inline transfer
-methods, giving better performance. They may not be useful if you use
-many remote machines where you cannot log in without a password.
+methods, giving better performance.
 
 @xref{Inline methods}.
 @xref{External transfer methods}.
@@ -1101,8 +1101,9 @@
 
 I guess that these days, most people can access a remote machine by
 using @code{ssh}.  So I suggest that you use the @code{ssh} method.
-So, type @kbd{C-x C-f /ssh:root@@otherhost:/etc/motd @key{RET}} to
-edit the @file{/etc/motd} file on the other host.
+So, type @kbd{C-x C-f
+@value{prefix}ssh@value{postfixsinglehop}root@@otherhost@value{postfix}/etc/motd
+@key{RET}} to edit the @file{/etc/motd} file on the other host.
 
 If you can't use @code{ssh} to log in to the remote host, then select a
 method that uses a program that works.  For instance, Windows users
@@ -1120,11 +1121,6 @@
 out-of-band method!  Maybe even for large files, inline methods are
 fast enough.
 
-The reason why I'm suggesting to use inline methods is that they work
-even if the remote end is asking you for a password.  Out-of-band
-methods don't work in this situation.  Also, multi-hop methods are
-inherently inline.
-
 
 @node Customizing Methods
 @section Using Non-Standard Methods
@@ -1267,13 +1263,13 @@
 the choosen method does not support access without password prompt
 throught own configuration.
 
-By default, @tramp{} caches the passwords entered by you.  They will
+By default, @value{tramp} caches the passwords entered by you.  They will
 be reused next time if a connection needs them for the same user name
 and host name, independant of the connection method.
 
 @vindex password-cache-expiry
 Passwords are not saved permanently, that means the password caching
-is limited to the lifetime of your @value{emacs-name} session.  You
+is limited to the lifetime of your @value{emacsname} session.  You
 can influence the lifetime of password caching by customizing the
 variable @code{password-cache-expiry}.  The value is the number of
 seconds how long passwords are cached.  Setting it to @code{nil}
@@ -1292,19 +1288,19 @@
 
 Implementation Note: password caching is based on the package
 password.el in No Gnus.  For the time being, it is activated only when
-this package is seen in the @code{load-path} while loading @tramp{}.
-@ifset tramp-inst
-If you don't use No Gnus, you can take password.el from the @tramp{}
+this package is seen in the @code{load-path} while loading @value{tramp}.
+@ifset installchapter
+If you don't use No Gnus, you can take password.el from the @value{tramp}
 @file{contrib} directory, see @ref{Installation parameters}.
 @end ifset
 It will be activated mandatory once No Gnus has found its way into
-@value{emacs-name}.
+@value{emacsname}.
 
 
 @node Remote Programs
-@section How @tramp{} finds and uses programs on the remote machine.
-
-@tramp{} depends on a number of programs on the remote host in order to
+@section How @value{tramp} finds and uses programs on the remote machine.
+
+@value{tramp} depends on a number of programs on the remote host in order to
 function, including @command{ls}, @command{test}, @command{find} and
 @command{cat}.
 
@@ -1318,7 +1314,7 @@
 remote file access.
 
 @vindex tramp-remote-path
-When @tramp{} connects to the remote machine, it searches for the
+When @value{tramp} connects to the remote machine, it searches for the
 programs that it can use. The variable @var{tramp-remote-path} controls
 the directories searched on the remote machine.
 
@@ -1327,16 +1323,16 @@
 administrator has put the tools you want in some obscure local
 directory.
 
-In this case, you can still use them with @tramp{}. You simply need to
+In this case, you can still use them with @value{tramp}. You simply need to
 add code to your @file{.emacs} to add the directory to the remote path.
-This will then be searched by @tramp{} when you connect and the software
+This will then be searched by @value{tramp} when you connect and the software
 found.
 
 To add a directory to the remote search path, you could use code such
 as:
 
 @lisp
-@i{;; We load @tramp{} to define the variable.}
+@i{;; We load @value{tramp} to define the variable.}
 (require 'tramp)
 @i{;; We have @command{perl} in "/usr/local/perl/bin"}
 (add-to-list 'tramp-remote-path "/usr/local/perl/bin")
@@ -1351,19 +1347,19 @@
 @cindex @file{.login} file
 @cindex shell init files
 
-As explained in the @ref{Overview} section, @tramp{} connects to the
+As explained in the @ref{Overview} section, @value{tramp} connects to the
 remote host and talks to the shell it finds there.  Of course, when you
 log in, the shell executes its init files.  Suppose your init file
-requires you to enter the birth date of your mother; clearly @tramp{}
+requires you to enter the birth date of your mother; clearly @value{tramp}
 does not know this and hence fails to log you in to that host.
 
 There are different possible strategies for pursuing this problem.  One
-strategy is to enable @tramp{} to deal with all possible situations.
+strategy is to enable @value{tramp} to deal with all possible situations.
 This is a losing battle, since it is not possible to deal with
 @emph{all} situations.  The other strategy is to require you to set up
-the remote host such that it behaves like @tramp{} expects.  This might
+the remote host such that it behaves like @value{tramp} expects.  This might
 be inconvenient because you have to invest a lot of effort into shell
-setup before you can begin to use @tramp{}.
+setup before you can begin to use @value{tramp}.
 
 The package, therefore, pursues a combined approach.  It tries to figure
 out some of the more common setups, and only requires you to avoid
@@ -1376,34 +1372,34 @@
 @code{/bin/test -e} works.  And on still other hosts, @code{ls -d} is
 the right way to do this.)
 
-Below you find a discussion of a few things that @tramp{} does not deal
+Below you find a discussion of a few things that @value{tramp} does not deal
 with, and that you therefore have to set up correctly.
 
 @table @asis
 @item @var{shell-prompt-pattern}
 @vindex shell-prompt-pattern
 
-After logging in to the remote host, @tramp{} has to wait for the remote
+After logging in to the remote host, @value{tramp} has to wait for the remote
 shell startup to finish before it can send commands to the remote
 shell.  The strategy here is to wait for the shell prompt.  In order to
 recognize the shell prompt, the variable @code{shell-prompt-pattern} has
 to be set correctly to recognize the shell prompt on the remote host.
 
-Note that @tramp{} requires the match for @code{shell-prompt-pattern}
+Note that @value{tramp} requires the match for @code{shell-prompt-pattern}
 to be at the end of the buffer.  Many people have something like the
 following as the value for the variable: @code{"^[^>$][>$] *"}.  Now
 suppose your shell prompt is @code{a <b> c $ }.  In this case,
-@tramp{} recognizes the @code{>} character as the end of the prompt,
+@value{tramp} recognizes the @code{>} character as the end of the prompt,
 but it is not at the end of the buffer.
 
 @item @var{tramp-shell-prompt-pattern}
 @vindex tramp-shell-prompt-pattern
 
-This regular expression is used by @tramp{} in the same way as
+This regular expression is used by @value{tramp} in the same way as
 @code{shell-prompt-pattern}, to match prompts from the remote shell.
 This second variable exists because the prompt from the remote shell
 might be different from the prompt from a local shell --- after all,
-the whole point of @tramp{} is to log in to remote hosts as a
+the whole point of @value{tramp} is to log in to remote hosts as a
 different user.  The default value of
 @code{tramp-shell-prompt-pattern} is the same as the default value of
 @code{shell-prompt-pattern}, which is reported to work well in many
@@ -1415,10 +1411,10 @@
 
 Some people invoke the @code{tset} program from their shell startup
 scripts which asks the user about the terminal type of the shell.
-Maybe some shells ask other questions when they are started.  @tramp{}
+Maybe some shells ask other questions when they are started.  @value{tramp}
 does not know how to answer these questions.  There are two approaches
 for dealing with this problem.  One approach is to take care that the
-shell does not ask any questions when invoked from @tramp{}.  You can
+shell does not ask any questions when invoked from @value{tramp}.  You can
 do this by checking the @code{TERM} environment variable, it will be
 set to @code{dumb} when connecting.
 
@@ -1426,7 +1422,7 @@
 The variable @code{tramp-terminal-type} can be used to change this value
 to @code{dumb}.
 
-The other approach is to teach @tramp{} about these questions.  See
+The other approach is to teach @value{tramp} about these questions.  See
 the variables @code{tramp-actions-before-shell} and
 @code{tramp-multi-actions} (for multi-hop connections).
 
@@ -1437,12 +1433,12 @@
 your shell environment, then this might cause trouble.  Maybe rename
 the variable to @code{FRUMPLE_DIR} or the like.
 
-This weird effect was actually reported by a @tramp{} user!
+This weird effect was actually reported by a @value{tramp} user!
 
 
 @item Non-Bourne commands in @file{.profile}
 
-After logging in to the remote host, @tramp{} issues the command
+After logging in to the remote host, @value{tramp} issues the command
 @code{exec /bin/sh}.  (Actually, the command is slightly different.)
 When @code{/bin/sh} is executed, it reads some init files, such as
 @file{~/.shrc} or @file{~/.profile}.
@@ -1476,9 +1472,9 @@
 aficionados just rename their @file{~/.profile} to
 @file{~/.bash_profile} on all remote hosts, and Bob's your uncle.
 
-The @tramp{} developers would like to circumvent this problem, so if you
+The @value{tramp} developers would like to circumvent this problem, so if you
 have an idea about it, please tell us.  However, we are afraid it is not
-that simple: before saying @code{exec /bin/sh}, @tramp{} does not know
+that simple: before saying @code{exec /bin/sh}, @value{tramp} does not know
 which kind of shell it might be talking to.  It could be a Bourne-ish
 shell like ksh or bash, or it could be a csh derivative like tcsh, or
 it could be zsh, or even rc.  If the shell is Bourne-ish already, then
@@ -1492,42 +1488,122 @@
 @section Auto-save and Backup configuration
 @cindex auto-save
 @cindex backup
+@ifset emacs
 @vindex backup-directory-alist
-
-Normally, @value{emacs-name} writes backup files to the same directory
+@end ifset
+@ifset xemacs
+@vindex bkup-backup-directory-info
+@end ifset
+
+Normally, @value{emacsname} writes backup files to the same directory
 as the original files, but this behavior can be changed via the
-variable @code{backup-directory-alist}.  In connection with @tramp{},
-this can have unexpected side effects.  Suppose that you specify that
-all backups should go to the directory @file{~/.emacs.d/backups/}, and
-then you edit the file @file{/su:root@@localhost:/etc/secretfile}.
+variable
+@ifset emacs
+@code{backup-directory-alist}.
+@end ifset
+@ifset xemacs
+@code{bkup-backup-directory-info}.
+@end ifset
+In connection with @value{tramp}, this can have unexpected side effects.
+Suppose that you specify that all backups should go to the directory
+@file{~/.emacs.d/backups/}, and then you edit the file
+@file{@value{prefix}su@value{postfixsinglehop}root@@localhost@value{postfix}/etc/secretfile}.
 The effect is that the backup file will be owned by you and not by
 root, thus possibly enabling others to see it even if they were not
 intended to see it.
 
-When @code{backup-directory-alist} is nil (the default), such problems
-do not occur.
-
-If you wish to customize the variable, the workaround is to include
-special settings for @tramp{} files.  For example, the following statement
-effectively `turns off' the effect of @code{backup-directory-alist} for
-@tramp{} files:
-
+When
+@ifset emacs
+@code{backup-directory-alist}
+@end ifset
+@ifset xemacs
+@code{bkup-backup-directory-info}
+@end ifset
+is nil (the default), such problems do not occur.
+
+Therefore, it is usefull to set special values for @value{tramp}
+files.  For example, the following statement effectively `turns off'
+the effect of
+@ifset emacs
+@code{backup-directory-alist}
+@end ifset
+@ifset xemacs
+@code{bkup-backup-directory-info}
+@end ifset
+for @value{tramp} files:
+
+@ifset emacs
 @lisp
-(require 'tramp)
 (add-to-list 'backup-directory-alist
              (cons tramp-file-name-regexp nil))
 @end lisp
+@end ifset
+@ifset xemacs
+@lisp
+(require 'backup-dir)
+(add-to-list 'bkup-backup-directory-info
+             (list tramp-file-name-regexp ""))
+@end lisp
+@end ifset
+
+Another possibility is to use the @value{tramp} variable
+@ifset emacs
+@code{tramp-backup-directory-alist}.
+@end ifset
+@ifset xemacs
+@code{tramp-bkup-backup-directory-info}.
+@end ifset
+This variable has the same meaning like
+@ifset emacs
+@code{backup-directory-alist}.
+@end ifset
+@ifset xemacs
+@code{bkup-backup-directory-info}.
+@end ifset
+If a @value{tramp} file is backed up, and DIRECTORY is an absolute
+local file name, DIRECTORY is prepended with the @value{tramp} file
+name prefix of the file to be backed up.
+
+@noindent
+Example:
+
+@ifset emacs
+@lisp
+(add-to-list 'backup-directory-alist
+             (cons "." "~/.emacs.d/backups/"))
+(setq tramp-backup-directory-alist backup-directory-alist)
+@end lisp
+@end ifset
+@ifset xemacs
+@lisp
+(require 'backup-dir)
+(add-to-list 'bkup-backup-directory-info
+             (list "." "~/.emacs.d/backups/" 'full-path))
+(setq tramp-bkup-backup-directory-info bkup-backup-directory-info)
+@end lisp
+@end ifset
+
+@noindent
+The backup file name of
+@file{@value{prefix}su@value{postfixsinglehop}root@@localhost@value{postfix}/etc/secretfile}
+would be
+@ifset emacs
+@file{@value{prefix}su@value{postfixsinglehop}root@@localhost@value{postfix}~/.emacs.d/backups/!su:root@@localhost:!etc!secretfile~}
+@end ifset
+@ifset xemacs
+@file{@value{prefix}su@value{postfixsinglehop}root@@localhost@value{postfix}~/.emacs.d/backups/![su!root@@localhost]!etc!secretfile~}
+@end ifset
 
 The same problem can happen with auto-saving files.
 @ifset emacs
-Since @value{emacs-name} 21, the variable
+Since @value{emacsname} 21, the variable
 @code{auto-save-file-name-transforms} keeps information, on which
 directory an auto-saved file should go.  By default, it is initialized
-for @tramp{} files to the local temporary directory.
-
-On some versions of @value{emacs-name}, namely the version built for
+for @value{tramp} files to the local temporary directory.
+
+On some versions of @value{emacsname}, namely the version built for
 Debian Linux, the variable @code{auto-save-file-name-transforms}
-contains the directory where @value{emacs-name} was built.  A
+contains the directory where @value{emacsname} was built.  A
 workaround is to manually set the variable to a sane value.
 
 If auto-saved files should go into the same directory as the original
@@ -1537,8 +1613,8 @@
 @code{tramp-auto-save-directory} to a proper value.
 @end ifset
 @ifset xemacs
-For this purpose you can set the variable
-@code{tramp-auto-save-directory} to a proper value.
+For this purpose you can set the variable @code{auto-save-directory}
+to a proper value.
 @end ifset
 
 
@@ -1558,7 +1634,7 @@
 @cindex method scpx with Cygwin
 @cindex scpx method with Cygwin
 If you wish to use the @code{scpx} connection method, then you might
-have the problem that @value{emacs-name} calls @code{scp} with a
+have the problem that @value{emacsname} calls @code{scp} with a
 Windows filename such as @code{c:/foo}.  The Cygwin version of
 @code{scp} does not know about Windows filenames and interprets this
 as a remote filename on the host @code{c}.
@@ -1566,21 +1642,19 @@
 One possible workaround is to write a wrapper script for @code{scp}
 which converts the Windows filename to a Cygwinized filename.
 
-I guess that another workaround is to run @value{emacs-name} under
-Cygwin, or to run a Cygwinized @value{emacs-name}.
+I guess that another workaround is to run @value{emacsname} under
+Cygwin, or to run a Cygwinized @value{emacsname}.
 
 @cindex Cygwin and ssh-agent
-@cindex SSH_AUTH_SOCK and @value{emacs-name} on Windows
+@cindex SSH_AUTH_SOCK and @value{emacsname} on Windows
 If you want to use either @code{ssh} based method on Windows, then you
 might encounter problems with @code{ssh-agent}.  Using this program,
-you can avoid typing the pass-phrase every time you log in (and the
-@code{scpx} method more or less requires you to use @code{ssh-agent}
-because it does not allow you to type a password or pass-phrase).
-However, if you start @value{emacs-name} from a desktop shortcut, then
-the environment variable @code{SSH_AUTH_SOCK} is not set and so
-@value{emacs-name} and thus @tramp{} and thus @code{ssh} and
-@code{scp} started from @tramp{} cannot communicate with
-@code{ssh-agent}.  It works better to start @value{emacs-name} from
+you can avoid typing the pass-phrase every time you log in.  However,
+if you start @value{emacsname} from a desktop shortcut, then the
+environment variable @code{SSH_AUTH_SOCK} is not set and so
+@value{emacsname} and thus @value{tramp} and thus @code{ssh} and
+@code{scp} started from @value{tramp} cannot communicate with
+@code{ssh-agent}.  It works better to start @value{emacsname} from
 the shell.
 
 If anyone knows how to start @code{ssh-agent} under Windows in such a
@@ -1589,30 +1663,30 @@
 
 
 @node Usage
-@chapter Using @tramp{}
-@cindex using @tramp{}
-
-Once you have installed @tramp{} it will operate fairly transparently. You
+@chapter Using @value{tramp}
+@cindex using @value{tramp}
+
+Once you have installed @value{tramp} it will operate fairly transparently. You
 will be able to access files on any remote machine that you can log in
 to as though they were local.
 
-Files are specified to @tramp{} using a formalized syntax specifying the
+Files are specified to @value{tramp} using a formalized syntax specifying the
 details of the system to connect to.  This is similar to the syntax used
-by the @value{ftp-package-name} package.
+by the @value{ftppackagename} package.
 
 @cindex type-ahead
 Something that might happen which surprises you is that
-@value{emacs-name} remembers all your keystrokes, so if you see a
-password prompt from @value{emacs-name}, say, and hit @kbd{@key{RET}}
+@value{emacsname} remembers all your keystrokes, so if you see a
+password prompt from @value{emacsname}, say, and hit @kbd{@key{RET}}
 twice instead of once, then the second keystroke will be processed by
-@value{emacs-name} after @tramp{} has done its thing.  Why, this
+@value{emacsname} after @value{tramp} has done its thing.  Why, this
 type-ahead is normal behavior, you say.  Right you are, but be aware
 that opening a remote file might take quite a while, maybe half a
 minute when a connection needs to be opened.  Maybe after half a
 minute you have already forgotten that you hit that key!
 
 @menu
-* Filename Syntax::             @tramp{} filename conventions.
+* Filename Syntax::             @value{tramp} filename conventions.
 * Multi-hop filename syntax::   Multi-hop filename conventions.
 * Filename completion::         Filename completion.
 * Dired::                       Dired.
@@ -1620,66 +1694,66 @@
 
 
 @node Filename Syntax
-@section @tramp{} filename conventions
+@section @value{tramp} filename conventions
 @cindex filename syntax
 @cindex filename examples
 
 To access the file @var{localname} on the remote machine @var{machine} you
 would specify the filename
-@file{@value{tramp-prefix}@var{machine}@value{tramp-postfix}@var{localname}}.
+@file{@value{prefix}@var{machine}@value{postfix}@var{localname}}.
 This will connect to @var{machine} and transfer the file using the
 default method.  @xref{Default Method}.
 
-Some examples of @tramp{} filenames are shown below.
+Some examples of @value{tramp} filenames are shown below.
 
 @table @file
-@item @value{tramp-prefix}melancholia@value{tramp-postfix}.emacs
+@item @value{prefix}melancholia@value{postfix}.emacs
 Edit the file @file{.emacs} in your home directory on the machine
 @code{melancholia}.
 
-@item @value{tramp-prefix}melancholia.danann.net@value{tramp-postfix}.emacs
+@item @value{prefix}melancholia.danann.net@value{postfix}.emacs
 This edits the same file, using the fully qualified domain name of
 the machine.
 
-@item @value{tramp-prefix}melancholia@value{tramp-postfix}~/.emacs
+@item @value{prefix}melancholia@value{postfix}~/.emacs
 This also edits the same file --- the @file{~} is expanded to your
 home directory on the remote machine, just like it is locally.
 
-@item @value{tramp-prefix}melancholia@value{tramp-postfix}~daniel/.emacs
+@item @value{prefix}melancholia@value{postfix}~daniel/.emacs
 This edits the file @file{.emacs} in the home directory of the user
 @code{daniel} on the machine @code{melancholia}. The @file{~<user>}
 construct is expanded to the home directory of that user on the remote
 machine.
 
-@item @value{tramp-prefix}melancholia@value{tramp-postfix}/etc/squid.conf
+@item @value{prefix}melancholia@value{postfix}/etc/squid.conf
 This edits the file @file{/etc/squid.conf} on the machine
 @code{melancholia}.
 
 @end table
 
-Unless you specify a different name to use, @tramp{} will use the
+Unless you specify a different name to use, @value{tramp} will use the
 current local user name as the remote user name to log in with. If you
 need to log in as a different user, you can specify the user name as
 part of the filename.
 
 To log in to the remote machine as a specific user, you use the syntax
-@file{@value{tramp-prefix}@var{user}@@@var{machine}@value{tramp-postfix}/@var{path/to.file}}.
+@file{@value{prefix}@var{user}@@@var{machine}@value{postfix}/@var{path/to.file}}.
 That means that connecting to @code{melancholia} as @code{daniel} and
 editing @file{.emacs} in your home directory you would specify
-@file{@value{tramp-prefix}daniel@@melancholia@value{tramp-postfix}.emacs}.
+@file{@value{prefix}daniel@@melancholia@value{postfix}.emacs}.
 
 It is also possible to specify other file transfer methods
 (@pxref{Default Method}) as part of the filename.
 @ifset emacs
 This is done by putting the method before the user and host name, as
 in
-@file{@value{tramp-prefix}@var{method}@value{tramp-postfix-single-hop}}
+@file{@value{prefix}@var{method}@value{postfixsinglehop}}
 (Note the trailing colon).
 @end ifset
 @ifset xemacs
 This is done by replacing the initial
-@file{@value{tramp-prefix}} with
-@file{@value{tramp-prefix}<method>@value{tramp-postfix-single-hop}}.
+@file{@value{prefix}} with
+@file{@value{prefix}<method>@value{postfixsinglehop}}.
 (Note the trailing slash!).
 @end ifset
 The user, machine and file specification remain the same.
@@ -1687,7 +1761,7 @@
 So, to connect to the machine @code{melancholia} as @code{daniel},
 using the @option{ssh} method to transfer files, and edit @file{.emacs}
 in my home directory I would specify the filename
-@file{@value{tramp-prefix}ssh@value{tramp-postfix-single-hop}daniel@@melancholia@value{tramp-postfix}.emacs}.
+@file{@value{prefix}ssh@value{postfixsinglehop}daniel@@melancholia@value{postfix}.emacs}.
 
 
 @node Multi-hop filename syntax
@@ -1696,11 +1770,11 @@
 @cindex multi-hop filename syntax
 
 The syntax of multi-hop file names is necessarily slightly different
-than the syntax of other @tramp{} file names.  Here's an example
+than the syntax of other @value{tramp} file names.  Here's an example
 multi-hop file name:
 
 @example
-@value{tramp-prefix}multi@value{tramp-postfix-single-hop}rsh@value{tramp-postfix-multi-hop}out@@gate@value{tramp-postfix-single-hop}telnet@value{tramp-postfix-multi-hop}kai@@real.host@value{tramp-postfix}/path/to.file
+@value{prefix}multi@value{postfixsinglehop}rsh@value{postfixmultihop}out@@gate@value{postfixsinglehop}telnet@value{postfixmultihop}kai@@real.host@value{postfix}/path/to.file
 @end example
 
 This is quite a mouthful.  So let's go through it step by step.  The
@@ -1711,9 +1785,9 @@
 @ifset xemacs
 The parts are separated by slashes and square brackets.
 @end ifset
-The first part is @file{@value{tramp-prefix}multi}, the method
+The first part is @file{@value{prefix}multi}, the method
 specification.  The second part is
-@file{rsh@value{tramp-postfix-multi-hop}out@@gate@value{tramp-postfix-single-hop}telnet@value{tramp-postfix-multi-hop}kai@@real.host}
+@file{rsh@value{postfixmultihop}out@@gate@value{postfixsinglehop}telnet@value{postfixmultihop}kai@@real.host}
 and specifies the hops.  The final part is @file{/path/to.file} and
 specifies the file name on the remote host.
 
@@ -1722,18 +1796,18 @@
 
 The second part can be subdivided again into components, so-called
 hops.  In the above file name, there are two hops,
-@file{rsh@value{tramp-postfix-multi-hop}out@@gate} and
-@file{telnet@value{tramp-postfix-multi-hop}kai@@real.host}.
+@file{rsh@value{postfixmultihop}out@@gate} and
+@file{telnet@value{postfixmultihop}kai@@real.host}.
 
 Each hop can @emph{again} be subdivided into (three) components, the
 @dfn{hop method}, the @dfn{user name} and the @dfn{host name}.  The
 meaning of the second and third component should be clear, and the hop
 method says what program to use to perform that hop.
 
-The first hop, @file{rsh@value{tramp-postfix-multi-hop}out@@gate},
+The first hop, @file{rsh@value{postfixmultihop}out@@gate},
 says to use @command{rsh} to log in as user @code{out} to the host
 @code{gate}.  Starting at that host, the second hop,
-@file{telnet@value{tramp-postfix-multi-hop}kai@@real.host}, says to
+@file{telnet@value{postfixmultihop}kai@@real.host}, says to
 use @command{telnet} to log in as user @code{kai} to host
 @code{real.host}.
 
@@ -1747,54 +1821,54 @@
 @section Filename completion
 @cindex filename completion
 
-Filename completion works with @tramp{} for both completing methods,
+Filename completion works with @value{tramp} for both completing methods,
 user names and machine names (except multi hop methods) as well as for
 files on remote machines.
 
-If you, for example, type @kbd{C-x C-f @value{tramp-prefix}t
-@key{TAB}}, @tramp{} might give you as result the choice for
+If you, for example, type @kbd{C-x C-f @value{prefix}t
+@key{TAB}}, @value{tramp} might give you as result the choice for
 
 @example
 @ifset emacs
-@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}				   tmp/
-@value{tramp-prefix-single-hop}toto@value{tramp-postfix}
+@value{prefixsinglehop}telnet@value{postfixsinglehop}				   tmp/
+@value{prefixsinglehop}toto@value{postfix}
 @end ifset
 @ifset xemacs
-@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}				   @value{tramp-prefix-single-hop}toto@value{tramp-postfix}
+@value{prefixsinglehop}telnet@value{postfixsinglehop}				   @value{prefixsinglehop}toto@value{postfix}
 @end ifset
 @end example
 
-@samp{@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}}
+@samp{@value{prefixsinglehop}telnet@value{postfixsinglehop}}
 is a possible completion for the respective method,
 @ifset emacs
 @samp{tmp/} stands for the directory @file{/tmp} on your local
 machine,
 @end ifset
-and @samp{@value{tramp-prefix-single-hop}toto@value{tramp-postfix}}
-might be a host @tramp{} has detected in your @file{~/.ssh/known_hosts}
+and @samp{@value{prefixsinglehop}toto@value{postfix}}
+might be a host @value{tramp} has detected in your @file{~/.ssh/known_hosts}
 file (given you're using default method @option{ssh}).
 
 If you go on to type @kbd{e @key{TAB}}, the minibuffer is completed to
-@samp{@value{tramp-prefix}telnet@value{tramp-postfix-single-hop}}.
-Next @kbd{@key{TAB}} brings you all machine names @tramp{} detects in
+@samp{@value{prefix}telnet@value{postfixsinglehop}}.
+Next @kbd{@key{TAB}} brings you all machine names @value{tramp} detects in
 your @file{/etc/hosts} file, let's say
 
 @example
-@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}127.0.0.1@value{tramp-postfix}		   @value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}192.168.0.1@value{tramp-postfix}
-@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}localhost@value{tramp-postfix}		   @value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}melancholia.danann.net@value{tramp-postfix}
-@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}melancholia@value{tramp-postfix}
+@value{prefixsinglehop}telnet@value{postfixsinglehop}127.0.0.1@value{postfix}		   @value{prefixsinglehop}telnet@value{postfixsinglehop}192.168.0.1@value{postfix}
+@value{prefixsinglehop}telnet@value{postfixsinglehop}localhost@value{postfix}		   @value{prefixsinglehop}telnet@value{postfixsinglehop}melancholia.danann.net@value{postfix}
+@value{prefixsinglehop}telnet@value{postfixsinglehop}melancholia@value{postfix}
 @end example
 
 Now you can choose the desired machine, and you can continue to
 complete file names on that machine.
 
 As filename completion needs to fetch the listing of files from the
-remote machine, this feature is sometimes fairly slow.  As @tramp{}
+remote machine, this feature is sometimes fairly slow.  As @value{tramp}
 does not yet cache the results of directory listing, there is no gain
 in performance the second time you complete filenames.
 
 If the configuration files (@pxref{Customizing Completion}), which
-@tramp{} uses for analysis of completion, offer user names, those user
+@value{tramp} uses for analysis of completion, offer user names, those user
 names will be taken into account as well.
 
 
@@ -1802,7 +1876,7 @@
 @section Dired
 @cindex dired
 
-@tramp{} works transparently with dired, enabling you to use this powerful
+@value{tramp} works transparently with dired, enabling you to use this powerful
 file management tool to manage files on any machine you have access to
 over the Internet.
 
@@ -1815,11 +1889,11 @@
 @chapter Reporting Bugs and Problems
 @cindex bug reports
 
-Bugs and problems with @tramp{} are actively worked on by the development
+Bugs and problems with @value{tramp} are actively worked on by the development
 team. Feature requests and suggestions are also more than welcome.
 
-The @tramp{} mailing list is a great place to get information on working
-with @tramp{}, solving problems and general discussion and advice on topics
+The @value{tramp} mailing list is a great place to get information on working
+with @value{tramp}, solving problems and general discussion and advice on topics
 relating to the package.
 
 The  mailing list is at @email{tramp-devel@@mail.freesoftware.fsf.org}.
@@ -1830,9 +1904,9 @@
 address, @email{tramp-devel-request@@mail.freesoftware.fsf.org}, with the
 subject @samp{help}.
 
-To report a bug in @tramp{}, you should execute @kbd{M-x tramp-bug}. This
+To report a bug in @value{tramp}, you should execute @kbd{M-x tramp-bug}. This
 will automatically generate a buffer with the details of your system and
-@tramp{} version.
+@value{tramp} version.
 
 When submitting a bug report, please try to describe in excruciating
 detail the steps required to reproduce the problem, the setup of the
@@ -1849,9 +1923,9 @@
 
 @itemize @bullet
 @item
-Where can I get the latest @tramp{}?
-
-@tramp{} is available under the URL below.
+Where can I get the latest @value{tramp}?
+
+@value{tramp} is available under the URL below.
 
 @noindent
 @uref{http://savannah.nongnu.org/download/tramp/}
@@ -1871,10 +1945,10 @@
 
 The package was intended to work on Unix, and it really expects a
 Unix-like system on the remote end (except the @option{smb} method),
-but some people seemed to have some success getting it to work on NT
-Emacs.
-
-There is some informations on @tramp{} on NT at the following URL;
+but some people seemed to have some success getting it to work on MS
+Windows NT/2000/XP @value{emacsname}.
+
+There is some informations on @value{tramp} on NT at the following URL;
 many thanks to Joe Stoy for providing the information:
 @uref{ftp://ftp.comlab.ox.ac.uk/tmp/Joe.Stoy/}
 
@@ -1889,12 +1963,12 @@
 
 
 @item
-I can't stop @value{ftp-package-name} starting with @value{emacs-name}
+I can't stop @value{ftppackagename} starting with @value{emacsname}
 
 @ifset emacs
-@value{ftp-package-name} is loaded from @tramp{} automatically if you
+@value{ftppackagename} is loaded from @value{tramp} automatically if you
 require a file by the ftp method.  Unfortunately, there are some Lisp
-packages which make @value{ftp-package-name} file name handlers active.
+packages which make @value{ftppackagename} file name handlers active.
 You can see it applying @kbd{C-h v file-name-handler-alist}:
 
 @example
@@ -1907,27 +1981,27 @@
 @end example
 
 Please try to find out which package is responsible for loading
-@value{ftp-package-name}, and raise a bug report.
-
-A workaround is to require @value{ftp-package-name} before @tramp{} in
-your @file{~/.emacs}, because @tramp{} cleans up the entries in
+@value{ftppackagename}, and raise a bug report.
+
+A workaround is to require @value{ftppackagename} before @value{tramp} in
+your @file{~/.emacs}, because @value{tramp} cleans up the entries in
 @code{file-name-handler-alist}:
 
 @lisp
-;; @value{ftp-package-name} temporarily required
+;; @value{ftppackagename} temporarily required
 (require 'ange-ftp)
-;; @tramp{} cleans up @code{file-name-handler-alist}
+;; @value{tramp} cleans up @code{file-name-handler-alist}
 (require 'tramp)
 @end lisp
 @end ifset
 
 @ifset xemacs
-Not all the older versions of @tramp{} supported @value{emacs-name}
+Not all the older versions of @value{tramp} supported @value{emacsname}
 correctly.  The first thing to do is to make sure that you have the
-latest version of @tramp{} installed.
+latest version of @value{tramp} installed.
 
 If you do, please try and find out exactly the conditions required for
-the @value{ftp-package-name} handlers to fire.  If you can, putting a
+the @value{ftppackagename} handlers to fire.  If you can, putting a
 breakpoint on @code{efs-ftp-path} and sending in the stack trace along
 with your bug report would make it easier for the developers to work out
 what is going wrong.
@@ -1935,14 +2009,14 @@
 
 
 @item
-File name completion does not work with @tramp{}
+File name completion does not work with @value{tramp}
 
 When you log in to the remote machine, do you see the output of
 @command{ls} in color? If so, this may be the cause of your problems.
 
 @command{ls} outputs @acronym{ANSI} escape sequences that your terminal
 emulator interprets to set the colors.  These escape sequences will
-confuse @tramp{} however.
+confuse @value{tramp} however.
 
 In your @file{.bashrc}, @file{.profile} or equivalent on the remote
 machine you probably have an alias configured that adds the option
@@ -1950,13 +2024,13 @@
 
 You should remove that alias and ensure that a new login @emph{does not}
 display the output of @command{ls} in color.  If you still cannot use
-filename completion, report a bug to the @tramp{} developers.
+filename completion, report a bug to the @value{tramp} developers.
 
 
 @item
 File name completion does not work in large directories
 
-@tramp{} uses globbing for some operations.  (Globbing means to use the
+@value{tramp} uses globbing for some operations.  (Globbing means to use the
 shell to expand wildcards such as `*.c'.)  This might create long
 command lines, especially in directories with many files.  Some shells
 choke on long command lines, or don't cope well with the globbing
@@ -1970,18 +2044,10 @@
 
 
 @item
-What kinds of systems does @tramp{} work on
-
-@tramp{} really expects the remote system to be a Unix-like system.  The
-local system should preferably be Unix-like, as well, but @tramp{} might
-work on NT with some tweaking.
-
-
-@item
-How can I get notified when @tramp{} file transfers are complete?
+How can I get notified when @value{tramp} file transfers are complete?
 
 The following snippet can be put in your @file{~/.emacs} file.  It
-makes @value{emacs-name} beep after reading from or writing to the
+makes @value{emacsname} beep after reading from or writing to the
 remote host.
 
 @lisp
@@ -2007,8 +2073,8 @@
 There's this @file{~/.sh_history} file on the remote host which keeps
 growing and growing.  What's that?
 
-Sometimes, @tramp{} starts @code{ksh} on the remote host for tilde
-expansion.  Maybe @code{ksh} saves the history by default.  @tramp{}
+Sometimes, @value{tramp} starts @code{ksh} on the remote host for tilde
+expansion.  Maybe @code{ksh} saves the history by default.  @value{tramp}
 tries to turn off saving the history, but maybe you have to help.  For
 example, you could put this in your @file{.kshrc}:
 
@@ -2025,7 +2091,7 @@
 @end example
 
 
-@item @tramp{} doesn't transfer strings with more than 500 characters
+@item @value{tramp} doesn't transfer strings with more than 500 characters
 correctly
 
 On some few systems, the implementation of @code{process-send-string}
@@ -2042,16 +2108,16 @@
 @chapter The inner workings of remote version control
 @cindex Version Control
 
-Unlike @value{ftp-package-name}, @tramp{} has full shell access to the
+Unlike @value{ftppackagename}, @value{tramp} has full shell access to the
 remote machine. This makes it possible to provide version control for
-files accessed under @tramp{}.
+files accessed under @value{tramp}.
 
 The actual version control binaries must be installed on the remote
 machine, accessible in the directories specified in
 @var{tramp-remote-path}.
 
 This transparent integration with the version control systems is one of
-the most valuable features provided by @tramp{}, but it is far from perfect.
+the most valuable features provided by @value{tramp}, but it is far from perfect.
 Work is ongoing to improve the transparency of the system.
 
 @menu
@@ -2068,7 +2134,7 @@
 
 The VC package uses the existence of on-disk revision control master
 files to determine if a given file is under revision control. These file
-tests happen on the remote machine through the standard @tramp{} mechanisms.
+tests happen on the remote machine through the standard @value{tramp} mechanisms.
 
 
 @node Remote Commands
@@ -2082,7 +2148,7 @@
 
 To work around this, the functions @code{vc-do-command} and
 @code{vc-simple-command} have been advised to intercept requests for
-operations on files accessed via @tramp{}.
+operations on files accessed via @value{tramp}.
 
 In the case of a remote file, the @code{shell-command} interface is
 used, with some wrapper code, to provide the same functionality on the
@@ -2094,7 +2160,7 @@
 
 As there is currently no way to get access to the mtime of a file on a
 remote machine in a portable way, the @code{vc-workfile-unchanged-p}
-function is advised to call an @tramp{} specific function for remote files.
+function is advised to call an @value{tramp} specific function for remote files.
 
 The @code{tramp-vc-workfile-unchanged-p} function uses the functioning VC
 diff functionality to determine if any changes have occurred between the
@@ -2111,7 +2177,7 @@
 
 VC will, by default, check for remote files and refuse to act on them
 when checking out files from the repository. To work around this
-problem, the function @code{vc-checkout} knows about @tramp{} files and
+problem, the function @code{vc-checkout} knows about @value{tramp} files and
 allows version control to occur.
 
 
@@ -2129,7 +2195,7 @@
 @node Remote File Ownership
 @subsection How VC determines who owns a workfile
 
-@value{emacs-name} provides the @code{user-full-name} function to
+@value{emacsname} provides the @code{user-full-name} function to
 return the login name of the current user as well as mapping from
 arbitrary user id values back to login names. The VC code uses this
 functionality to map from the uid of the owner of a workfile to the
@@ -2171,9 +2237,9 @@
 of the version control tools and, while this is painful, we need to
 ensure that unavailable features are not used remotely.
 
-To resolve this issue, @tramp{} currently takes the sledgehammer
+To resolve this issue, @value{tramp} currently takes the sledgehammer
 approach of making the release values of the revision control tools
-local to each @tramp{} buffer, forcing VC to determine these values
+local to each @value{tramp} buffer, forcing VC to determine these values
 again each time a new file is visited.
 
 This has, quite obviously, some performance implications. Thankfully,
@@ -2181,7 +2247,7 @@
 that the remote version be known. This makes the problem far less
 apparent.
 
-Eventually these values will be captured by @tramp{} on a system by
+Eventually these values will be captured by @value{tramp} on a system by
 system basis and the results cached to improve performance.
 
 
@@ -2196,17 +2262,17 @@
 @node Localname deconstruction
 @section Breaking a localname into its components.
 
-@tramp{} file names are somewhat different, obviously, to ordinary file
+@value{tramp} file names are somewhat different, obviously, to ordinary file
 names. As such, the lisp functions @code{file-name-directory} and
-@code{file-name-nondirectory} are overridden within the @tramp{}
+@code{file-name-nondirectory} are overridden within the @value{tramp}
 package.
 
 Their replacements are reasonably simplistic in their approach. They
 dissect the filename, call the original handler on the localname and
-then rebuild the @tramp{} file name with the result.
+then rebuild the @value{tramp} file name with the result.
 
 This allows the platform specific hacks in the original handlers to take
-effect while preserving the @tramp{} file name information.
+effect while preserving the @value{tramp} file name information.
 
 
 @node Issues
@@ -2215,7 +2281,7 @@
 @itemize @bullet
 @item The uuencode method does not always work.
 
-Due to the design of @tramp{}, the encoding and decoding programs need to
+Due to the design of @value{tramp}, the encoding and decoding programs need to
 read from stdin and write to stdout.  On some systems, @code{uudecode -o
 -} will read stdin and write the decoded file to stdout, on other
 systems @code{uudecode -p} does the same thing.  But some systems have
@@ -2231,29 +2297,29 @@
 But I have decided that this is too fragile to reliably work, so on some
 systems you'll have to do without the uuencode methods.
 
-@item @tramp{} does not work on XEmacs 20.
+@item @value{tramp} does not work on XEmacs 20.
 
 This is because it requires the macro @code{with-timeout} which does not
 appear to exist in XEmacs 20.  I'm somewhat reluctant to add an
-emulation macro to @tramp{}, but if somebody who uses XEmacs 20 steps
+emulation macro to @value{tramp}, but if somebody who uses XEmacs 20 steps
 forward and wishes to implement and test it, please contact me or the
 mailing list.
 
-@item The @tramp{} filename syntax differs between Emacs and XEmacs.
+@item The @value{tramp} filename syntax differs between Emacs and XEmacs.
 
 The Emacs maintainers wish to use a unified filename syntax for
-Ange-FTP and @tramp{} so that users don't have to learn a new
+Ange-FTP and @value{tramp} so that users don't have to learn a new
 syntax.  It is sufficient to learn some extensions to the old syntax.
 
 For the XEmacs maintainers, the problems caused from using a unified
 filename syntax are greater than the gains.  The XEmacs package system
 uses EFS for downloading new packages.  So, obviously, EFS has to be
-installed from the start.  If the filenames were unified, @tramp{}
+installed from the start.  If the filenames were unified, @value{tramp}
 would have to be installed from the start, too.
 
 @ifset xemacs
 @strong{Note:} If you'ld like to use a similar syntax like
-@value{ftp-package-name}, you need the following settings in your init
+@value{ftppackagename}, you need the following settings in your init
 file:
 
 @lisp
@@ -2261,17 +2327,17 @@
 (require 'tramp)
 @end lisp
 
-The autoload of the @value{emacs-name} @tramp{} package must be
+The autoload of the @value{emacsname} @value{tramp} package must be
 disabled.  This can be achieved by setting file permissions @code{000}
 to the files @file{.../xemacs-packages/lisp/tramp/auto-autoloads.el*}.
 
-In case of unified filenames, all @value{emacs-name} download sites
+In case of unified filenames, all @value{emacsname} download sites
 are added to @code{tramp-default-method-alist} with default method
 @code{ftp} @xref{Default Method}.  These settings shouldn't be touched
-for proper working of the @value{emacs-name} package system.
-
-The syntax for unified filenames is described in the @tramp{} manual
-for @value{emacs-other-name}.
+for proper working of the @value{emacsname} package system.
+
+The syntax for unified filenames is described in the @value{tramp} manual
+for @value{emacsothername}.
 @end ifset
 
 @end itemize
--- a/man/trampver.texi	Sat May 08 16:20:28 2004 +0000
+++ b/man/trampver.texi	Sat May 08 20:22:26 2004 +0000
@@ -4,15 +4,16 @@
 @c In the Tramp CVS, the version number is auto-frobbed from
 @c configure.ac, so you should edit that file and run
 @c "autoconf && ./configure" to change the version number.
-@macro trampver{}
-2.0.39
-@end macro
+@set trampver 2.0.40
 
 @c Other flags from configuration
 @set prefix /usr/local
 @set lispdir /usr/local/share/emacs/site-lisp
 @set infodir /usr/local/info
 
+@c Formatting of the tramp program name consistent.
+@set tramp @sc{tramp}
+
 @c Some flags which make the text independent on the (X)Emacs flavor.
 @c "emacs" resp "xemacs" are set in the Makefile.  Default is "emacs".
 
@@ -24,41 +25,36 @@
 
 @c Emacs values.
 @ifset emacs
-@set emacs-name               Emacs
-@set emacs-dir                emacs
-@set ftp-package-name         Ange-FTP
-@set tramp-prefix             /
-@set tramp-prefix-single-hop
-@set tramp-postfix            :
-@set tramp-postfix-single-hop :
-@set tramp-postfix-multi-hop  :
-@set japanese-manual          tramp_ja-emacs.html
+@set emacsname          Emacs
+@set emacsdir           emacs
+@set ftppackagename     Ange-FTP
+@set prefix             /
+@set prefixsinglehop
+@set postfix            :
+@set postfixsinglehop   :
+@set postfixmultihop    :
+@set emacsothername     XEmacs
+@set emacsotherdir      xemacs
+@set emacsotherfilename tramp-xemacs.html
+@set japanesemanual     tramp_ja-emacs.html
 @end ifset
 
 @c XEmacs counterparts.
 @ifset xemacs
-@set emacs-name               XEmacs
-@set emacs-dir                xemacs
-@set ftp-package-name         EFS
-@set tramp-prefix             /[
-@set tramp-prefix-single-hop  [
-@set tramp-postfix            ]
-@set tramp-postfix-single-hop /
-@set tramp-postfix-multi-hop  :
-@set japanese-manual          tramp_ja-xemacs.html
+@set emacsname          XEmacs
+@set emacsdir           xemacs
+@set ftppackagename     EFS
+@set prefix             /[
+@set prefixsinglehop    [
+@set postfix            ]
+@set postfixsinglehop   /
+@set postfixmultihop    :
+@set emacsothername     Emacs
+@set emacsotherdir      emacs
+@set emacsotherfilename tramp-emacs.html
+@set japanesemanual     tramp_ja-xemacs.html
 @end ifset
 
-@c Empty macro definitions in order to satisfy texi2dvi
-@macro otherflavor
-@end macro
-
-@macro installationchapter
-@end macro
-
-@c The installation chapter is needed only in case Tramp is installed
-@c standalone.  That's why it is included from `trampinst.texi'.
-@c Otherwise, '/dev/null/' is taken, which leaves this part empty.
-
 @ignore
    arch-tag: e0fe322c-e06b-46eb-bb5b-d091b521f41c
 @end ignore
--- a/src/ChangeLog	Sat May 08 16:20:28 2004 +0000
+++ b/src/ChangeLog	Sat May 08 20:22:26 2004 +0000
@@ -1,3 +1,25 @@
+2004-05-08  Juanma Barranquero  <lektu@terra.es>
+
+	* editfns.c (Finsert_buffer_substring): Make argument names match their
+	use in docstring.
+
+	* syntax.c (Fmodify_syntax_entry): Fix docstring.
+
+2004-05-07  Steven Tamm  <steventamm@mac.com>
+
+	* macterm.c (mac_check_for_quit_char): Adding BLOCK_INPUT
+	around call to ReceiveEvent to avoid certain crashes.
+
+2004-05-07  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
+	* macterm.c (mac_draw_line_to_pixmap, XCreatePixmapFromBitmapData)
+	(mac_fill_rectangle_to_pixmap, mac_draw_rectangle_to_pixmap)
+	(mac_copy_area_to_pixmap, mac_copy_area_with_mask_to_pixmap):
+	Save/restore the current graphics port and device handle when
+	drawing into an offscreen graphics world.
+
+	* image.c [MAC_OS] (XPutPixel, XGetPixel, image_load_qt_1)
+	(gif_load): Likewise.
+
 2004-05-07  Juanma Barranquero  <lektu@terra.es>
 
 	* window.c (Fset_window_buffer): Fix docstring.
--- a/src/editfns.c	Sat May 08 16:20:28 2004 +0000
+++ b/src/editfns.c	Sat May 08 20:22:26 2004 +0000
@@ -2347,21 +2347,21 @@
 
 DEFUN ("insert-buffer-substring", Finsert_buffer_substring, Sinsert_buffer_substring,
        1, 3, 0,
-       doc: /* Insert before point a substring of the contents of buffer BUFFER.
+       doc: /* Insert before point a substring of the contents of BUFFER.
 BUFFER may be a buffer or a buffer name.
 Arguments START and END are character numbers specifying the substring.
 They default to the beginning and the end of BUFFER.  */)
-     (buf, start, end)
-     Lisp_Object buf, start, end;
+     (buffer, start, end)
+     Lisp_Object buffer, start, end;
 {
   register int b, e, temp;
   register struct buffer *bp, *obuf;
-  Lisp_Object buffer;
-
-  buffer = Fget_buffer (buf);
-  if (NILP (buffer))
-    nsberror (buf);
-  bp = XBUFFER (buffer);
+  Lisp_Object buf;
+
+  buf = Fget_buffer (buffer);
+  if (NILP (buf))
+    nsberror (buffer);
+  bp = XBUFFER (buf);
   if (NILP (bp->name))
     error ("Selecting deleted buffer");
 
--- a/src/image.c	Sat May 08 16:20:28 2004 +0000
+++ b/src/image.c	Sat May 08 20:22:26 2004 +0000
@@ -174,14 +174,19 @@
      int x, y;
      unsigned long pixel;
 {
+  CGrafPtr old_port;
+  GDHandle old_gdh;
   RGBColor color;
 
+  GetGWorld (&old_port, &old_gdh);
   SetGWorld (ximage, NULL);
 
   color.red = RED16_FROM_ULONG (pixel);
   color.green = GREEN16_FROM_ULONG (pixel);
   color.blue = BLUE16_FROM_ULONG (pixel);
   SetCPixel (x, y, &color);
+
+  SetGWorld (old_port, old_gdh);
 }
 
 static unsigned long
@@ -189,11 +194,16 @@
      XImagePtr ximage;
      int x, y;
 {
+  CGrafPtr old_port;
+  GDHandle old_gdh;
   RGBColor color;
 
+  GetGWorld (&old_port, &old_gdh);
   SetGWorld (ximage, NULL);
 
   GetCPixel (x, y, &color);
+
+  SetGWorld (old_port, old_gdh);
   return RGB_TO_ULONG (color.red >> 8, color.green >> 8, color.blue >> 8);
 }
 
@@ -2196,6 +2206,10 @@
     goto error;
   if (draw_all_pixels != graphicsImporterDrawsAllPixels)
     {
+      CGrafPtr old_port;
+      GDHandle old_gdh;
+
+      GetGWorld (&old_port, &old_gdh);
       SetGWorld (ximg, NULL);
       bg_color.red = color.red;
       bg_color.green = color.green;
@@ -2207,6 +2221,7 @@
 #else
       EraseRect (&(ximg->portRect));
 #endif
+      SetGWorld (old_port, old_gdh);
     }
   GraphicsImportSetGWorld (gi, ximg, NULL);
   GraphicsImportDraw (gi);
@@ -6883,6 +6898,8 @@
   TimeValue time;
   struct gcpro gcpro1;
   int ino;
+  CGrafPtr old_port;
+  GDHandle old_gdh;
 
   specified_file = image_spec_value (img->spec, QCfile, NULL);
   specified_data = image_spec_value (img->spec, QCdata, NULL);
@@ -7000,11 +7017,13 @@
   if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
     goto error;
 
+  GetGWorld (&old_port, &old_gdh);
   SetGWorld (ximg, NULL);
   bg_color.red = color.red;
   bg_color.green = color.green;
   bg_color.blue = color.blue;
   RGBBackColor (&bg_color);
+  SetGWorld (old_port, old_gdh);
   SetMovieActive (movie, TRUE);
   SetMovieGWorld (movie, ximg, NULL);
   SampleNumToMediaTime (media, ino + 1, &time, NULL);
--- a/src/macterm.c	Sat May 08 16:20:28 2004 +0000
+++ b/src/macterm.c	Sat May 08 20:22:26 2004 +0000
@@ -383,6 +383,10 @@
      GC gc;
      int x1, y1, x2, y2;
 {
+  CGrafPtr old_port;
+  GDHandle old_gdh;
+
+  GetGWorld (&old_port, &old_gdh);
   SetGWorld (p, NULL);
 
   mac_set_colors (gc);
@@ -391,6 +395,8 @@
   MoveTo (x1, y1);
   LineTo (x2, y2);
   UnlockPixels (GetGWorldPixMap (p));
+
+  SetGWorld (old_port, old_gdh);
 }
 
 /* Mac version of XClearArea.  */
@@ -620,11 +626,14 @@
 {
   Pixmap pixmap;
   BitMap bitmap;
+  CGrafPtr old_port;
+  GDHandle old_gdh;
 
   pixmap = XCreatePixmap (display, w, width, height, depth);
   if (pixmap == NULL)
     return NULL;
 
+  GetGWorld (&old_port, &old_gdh);
   SetGWorld (pixmap, NULL);
   mac_create_bitmap_from_bitmap_data (&bitmap, data, width, height);
   mac_set_forecolor (fg);
@@ -638,6 +647,7 @@
 	    &bitmap.bounds, &bitmap.bounds, srcCopy, 0);
 #endif /* not TARGET_API_MAC_CARBON */
   UnlockPixels (GetGWorldPixMap (pixmap));
+  SetGWorld (old_port, old_gdh);
   mac_free_bitmap (&bitmap);
 
   return pixmap;
@@ -677,8 +687,11 @@
      int x, y;
      unsigned int width, height;
 {
+  CGrafPtr old_port;
+  GDHandle old_gdh;
   Rect r;
 
+  GetGWorld (&old_port, &old_gdh);
   SetGWorld (p, NULL);
   mac_set_colors (gc);
   SetRect (&r, x, y, x + width, y + height);
@@ -686,6 +699,8 @@
   LockPixels (GetGWorldPixMap (p));
   PaintRect (&r); /* using foreground color of gc */
   UnlockPixels (GetGWorldPixMap (p));
+
+  SetGWorld (old_port, old_gdh);
 }
 
 
@@ -724,8 +739,11 @@
      int x, y;
      unsigned int width, height;
 {
+  CGrafPtr old_port;
+  GDHandle old_gdh;
   Rect r;
 
+  GetGWorld (&old_port, &old_gdh);
   SetGWorld (p, NULL);
   mac_set_colors (gc);
   SetRect (&r, x, y, x + width + 1, y + height + 1);
@@ -733,6 +751,8 @@
   LockPixels (GetGWorldPixMap (p));
   FrameRect (&r); /* using foreground color of gc */
   UnlockPixels (GetGWorldPixMap (p));
+
+  SetGWorld (old_port, old_gdh);
 }
 
 
@@ -1003,8 +1023,11 @@
      unsigned int width, height;
      int dest_x, dest_y;
 {
+  CGrafPtr old_port;
+  GDHandle old_gdh;
   Rect src_r, dest_r;
 
+  GetGWorld (&old_port, &old_gdh);
   SetGWorld (dest, NULL);
   ForeColor (blackColor);
   BackColor (whiteColor);
@@ -1023,6 +1046,8 @@
 #endif /* not TARGET_API_MAC_CARBON */
   UnlockPixels (GetGWorldPixMap (dest));
   UnlockPixels (GetGWorldPixMap (src));
+
+  SetGWorld (old_port, old_gdh);
 }
 
 
@@ -1036,8 +1061,11 @@
      unsigned int width, height;
      int dest_x, dest_y;
 {
+  CGrafPtr old_port;
+  GDHandle old_gdh;
   Rect src_r, dest_r;
 
+  GetGWorld (&old_port, &old_gdh);
   SetGWorld (dest, NULL);
   ForeColor (blackColor);
   BackColor (whiteColor);
@@ -1058,6 +1086,8 @@
   UnlockPixels (GetGWorldPixMap (dest));
   UnlockPixels (GetGWorldPixMap (mask));
   UnlockPixels (GetGWorldPixMap (src));
+
+  SetGWorld (old_port, old_gdh);
 }
 
 
@@ -8980,9 +9010,11 @@
   mac_determine_quit_char_modifiers ();
 
   /* Fill the queue with events */
+  BLOCK_INPUT;
   ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &event);
   event = FindSpecificEventInQueue (GetMainEventQueue (), quit_char_comp,
 				    NULL);
+  UNBLOCK_INPUT;
   if (event)
     {
       struct input_event e;
--- a/src/syntax.c	Sat May 08 16:20:28 2004 +0000
+++ b/src/syntax.c	Sat May 08 20:22:26 2004 +0000
@@ -977,7 +977,7 @@
 DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3,
   "cSet syntax for character: \nsSet syntax for %s to: ",
        doc: /* Set syntax for character CHAR according to string NEWENTRY.
-The syntax is changed only for table SYNTAX_TABLE, which defaults to
+The syntax is changed only for table SYNTAX-TABLE, which defaults to
  the current buffer's syntax table.
 The first character of NEWENTRY should be one of the following:
   Space or -  whitespace syntax.    w   word constituent.
@@ -1517,12 +1517,12 @@
     if (forwardp)
       {
 	endp = (XINT (lim) == GPT) ? GPT_ADDR : CHAR_POS_ADDR (XINT (lim));
-	stop = (pos < GPT && GPT < XINT (lim)) ? GPT_ADDR : endp; 
+	stop = (pos < GPT && GPT < XINT (lim)) ? GPT_ADDR : endp;
       }
     else
       {
 	endp = CHAR_POS_ADDR (XINT (lim));
-	stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp; 
+	stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp;
       }
 
     immediate_quit = 1;