diff options
| author | Michael Albinus | 2009-09-02 11:15:56 +0000 |
|---|---|---|
| committer | Michael Albinus | 2009-09-02 11:15:56 +0000 |
| commit | e5aa47f99367af4663ebf0a87bae83e23cc4085e (patch) | |
| tree | 063b428f4c2ee8ba60ef5e2b52877d63203a65d8 | |
| parent | 7f49fe463d55007ff962d9fe217add604921fba8 (diff) | |
| download | emacs-e5aa47f99367af4663ebf0a87bae83e23cc4085e.tar.gz emacs-e5aa47f99367af4663ebf0a87bae83e23cc4085e.zip | |
* net/tramp-compat.el (top): Autoload used functions from
tramp.el.
(file-remote-p, process-file, start-file-process, set-file-times)
(tramp-compat-file-attributes): Compatibility functions shall not
call directly `tramp-handle-*', because this would bypass the
locking mechanism.
(tramp-compat-number-sequence): New defun.
| -rw-r--r-- | lisp/ChangeLog | 30 | ||||
| -rw-r--r-- | lisp/net/tramp-compat.el | 63 |
2 files changed, 84 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 72ffb0d0de5..58139d07651 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,33 @@ | |||
| 1 | 2009-09-02 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * net/tramp.el (tramp-handle-file-attributes-with-ls) | ||
| 4 | (tramp-do-file-attributes-with-perl) | ||
| 5 | (tramp-do-file-attributes-with-stat): Rename from | ||
| 6 | `tramp-handle-file-attributes-with-*'. | ||
| 7 | (tramp-handle-file-attributes): Use them. | ||
| 8 | (tramp-do-directory-files-and-attributes-with-perl) | ||
| 9 | (tramp-do-directory-files-and-attributes-with-stat): Rename from | ||
| 10 | `tramp-handle-directory-files-and-attributes-with-*'. | ||
| 11 | (tramp-handle-directory-files-and-attributes): Use them. | ||
| 12 | (tramp-method-out-of-band-p): Additional parameter SIZE. | ||
| 13 | (tramp-do-copy-or-rename-file, tramp-handle-file-local-copy) | ||
| 14 | (tramp-handle-write-region): Use it. | ||
| 15 | (tramp-handle-insert-directory): Use "?\ " for compatibility | ||
| 16 | reasons. | ||
| 17 | (tramp-handle-vc-registered): Check, whether the first run did | ||
| 18 | return files to be tested. | ||
| 19 | (tramp-advice-make-auto-save-file-name): Do not call directly | ||
| 20 | `tramp-handle-make-auto-save-file-name', because this would bypass | ||
| 21 | the locking mechanism. | ||
| 22 | |||
| 23 | * net/tramp-compat.el (top): Autoload used functions from | ||
| 24 | tramp.el. | ||
| 25 | (file-remote-p, process-file, start-file-process, set-file-times) | ||
| 26 | (tramp-compat-file-attributes): Compatibility functions shall not | ||
| 27 | call directly `tramp-handle-*', because this would bypass the | ||
| 28 | locking mechanism. | ||
| 29 | (tramp-compat-number-sequence): New defun. | ||
| 30 | |||
| 1 | 2009-09-02 Glenn Morris <rgm@gnu.org> | 31 | 2009-09-02 Glenn Morris <rgm@gnu.org> |
| 2 | 32 | ||
| 3 | * calendar/time-date.el (time-to-seconds): In Emacs, make it an obsolete | 33 | * calendar/time-date.el (time-to-seconds): In Emacs, make it an obsolete |
diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index a4b3dc7728f..3a10a0c3c37 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el | |||
| @@ -42,6 +42,9 @@ | |||
| 42 | (require 'timer-funcs) | 42 | (require 'timer-funcs) |
| 43 | (require 'timer)) | 43 | (require 'timer)) |
| 44 | 44 | ||
| 45 | (autoload 'tramp-tramp-file-p "tramp") | ||
| 46 | (autoload 'tramp-file-name-handler "tramp") | ||
| 47 | |||
| 45 | ;; tramp-util offers integration into other (X)Emacs packages like | 48 | ;; tramp-util offers integration into other (X)Emacs packages like |
| 46 | ;; compile.el, gud.el etc. Not necessary in Emacs 23. | 49 | ;; compile.el, gud.el etc. Not necessary in Emacs 23. |
| 47 | (eval-after-load "tramp" | 50 | (eval-after-load "tramp" |
| @@ -99,24 +102,46 @@ | |||
| 99 | (unless (fboundp 'font-lock-add-keywords) | 102 | (unless (fboundp 'font-lock-add-keywords) |
| 100 | (defalias 'font-lock-add-keywords 'ignore)) | 103 | (defalias 'font-lock-add-keywords 'ignore)) |
| 101 | 104 | ||
| 105 | ;; The following functions cannot be aliases of the corresponding | ||
| 106 | ;; `tramp-handle-*' functions, because this would bypass the locking | ||
| 107 | ;; mechanism. | ||
| 108 | |||
| 102 | ;; `file-remote-p' has been introduced with Emacs 22. The version | 109 | ;; `file-remote-p' has been introduced with Emacs 22. The version |
| 103 | ;; of XEmacs is not a magic file name function (yet); this is | 110 | ;; of XEmacs is not a magic file name function (yet); this is |
| 104 | ;; corrected in tramp-util.el. Here it is sufficient if the | 111 | ;; corrected in tramp-util.el. Here it is sufficient if the |
| 105 | ;; function exists. | 112 | ;; function exists. |
| 106 | (unless (fboundp 'file-remote-p) | 113 | (unless (fboundp 'file-remote-p) |
| 107 | (defalias 'file-remote-p 'tramp-handle-file-remote-p)) | 114 | (defalias 'file-remote-p |
| 115 | (lambda (file &optional identification connected) | ||
| 116 | (when (tramp-tramp-file-p file) | ||
| 117 | (tramp-file-name-handler | ||
| 118 | 'file-remote-p file identification connected))))) | ||
| 108 | 119 | ||
| 109 | ;; `process-file' exists since Emacs 22. | 120 | ;; `process-file' exists since Emacs 22. |
| 110 | (unless (fboundp 'process-file) | 121 | (unless (fboundp 'process-file) |
| 111 | (defalias 'process-file 'tramp-handle-process-file)) | 122 | (defalias 'process-file |
| 123 | (lambda (program &optional infile buffer display &rest args) | ||
| 124 | (when (tramp-tramp-file-p default-directory) | ||
| 125 | (apply | ||
| 126 | 'tramp-file-name-handler | ||
| 127 | 'process-file program infile buffer display args))))) | ||
| 112 | 128 | ||
| 113 | ;; `start-file-process' is new in Emacs 23. | 129 | ;; `start-file-process' is new in Emacs 23. |
| 114 | (unless (fboundp 'start-file-process) | 130 | (unless (fboundp 'start-file-process) |
| 115 | (defalias 'start-file-process 'tramp-handle-start-file-process)) | 131 | (defalias 'start-file-process |
| 132 | (lambda (name buffer program &rest program-args) | ||
| 133 | (when (tramp-tramp-file-p default-directory) | ||
| 134 | (apply | ||
| 135 | 'tramp-file-name-handler | ||
| 136 | 'start-file-process name buffer program program-args))))) | ||
| 116 | 137 | ||
| 117 | ;; `set-file-times' is also new in Emacs 23. | 138 | ;; `set-file-times' is also new in Emacs 23. |
| 118 | (unless (fboundp 'set-file-times) | 139 | (unless (fboundp 'set-file-times) |
| 119 | (defalias 'set-file-times 'tramp-handle-set-file-times))) | 140 | (defalias 'set-file-times |
| 141 | (lambda (filename &optional time) | ||
| 142 | (when (tramp-tramp-file-p filename) | ||
| 143 | (tramp-file-name-handler | ||
| 144 | 'set-file-times filename time)))))) | ||
| 120 | 145 | ||
| 121 | (defsubst tramp-compat-line-end-position () | 146 | (defsubst tramp-compat-line-end-position () |
| 122 | "Return point at end of line (compat function). | 147 | "Return point at end of line (compat function). |
| @@ -197,10 +222,8 @@ Add the extension of FILENAME, if existing." | |||
| 197 | (cond | 222 | (cond |
| 198 | ((or (null id-format) (eq id-format 'integer)) | 223 | ((or (null id-format) (eq id-format 'integer)) |
| 199 | (file-attributes filename)) | 224 | (file-attributes filename)) |
| 200 | ;; FIXME: shouldn't that be tramp-file-p or somesuch? | 225 | ((tramp-tramp-file-p filename) |
| 201 | ((file-remote-p filename) | 226 | (tramp-file-name-handler 'file-attributes filename id-format)) |
| 202 | (funcall (symbol-function 'tramp-handle-file-attributes) | ||
| 203 | filename id-format)) | ||
| 204 | (t (condition-case nil | 227 | (t (condition-case nil |
| 205 | (funcall (symbol-function 'file-attributes) filename id-format) | 228 | (funcall (symbol-function 'file-attributes) filename id-format) |
| 206 | (error (file-attributes filename)))))) | 229 | (error (file-attributes filename)))))) |
| @@ -219,7 +242,7 @@ Add the extension of FILENAME, if existing." | |||
| 219 | ;; `copy-tree' is a built-in function in XEmacs. In Emacs 21, it is | 242 | ;; `copy-tree' is a built-in function in XEmacs. In Emacs 21, it is |
| 220 | ;; an autoloaded function in cl-extra.el. Since Emacs 22, it is part | 243 | ;; an autoloaded function in cl-extra.el. Since Emacs 22, it is part |
| 221 | ;; of subr.el. There are problems when autoloading, therefore we test | 244 | ;; of subr.el. There are problems when autoloading, therefore we test |
| 222 | ;; for `subrp' and `symbol-file'. Implementation is taken from Emacs23. | 245 | ;; for `subrp' and `symbol-file'. Implementation is taken from Emacs 23. |
| 223 | (defun tramp-compat-copy-tree (tree) | 246 | (defun tramp-compat-copy-tree (tree) |
| 224 | "Make a copy of TREE (compat function)." | 247 | "Make a copy of TREE (compat function)." |
| 225 | (if (or (subrp 'copy-tree) (symbol-file 'copy-tree)) | 248 | (if (or (subrp 'copy-tree) (symbol-file 'copy-tree)) |
| @@ -233,6 +256,28 @@ Add the extension of FILENAME, if existing." | |||
| 233 | (setq tree (cdr tree))) | 256 | (setq tree (cdr tree))) |
| 234 | (nconc (nreverse result) tree)))) | 257 | (nconc (nreverse result) tree)))) |
| 235 | 258 | ||
| 259 | ;; `number-sequence' has been introduced in Emacs 22. Implementation | ||
| 260 | ;; is taken from Emacs 23. | ||
| 261 | (defun tramp-compat-number-sequence (from &optional to inc) | ||
| 262 | "Return a sequence of numbers from FROM to TO as a list (compat function)." | ||
| 263 | (if (or (subrp 'number-sequence) (symbol-file 'number-sequence)) | ||
| 264 | (funcall (symbol-function 'number-sequence) from to inc) | ||
| 265 | (if (or (not to) (= from to)) | ||
| 266 | (list from) | ||
| 267 | (or inc (setq inc 1)) | ||
| 268 | (when (zerop inc) (error "The increment can not be zero")) | ||
| 269 | (let (seq (n 0) (next from)) | ||
| 270 | (if (> inc 0) | ||
| 271 | (while (<= next to) | ||
| 272 | (setq seq (cons next seq) | ||
| 273 | n (1+ n) | ||
| 274 | next (+ from (* n inc)))) | ||
| 275 | (while (>= next to) | ||
| 276 | (setq seq (cons next seq) | ||
| 277 | n (1+ n) | ||
| 278 | next (+ from (* n inc))))) | ||
| 279 | (nreverse seq))))) | ||
| 280 | |||
| 236 | (defun tramp-compat-split-string (string pattern) | 281 | (defun tramp-compat-split-string (string pattern) |
| 237 | "Like `split-string' but omit empty strings. | 282 | "Like `split-string' but omit empty strings. |
| 238 | In Emacs, (split-string \"/foo/bar\" \"/\") returns (\"foo\" \"bar\"). | 283 | In Emacs, (split-string \"/foo/bar\" \"/\") returns (\"foo\" \"bar\"). |