Mercurial > emacs
annotate lisp/net/tramp-compat.el @ 106717:15eb515afd85
* net/browse-url.el (browse-url-encode-url): Don't escape commas.
They are valid characters in URL paths (rfc3986), and at least
Firefox does not understand the encoded version (Bug#3166).
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sat, 02 Jan 2010 15:14:54 -0500 |
parents | 291ea018e478 |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
1 ;;; tramp-compat.el --- Tramp compatibility functions |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
2 |
100908 | 3 ;; Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
4 |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
5 ;; Author: Michael Albinus <michael.albinus@gmx.de> |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
6 ;; Keywords: comm, processes |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
7 |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
9 |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94402
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94402
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94402
diff
changeset
|
13 ;; (at your option) any later version. |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
14 |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful, |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
18 ;; GNU General Public License for more details. |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
19 |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94402
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
22 |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
23 ;;; Commentary: |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
24 |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
25 ;; Tramp's main Emacs version for development is GNU Emacs 23. This |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
26 ;; package provides compatibility functions for GNU Emacs 21, GNU |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
27 ;; Emacs 22 and XEmacs 21.4+. |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
28 |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
29 ;;; Code: |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
30 |
87322
e99e230d7eb3
* files.el (cd-absolute): Set `list-buffers-directory' in order to
Michael Albinus <michael.albinus@gmx.de>
parents:
85067
diff
changeset
|
31 (eval-when-compile |
e99e230d7eb3
* files.el (cd-absolute): Set `list-buffers-directory' in order to
Michael Albinus <michael.albinus@gmx.de>
parents:
85067
diff
changeset
|
32 |
e99e230d7eb3
* files.el (cd-absolute): Set `list-buffers-directory' in order to
Michael Albinus <michael.albinus@gmx.de>
parents:
85067
diff
changeset
|
33 ;; Pacify byte-compiler. |
e99e230d7eb3
* files.el (cd-absolute): Set `list-buffers-directory' in order to
Michael Albinus <michael.albinus@gmx.de>
parents:
85067
diff
changeset
|
34 (require 'cl)) |
e99e230d7eb3
* files.el (cd-absolute): Set `list-buffers-directory' in order to
Michael Albinus <michael.albinus@gmx.de>
parents:
85067
diff
changeset
|
35 |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
36 (eval-and-compile |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
37 |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
38 (require 'custom) |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
39 |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
40 ;; Load the appropriate timer package. |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
41 (if (featurep 'xemacs) |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
42 (require 'timer-funcs) |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
43 (require 'timer)) |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
44 |
104808
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
45 (autoload 'tramp-tramp-file-p "tramp") |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
46 (autoload 'tramp-file-name-handler "tramp") |
106613
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
47 (autoload 'tramp-handle-file-remote-p "tramp") |
104808
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
48 |
85067
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
49 ;; tramp-util offers integration into other (X)Emacs packages like |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
50 ;; compile.el, gud.el etc. Not necessary in Emacs 23. |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
51 (eval-after-load "tramp" |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
52 ;; We check whether `start-file-process' is an alias. |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
53 '(when (or (not (fboundp 'start-file-process)) |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
54 (symbolp (symbol-function 'start-file-process))) |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
55 (require 'tramp-util) |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
56 (add-hook 'tramp-unload-hook |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
57 '(lambda () |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
58 (when (featurep 'tramp-util) |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
59 (unload-feature 'tramp-util 'force)))))) |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
60 |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
61 ;; Make sure that we get integration with the VC package. When it |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
62 ;; is loaded, we need to pull in the integration module. Not |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
63 ;; necessary in Emacs 23. |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
64 (eval-after-load "vc" |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
65 (eval-after-load "tramp" |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
66 ;; We check whether `start-file-process' is an alias. |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
67 '(when (or (not (fboundp 'start-file-process)) |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
68 (symbolp (symbol-function 'start-file-process))) |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
69 (require 'tramp-vc) |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
70 (add-hook 'tramp-unload-hook |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
71 '(lambda () |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
72 (when (featurep 'tramp-vc) |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
73 (unload-feature 'tramp-vc 'force))))))) |
4636000015c5
* net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents:
85041
diff
changeset
|
74 |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
75 ;; Avoid byte-compiler warnings if the byte-compiler supports this. |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
76 ;; Currently, XEmacs supports this. |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
77 (when (featurep 'xemacs) |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
78 (unless (boundp 'byte-compile-default-warnings) |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
79 (defvar byte-compile-default-warnings nil)) |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
80 (delq 'unused-vars byte-compile-default-warnings)) |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
81 |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
82 ;; `last-coding-system-used' is unknown in XEmacs. |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
83 (unless (boundp 'last-coding-system-used) |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
84 (defvar last-coding-system-used nil)) |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
85 |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
86 ;; `directory-sep-char' is an obsolete variable in Emacs. But it is |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
87 ;; used in XEmacs, so we set it here and there. The following is |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
88 ;; needed to pacify Emacs byte-compiler. |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
89 (unless (boundp 'byte-compile-not-obsolete-var) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
90 (defvar byte-compile-not-obsolete-var nil)) |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
91 (setq byte-compile-not-obsolete-var 'directory-sep-char) |
105044
2e1ecbf638ee
(byte-compile-not-obsolete-vars): Set if bound.
Glenn Morris <rgm@gnu.org>
parents:
104851
diff
changeset
|
92 (if (boundp 'byte-compile-not-obsolete-vars) ; Emacs 23.2 |
2e1ecbf638ee
(byte-compile-not-obsolete-vars): Set if bound.
Glenn Morris <rgm@gnu.org>
parents:
104851
diff
changeset
|
93 (setq byte-compile-not-obsolete-vars '(directory-sep-char))) |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
94 |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
95 ;; `with-temp-message' does not exists in XEmacs. |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
96 (condition-case nil |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
97 (with-temp-message (current-message) nil) |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
98 (error (defmacro with-temp-message (message &rest body) `(progn ,@body)))) |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
99 |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
100 ;; `set-buffer-multibyte' comes from Emacs Leim. |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
101 (unless (fboundp 'set-buffer-multibyte) |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
102 (defalias 'set-buffer-multibyte 'ignore)) |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
103 |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
104 ;; `font-lock-add-keywords' does not exist in XEmacs. |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
105 (unless (fboundp 'font-lock-add-keywords) |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
106 (defalias 'font-lock-add-keywords 'ignore)) |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
107 |
104808
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
108 ;; The following functions cannot be aliases of the corresponding |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
109 ;; `tramp-handle-*' functions, because this would bypass the locking |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
110 ;; mechanism. |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
111 |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
112 ;; `file-remote-p' has been introduced with Emacs 22. The version |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
113 ;; of XEmacs is not a magic file name function (yet); this is |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
114 ;; corrected in tramp-util.el. Here it is sufficient if the |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
115 ;; function exists. |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
116 (unless (fboundp 'file-remote-p) |
104808
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
117 (defalias 'file-remote-p |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
118 (lambda (file &optional identification connected) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
119 (when (tramp-tramp-file-p file) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
120 (tramp-file-name-handler |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
121 'file-remote-p file identification connected))))) |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
122 |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
123 ;; `process-file' exists since Emacs 22. |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
124 (unless (fboundp 'process-file) |
104808
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
125 (defalias 'process-file |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
126 (lambda (program &optional infile buffer display &rest args) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
127 (when (tramp-tramp-file-p default-directory) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
128 (apply |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
129 'tramp-file-name-handler |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
130 'process-file program infile buffer display args))))) |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
131 |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
132 ;; `start-file-process' is new in Emacs 23. |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
133 (unless (fboundp 'start-file-process) |
104808
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
134 (defalias 'start-file-process |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
135 (lambda (name buffer program &rest program-args) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
136 (when (tramp-tramp-file-p default-directory) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
137 (apply |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
138 'tramp-file-name-handler |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
139 'start-file-process name buffer program program-args))))) |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
140 |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
141 ;; `set-file-times' is also new in Emacs 23. |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
142 (unless (fboundp 'set-file-times) |
104808
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
143 (defalias 'set-file-times |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
144 (lambda (filename &optional time) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
145 (when (tramp-tramp-file-p filename) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
146 (tramp-file-name-handler |
106613
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
147 'set-file-times filename time))))) |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
148 |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
149 ;; We currently use "[" and "]" in the filename format for IPv6 |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
150 ;; hosts of GNU Emacs. This means, that Emacs wants to expand |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
151 ;; wildcards if `find-file-wildcards' is non-nil, and then barfs |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
152 ;; because no expansion could be found. We detect this situation |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
153 ;; and do something really awful: we have `file-expand-wildcards' |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
154 ;; return the original filename if it can't expand anything. Let's |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
155 ;; just hope that this doesn't break anything else. |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
156 ;; It is not needed anymore since GNU Emacs 23.2. |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
157 (unless (or (featurep 'xemacs) (featurep 'files 'remote-wildcards)) |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
158 (defadvice file-expand-wildcards |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
159 (around tramp-advice-file-expand-wildcards activate) |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
160 (let ((name (ad-get-arg 0))) |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
161 ;; If it's a Tramp file, look if wildcards need to be expanded |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
162 ;; at all. |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
163 (if (and |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
164 (tramp-tramp-file-p name) |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
165 (not (string-match |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
166 "[[*?]" (tramp-handle-file-remote-p name 'localname)))) |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
167 (setq ad-return-value (list name)) |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
168 ;; Otherwise, just run the original function. |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
169 ad-do-it))) |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
170 (add-hook |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
171 'tramp-unload-hook |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
172 (lambda () |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
173 (ad-remove-advice |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
174 'file-expand-wildcards 'around 'tramp-advice-file-expand-wildcards) |
291ea018e478
* files.el (file-expand-wildcards): In case of remote files, check
Michael Albinus <michael.albinus@gmx.de>
parents:
105892
diff
changeset
|
175 (ad-activate 'file-expand-wildcards))))) |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
176 |
104851
5e1bd0e3a13b
* net/tramp-compat.el (tramp-compat-line-beginning-position): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
104808
diff
changeset
|
177 (defsubst tramp-compat-line-beginning-position () |
5e1bd0e3a13b
* net/tramp-compat.el (tramp-compat-line-beginning-position): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
104808
diff
changeset
|
178 "Return point at beginning of line (compat function). |
5e1bd0e3a13b
* net/tramp-compat.el (tramp-compat-line-beginning-position): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
104808
diff
changeset
|
179 Calls `line-beginning-position' or `point-at-bol' if defined, else |
5e1bd0e3a13b
* net/tramp-compat.el (tramp-compat-line-beginning-position): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
104808
diff
changeset
|
180 own implementation." |
5e1bd0e3a13b
* net/tramp-compat.el (tramp-compat-line-beginning-position): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
104808
diff
changeset
|
181 (cond |
5e1bd0e3a13b
* net/tramp-compat.el (tramp-compat-line-beginning-position): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
104808
diff
changeset
|
182 ((fboundp 'line-beginning-position) |
5e1bd0e3a13b
* net/tramp-compat.el (tramp-compat-line-beginning-position): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
104808
diff
changeset
|
183 (funcall (symbol-function 'line-beginning-position))) |
5e1bd0e3a13b
* net/tramp-compat.el (tramp-compat-line-beginning-position): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
104808
diff
changeset
|
184 ((fboundp 'point-at-bol) (funcall (symbol-function 'point-at-bol))) |
5e1bd0e3a13b
* net/tramp-compat.el (tramp-compat-line-beginning-position): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
104808
diff
changeset
|
185 (t (save-excursion (beginning-of-line) (point))))) |
5e1bd0e3a13b
* net/tramp-compat.el (tramp-compat-line-beginning-position): New defun.
Michael Albinus <michael.albinus@gmx.de>
parents:
104808
diff
changeset
|
186 |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
187 (defsubst tramp-compat-line-end-position () |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
188 "Return point at end of line (compat function). |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
189 Calls `line-end-position' or `point-at-eol' if defined, else |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
190 own implementation." |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
191 (cond |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
192 ((fboundp 'line-end-position) (funcall (symbol-function 'line-end-position))) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
193 ((fboundp 'point-at-eol) (funcall (symbol-function 'point-at-eol))) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
194 (t (save-excursion (end-of-line) (point))))) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
195 |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
196 (defsubst tramp-compat-temporary-file-directory () |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
197 "Return name of directory for temporary files (compat function). |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
198 For Emacs, this is the variable `temporary-file-directory', for XEmacs |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
199 this is the function `temp-directory'." |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
200 (cond |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
201 ((boundp 'temporary-file-directory) (symbol-value 'temporary-file-directory)) |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
202 ((fboundp 'temp-directory) (funcall (symbol-function 'temp-directory))) |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
203 ((let ((d (getenv "TEMP"))) (and d (file-directory-p d))) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
204 (file-name-as-directory (getenv "TEMP"))) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
205 ((let ((d (getenv "TMP"))) (and d (file-directory-p d))) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
206 (file-name-as-directory (getenv "TMP"))) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
207 ((let ((d (getenv "TMPDIR"))) (and d (file-directory-p d))) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
208 (file-name-as-directory (getenv "TMPDIR"))) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
209 ((file-exists-p "c:/temp") (file-name-as-directory "c:/temp")) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
210 (t (message (concat "Neither `temporary-file-directory' nor " |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
211 "`temp-directory' is defined -- using /tmp.")) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
212 (file-name-as-directory "/tmp")))) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
213 |
85041
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
214 ;; `make-temp-file' exists in Emacs only. The third parameter SUFFIX |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
215 ;; has been introduced with Emacs 22. We try it, if it fails, we fall |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
216 ;; back to `make-temp-name', creating the temporary file immediately |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
217 ;; in order to avoid a security hole. |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
218 (defsubst tramp-compat-make-temp-file (filename) |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
219 "Create a temporary file (compat function). |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
220 Add the extension of FILENAME, if existing." |
94402
2faa99de7eef
* net/tramp.el (tramp-handle-make-symbolic-link)
Michael Albinus <michael.albinus@gmx.de>
parents:
92981
diff
changeset
|
221 (let* (file-name-handler-alist |
2faa99de7eef
* net/tramp.el (tramp-handle-make-symbolic-link)
Michael Albinus <michael.albinus@gmx.de>
parents:
92981
diff
changeset
|
222 (prefix (expand-file-name |
2faa99de7eef
* net/tramp.el (tramp-handle-make-symbolic-link)
Michael Albinus <michael.albinus@gmx.de>
parents:
92981
diff
changeset
|
223 (symbol-value 'tramp-temp-name-prefix) |
2faa99de7eef
* net/tramp.el (tramp-handle-make-symbolic-link)
Michael Albinus <michael.albinus@gmx.de>
parents:
92981
diff
changeset
|
224 (tramp-compat-temporary-file-directory))) |
2faa99de7eef
* net/tramp.el (tramp-handle-make-symbolic-link)
Michael Albinus <michael.albinus@gmx.de>
parents:
92981
diff
changeset
|
225 (extension (file-name-extension filename t)) |
2faa99de7eef
* net/tramp.el (tramp-handle-make-symbolic-link)
Michael Albinus <michael.albinus@gmx.de>
parents:
92981
diff
changeset
|
226 result) |
85041
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
227 (condition-case nil |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
228 (setq result |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
229 (funcall (symbol-function 'make-temp-file) prefix nil extension)) |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
230 (error |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
231 ;; We use our own implementation, taken from files.el. |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
232 (while |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
233 (condition-case () |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
234 (progn |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
235 (setq result (concat (make-temp-name prefix) extension)) |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
236 (write-region |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
237 "" nil result nil 'silent nil |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
238 ;; 7th parameter is MUSTBENEW in Emacs, and |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
239 ;; CODING-SYSTEM in XEmacs. It is not a security |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
240 ;; hole in XEmacs if we cannot use this parameter, |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
241 ;; because XEmacs uses a user-specific subdirectory |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
242 ;; with 0700 permissions. |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
243 (when (not (featurep 'xemacs)) 'excl)) |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
244 nil) |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
245 (file-already-exists t)) |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
246 ;; The file was somehow created by someone else between |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
247 ;; `make-temp-name' and `write-region', let's try again. |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
248 nil))) |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
249 result)) |
a42b8750a992
* net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
85024
diff
changeset
|
250 |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
251 ;; `most-positive-fixnum' arrived in Emacs 22. Before, and in XEmacs, |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
252 ;; it is a fixed value. |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
253 (defsubst tramp-compat-most-positive-fixnum () |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
254 "Return largest positive integer value (compat function)." |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
255 (cond |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
256 ((boundp 'most-positive-fixnum) (symbol-value 'most-positive-fixnum)) |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
257 ;; Default value in XEmacs and Emacs 21. |
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
258 (t 134217727))) |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
259 |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
260 ;; ID-FORMAT exists since Emacs 22. |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
261 (defun tramp-compat-file-attributes (filename &optional id-format) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
262 "Like `file-attributes' for Tramp files (compat function)." |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
263 (cond |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
264 ((or (null id-format) (eq id-format 'integer)) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
265 (file-attributes filename)) |
104808
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
266 ((tramp-tramp-file-p filename) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
267 (tramp-file-name-handler 'file-attributes filename id-format)) |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
268 (t (condition-case nil |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
269 (funcall (symbol-function 'file-attributes) filename id-format) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
270 (error (file-attributes filename)))))) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
271 |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
272 ;; PRESERVE-UID-GID has been introduced with Emacs 23. It does not |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
273 ;; hurt to ignore it for other (X)Emacs versions. |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
274 (defun tramp-compat-copy-file |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
275 (filename newname &optional ok-if-already-exists keep-date preserve-uid-gid) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
276 "Like `copy-file' for Tramp files (compat function)." |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
277 (if preserve-uid-gid |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
278 (funcall |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
279 (symbol-function 'copy-file) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
280 filename newname ok-if-already-exists keep-date preserve-uid-gid) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
281 (copy-file filename newname ok-if-already-exists keep-date))) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
282 |
105892
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
283 ;; `copy-directory' is a new function in Emacs 23.2. Implementation |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
284 ;; is taken from there. |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
285 (defun tramp-compat-copy-directory |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
286 (directory newname &optional keep-time parents) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
287 "Make a copy of DIRECTORY (compat function)." |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
288 (if (fboundp 'copy-directory) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
289 (funcall |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
290 (symbol-function 'copy-directory) directory newname keep-time parents) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
291 |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
292 ;; If default-directory is a remote directory, make sure we find |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
293 ;; its copy-directory handler. |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
294 (let ((handler (or (find-file-name-handler directory 'copy-directory) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
295 (find-file-name-handler newname 'copy-directory)))) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
296 (if handler |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
297 (funcall handler 'copy-directory directory newname keep-time parents) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
298 |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
299 ;; Compute target name. |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
300 (setq directory (directory-file-name (expand-file-name directory)) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
301 newname (directory-file-name (expand-file-name newname))) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
302 (if (and (file-directory-p newname) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
303 (not (string-equal (file-name-nondirectory directory) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
304 (file-name-nondirectory newname)))) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
305 (setq newname |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
306 (expand-file-name |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
307 (file-name-nondirectory directory) newname))) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
308 (if (not (file-directory-p newname)) (make-directory newname parents)) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
309 |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
310 ;; Copy recursively. |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
311 (mapc |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
312 (lambda (file) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
313 (if (file-directory-p file) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
314 (tramp-compat-copy-directory file newname keep-time parents) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
315 (copy-file file newname t keep-time))) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
316 ;; We do not want to delete "." and "..". |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
317 (directory-files |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
318 directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
319 |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
320 ;; Set directory attributes. |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
321 (set-file-modes newname (file-modes directory)) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
322 (if keep-time |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
323 (set-file-times newname (nth 5 (file-attributes directory)))))))) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
324 |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
325 ;; `copy-tree' is a built-in function in XEmacs. In Emacs 21, it is |
92981
9ee1ca8ab653
*** empty log message ***
Michael Albinus <michael.albinus@gmx.de>
parents:
91790
diff
changeset
|
326 ;; an autoloaded function in cl-extra.el. Since Emacs 22, it is part |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
327 ;; of subr.el. There are problems when autoloading, therefore we test |
104808
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
328 ;; for `subrp' and `symbol-file'. Implementation is taken from Emacs 23. |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
329 (defun tramp-compat-copy-tree (tree) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
330 "Make a copy of TREE (compat function)." |
85024
ef71cdab0d5c
* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents:
84992
diff
changeset
|
331 (if (or (subrp 'copy-tree) (symbol-file 'copy-tree)) |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
332 (funcall (symbol-function 'copy-tree) tree) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
333 (let (result) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
334 (while (consp tree) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
335 (let ((newcar (car tree))) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
336 (if (consp (car tree)) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
337 (setq newcar (tramp-compat-copy-tree (car tree)))) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
338 (push newcar result)) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
339 (setq tree (cdr tree))) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
340 (nconc (nreverse result) tree)))) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
341 |
105892
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
342 ;; RECURSIVE has been introduced with Emacs 23.2. |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
343 (defun tramp-compat-delete-directory (directory &optional recursive) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
344 "Like `delete-directory' for Tramp files (compat function)." |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
345 (if recursive |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
346 (funcall (symbol-function 'delete-directory) directory recursive) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
347 (delete-directory directory))) |
ac069dcbfe75
* net/tramp-compat.el (tramp-compat-copy-directory)
Michael Albinus <michael.albinus@gmx.de>
parents:
105493
diff
changeset
|
348 |
104808
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
349 ;; `number-sequence' has been introduced in Emacs 22. Implementation |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
350 ;; is taken from Emacs 23. |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
351 (defun tramp-compat-number-sequence (from &optional to inc) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
352 "Return a sequence of numbers from FROM to TO as a list (compat function)." |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
353 (if (or (subrp 'number-sequence) (symbol-file 'number-sequence)) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
354 (funcall (symbol-function 'number-sequence) from to inc) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
355 (if (or (not to) (= from to)) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
356 (list from) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
357 (or inc (setq inc 1)) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
358 (when (zerop inc) (error "The increment can not be zero")) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
359 (let (seq (n 0) (next from)) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
360 (if (> inc 0) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
361 (while (<= next to) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
362 (setq seq (cons next seq) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
363 n (1+ n) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
364 next (+ from (* n inc)))) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
365 (while (>= next to) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
366 (setq seq (cons next seq) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
367 n (1+ n) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
368 next (+ from (* n inc))))) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
369 (nreverse seq))))) |
90ec0abf1017
* net/tramp-compat.el (top): Autoload used functions from
Michael Albinus <michael.albinus@gmx.de>
parents:
103529
diff
changeset
|
370 |
103529
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
371 (defun tramp-compat-split-string (string pattern) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
372 "Like `split-string' but omit empty strings. |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
373 In Emacs, (split-string \"/foo/bar\" \"/\") returns (\"foo\" \"bar\"). |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
374 This is, the first, empty, element is omitted. In XEmacs, the first |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
375 element is not omitted." |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
376 (delete "" (split-string string pattern))) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
377 |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
378 (defun tramp-compat-process-running-p (process-name) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
379 "Returns `t' if system process PROCESS-NAME is running for `user-login-name'." |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
380 (when (stringp process-name) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
381 (cond |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
382 ;; GNU Emacs 22 on w32. |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
383 ((fboundp 'w32-window-exists-p) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
384 (funcall (symbol-function 'w32-window-exists-p) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
385 process-name process-name)) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
386 |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
387 ;; GNU Emacs 23. |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
388 ((and (fboundp 'list-system-processes) (fboundp 'process-attributes)) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
389 (let (result) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
390 (dolist (pid (funcall (symbol-function 'list-system-processes)) result) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
391 (let ((attributes |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
392 (funcall (symbol-function 'process-attributes) pid))) |
105493
c8d4e5f3f0c8
(tramp-compat-process-running-p): Check that
Sam Steingold <sds@gnu.org>
parents:
105044
diff
changeset
|
393 (when (and (string-equal |
c8d4e5f3f0c8
(tramp-compat-process-running-p): Check that
Sam Steingold <sds@gnu.org>
parents:
105044
diff
changeset
|
394 (cdr (assoc 'user attributes)) (user-login-name)) |
c8d4e5f3f0c8
(tramp-compat-process-running-p): Check that
Sam Steingold <sds@gnu.org>
parents:
105044
diff
changeset
|
395 (let ((comm (cdr (assoc 'comm attributes)))) |
c8d4e5f3f0c8
(tramp-compat-process-running-p): Check that
Sam Steingold <sds@gnu.org>
parents:
105044
diff
changeset
|
396 ;; The returned command name could be truncated |
c8d4e5f3f0c8
(tramp-compat-process-running-p): Check that
Sam Steingold <sds@gnu.org>
parents:
105044
diff
changeset
|
397 ;; to 15 characters. Therefore, we cannot check |
c8d4e5f3f0c8
(tramp-compat-process-running-p): Check that
Sam Steingold <sds@gnu.org>
parents:
105044
diff
changeset
|
398 ;; for `string-equal'. |
c8d4e5f3f0c8
(tramp-compat-process-running-p): Check that
Sam Steingold <sds@gnu.org>
parents:
105044
diff
changeset
|
399 (and comm (string-match |
c8d4e5f3f0c8
(tramp-compat-process-running-p): Check that
Sam Steingold <sds@gnu.org>
parents:
105044
diff
changeset
|
400 (concat "^" (regexp-quote comm)) |
c8d4e5f3f0c8
(tramp-compat-process-running-p): Check that
Sam Steingold <sds@gnu.org>
parents:
105044
diff
changeset
|
401 process-name)))) |
103529
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
402 (setq result t)))))) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
403 |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
404 ;; Fallback, if there is no Lisp support yet. |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
405 (t (let ((default-directory |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
406 (if (file-remote-p default-directory) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
407 (tramp-compat-temporary-file-directory) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
408 default-directory)) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
409 (unix95 (getenv "UNIX95")) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
410 result) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
411 (setenv "UNIX95" "1") |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
412 (when (member |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
413 (user-login-name) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
414 (tramp-compat-split-string |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
415 (shell-command-to-string |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
416 (format "ps -C %s -o user=" process-name)) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
417 "[ \f\t\n\r\v]+")) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
418 (setq result t)) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
419 (setenv "UNIX95" unix95) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
420 result))))) |
83914fa17916
* net/tramp-compat.el (tramp-compat-split-string)
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
421 |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
422 (provide 'tramp-compat) |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
423 |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
424 ;;; TODO: |
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
425 |
84992 | 426 ;; arch-tag: 0e724b18-6699-4f87-ad96-640b272e5c85 |
84985
f7642749252b
* net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
427 ;;; tramp-compat.el ends here |