annotate lisp/net/tramp-compat.el @ 92606:f49e5129551f

(persian-calendar-month-name-array, persian-calendar-epoch): Make constants. (persian-prompt-for-date): Use zerop.
author Glenn Morris <rgm@gnu.org>
date Sat, 08 Mar 2008 04:18:57 +0000
parents c568e49dbbc5
children 9ee1ca8ab653
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
87665
b9e8ab94c460 Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 87322
diff changeset
3 ;; Copyright (C) 2007, 2008 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
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
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
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 3, or (at your option)
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
13 ;; any later version.
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
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, see
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
22 ;; <http://www.gnu.org/licenses/>.
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
23
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
24 ;;; Commentary:
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
25
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
26 ;; 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
27 ;; 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
28 ;; Emacs 22 and XEmacs 21.4+.
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
29
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
30 ;;; Code:
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
31
87322
e99e230d7eb3 * files.el (cd-absolute): Set `list-buffers-directory' in order to
Michael Albinus <michael.albinus@gmx.de>
parents: 85067
diff changeset
32 (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
33
e99e230d7eb3 * files.el (cd-absolute): Set `list-buffers-directory' in order to
Michael Albinus <michael.albinus@gmx.de>
parents: 85067
diff changeset
34 ;; 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
35 (require 'cl))
e99e230d7eb3 * files.el (cd-absolute): Set `list-buffers-directory' in order to
Michael Albinus <michael.albinus@gmx.de>
parents: 85067
diff changeset
36
85024
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
37 (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
38
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
39 (require 'custom)
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
40
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
41 ;; 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
42 (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
43 (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
44 (require 'timer))
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
45
85067
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
46 ;; 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
47 ;; 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
48 (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
49 ;; 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
50 '(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
51 (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
52 (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
53 (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
54 '(lambda ()
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
55 (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
56 (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
57
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
58 ;; 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
59 ;; 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
60 ;; 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
61 (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
62 (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
63 ;; 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
64 '(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
65 (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
66 (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
67 (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
68 '(lambda ()
4636000015c5 * net/tramp.el (top): Move loading of tramp-util.el and
Michael Albinus <michael.albinus@gmx.de>
parents: 85041
diff changeset
69 (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
70 (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
71
85024
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
72 ;; 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
73 ;; 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
74 (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
75 (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
76 (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
77 (delq 'unused-vars byte-compile-default-warnings))
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
78
85024
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
79 ;; `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
80 (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
81 (defvar last-coding-system-used nil))
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
82
85024
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
83 ;; `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
84 ;; 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
85 ;; needed to pacify Emacs byte-compiler.
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
86 (unless (boundp 'byte-compile-not-obsolete-var)
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
87 (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
88 (setq byte-compile-not-obsolete-var 'directory-sep-char)
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
89
85024
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
90 ;; `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
91 (condition-case nil
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
92 (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
93 (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
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 ;; `set-buffer-multibyte' comes from Emacs Leim.
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
96 (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
97 (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
98
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
99 ;; `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
100 (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
101 (defalias 'font-lock-add-keywords 'ignore))
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
102
85024
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
103 ;; `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
104 ;; 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
105 ;; 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
106 ;; function exists.
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
107 (unless (fboundp 'file-remote-p)
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
108 (defalias 'file-remote-p 'tramp-handle-file-remote-p))
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
109
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
110 ;; `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
111 (unless (fboundp 'process-file)
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
112 (defalias 'process-file 'tramp-handle-process-file))
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
113
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
114 ;; `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
115 (unless (fboundp 'start-file-process)
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
116 (defalias 'start-file-process 'tramp-handle-start-file-process))
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
117
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
118 ;; `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
119 (unless (fboundp 'set-file-times)
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
120 (defalias 'set-file-times 'tramp-handle-set-file-times)))
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
121
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
122 (defsubst tramp-compat-line-end-position ()
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
123 "Return point at end of line (compat function).
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
124 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
125 own implementation."
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
126 (cond
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
127 ((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
128 ((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
129 (t (save-excursion (end-of-line) (point)))))
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
130
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
131 (defsubst tramp-compat-temporary-file-directory ()
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
132 "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
133 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
134 this is the function `temp-directory'."
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
135 (cond
85024
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
136 ((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
137 ((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
138 ((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
139 (file-name-as-directory (getenv "TEMP")))
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
140 ((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
141 (file-name-as-directory (getenv "TMP")))
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
142 ((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
143 (file-name-as-directory (getenv "TMPDIR")))
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
144 ((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
145 (t (message (concat "Neither `temporary-file-directory' nor "
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
146 "`temp-directory' is defined -- using /tmp."))
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
147 (file-name-as-directory "/tmp"))))
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
148
85041
a42b8750a992 * net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents: 85024
diff changeset
149 ;; `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
150 ;; 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
151 ;; 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
152 ;; 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
153 (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
154 "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
155 Add the extension of FILENAME, if existing."
a42b8750a992 * net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents: 85024
diff changeset
156 (let ((prefix (expand-file-name
a42b8750a992 * net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents: 85024
diff changeset
157 (symbol-value 'tramp-temp-name-prefix)
a42b8750a992 * net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents: 85024
diff changeset
158 (tramp-compat-temporary-file-directory)))
a42b8750a992 * net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents: 85024
diff changeset
159 (extension (file-name-extension filename t))
a42b8750a992 * net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents: 85024
diff changeset
160 result)
a42b8750a992 * net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents: 85024
diff changeset
161 (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
162 (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
163 (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
164 (error
a42b8750a992 * net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents: 85024
diff changeset
165 ;; 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
166 (while
a42b8750a992 * net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents: 85024
diff changeset
167 (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
168 (progn
a42b8750a992 * net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents: 85024
diff changeset
169 (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
170 (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
171 "" 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
172 ;; 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
173 ;; 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
174 ;; 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
175 ;; 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
176 ;; 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
177 (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
178 nil)
a42b8750a992 * net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents: 85024
diff changeset
179 (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
180 ;; 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
181 ;; `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
182 nil)))
a42b8750a992 * net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents: 85024
diff changeset
183 result))
a42b8750a992 * net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el.
Michael Albinus <michael.albinus@gmx.de>
parents: 85024
diff changeset
184
85024
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
185 ;; `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
186 ;; it is a fixed value.
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
187 (defsubst tramp-compat-most-positive-fixnum ()
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
188 "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
189 (cond
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
190 ((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
191 ;; 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
192 (t 134217727)))
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
193
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
194 ;; ID-FORMAT exists since Emacs 22.
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
195 (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
196 "Like `file-attributes' for Tramp files (compat function)."
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
197 (cond
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
198 ((or (null id-format) (eq id-format 'integer))
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
199 (file-attributes filename))
91790
c568e49dbbc5 (tramp-compat-file-attributes): Add comment.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87665
diff changeset
200 ;; FIXME: shouldn't that be tramp-file-p or somesuch?
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
201 ((file-remote-p filename)
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
202 (funcall (symbol-function 'tramp-handle-file-attributes)
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
203 filename id-format))
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
204 (t (condition-case nil
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
205 (funcall (symbol-function 'file-attributes) filename id-format)
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
206 (error (file-attributes filename))))))
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
207
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
208 ;; 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
209 ;; 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
210 (defun tramp-compat-copy-file
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
211 (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
212 "Like `copy-file' for Tramp files (compat function)."
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
213 (if preserve-uid-gid
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
214 (funcall
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
215 (symbol-function 'copy-file)
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
216 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
217 (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
218
85024
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
219 ;; `copy-tree' is a built-in function in XEmacs. In Emacs 21, it is
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
220 ;; an auoloaded function in cl-extra.el. Since Emacs 22, it is part
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
221 ;; of subr.el. There are problems when autoloading, therefore we test
ef71cdab0d5c * net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'.
Michael Albinus <michael.albinus@gmx.de>
parents: 84992
diff changeset
222 ;; for for `subrp' and `symbol-file'. Implementation is taken from Emacs23.
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
223 (defun tramp-compat-copy-tree (tree)
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
224 "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
225 (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
226 (funcall (symbol-function 'copy-tree) tree)
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
227 (let (result)
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
228 (while (consp tree)
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
229 (let ((newcar (car tree)))
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
230 (if (consp (car tree))
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
231 (setq newcar (tramp-compat-copy-tree (car tree))))
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
232 (push newcar result))
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
233 (setq tree (cdr tree)))
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
234 (nconc (nreverse result) tree))))
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
235
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
236 (provide 'tramp-compat)
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
237
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
238 ;;; TODO:
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
239
84992
5a1966aded2d Add arch tagline
Miles Bader <miles@gnu.org>
parents: 84985
diff changeset
240 ;; arch-tag: 0e724b18-6699-4f87-ad96-640b272e5c85
84985
f7642749252b * net/tramp-compat.el: New file.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
241 ;;; tramp-compat.el ends here