Mercurial > emacs
changeset 93040:ba82da0cb626
* net/tramp.el (tramp-root-regexp): Simplify.
(tramp-completion-file-name-regexp-separate): Don't insist on
leading "[". This prevents method or user or host completion.
(tramp-let-maybe): Autoload it.
(tramp-drop-volume-letter): Don't autoload. When not on W32, it is
an alias for `identity'.
(tramp-handle-write-region): Protect `last-coding-system-used'
over the trailing statements.
(tramp-completion-file-name-handler-post-function): Removed.
(tramp-completion-file-name-handler): Let-bind
`directory-sep-char' instead of calling
`tramp-drop-volume-letter'.
(top): Move coding cookie at the end.
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Mon, 17 Mar 2008 22:54:28 +0000 |
parents | e48df1ee4371 |
children | dd3ebf4e05d4 |
files | lisp/net/tramp.el |
diffstat | 1 files changed, 42 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/net/tramp.el Mon Mar 17 21:58:19 2008 +0000 +++ b/lisp/net/tramp.el Mon Mar 17 22:54:28 2008 +0000 @@ -1,12 +1,11 @@ ;;; tramp.el --- Transparent Remote Access, Multiple Protocol -;;; -*- mode: Emacs-Lisp; coding: utf-8; -*- ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. ;; (copyright statements below in code to be updated with the above notice) -;; Author: Kai Großjohann <kai.grossjohann@gmx.net> +;; Author: Kai Großjohann <kai.grossjohann@gmx.net> ;; Michael Albinus <michael.albinus@gmx.de> ;; Keywords: comm, processes @@ -1267,12 +1266,11 @@ ;;;###autoload (defconst tramp-root-regexp (if (memq system-type '(cygwin windows-nt)) - "^/$\\|^\\([a-zA-Z]:\\)?\\(/\\|\\\\\\(\\\\\\)?\\)" - "^/$\\|^/") + "^\\([a-zA-Z]:\\)?/" + "^/") "Beginning of an incomplete Tramp file name. Usually, it is just \"^/\". On W32 systems, there might be a -volume letter, which will be removed by `tramp-drop-volume-letter'. -It could be either \"^x:/\", either \"^x:\\\\\".") +volume letter, which will be removed by `tramp-drop-volume-letter'.") ;;;###autoload (defconst tramp-completion-file-name-regexp-unified @@ -1283,7 +1281,7 @@ ;;;###autoload (defconst tramp-completion-file-name-regexp-separate - (concat tramp-root-regexp "[[][^]]*$") + (concat tramp-root-regexp "\\([[][^]]*\\)?$") "Value for `tramp-completion-file-name-regexp' for separate remoting. XEmacs uses a separate filename syntax for Tramp and EFS. See `tramp-file-name-structure' for more explanations.") @@ -1959,6 +1957,7 @@ (put 'with-connection-property 'edebug-form-spec t) (font-lock-add-keywords 'emacs-lisp-mode '("\\<with-connection-property\\>")) +;;;###autoload (defmacro tramp-let-maybe (variable value &rest body) "Let-bind VARIABLE to VALUE in BODY, but only if VARIABLE is not obsolete. BODY is executed whether or not the variable is obsolete. @@ -3498,19 +3497,16 @@ ;; Canonicalization of file names. -;;;###autoload -(defun tramp-drop-volume-letter (name) - "Cut off unnecessary drive letter from file NAME. +(if (memq system-type '(cygwin windows-nt)) + (defun tramp-drop-volume-letter (name) + "Cut off unnecessary drive letter from file NAME. The function `tramp-handle-expand-file-name' calls `expand-file-name' locally on a remote file name. When the local system is a W32 system but the remote system is Unix, this introduces a superfluous drive -letter into the file name. This function removes it. - -Doesn't do anything if the NAME does not start with a drive letter." - (save-match-data - (if (and (stringp name) (string-match tramp-root-regexp name)) - (replace-match "/" nil nil name) - name))) +letter into the file name. This function removes it." + (save-match-data (replace-regexp-in-string tramp-root-regexp "/" name))) + + (defalias 'tramp-drop-volume-letter 'identity)) (defun tramp-handle-expand-file-name (name &optional dir) "Like `expand-file-name' for Tramp files. @@ -4274,19 +4270,22 @@ (when coding-system-used (set 'last-coding-system-used coding-system-used)))) - ;; Set file modification time. - (when (or (eq visit t) (stringp visit)) - (set-visited-file-modtime - ;; We must pass modtime explicitely, because filename can - ;; be different from (buffer-file-name), f.e. if - ;; `file-precious-flag' is set. - (nth 5 (file-attributes filename)))) - - ;; Set the ownership. - (tramp-set-file-uid-gid filename uid gid) - (when (or (eq visit t) (null visit) (stringp visit)) - (tramp-message v 0 "Wrote %s" filename)) - (run-hooks 'tramp-handle-write-region-hook)))) + ;; We must protect `last-coding-system-used', now we have set it + ;; to its correct value. + (let (last-coding-system-used) + ;; Set file modification time. + (when (or (eq visit t) (stringp visit)) + (set-visited-file-modtime + ;; We must pass modtime explicitely, because filename can + ;; be different from (buffer-file-name), f.e. if + ;; `file-precious-flag' is set. + (nth 5 (file-attributes filename)))) + + ;; Set the ownership. + (tramp-set-file-uid-gid filename uid gid) + (when (or (eq visit t) (null visit) (stringp visit)) + (tramp-message v 0 "Wrote %s" filename)) + (run-hooks 'tramp-handle-write-region-hook))))) ;;;###autoload (progn (defun tramp-run-real-handler (operation args) @@ -4493,25 +4492,16 @@ (setq tramp-locked tl)))) ;;;###autoload -(defconst tramp-completion-file-name-handler-post-function - (if (and (featurep 'xemacs) (memq system-type '(cygwin windows-nt))) - 'tramp-drop-volume-letter - 'identity) - "Function to be called on the result of `tramp-completion-file-name-handler'. -For GNU Emacs, handling of `file-name-all-completions' and -`file-name-completion' is sufficient. In the XEmacs case, there -are more disturbing drive letters.") - -;;;###autoload (progn (defun tramp-completion-file-name-handler (operation &rest args) "Invoke Tramp file name completion handler. Falls back to normal file name handler if no Tramp file name handler exists." - (funcall - tramp-completion-file-name-handler-post-function - (let ((fn (assoc operation tramp-completion-file-name-handler-alist))) - (if fn - (save-match-data (apply (cdr fn) args)) - (tramp-completion-run-real-handler operation args)))))) + ;; We bind `directory-sep-char' here for XEmacs on Windows, which + ;; would otherwise use backslash. + (tramp-let-maybe directory-sep-char ?/ + (let ((fn (assoc operation tramp-completion-file-name-handler-alist))) + (if fn + (save-match-data (apply (cdr fn) args)) + (tramp-completion-run-real-handler operation args)))))) ;;;###autoload (defsubst tramp-register-file-name-handler () @@ -7353,7 +7343,6 @@ ;; * Autodetect if remote `ls' groks the "--dired" switch. ;; * Rewrite `tramp-shell-quote-argument' to abstain from using ;; `shell-quote-argument'. -;; * Completion gets confused when you leave out the method name. ;; * 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) @@ -7361,10 +7350,6 @@ ;; * When logging in, keep looking for questions according to an alist ;; and then invoke the right function. ;; * Case-insensitive filename completion. (Norbert Goevert.) -;; * Running CVS remotely doesn't appear to work right. It thinks -;; files are locked by somebody else even if I'm the locking user. -;; Sometimes, one gets `No CVSROOT specified' errors from CVS. -;; (Skip Montanaro) ;; * Don't use globbing for directories with many files, as this is ;; likely to produce long command lines, and some shells choke on ;; long command lines. @@ -7383,7 +7368,7 @@ ;; transfer method to use. (Greg Stark) ;; * Remove unneeded parameters from methods. ;; * Invoke rsync once for copying a whole directory hierarchy. -;; (Francesco Potortì) +;; (Francesco Potortì) ;; * Make it work for different encodings, and for different file name ;; encodings, too. (Daniel Pittman) ;; * Progress reports while copying files. (Michael Kifer) @@ -7438,3 +7423,8 @@ ;;; arch-tag: 3a21a994-182b-48fa-b0cd-c1d9fede424a ;;; tramp.el ends here + +;; Local Variables: +;; mode: Emacs-Lisp +;; coding: utf-8 +;; End: