--- /dev/null
+;;; tramp-gw.el --- Tramp compatibility functions
+
+;; Copyright (C) 2007 Free Software Foundation, Inc.
+
+;; Author: Michael Albinus <michael.albinus@gmx.de>
+;; Keywords: comm, processes
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, see
+;; <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Tramp's main Emacs version for development is GNU Emacs 23. This
+;; package provides compatibility functions for GNU Emacs 21, GNU
+;; Emacs 22 and XEmacs 21.4+.
+
+;;; Code:
+
+;; Pacify byte-compiler
+(eval-when-compile
+ (require 'cl)
+ (require 'custom))
+
+;; Avoid byte-compiler warnings if the byte-compiler supports this.
+;; Currently, XEmacs supports this.
+;(eval-when-compile
+; (when (featurep 'xemacs)
+; (byte-compiler-options (warnings (- unused-vars)))))
+
+;; `last-coding-system-used' is unknown in XEmacs.
+(eval-when-compile
+ (unless (boundp 'last-coding-system-used)
+ (defvar last-coding-system-used nil)))
+
+;; `directory-sep-char' is an obsolete variable in Emacs. But it is
+;; used in XEmacs, so we set it here and there. The following is needed
+;; to pacify Emacs byte-compiler.
+(eval-when-compile
+ (unless (boundp 'byte-compile-not-obsolete-var)
+ (defvar byte-compile-not-obsolete-var nil))
+ (setq byte-compile-not-obsolete-var 'directory-sep-char))
+
+;; `with-temp-message' does not exists in XEmacs.
+(eval-and-compile
+ (condition-case nil
+ (with-temp-message (current-message) nil)
+ (error (defmacro with-temp-message (message &rest body) `(progn ,@body)))))
+
+;; `set-buffer-multibyte' comes from Emacs Leim.
+(eval-and-compile
+ (unless (fboundp 'set-buffer-multibyte)
+ (defalias 'set-buffer-multibyte 'ignore)))
+
+;; `font-lock-add-keywords' does not exist in XEmacs.
+(eval-and-compile
+ (unless (fboundp 'font-lock-add-keywords)
+ (defalias 'font-lock-add-keywords 'ignore)))
+
+(defsubst tramp-compat-line-end-position ()
+ "Return point at end of line (compat function).
+Calls `line-end-position' or `point-at-eol' if defined, else
+own implementation."
+ (cond
+ ((fboundp 'line-end-position) (funcall (symbol-function 'line-end-position)))
+ ((fboundp 'point-at-eol) (funcall (symbol-function 'point-at-eol)))
+ (t (save-excursion (end-of-line) (point)))))
+
+(defsubst tramp-compat-temporary-file-directory ()
+ "Return name of directory for temporary files (compat function).
+For Emacs, this is the variable `temporary-file-directory', for XEmacs
+this is the function `temp-directory'."
+ (cond
+ ((boundp 'temporary-file-directory)
+ (symbol-value 'temporary-file-directory))
+ ((fboundp 'temp-directory)
+ (funcall (symbol-function 'temp-directory))) ;pacify byte-compiler
+ ((let ((d (getenv "TEMP"))) (and d (file-directory-p d)))
+ (file-name-as-directory (getenv "TEMP")))
+ ((let ((d (getenv "TMP"))) (and d (file-directory-p d)))
+ (file-name-as-directory (getenv "TMP")))
+ ((let ((d (getenv "TMPDIR"))) (and d (file-directory-p d)))
+ (file-name-as-directory (getenv "TMPDIR")))
+ ((file-exists-p "c:/temp") (file-name-as-directory "c:/temp"))
+ (t (message (concat "Neither `temporary-file-directory' nor "
+ "`temp-directory' is defined -- using /tmp."))
+ (file-name-as-directory "/tmp"))))
+
+;; `most-positive-fixnum' arrived in Emacs 22.
+(defsubst tramp-compat-most-positive-fixnum ()
+ "Return largest positive integer value (compat function)."
+ (cond ((boundp 'most-positive-fixnum)
+ (symbol-value 'most-positive-fixnum))
+ (t 134217727)))
+
+;; ID-FORMAT exists since Emacs 22.
+(defun tramp-compat-file-attributes (filename &optional id-format)
+ "Like `file-attributes' for Tramp files (compat function)."
+ (cond
+ ((or (null id-format) (eq id-format 'integer))
+ (file-attributes filename))
+ ((file-remote-p filename)
+ (funcall (symbol-function 'tramp-handle-file-attributes)
+ filename id-format))
+ (t (condition-case nil
+ (funcall (symbol-function 'file-attributes) filename id-format)
+ (error (file-attributes filename))))))
+
+;; PRESERVE-UID-GID has been introduced with Emacs 23. It does not
+;; hurt to ignore it for other (X)Emacs versions.
+(defun tramp-compat-copy-file
+ (filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
+ "Like `copy-file' for Tramp files (compat function)."
+ (if preserve-uid-gid
+ (funcall
+ (symbol-function 'copy-file)
+ filename newname ok-if-already-exists keep-date preserve-uid-gid)
+ (copy-file filename newname ok-if-already-exists keep-date)))
+
+;; `copy-tree' is introduced with Emacs 22. We've adapted the
+;; implementation from Emacs 23.
+(defun tramp-compat-copy-tree (tree)
+ "Make a copy of TREE (compat function)."
+ (if (functionp 'copy-tree)
+ (funcall (symbol-function 'copy-tree) tree)
+ (let (result)
+ (while (consp tree)
+ (let ((newcar (car tree)))
+ (if (consp (car tree))
+ (setq newcar (tramp-compat-copy-tree (car tree))))
+ (push newcar result))
+ (setq tree (cdr tree)))
+ (nconc (nreverse result) tree))))
+
+(eval-and-compile
+ (unless (fboundp 'file-remote-p)
+ (defalias 'file-remote-p 'tramp-handle-file-remote-p))
+
+ (unless (fboundp 'process-file)
+ (defalias 'process-file 'tramp-handle-process-file))
+
+ (unless (fboundp 'start-file-process)
+ (defalias 'start-file-process 'tramp-handle-start-file-process))
+
+ (unless (fboundp 'set-file-times)
+ (defalias 'set-file-times 'tramp-handle-set-file-times)))
+
+(provide 'tramp-compat)
+
+;;; TODO:
+
+;;; tramp-compat.el ends here
-;;; -*- mode: Emacs-Lisp; coding: utf-8; -*-
;;; tramp.el --- Transparent Remote Access, Multiple Protocol
+;;; -*- mode: Emacs-Lisp; coding: utf-8; -*-
;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
;; 2005, 2006, 2007 Free Software Foundation, Inc.
(when (featurep 'trampver)
(unload-feature 'trampver 'force))))
+(require 'tramp-compat)
+
+;; `directory-sep-char' is an obsolete variable in Emacs. But it is
+;; used in XEmacs, so we set it here and there. The following is needed
+;; to pacify Emacs byte-compiler.
+(eval-when-compile
+ (setq byte-compile-not-obsolete-var 'directory-sep-char))
+
(require 'custom)
(if (featurep 'xemacs)
(require 'shell)
(require 'advice)
-;; `copy-tree' is part of subr.el since Emacs 22.
-(eval-when-compile
- (unless (functionp 'copy-tree)
- (require 'cl)))
-
;; Requiring 'tramp-cache results in an endless loop.
(autoload 'tramp-get-file-property "tramp-cache")
(autoload 'tramp-set-file-property "tramp-cache")
(when (featurep 'tramp-util)
(unload-feature 'tramp-util 'force)))))))
-;; Avoid byte-compiler warnings if the byte-compiler supports this.
-;; Currently, XEmacs supports this.
-(eval-when-compile
- (when (featurep 'xemacs)
- (byte-compiler-options (warnings (- unused-vars)))))
-
-;; `last-coding-system-used' is unknown in XEmacs.
-(eval-when-compile
- (unless (boundp 'last-coding-system-used)
- (defvar last-coding-system-used nil)))
-
-;; `directory-sep-char' is an obsolete variable in Emacs. But it is
-;; used in XEmacs, so we set it here and there. The following is needed
-;; to pacify Emacs byte-compiler.
-(eval-when-compile
- (unless (boundp 'byte-compile-not-obsolete-var)
- (defvar byte-compile-not-obsolete-var nil))
- (setq byte-compile-not-obsolete-var 'directory-sep-char))
-
-;; `with-temp-message' does not exists in XEmacs.
-(eval-and-compile
- (condition-case nil
- (with-temp-message (current-message) nil)
- (error (defmacro with-temp-message (message &rest body) `(progn ,@body)))))
-
-;; `set-buffer-multibyte' comes from Emacs Leim.
-(eval-and-compile
- (unless (fboundp 'set-buffer-multibyte)
- (defalias 'set-buffer-multibyte 'ignore)))
-
;;; User Customizable Internal Variables:
(defgroup tramp nil
"*Prefix to use for temporary files.
If this is a relative file name (such as \"tramp.\"), it is considered
relative to the directory name returned by the function
-`tramp-temporary-file-directory' (which see). It may also be an
+`tramp-compat-temporary-file-directory' (which see). It may also be an
absolute file name; don't forget to include a prefix for the filename
part, though."
:group 'tramp
(tramp-get-buffer vec-or-proc)))
(sit-for 30))))))
-(defsubst tramp-line-end-position nil
- "Return point at end of line.
-Calls `line-end-position' or `point-at-eol' if defined, else
-own implementation."
- (cond
- ((fboundp 'line-end-position) (funcall (symbol-function 'line-end-position)))
- ((fboundp 'point-at-eol) (funcall (symbol-function 'point-at-eol)))
- (t (save-excursion (end-of-line) (point)))))
-
(defmacro with-parsed-tramp-file-name (filename var &rest body)
"Parse a Tramp filename and make components available in the body.
(put 'with-parsed-tramp-file-name 'lisp-indent-function 2)
(put 'with-parsed-tramp-file-name 'edebug-form-spec '(form symbolp body))
-(when (functionp 'font-lock-add-keywords)
- (apply 'font-lock-add-keywords
- (list 'emacs-lisp-mode '("\\<with-parsed-tramp-file-name\\>"))))
+(font-lock-add-keywords 'emacs-lisp-mode '("\\<with-parsed-tramp-file-name\\>"))
(defmacro with-file-property (vec file property &rest body)
"Check in Tramp cache for PROPERTY, otherwise execute BODY and set cache.
(put 'with-file-property 'lisp-indent-function 3)
(put 'with-file-property 'edebug-form-spec t)
-(when (functionp 'font-lock-add-keywords)
- (apply 'font-lock-add-keywords
- (list 'emacs-lisp-mode '("\\<with-file-property\\>"))))
+(font-lock-add-keywords 'emacs-lisp-mode '("\\<with-file-property\\>"))
(defmacro with-connection-property (key property &rest body)
"Checks in Tramp for property PROPERTY, otherwise executes BODY and set."
(put 'with-connection-property 'lisp-indent-function 2)
(put 'with-connection-property 'edebug-form-spec t)
-(when (functionp 'font-lock-add-keywords)
- (apply 'font-lock-add-keywords
- (list 'emacs-lisp-mode '("\\<with-connection-property\\>"))))
+(font-lock-add-keywords 'emacs-lisp-mode '("\\<with-connection-property\\>"))
(defmacro tramp-let-maybe (variable value &rest body)
"Let-bind VARIABLE to VALUE in BODY, but only if VARIABLE is not obsolete.
(concat
(funcall (if (fboundp 'make-temp-file) 'make-temp-file 'make-temp-name)
(expand-file-name tramp-temp-name-prefix
- (tramp-temporary-file-directory)))
+ (tramp-compat-temporary-file-directory)))
(file-name-extension filename t)))
(defsubst tramp-make-tramp-temp-file (vec)
special handling of `substitute-in-file-name'."
(when (symbol-value 'minibuffer-completing-file-name)
(setq tramp-rfn-eshadow-overlay
- (apply
- 'make-overlay
- (list (apply (symbol-function 'minibuffer-prompt-end))
- (apply (symbol-function 'minibuffer-prompt-end)))))
+ (funcall (symbol-function 'make-overlay)
+ (funcall (symbol-function 'minibuffer-prompt-end))
+ (funcall (symbol-function 'minibuffer-prompt-end))))
;; Copy rfn-eshadow-overlay properties.
- (let ((props (apply 'overlay-properties
- (list (symbol-value 'rfn-eshadow-overlay)))))
+ (let ((props (funcall (symbol-function 'overlay-properties)
+ (symbol-value 'rfn-eshadow-overlay))))
(while props
- (apply 'overlay-put
- (list tramp-rfn-eshadow-overlay (pop props) (pop props)))))))
+ (funcall (symbol-function 'overlay-put)
+ tramp-rfn-eshadow-overlay (pop props) (pop props))))))
(when (boundp 'rfn-eshadow-setup-minibuffer-hook)
(add-hook 'rfn-eshadow-setup-minibuffer-hook
`file-name-shadow-mode'; the minibuffer should have already
been set up by `rfn-eshadow-setup-minibuffer'."
;; In remote files name, there is a shadowing just for the local part.
- (let ((end (or (apply 'overlay-end (list (symbol-value 'rfn-eshadow-overlay)))
- (apply (symbol-function 'minibuffer-prompt-end)))))
- (when (apply 'file-remote-p
- (list (buffer-substring-no-properties end (point-max))))
+ (let ((end (or (funcall (symbol-function 'overlay-end)
+ (symbol-value 'rfn-eshadow-overlay))
+ (funcall (symbol-function 'minibuffer-prompt-end)))))
+ (when (file-remote-p (buffer-substring-no-properties end (point-max)))
(narrow-to-region
(1+ (or (string-match "/" (buffer-string) end) end)) (point-max))
(let ((rfn-eshadow-overlay tramp-rfn-eshadow-overlay)
(rfn-eshadow-update-overlay-hook nil))
- (apply (symbol-function 'rfn-eshadow-update-overlay)))
+ (funcall (symbol-function 'rfn-eshadow-update-overlay)))
(widen))))
(when (boundp 'rfn-eshadow-update-overlay-hook)
(when symlinkp
(search-forward "-> ")
(setq res-symlink-target
- (buffer-substring (point) (tramp-line-end-position))))
+ (buffer-substring (point) (tramp-compat-line-end-position))))
;; return data gathered
(list
;; 0. t for directory, string (name linked to) for symbolic
(defun tramp-handle-set-file-times (filename &optional time)
"Like `set-file-times' for Tramp files."
(zerop
- (if (apply 'file-remote-p (list filename))
+ (if (file-remote-p filename)
(with-parsed-tramp-file-name filename nil
(tramp-flush-file-property v localname)
(let ((time (if (or (null time) (equal time '(0 0)))
;; another implementation, see `dired-do-chown'. OTOH, it is
;; mostly working with su(do)? when it is needed, so it shall
;; succeed in the majority of cases.
- (if (apply 'file-remote-p (list filename))
+ (if (file-remote-p filename)
(with-parsed-tramp-file-name filename nil
(let ((uid (or (and (integerp uid) uid)
(tramp-get-remote-uid v 'integer)))
;; `set-file-uid-gid'.
(let ((uid (or (and (integerp uid) uid) (tramp-get-local-uid 'integer)))
(gid (or (and (integerp gid) gid) (tramp-get-local-uid 'integer)))
- (default-directory (tramp-temporary-file-directory)))
+ (default-directory (tramp-compat-temporary-file-directory)))
(call-process
"chown" nil nil nil
(format "%d:%d" uid gid) (tramp-shell-quote-argument filename)))))
(when (file-directory-p directory)
(setq directory (expand-file-name directory))
(let* ((temp
- (copy-tree
+ (tramp-compat-copy-tree
(with-parsed-tramp-file-name directory nil
(with-file-property
v localname
(with-current-buffer (tramp-get-buffer v)
(goto-char (point-max))
(while (zerop (forward-line -1))
- (push (buffer-substring (point) (tramp-line-end-position))
+ (push (buffer-substring
+ (point) (tramp-compat-line-end-position))
result)))
result)))))))
(filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
"Like `copy-file' for Tramp files."
;; Check if both files are local -- invoke normal copy-file.
- ;; Otherwise, use tramp from local system.
+ ;; Otherwise, use Tramp from local system.
(setq filename (expand-file-name filename))
(setq newname (expand-file-name newname))
- ;; At least one file a tramp file?
- (if (or (tramp-tramp-file-p filename)
- (tramp-tramp-file-p newname))
- (tramp-do-copy-or-rename-file
- 'copy filename newname ok-if-already-exists keep-date preserve-uid-gid)
+ (cond
+ ;; At least one file a tramp file?
+ ((or (tramp-tramp-file-p filename)
+ (tramp-tramp-file-p newname))
+ (tramp-do-copy-or-rename-file
+ 'copy filename newname ok-if-already-exists keep-date preserve-uid-gid))
+ ;; Compat section.
+ (preserve-uid-gid
(tramp-run-real-handler
'copy-file
- (list filename newname ok-if-already-exists keep-date preserve-uid-gid))))
+ (list filename newname ok-if-already-exists keep-date preserve-uid-gid)))
+ (t
+ (tramp-run-real-handler
+ 'copy-file (list filename newname ok-if-already-exists keep-date)))))
(defun tramp-handle-rename-file
(filename newname &optional ok-if-already-exists)
(jka-compr-inhibit t))
(write-region (point-min) (point-max) newname))))
;; KEEP-DATE handling.
- (when keep-date (apply 'set-file-times (list newname modtime)))
+ (when keep-date (set-file-times newname modtime))
;; Set the mode.
(set-file-modes newname (file-modes filename))
;; If the operation was `rename', delete the original file.
(if t1 (tramp-handle-file-remote-p filename 'localname) filename))
(localname2
(if t2 (tramp-handle-file-remote-p newname 'localname) newname))
- (prefix (apply 'file-remote-p (list (if t1 filename newname))))
+ (prefix (file-remote-p (if t1 filename newname)))
(tmpfile (tramp-make-temp-file localname1)))
(cond
((and (file-readable-p localname1)
(file-writable-p (file-name-directory localname2)))
(if (eq op 'copy)
- (apply
- 'copy-file
- (list localname1 localname2 ok-if-already-exists
- keep-date preserve-uid-gid))
+ (tramp-compat-copy-file
+ localname1 localname2 ok-if-already-exists
+ keep-date preserve-uid-gid)
(rename-file localname1 localname2 ok-if-already-exists)))
;; We can do it directly with `tramp-send-command'
(tramp-get-local-gid 'integer)))
(t2
(if (eq op 'copy)
- (apply
- 'copy-file
- (list localname1 tmpfile ok-if-already-exists
- keep-date preserve-uid-gid))
+ (tramp-compat-copy-file
+ localname1 tmpfile ok-if-already-exists
+ keep-date preserve-uid-gid)
(rename-file localname1 tmpfile ok-if-already-exists))
;; We must change the ownership as local user.
(tramp-set-file-uid-gid
(tramp-shell-quote-argument localname2))))
(t1
(if (eq op 'copy)
- (apply
- 'copy-file
- (list tmpfile localname2 ok-if-already-exists
- keep-date preserve-uid-gid))
+ (tramp-compat-copy-file
+ tmpfile localname2 ok-if-already-exists
+ keep-date preserve-uid-gid)
(rename-file tmpfile localname2 ok-if-already-exists))))
;; Remove temporary file.
;; Won't be applied for 'rename.
(condition-case nil
(when (and keep-date (not preserve-uid-gid))
- (apply 'set-file-times
- (list newname (nth 5 (file-attributes filename))))
+ (set-file-times newname (nth 5 (file-attributes filename)))
(set-file-modes newname (file-modes filename)))
(error)))))
;; Check for program.
(when (and (fboundp 'executable-find)
(not (let ((default-directory
- (tramp-temporary-file-directory)))
+ (tramp-compat-temporary-file-directory)))
(executable-find copy-program))))
(tramp-error
v 'file-error "Cannot find copy program: %s" copy-program))
;; set a timeout, because the copying of large files can
;; last longer than 60 secs.
(let ((p (let ((default-directory
- (tramp-temporary-file-directory)))
+ (tramp-compat-temporary-file-directory)))
(apply 'start-process
(tramp-get-connection-property
v "process-name" nil)
;; Handle KEEP-DATE argument.
(when (and keep-date (not copy-keep-date))
- (apply 'set-file-times
- (list newname (nth 5 (file-attributes filename)))))
+ (set-file-times newname (nth 5 (file-attributes filename))))
;; Set the mode.
(unless (and keep-date copy-keep-date)
(tramp-send-command v (format "cd %s; pwd" uname))
(with-current-buffer (tramp-get-buffer v)
(goto-char (point-min))
- (buffer-substring (point) (tramp-line-end-position)))))
+ (buffer-substring (point) (tramp-compat-line-end-position)))))
(setq localname (concat uname fname))))
;; There might be a double slash, for example when "~/"
;; expands to "/". Remove this.
;; bound, because on Windows there would be problems with UNC
;; shares or Cygwin mounts.
(tramp-let-maybe directory-sep-char ?/
- (let ((default-directory (tramp-temporary-file-directory)))
+ (let ((default-directory (tramp-compat-temporary-file-directory)))
(tramp-make-tramp-file-name
method user host
(tramp-drop-volume-letter
;; In XEmacs, electricity is implemented via a key map for ?/ and ?~,
;; which calls corresponding functions (see minibuf.el).
(when (fboundp 'minibuffer-electric-separator)
- (mapcar
+ (mapc
'(lambda (x)
(eval
`(defadvice ,x
(if (integerp asynchronous)
(apply 'tramp-handle-start-file-process
"*Async Shell*" buffer args)
- (apply 'tramp-handle-process-file
+ (apply 'process-file
(car args) nil buffer nil (cdr args)))
;; Insert error messages if they were separated.
(when (listp buffer)
;; There's some output, display it.
(when (with-current-buffer output-buffer (> (point-max) (point-min)))
(if (functionp 'display-message-or-buffer)
- (apply 'display-message-or-buffer (list output-buffer))
+ (funcall (symbol-function 'display-message-or-buffer) output-buffer)
(pop-to-buffer output-buffer))))))
;; File Editing.
;; UNIQUIFY element of `auto-save-file-name-transforms'); but for
;; all other cases we must do it ourselves.
(when (boundp 'auto-save-file-name-transforms)
- (mapcar
+ (mapc
'(lambda (x)
(when (and (string-match (car x) buffer-file-name)
(not (car (cddr x))))
(setq tramp-auto-save-directory
(or tramp-auto-save-directory
- (tramp-temporary-file-directory)))))
+ (tramp-compat-temporary-file-directory)))))
(symbol-value 'auto-save-file-name-transforms)))
;; Create directory.
(when tramp-auto-save-directory
;; files, it seems.) The file in question is a
;; tmp file anyway.
(let ((default-directory
- (tramp-temporary-file-directory)))
+ (tramp-compat-temporary-file-directory)))
(funcall loc-enc (point-min) (point-max))))
(tramp-message
(erase-buffer)
(and
;; cksum runs locally
- (let ((default-directory (tramp-temporary-file-directory)))
+ (let ((default-directory
+ (tramp-compat-temporary-file-directory)))
(zerop (call-process "cksum" tmpfil t)))
;; cksum runs remotely
(zerop
;; `partial-completion-mode' is unknown in XEmacs. So we should
;; load it unconditionally there. In the GNU Emacs case, method/
;; user/host name completion shall be bound to `partial-completion-mode'.
+ ;; `ido-mode' and `icy-mode' are other packages which extend file
+ ;; name completion.
(when (or (not (boundp 'partial-completion-mode))
(symbol-value 'partial-completion-mode)
- (featurep 'ido))
+ (featurep 'ido)
+ (featurep 'icicles))
(add-to-list 'file-name-handler-alist
(cons tramp-completion-file-name-regexp
'tramp-completion-file-name-handler))
;;- method user host
;;- (format "echo %s" (comint-quote-filename localname))))
(tramp-send-command v (format "echo %s" localname))
- (setq bufstr (buffer-substring (point-min)
- (tramp-line-end-position)))
+ (setq bufstr (buffer-substring
+ (point-min) (tramp-compat-line-end-position)))
(with-current-buffer (tramp-get-buffer v)
(goto-char (point-min))
(if (string-equal localname bufstr)
;; Method dependent user / host combinations.
(progn
- (mapcar
+ (mapc
(lambda (x)
(setq all-user-hosts
(append all-user-hosts
(funcall (nth 0 x) (nth 1 x)))))
(tramp-get-completion-function m))
- (setq result (append result
- (mapcar
- (lambda (x)
- (tramp-get-completion-user-host
- method user host (nth 0 x) (nth 1 x)))
- (delq nil all-user-hosts)))))
+ (setq result
+ (append result
+ (mapcar
+ (lambda (x)
+ (tramp-get-completion-user-host
+ method user host (nth 0 x) (nth 1 x)))
+ (delq nil all-user-hosts)))))
;; Possible methods.
(setq result
(concat tramp-prefix-regexp "/$"))
1 nil 3 nil)))
- (mapcar (lambda (regexp)
+ (mapc (lambda (regexp)
(add-to-list 'result
(tramp-completion-dissect-file-name1 regexp name)))
(list
Either user or host may be nil."
;; On Windows, there are problems in completion when
;; `default-directory' is remote.
- (let ((default-directory (tramp-temporary-file-directory))
+ (let ((default-directory (tramp-compat-temporary-file-directory))
res)
(when (file-readable-p filename)
(with-temp-buffer
(concat
"^\\(" tramp-host-regexp "\\)"
"\\([ \t]+" "\\(" tramp-user-regexp "\\)" "\\)?")))
- (narrow-to-region (point) (tramp-line-end-position))
+ (narrow-to-region (point) (tramp-compat-line-end-position))
(when (re-search-forward regexp nil t)
(setq result (append (list (match-string 3) (match-string 1)))))
(widen)
User is always nil."
;; On Windows, there are problems in completion when
;; `default-directory' is remote.
- (let ((default-directory (tramp-temporary-file-directory))
+ (let ((default-directory (tramp-compat-temporary-file-directory))
res)
(when (file-readable-p filename)
(with-temp-buffer
User is always nil."
(let ((result)
(regexp (concat "^\\(" tramp-host-regexp "\\)")))
- (narrow-to-region (point) (tramp-line-end-position))
+ (narrow-to-region (point) (tramp-compat-line-end-position))
(when (re-search-forward regexp nil t)
(setq result (list nil (match-string 1))))
(widen)
User is always nil."
;; On Windows, there are problems in completion when
;; `default-directory' is remote.
- (let ((default-directory (tramp-temporary-file-directory))
+ (let ((default-directory (tramp-compat-temporary-file-directory))
res)
(when (file-readable-p filename)
(with-temp-buffer
User is always nil."
(let ((result)
(regexp (concat "^[ \t]*Host[ \t]+" "\\(" tramp-host-regexp "\\)")))
- (narrow-to-region (point) (tramp-line-end-position))
+ (narrow-to-region (point) (tramp-compat-line-end-position))
(when (re-search-forward regexp nil t)
(setq result (list nil (match-string 1))))
(widen)
User is always nil."
;; On Windows, there are problems in completion when
;; `default-directory' is remote.
- (let* ((default-directory (tramp-temporary-file-directory))
+ (let* ((default-directory (tramp-compat-temporary-file-directory))
(regexp (concat "^key_[0-9]+_\\(" tramp-host-regexp "\\)\\.pub$"))
(files (when (file-directory-p dirname) (directory-files dirname)))
result)
User is always nil."
;; On Windows, there are problems in completion when
;; `default-directory' is remote.
- (let* ((default-directory (tramp-temporary-file-directory))
+ (let* ((default-directory (tramp-compat-temporary-file-directory))
(regexp (concat "^\\(" tramp-host-regexp
"\\)\\.ssh-\\(dss\\|rsa\\)\\.pub$"))
(files (when (file-directory-p dirname) (directory-files dirname)))
User is always nil."
;; On Windows, there are problems in completion when
;; `default-directory' is remote.
- (let ((default-directory (tramp-temporary-file-directory))
+ (let ((default-directory (tramp-compat-temporary-file-directory))
res)
(when (file-readable-p filename)
(with-temp-buffer
User is always nil."
(let ((result)
(regexp (concat "^\\(" tramp-host-regexp "\\)")))
- (narrow-to-region (point) (tramp-line-end-position))
+ (narrow-to-region (point) (tramp-compat-line-end-position))
(when (re-search-forward regexp nil t)
(unless (char-equal (or (char-after) ?\n) ?:) ; no IPv6
(setq result (list nil (match-string 1)))))
Host is always \"localhost\"."
;; On Windows, there are problems in completion when
;; `default-directory' is remote.
- (let ((default-directory (tramp-temporary-file-directory))
+ (let ((default-directory (tramp-compat-temporary-file-directory))
res)
(if (zerop (length tramp-current-user))
'(("root" nil))
Host is always \"localhost\"."
(let ((result)
(regexp (concat "^\\(" tramp-user-regexp "\\):")))
- (narrow-to-region (point) (tramp-line-end-position))
+ (narrow-to-region (point) (tramp-compat-line-end-position))
(when (re-search-forward regexp nil t)
(setq result (list (match-string 1) "localhost")))
(widen)
User may be nil."
;; On Windows, there are problems in completion when
;; `default-directory' is remote.
- (let ((default-directory (tramp-temporary-file-directory))
+ (let ((default-directory (tramp-compat-temporary-file-directory))
res)
(when (file-readable-p filename)
(with-temp-buffer
(concat
"^[ \t]*machine[ \t]+" "\\(" tramp-host-regexp "\\)"
"\\([ \t]+login[ \t]+" "\\(" tramp-user-regexp "\\)" "\\)?")))
- (narrow-to-region (point) (tramp-line-end-position))
+ (narrow-to-region (point) (tramp-compat-line-end-position))
(when (re-search-forward regexp nil t)
(setq result (list (match-string 3) (match-string 1))))
(widen)
User is always nil."
;; On Windows, there are problems in completion when
;; `default-directory' is remote.
- (let ((default-directory (tramp-temporary-file-directory))
+ (let ((default-directory (tramp-compat-temporary-file-directory))
res)
(with-temp-buffer
(when (zerop (call-process "reg" nil t nil "query" registry))
User is always nil."
(let ((result)
(regexp (concat (regexp-quote registry) "\\\\\\(.+\\)")))
- (narrow-to-region (point) (tramp-line-end-position))
+ (narrow-to-region (point) (tramp-compat-line-end-position))
(when (re-search-forward regexp nil t)
(setq result (list nil (match-string 1))))
(widen)
;; `outline-mode-hook'. We must prevent that local processes
;; die. Yes: I've seen `flyspell-mode', which starts "ispell"
;; ...
- (let ((default-directory (tramp-temporary-file-directory)))
+ (let ((default-directory (tramp-compat-temporary-file-directory)))
(outline-mode))
(set (make-local-variable 'outline-regexp)
"[0-9]+:[0-9]+:[0-9]+ [a-z0-9-]+ (\\([0-9]+\\)) #")
(when (search-backward "tramp_executable " nil t)
(skip-chars-forward "^ ")
(skip-chars-forward " ")
- (setq result (buffer-substring (point) (tramp-line-end-position)))))
+ (setq result (buffer-substring
+ (point) (tramp-compat-line-end-position)))))
result)))
(defun tramp-set-remote-path (vec)
OUTPUT can be a string (which specifies a filename), or t (which
means standard output and thus the current buffer), or nil (which
means discard it)."
- (let ((default-directory (tramp-temporary-file-directory)))
+ (let ((default-directory (tramp-compat-temporary-file-directory)))
(call-process
tramp-encoding-shell ;program
(when (and input (not (string-match "%s" cmd)))
'target-alist
(vector
(tramp-file-name-method hop) (tramp-file-name-user hop)
- (funcall (intern "tramp-gw-open-connection") vec gw hop) nil))
+ (funcall (symbol-function 'tramp-gw-open-connection) vec gw hop) nil))
;; For the password prompt, we need the correct values.
;; Therefore, we must remember the gateway vector. But we
;; cannot do it as connection property, because it shouldn't
(process-adaptive-read-buffering nil)
(coding-system-for-read nil)
;; This must be done in order to avoid our file name handler.
- (p (let ((default-directory (tramp-temporary-file-directory)))
+ (p (let ((default-directory
+ (tramp-compat-temporary-file-directory)))
(start-process
(or (tramp-get-connection-property vec "process-name" nil)
(tramp-buffer-name vec))
(condition-case nil
(prog1 (read (current-buffer))
;; Error handling.
- (when (re-search-forward "\\S-" (tramp-line-end-position) t)
+ (when (re-search-forward "\\S-" (tramp-compat-line-end-position) t)
(error nil)))
(error (tramp-error
vec 'file-error
;; Convert file size.
(when (< (nth 7 attr) 0)
(setcar (nthcdr 7 attr) -1))
- (when (and (floatp (nth 7 attr)) (<= (nth 7 attr) most-positive-fixnum))
+ (when (and (floatp (nth 7 attr))
+ (<= (nth 7 attr) (tramp-compat-most-positive-fixnum)))
(setcar (nthcdr 7 attr) (round (nth 7 attr))))
;; Convert file mode bits to string.
(unless (stringp (nth 8 attr))
would yield `t'. On the other hand, the following check results in nil:
(tramp-equal-remote \"/sudo::/etc\" \"/su::/etc\")"
- (and (stringp (apply 'file-remote-p (list file1)))
- (stringp (apply 'file-remote-p (list file2)))
- (string-equal (apply 'file-remote-p (list file1))
- (apply 'file-remote-p (list file2)))))
+ (and (stringp (file-remote-p file1))
+ (stringp (file-remote-p file2))
+ (string-equal (file-remote-p file1)
+ (file-remote-p file2))))
(defun tramp-make-tramp-file-name (method user host localname)
"Constructs a Tramp file name from METHOD, USER, HOST and LOCALNAME."
(defun tramp-get-remote-path (vec)
(with-connection-property vec "remote-path"
- (let* ((remote-path (copy-tree tramp-remote-path))
+ (let* ((remote-path (tramp-compat-copy-tree tramp-remote-path))
(elt (memq 'tramp-default-remote-path remote-path))
(default-remote-path
(when elt
(if (equal id-format 'integer) (user-uid) (user-login-name)))
(defun tramp-get-local-gid (id-format)
- (nth 3 (tramp-handle-file-attributes "~/" id-format)))
+ (nth 3 (tramp-compat-file-attributes "~/" id-format)))
;; Some predefined connection properties.
(defun tramp-get-remote-coding (vec prop)
;; -- Compatibility functions section --
;; ------------------------------------------------------------
-(defun tramp-temporary-file-directory ()
- "Return name of directory for temporary files (compat function).
-For Emacs, this is the variable `temporary-file-directory', for XEmacs
-this is the function `temp-directory'."
- (cond ((boundp 'temporary-file-directory)
- (symbol-value 'temporary-file-directory))
- ((fboundp 'temp-directory)
- (funcall (symbol-function 'temp-directory))) ;pacify byte-compiler
- ((let ((d (getenv "TEMP"))) (and d (file-directory-p d)))
- (file-name-as-directory (getenv "TEMP")))
- ((let ((d (getenv "TMP"))) (and d (file-directory-p d)))
- (file-name-as-directory (getenv "TMP")))
- ((let ((d (getenv "TMPDIR"))) (and d (file-directory-p d)))
- (file-name-as-directory (getenv "TMPDIR")))
- ((file-exists-p "c:/temp") (file-name-as-directory "c:/temp"))
- (t (message (concat "Neither `temporary-file-directory' nor "
- "`temp-directory' is defined -- using /tmp."))
- (file-name-as-directory "/tmp"))))
-
(defun tramp-read-passwd (proc &optional prompt)
"Read a password from user (compat function).
Invokes `password-read' if available, `read-passwd' else."
(tramp-check-for-regexp proc tramp-password-prompt-regexp)
(format "%s for %s " (capitalize (match-string 1)) key)))))
(if (functionp 'password-read)
- (let ((password (apply #'password-read (list pw-prompt key))))
- (apply #'password-cache-add (list key password))
+ (let ((password (funcall (symbol-function 'password-read)
+ pw-prompt key)))
+ (funcall (symbol-function 'password-cache-add) key password)
password)
(read-passwd pw-prompt))))
If METHOD, USER or HOST is given, take then for computing the key."
(interactive)
(when (functionp 'password-cache-remove)
- (apply #'password-cache-remove
- (list (tramp-make-tramp-file-name
- tramp-current-method
- tramp-current-user
- tramp-current-host
- "")))))
+ (funcall (symbol-function 'password-cache-remove)
+ (tramp-make-tramp-file-name
+ tramp-current-method
+ tramp-current-user
+ tramp-current-host
+ ""))))
;; Snarfed code from time-date.el and parse-time.el
"Return a coding system like CODING-SYSTEM but with given EOL-TYPE.
EOL-TYPE can be one of `dos', `unix', or `mac'."
(cond ((fboundp 'coding-system-change-eol-conversion)
- (apply #'coding-system-change-eol-conversion
- (list coding-system eol-type)))
+ (funcall (symbol-function 'coding-system-change-eol-conversion)
+ coding-system eol-type))
((fboundp 'subsidiary-coding-system)
- (apply
- #'subsidiary-coding-system
- (list coding-system
- (cond ((eq eol-type 'dos) 'crlf)
- ((eq eol-type 'unix) 'lf)
- ((eq eol-type 'mac) 'cr)
- (t
- (error "Unknown EOL-TYPE `%s', must be %s"
- eol-type
- "`dos', `unix', or `mac'"))))))
+ (funcall (symbol-function 'subsidiary-coding-system)
+ coding-system
+ (cond ((eq eol-type 'dos) 'crlf)
+ ((eq eol-type 'unix) 'lf)
+ ((eq eol-type 'mac) 'cr)
+ (t
+ (error "Unknown EOL-TYPE `%s', must be %s"
+ eol-type
+ "`dos', `unix', or `mac'")))))
(t (error "Can't change EOL conversion -- is MULE missing?"))))
(defun tramp-split-string (string pattern)
(setq buffer-read-only nil)
(goto-char (point-min))
(while (not (eobp))
- (if (re-search-forward tramp-buf-regexp (tramp-line-end-position) t)
+ (if (re-search-forward
+ tramp-buf-regexp (tramp-compat-line-end-position) t)
(forward-line 1)
(forward-line 0)
(let ((start (point)))