2007-10-03 10:54:03 +00:00
|
|
|
;;; tramp-compat.el --- Tramp compatibility functions
|
2007-09-30 16:43:07 +00:00
|
|
|
|
2010-01-13 08:35:10 +00:00
|
|
|
;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
|
2007-09-30 16:43:07 +00:00
|
|
|
|
|
|
|
;; Author: Michael Albinus <michael.albinus@gmx.de>
|
|
|
|
;; Keywords: comm, processes
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 07:31:51 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2007-09-30 16:43:07 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 07:31:51 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
2007-09-30 16:43:07 +00:00
|
|
|
|
|
|
|
;; 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
|
2008-05-06 07:31:51 +00:00
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
2007-09-30 16:43:07 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
2010-04-10 12:50:31 +00:00
|
|
|
;; Tramp's main Emacs version for development is GNU Emacs 24. This
|
|
|
|
;; package provides compatibility functions for GNU Emacs 22, GNU
|
|
|
|
;; Emacs 23 and XEmacs 21.4+.
|
2007-09-30 16:43:07 +00:00
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2007-12-18 21:02:53 +00:00
|
|
|
(eval-when-compile
|
2007-10-03 10:54:03 +00:00
|
|
|
|
|
|
|
;; Pacify byte-compiler.
|
2007-12-18 21:02:53 +00:00
|
|
|
(require 'cl))
|
|
|
|
|
|
|
|
(eval-and-compile
|
|
|
|
|
2007-10-03 10:54:03 +00:00
|
|
|
(require 'custom)
|
2007-09-30 16:43:07 +00:00
|
|
|
|
2007-10-03 10:54:03 +00:00
|
|
|
;; Load the appropriate timer package.
|
|
|
|
(if (featurep 'xemacs)
|
|
|
|
(require 'timer-funcs)
|
|
|
|
(require 'timer))
|
2007-09-30 16:43:07 +00:00
|
|
|
|
2009-09-02 11:15:56 +00:00
|
|
|
(autoload 'tramp-tramp-file-p "tramp")
|
|
|
|
(autoload 'tramp-file-name-handler "tramp")
|
2010-06-12 08:59:37 +00:00
|
|
|
|
|
|
|
;; We check whether `start-file-process' is bound.
|
|
|
|
(unless (fboundp 'start-file-process)
|
|
|
|
|
|
|
|
;; tramp-util offers integration into other (X)Emacs packages like
|
|
|
|
;; compile.el, gud.el etc. Not necessary in Emacs 23.
|
2007-10-06 12:00:42 +00:00
|
|
|
(eval-after-load "tramp"
|
2010-06-12 08:59:37 +00:00
|
|
|
'(progn
|
|
|
|
(require 'tramp-util)
|
2007-10-06 12:00:42 +00:00
|
|
|
(add-hook 'tramp-unload-hook
|
|
|
|
'(lambda ()
|
2010-06-12 08:59:37 +00:00
|
|
|
(when (featurep 'tramp-util)
|
|
|
|
(unload-feature 'tramp-util 'force))))))
|
|
|
|
|
|
|
|
;; Make sure that we get integration with the VC package. When it
|
|
|
|
;; is loaded, we need to pull in the integration module. Not
|
|
|
|
;; necessary in Emacs 23.
|
|
|
|
(eval-after-load "vc"
|
|
|
|
(eval-after-load "tramp"
|
|
|
|
'(progn
|
|
|
|
(require 'tramp-vc)
|
|
|
|
(add-hook 'tramp-unload-hook
|
|
|
|
'(lambda ()
|
|
|
|
(when (featurep 'tramp-vc)
|
|
|
|
(unload-feature 'tramp-vc 'force))))))))
|
2007-10-06 12:00:42 +00:00
|
|
|
|
2007-10-03 10:54:03 +00:00
|
|
|
;; Avoid byte-compiler warnings if the byte-compiler supports this.
|
|
|
|
;; Currently, XEmacs supports this.
|
|
|
|
(when (featurep 'xemacs)
|
|
|
|
(unless (boundp 'byte-compile-default-warnings)
|
|
|
|
(defvar byte-compile-default-warnings nil))
|
|
|
|
(delq 'unused-vars byte-compile-default-warnings))
|
|
|
|
|
|
|
|
;; `last-coding-system-used' is unknown in XEmacs.
|
2007-09-30 16:43:07 +00:00
|
|
|
(unless (boundp 'last-coding-system-used)
|
2007-10-03 10:54:03 +00:00
|
|
|
(defvar last-coding-system-used nil))
|
2007-09-30 16:43:07 +00:00
|
|
|
|
2007-10-03 10:54:03 +00:00
|
|
|
;; `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.
|
2007-09-30 16:43:07 +00:00
|
|
|
(unless (boundp 'byte-compile-not-obsolete-var)
|
|
|
|
(defvar byte-compile-not-obsolete-var nil))
|
2007-10-03 10:54:03 +00:00
|
|
|
(setq byte-compile-not-obsolete-var 'directory-sep-char)
|
* net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if
not bound.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p)
* net/tramp.el (top, with-progress-reporter)
(tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp)
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers)
* net/tramp-gvfs.el (tramp-gvfs-handle-file-selinux-context): Use it.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
2010-05-09 19:57:55 +00:00
|
|
|
;; Emacs 23.2.
|
|
|
|
(unless (boundp 'byte-compile-not-obsolete-vars)
|
|
|
|
(defvar byte-compile-not-obsolete-vars nil))
|
|
|
|
(setq byte-compile-not-obsolete-vars '(directory-sep-char))
|
2007-09-30 16:43:07 +00:00
|
|
|
|
2007-10-03 10:54:03 +00:00
|
|
|
;; `with-temp-message' does not exists in XEmacs.
|
2007-09-30 16:43:07 +00:00
|
|
|
(condition-case nil
|
|
|
|
(with-temp-message (current-message) nil)
|
2007-10-03 10:54:03 +00:00
|
|
|
(error (defmacro with-temp-message (message &rest body) `(progn ,@body))))
|
2007-09-30 16:43:07 +00:00
|
|
|
|
* net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if
not bound.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p)
* net/tramp.el (top, with-progress-reporter)
(tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp)
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers)
* net/tramp-gvfs.el (tramp-gvfs-handle-file-selinux-context): Use it.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
2010-05-09 19:57:55 +00:00
|
|
|
;; For not existing functions, or functions with a changed argument
|
|
|
|
;; list, there are compiler warnings. We want to avoid them in
|
|
|
|
;; cases we know what we do.
|
|
|
|
(defmacro tramp-compat-funcall (function &rest arguments)
|
|
|
|
(if (featurep 'xemacs)
|
|
|
|
`(funcall (symbol-function ,function) ,@arguments)
|
|
|
|
`(when (or (subrp ,function) (functionp ,function))
|
|
|
|
(with-no-warnings (funcall ,function ,@arguments)))))
|
|
|
|
|
2007-10-03 10:54:03 +00:00
|
|
|
;; `set-buffer-multibyte' comes from Emacs Leim.
|
2007-09-30 16:43:07 +00:00
|
|
|
(unless (fboundp 'set-buffer-multibyte)
|
2007-10-03 10:54:03 +00:00
|
|
|
(defalias 'set-buffer-multibyte 'ignore))
|
2007-09-30 16:43:07 +00:00
|
|
|
|
2007-10-03 10:54:03 +00:00
|
|
|
;; `font-lock-add-keywords' does not exist in XEmacs.
|
2007-09-30 16:43:07 +00:00
|
|
|
(unless (fboundp 'font-lock-add-keywords)
|
2007-10-03 10:54:03 +00:00
|
|
|
(defalias 'font-lock-add-keywords 'ignore))
|
|
|
|
|
2009-09-02 11:15:56 +00:00
|
|
|
;; The following functions cannot be aliases of the corresponding
|
|
|
|
;; `tramp-handle-*' functions, because this would bypass the locking
|
|
|
|
;; mechanism.
|
|
|
|
|
2007-10-03 10:54:03 +00:00
|
|
|
;; `file-remote-p' has been introduced with Emacs 22. The version
|
|
|
|
;; of XEmacs is not a magic file name function (yet); this is
|
|
|
|
;; corrected in tramp-util.el. Here it is sufficient if the
|
|
|
|
;; function exists.
|
|
|
|
(unless (fboundp 'file-remote-p)
|
2009-09-02 11:15:56 +00:00
|
|
|
(defalias 'file-remote-p
|
|
|
|
(lambda (file &optional identification connected)
|
|
|
|
(when (tramp-tramp-file-p file)
|
|
|
|
(tramp-file-name-handler
|
|
|
|
'file-remote-p file identification connected)))))
|
2007-10-03 10:54:03 +00:00
|
|
|
|
2010-04-10 12:50:31 +00:00
|
|
|
;; `process-file' does not exist in XEmacs.
|
2007-10-03 10:54:03 +00:00
|
|
|
(unless (fboundp 'process-file)
|
2009-09-02 11:15:56 +00:00
|
|
|
(defalias 'process-file
|
|
|
|
(lambda (program &optional infile buffer display &rest args)
|
|
|
|
(when (tramp-tramp-file-p default-directory)
|
|
|
|
(apply
|
|
|
|
'tramp-file-name-handler
|
|
|
|
'process-file program infile buffer display args)))))
|
2007-10-03 10:54:03 +00:00
|
|
|
|
|
|
|
;; `start-file-process' is new in Emacs 23.
|
|
|
|
(unless (fboundp 'start-file-process)
|
2009-09-02 11:15:56 +00:00
|
|
|
(defalias 'start-file-process
|
|
|
|
(lambda (name buffer program &rest program-args)
|
|
|
|
(when (tramp-tramp-file-p default-directory)
|
|
|
|
(apply
|
|
|
|
'tramp-file-name-handler
|
|
|
|
'start-file-process name buffer program program-args)))))
|
2007-10-03 10:54:03 +00:00
|
|
|
|
|
|
|
;; `set-file-times' is also new in Emacs 23.
|
|
|
|
(unless (fboundp 'set-file-times)
|
2009-09-02 11:15:56 +00:00
|
|
|
(defalias 'set-file-times
|
|
|
|
(lambda (filename &optional time)
|
|
|
|
(when (tramp-tramp-file-p filename)
|
|
|
|
(tramp-file-name-handler
|
2009-12-17 13:18:03 +00:00
|
|
|
'set-file-times filename time)))))
|
|
|
|
|
|
|
|
;; We currently use "[" and "]" in the filename format for IPv6
|
|
|
|
;; hosts of GNU Emacs. This means, that Emacs wants to expand
|
|
|
|
;; wildcards if `find-file-wildcards' is non-nil, and then barfs
|
|
|
|
;; because no expansion could be found. We detect this situation
|
|
|
|
;; and do something really awful: we have `file-expand-wildcards'
|
|
|
|
;; return the original filename if it can't expand anything. Let's
|
|
|
|
;; just hope that this doesn't break anything else.
|
|
|
|
;; It is not needed anymore since GNU Emacs 23.2.
|
2010-04-10 12:50:31 +00:00
|
|
|
(unless (or (featurep 'xemacs)
|
|
|
|
;; `featurep' has only one argument in XEmacs.
|
|
|
|
(funcall 'featurep 'files 'remote-wildcards))
|
2009-12-17 13:18:03 +00:00
|
|
|
(defadvice file-expand-wildcards
|
|
|
|
(around tramp-advice-file-expand-wildcards activate)
|
|
|
|
(let ((name (ad-get-arg 0)))
|
|
|
|
;; If it's a Tramp file, look if wildcards need to be expanded
|
|
|
|
;; at all.
|
|
|
|
(if (and
|
|
|
|
(tramp-tramp-file-p name)
|
|
|
|
(not (string-match
|
2010-06-12 08:59:37 +00:00
|
|
|
"[[*?]" (tramp-compat-funcall
|
|
|
|
'file-remote-p name 'localname))))
|
2009-12-17 13:18:03 +00:00
|
|
|
(setq ad-return-value (list name))
|
|
|
|
;; Otherwise, just run the original function.
|
|
|
|
ad-do-it)))
|
|
|
|
(add-hook
|
|
|
|
'tramp-unload-hook
|
|
|
|
(lambda ()
|
|
|
|
(ad-remove-advice
|
|
|
|
'file-expand-wildcards 'around 'tramp-advice-file-expand-wildcards)
|
|
|
|
(ad-activate 'file-expand-wildcards)))))
|
2007-09-30 16:43:07 +00:00
|
|
|
|
2009-09-04 08:15:28 +00:00
|
|
|
(defsubst tramp-compat-line-beginning-position ()
|
|
|
|
"Return point at beginning of line (compat function).
|
|
|
|
Calls `line-beginning-position' or `point-at-bol' if defined, else
|
|
|
|
own implementation."
|
|
|
|
(cond
|
|
|
|
((fboundp 'line-beginning-position)
|
* net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if
not bound.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p)
* net/tramp.el (top, with-progress-reporter)
(tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp)
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers)
* net/tramp-gvfs.el (tramp-gvfs-handle-file-selinux-context): Use it.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
2010-05-09 19:57:55 +00:00
|
|
|
(tramp-compat-funcall 'line-beginning-position))
|
|
|
|
((fboundp 'point-at-bol) (tramp-compat-funcall 'point-at-bol))
|
2009-09-04 08:15:28 +00:00
|
|
|
(t (save-excursion (beginning-of-line) (point)))))
|
|
|
|
|
2007-09-30 16:43:07 +00:00
|
|
|
(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
|
* net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if
not bound.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p)
* net/tramp.el (top, with-progress-reporter)
(tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp)
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers)
* net/tramp-gvfs.el (tramp-gvfs-handle-file-selinux-context): Use it.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
2010-05-09 19:57:55 +00:00
|
|
|
((fboundp 'line-end-position) (tramp-compat-funcall 'line-end-position))
|
|
|
|
((fboundp 'point-at-eol) (tramp-compat-funcall 'point-at-eol))
|
2007-09-30 16:43:07 +00:00
|
|
|
(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
|
2007-10-03 10:54:03 +00:00
|
|
|
((boundp 'temporary-file-directory) (symbol-value 'temporary-file-directory))
|
* net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if
not bound.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p)
* net/tramp.el (top, with-progress-reporter)
(tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp)
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers)
* net/tramp-gvfs.el (tramp-gvfs-handle-file-selinux-context): Use it.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
2010-05-09 19:57:55 +00:00
|
|
|
((fboundp 'temp-directory) (tramp-compat-funcall 'temp-directory))
|
2007-09-30 16:43:07 +00:00
|
|
|
((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"))))
|
|
|
|
|
2010-04-10 12:50:31 +00:00
|
|
|
;; `make-temp-file' exists in Emacs only. On XEmacs, we use our own
|
|
|
|
;; implementation with `make-temp-name', creating the temporary file
|
|
|
|
;; immediately in order to avoid a security hole.
|
2010-03-02 09:32:45 +00:00
|
|
|
(defsubst tramp-compat-make-temp-file (filename &optional dir-flag)
|
2007-10-04 20:09:32 +00:00
|
|
|
"Create a temporary file (compat function).
|
|
|
|
Add the extension of FILENAME, if existing."
|
2008-04-27 16:39:03 +00:00
|
|
|
(let* (file-name-handler-alist
|
|
|
|
(prefix (expand-file-name
|
|
|
|
(symbol-value 'tramp-temp-name-prefix)
|
|
|
|
(tramp-compat-temporary-file-directory)))
|
|
|
|
(extension (file-name-extension filename t))
|
|
|
|
result)
|
2010-06-12 08:59:37 +00:00
|
|
|
(condition-case nil
|
2007-10-04 20:09:32 +00:00
|
|
|
(setq result
|
* net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if
not bound.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p)
* net/tramp.el (top, with-progress-reporter)
(tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp)
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers)
* net/tramp-gvfs.el (tramp-gvfs-handle-file-selinux-context): Use it.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
2010-05-09 19:57:55 +00:00
|
|
|
(tramp-compat-funcall 'make-temp-file prefix dir-flag extension))
|
2010-06-12 08:59:37 +00:00
|
|
|
(error
|
|
|
|
;; We use our own implementation, taken from files.el.
|
|
|
|
(while
|
|
|
|
(condition-case ()
|
|
|
|
(progn
|
|
|
|
(setq result (concat (make-temp-name prefix) extension))
|
|
|
|
(if dir-flag
|
|
|
|
(make-directory result)
|
|
|
|
(write-region "" nil result nil 'silent))
|
|
|
|
nil)
|
|
|
|
(file-already-exists t))
|
|
|
|
;; The file was somehow created by someone else between
|
|
|
|
;; `make-temp-name' and `write-region', let's try again.
|
|
|
|
nil)))
|
2007-10-04 20:09:32 +00:00
|
|
|
result))
|
|
|
|
|
2010-04-10 12:50:31 +00:00
|
|
|
;; `most-positive-fixnum' does not exist in XEmacs.
|
2007-09-30 16:43:07 +00:00
|
|
|
(defsubst tramp-compat-most-positive-fixnum ()
|
|
|
|
"Return largest positive integer value (compat function)."
|
2007-10-03 10:54:03 +00:00
|
|
|
(cond
|
|
|
|
((boundp 'most-positive-fixnum) (symbol-value 'most-positive-fixnum))
|
2010-04-10 12:50:31 +00:00
|
|
|
;; Default value in XEmacs.
|
2007-10-03 10:54:03 +00:00
|
|
|
(t 134217727)))
|
2007-09-30 16:43:07 +00:00
|
|
|
|
2010-04-10 12:50:31 +00:00
|
|
|
;; ID-FORMAT does not exists in XEmacs.
|
2007-09-30 16:43:07 +00:00
|
|
|
(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))
|
2009-09-02 11:15:56 +00:00
|
|
|
((tramp-tramp-file-p filename)
|
|
|
|
(tramp-file-name-handler 'file-attributes filename id-format))
|
2007-09-30 16:43:07 +00:00
|
|
|
(t (condition-case nil
|
* net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if
not bound.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p)
* net/tramp.el (top, with-progress-reporter)
(tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp)
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers)
* net/tramp-gvfs.el (tramp-gvfs-handle-file-selinux-context): Use it.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
2010-05-09 19:57:55 +00:00
|
|
|
(tramp-compat-funcall 'file-attributes filename id-format)
|
2010-05-06 08:40:06 +00:00
|
|
|
(wrong-number-of-arguments (file-attributes filename))))))
|
2007-09-30 16:43:07 +00:00
|
|
|
|
|
|
|
;; PRESERVE-UID-GID has been introduced with Emacs 23. It does not
|
|
|
|
;; hurt to ignore it for other (X)Emacs versions.
|
* net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if
not bound.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p)
* net/tramp.el (top, with-progress-reporter)
(tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp)
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers)
* net/tramp-gvfs.el (tramp-gvfs-handle-file-selinux-context): Use it.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
2010-05-09 19:57:55 +00:00
|
|
|
;; PRESERVE-SELINUX-CONTEXT has been introduced with Emacs 24.
|
2007-09-30 16:43:07 +00:00
|
|
|
(defun tramp-compat-copy-file
|
* net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if
not bound.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p)
* net/tramp.el (top, with-progress-reporter)
(tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp)
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers)
* net/tramp-gvfs.el (tramp-gvfs-handle-file-selinux-context): Use it.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
2010-05-09 19:57:55 +00:00
|
|
|
(filename newname &optional ok-if-already-exists keep-date
|
|
|
|
preserve-uid-gid preserve-selinux-context)
|
2007-09-30 16:43:07 +00:00
|
|
|
"Like `copy-file' for Tramp files (compat function)."
|
* net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if
not bound.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p)
* net/tramp.el (top, with-progress-reporter)
(tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp)
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers)
* net/tramp-gvfs.el (tramp-gvfs-handle-file-selinux-context): Use it.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
2010-05-09 19:57:55 +00:00
|
|
|
(cond
|
|
|
|
(preserve-selinux-context
|
|
|
|
(tramp-compat-funcall
|
|
|
|
'copy-file filename newname ok-if-already-exists keep-date
|
|
|
|
preserve-uid-gid preserve-selinux-context))
|
|
|
|
(preserve-uid-gid
|
|
|
|
(tramp-compat-funcall
|
|
|
|
'copy-file filename newname ok-if-already-exists keep-date
|
|
|
|
preserve-uid-gid))
|
|
|
|
(t
|
|
|
|
(copy-file filename newname ok-if-already-exists keep-date))))
|
2007-09-30 16:43:07 +00:00
|
|
|
|
2009-11-07 23:51:17 +00:00
|
|
|
;; `copy-directory' is a new function in Emacs 23.2. Implementation
|
|
|
|
;; is taken from there.
|
|
|
|
(defun tramp-compat-copy-directory
|
|
|
|
(directory newname &optional keep-time parents)
|
|
|
|
"Make a copy of DIRECTORY (compat function)."
|
|
|
|
(if (fboundp 'copy-directory)
|
* net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if
not bound.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p)
* net/tramp.el (top, with-progress-reporter)
(tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp)
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers)
* net/tramp-gvfs.el (tramp-gvfs-handle-file-selinux-context): Use it.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
2010-05-09 19:57:55 +00:00
|
|
|
(tramp-compat-funcall 'copy-directory directory newname keep-time parents)
|
2009-11-07 23:51:17 +00:00
|
|
|
|
2010-04-10 12:50:31 +00:00
|
|
|
;; If `default-directory' is a remote directory, make sure we find
|
|
|
|
;; its `copy-directory' handler.
|
2009-11-07 23:51:17 +00:00
|
|
|
(let ((handler (or (find-file-name-handler directory 'copy-directory)
|
|
|
|
(find-file-name-handler newname 'copy-directory))))
|
|
|
|
(if handler
|
|
|
|
(funcall handler 'copy-directory directory newname keep-time parents)
|
|
|
|
|
|
|
|
;; Compute target name.
|
|
|
|
(setq directory (directory-file-name (expand-file-name directory))
|
|
|
|
newname (directory-file-name (expand-file-name newname)))
|
|
|
|
(if (and (file-directory-p newname)
|
|
|
|
(not (string-equal (file-name-nondirectory directory)
|
|
|
|
(file-name-nondirectory newname))))
|
|
|
|
(setq newname
|
|
|
|
(expand-file-name
|
|
|
|
(file-name-nondirectory directory) newname)))
|
|
|
|
(if (not (file-directory-p newname)) (make-directory newname parents))
|
|
|
|
|
|
|
|
;; Copy recursively.
|
|
|
|
(mapc
|
|
|
|
(lambda (file)
|
|
|
|
(if (file-directory-p file)
|
|
|
|
(tramp-compat-copy-directory file newname keep-time parents)
|
|
|
|
(copy-file file newname t keep-time)))
|
|
|
|
;; We do not want to delete "." and "..".
|
|
|
|
(directory-files
|
|
|
|
directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))
|
|
|
|
|
|
|
|
;; Set directory attributes.
|
|
|
|
(set-file-modes newname (file-modes directory))
|
|
|
|
(if keep-time
|
|
|
|
(set-file-times newname (nth 5 (file-attributes directory))))))))
|
|
|
|
|
Change delete-by-moving-to-trash so Lisp calls explicitly request trashing.
* src/fileio.c (Fdelete_file): Change meaning of optional arg to mean
whether to trash.
(internal_delete_file, Frename_file): Callers changed.
(delete_by_moving_to_trash): Doc fix.
(Fdelete_directory_internal): Don't move to trash.
* src/callproc.c (delete_temp_file):
* src/buffer.c (Fkill_buffer): Callers changed.
* src/lisp.h: Update prototype.
* lisp/diff.el (diff-sentinel):
* lisp/epg.el (epg--make-temp-file, epg-decrypt-string)
(epg-verify-string, epg-sign-string, epg-encrypt-string):
* lisp/jka-compr.el (jka-compr-partial-uncompress)
(jka-compr-call-process, jka-compr-write-region):
* lisp/server.el (server-sentinel): Remove optional arg from
delete-file, reverting 2010-05-03 change.
* lisp/dired.el (dired-delete-file): New arg TRASH.
(dired-internal-do-deletions): New arg TRASH. Use progress
reporter.
(dired-do-flagged-delete, dired-do-delete): Use trash.
* lisp/files.el (delete-directory): New arg TRASH.
* lisp/speedbar.el (speedbar-item-delete): Allow trashing.
* lisp/net/ange-ftp.el (ange-ftp-del-tmp-name, ange-ftp-delete-file)
(ange-ftp-rename-remote-to-remote)
(ange-ftp-rename-local-to-remote)
(ange-ftp-rename-remote-to-local, ange-ftp-load)
(ange-ftp-compress, ange-ftp-uncompress): Remove optional arg from
`delete-file'.
(ange-ftp-delete-directory): Add optional arg to `delete-file', to
allow trashing.
* lisp/net/tramp-compat.el (tramp-compat-delete-file): Rewrite to
handle new TRASH arg of `delete-file'.
* lisp/net/tramp-fish.el (tramp-fish-handle-delete-directory)
(tramp-fish-handle-delete-file)
(tramp-fish-handle-make-symbolic-link)
(tramp-fish-handle-process-file): Use null TRASH arg in
`tramp-compat-delete-file' call.
* lisp/net/tramp-ftp.el (tramp-ftp-file-name-handler): Use null TRASH
arg in `tramp-compat-delete-file' call.
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-delete-file): Rename arg.
(tramp-gvfs-handle-write-region): Use null TRASH arg in
`tramp-compat-delete-file' call.
* lisp/net/tramp-imap.el (tramp-imap-handle-delete-file): Rename arg.
(tramp-imap-do-copy-or-rename-file): Use null TRASH arg in
`tramp-compat-delete-file' call.
* lisp/net/tramp-smb.el (tramp-smb-handle-copy-file)
(tramp-smb-handle-file-local-copy, tramp-smb-handle-rename-file)
(tramp-smb-handle-write-region): Use null TRASH arg in
tramp-compat-delete-file call.
(tramp-smb-handle-delete-directory): Use tramp-compat-delete-file.
(tramp-smb-handle-delete-file): Rename arg.
* lisp/net/tramp.el (tramp-handle-delete-file): Change FORCE arg to TRASH.
(tramp-handle-make-symbolic-link, tramp-handle-load)
(tramp-do-copy-or-rename-file-via-buffer)
(tramp-do-copy-or-rename-file-directly)
(tramp-do-copy-or-rename-file-out-of-band)
(tramp-handle-process-file, tramp-handle-call-process-region)
(tramp-handle-shell-command, tramp-handle-file-local-copy)
(tramp-handle-insert-file-contents, tramp-handle-write-region)
(tramp-delete-temp-file-function): Use null TRASH arg in
tramp-compat-delete-file call.
2010-05-27 23:30:11 +00:00
|
|
|
;; TRASH has been introduced with Emacs 24.1.
|
|
|
|
(defun tramp-compat-delete-file (filename &optional trash)
|
Add FORCE argument to `delete-file'.
* net/ange-ftp.el (ange-ftp-del-tmp-name): Make it a defun,
forcing to delete the temporary file.
(ange-ftp-delete-file): Add FORCE arg.
(ange-ftp-rename-remote-to-remote)
(ange-ftp-rename-local-to-remote, ange-ftp-rename-remote-to-local)
(ange-ftp-load, ange-ftp-compress, ange-ftp-uncompress): Force
file deletion.
* net/tramp-compat.el (tramp-compat-delete-file): New defun.
* net/tramp.el (tramp-handle-delete-file): Add FORCE arg.
(tramp-handle-make-symbolic-link, tramp-handle-load)
(tramp-do-copy-or-rename-file-via-buffer)
(tramp-do-copy-or-rename-file-directly)
(tramp-do-copy-or-rename-file-out-of-band)
(tramp-handle-process-file, tramp-handle-call-process-region)
(tramp-handle-shell-command, tramp-handle-file-local-copy)
(tramp-handle-insert-file-contents, tramp-handle-write-region)
(tramp-delete-temp-file-function): Use `tramp-compat-delete-file'.
* net/tramp-fish.el (tramp-fish-handle-delete-file): Add FORCE arg.
(tramp-fish-handle-make-symbolic-link)
(tramp-fish-handle-process-file): Use `tramp-compat-delete-file'.
* net/tramp-ftp.el (tramp-ftp-file-name-handler): Use
`tramp-compat-delete-file'.
* net/tramp-gvfs.el (tramp-gvfs-handle-delete-file): Add FORCE arg.
(tramp-gvfs-handle-write-region): Use `tramp-compat-delete-file'.
* net/tramp-imap.el (tramp-imap-handle-delete-file): Add FORCE arg.
(tramp-imap-do-copy-or-rename-file): Use `tramp-compat-delete-file'.
* net/tramp-smb.el (tramp-smb-handle-delete-file): Add FORCE arg.
(tramp-smb-handle-copy-file, tramp-smb-handle-file-local-copy)
(tramp-smb-handle-rename-file, tramp-smb-handle-write-region): Use
`tramp-compat-delete-file'.
2010-05-05 10:20:23 +00:00
|
|
|
"Like `delete-file' for Tramp files (compat function)."
|
Change delete-by-moving-to-trash so Lisp calls explicitly request trashing.
* src/fileio.c (Fdelete_file): Change meaning of optional arg to mean
whether to trash.
(internal_delete_file, Frename_file): Callers changed.
(delete_by_moving_to_trash): Doc fix.
(Fdelete_directory_internal): Don't move to trash.
* src/callproc.c (delete_temp_file):
* src/buffer.c (Fkill_buffer): Callers changed.
* src/lisp.h: Update prototype.
* lisp/diff.el (diff-sentinel):
* lisp/epg.el (epg--make-temp-file, epg-decrypt-string)
(epg-verify-string, epg-sign-string, epg-encrypt-string):
* lisp/jka-compr.el (jka-compr-partial-uncompress)
(jka-compr-call-process, jka-compr-write-region):
* lisp/server.el (server-sentinel): Remove optional arg from
delete-file, reverting 2010-05-03 change.
* lisp/dired.el (dired-delete-file): New arg TRASH.
(dired-internal-do-deletions): New arg TRASH. Use progress
reporter.
(dired-do-flagged-delete, dired-do-delete): Use trash.
* lisp/files.el (delete-directory): New arg TRASH.
* lisp/speedbar.el (speedbar-item-delete): Allow trashing.
* lisp/net/ange-ftp.el (ange-ftp-del-tmp-name, ange-ftp-delete-file)
(ange-ftp-rename-remote-to-remote)
(ange-ftp-rename-local-to-remote)
(ange-ftp-rename-remote-to-local, ange-ftp-load)
(ange-ftp-compress, ange-ftp-uncompress): Remove optional arg from
`delete-file'.
(ange-ftp-delete-directory): Add optional arg to `delete-file', to
allow trashing.
* lisp/net/tramp-compat.el (tramp-compat-delete-file): Rewrite to
handle new TRASH arg of `delete-file'.
* lisp/net/tramp-fish.el (tramp-fish-handle-delete-directory)
(tramp-fish-handle-delete-file)
(tramp-fish-handle-make-symbolic-link)
(tramp-fish-handle-process-file): Use null TRASH arg in
`tramp-compat-delete-file' call.
* lisp/net/tramp-ftp.el (tramp-ftp-file-name-handler): Use null TRASH
arg in `tramp-compat-delete-file' call.
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-delete-file): Rename arg.
(tramp-gvfs-handle-write-region): Use null TRASH arg in
`tramp-compat-delete-file' call.
* lisp/net/tramp-imap.el (tramp-imap-handle-delete-file): Rename arg.
(tramp-imap-do-copy-or-rename-file): Use null TRASH arg in
`tramp-compat-delete-file' call.
* lisp/net/tramp-smb.el (tramp-smb-handle-copy-file)
(tramp-smb-handle-file-local-copy, tramp-smb-handle-rename-file)
(tramp-smb-handle-write-region): Use null TRASH arg in
tramp-compat-delete-file call.
(tramp-smb-handle-delete-directory): Use tramp-compat-delete-file.
(tramp-smb-handle-delete-file): Rename arg.
* lisp/net/tramp.el (tramp-handle-delete-file): Change FORCE arg to TRASH.
(tramp-handle-make-symbolic-link, tramp-handle-load)
(tramp-do-copy-or-rename-file-via-buffer)
(tramp-do-copy-or-rename-file-directly)
(tramp-do-copy-or-rename-file-out-of-band)
(tramp-handle-process-file, tramp-handle-call-process-region)
(tramp-handle-shell-command, tramp-handle-file-local-copy)
(tramp-handle-insert-file-contents, tramp-handle-write-region)
(tramp-delete-temp-file-function): Use null TRASH arg in
tramp-compat-delete-file call.
2010-05-27 23:30:11 +00:00
|
|
|
(condition-case nil
|
|
|
|
(tramp-compat-funcall 'delete-file filename trash)
|
|
|
|
;; This Emacs version does not support the TRASH flag.
|
|
|
|
(wrong-number-of-arguments
|
|
|
|
(let ((delete-by-moving-to-trash
|
|
|
|
(and (boundp 'delete-by-moving-to-trash)
|
2010-05-28 13:28:36 +00:00
|
|
|
(symbol-value 'delete-by-moving-to-trash)
|
Change delete-by-moving-to-trash so Lisp calls explicitly request trashing.
* src/fileio.c (Fdelete_file): Change meaning of optional arg to mean
whether to trash.
(internal_delete_file, Frename_file): Callers changed.
(delete_by_moving_to_trash): Doc fix.
(Fdelete_directory_internal): Don't move to trash.
* src/callproc.c (delete_temp_file):
* src/buffer.c (Fkill_buffer): Callers changed.
* src/lisp.h: Update prototype.
* lisp/diff.el (diff-sentinel):
* lisp/epg.el (epg--make-temp-file, epg-decrypt-string)
(epg-verify-string, epg-sign-string, epg-encrypt-string):
* lisp/jka-compr.el (jka-compr-partial-uncompress)
(jka-compr-call-process, jka-compr-write-region):
* lisp/server.el (server-sentinel): Remove optional arg from
delete-file, reverting 2010-05-03 change.
* lisp/dired.el (dired-delete-file): New arg TRASH.
(dired-internal-do-deletions): New arg TRASH. Use progress
reporter.
(dired-do-flagged-delete, dired-do-delete): Use trash.
* lisp/files.el (delete-directory): New arg TRASH.
* lisp/speedbar.el (speedbar-item-delete): Allow trashing.
* lisp/net/ange-ftp.el (ange-ftp-del-tmp-name, ange-ftp-delete-file)
(ange-ftp-rename-remote-to-remote)
(ange-ftp-rename-local-to-remote)
(ange-ftp-rename-remote-to-local, ange-ftp-load)
(ange-ftp-compress, ange-ftp-uncompress): Remove optional arg from
`delete-file'.
(ange-ftp-delete-directory): Add optional arg to `delete-file', to
allow trashing.
* lisp/net/tramp-compat.el (tramp-compat-delete-file): Rewrite to
handle new TRASH arg of `delete-file'.
* lisp/net/tramp-fish.el (tramp-fish-handle-delete-directory)
(tramp-fish-handle-delete-file)
(tramp-fish-handle-make-symbolic-link)
(tramp-fish-handle-process-file): Use null TRASH arg in
`tramp-compat-delete-file' call.
* lisp/net/tramp-ftp.el (tramp-ftp-file-name-handler): Use null TRASH
arg in `tramp-compat-delete-file' call.
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-delete-file): Rename arg.
(tramp-gvfs-handle-write-region): Use null TRASH arg in
`tramp-compat-delete-file' call.
* lisp/net/tramp-imap.el (tramp-imap-handle-delete-file): Rename arg.
(tramp-imap-do-copy-or-rename-file): Use null TRASH arg in
`tramp-compat-delete-file' call.
* lisp/net/tramp-smb.el (tramp-smb-handle-copy-file)
(tramp-smb-handle-file-local-copy, tramp-smb-handle-rename-file)
(tramp-smb-handle-write-region): Use null TRASH arg in
tramp-compat-delete-file call.
(tramp-smb-handle-delete-directory): Use tramp-compat-delete-file.
(tramp-smb-handle-delete-file): Rename arg.
* lisp/net/tramp.el (tramp-handle-delete-file): Change FORCE arg to TRASH.
(tramp-handle-make-symbolic-link, tramp-handle-load)
(tramp-do-copy-or-rename-file-via-buffer)
(tramp-do-copy-or-rename-file-directly)
(tramp-do-copy-or-rename-file-out-of-band)
(tramp-handle-process-file, tramp-handle-call-process-region)
(tramp-handle-shell-command, tramp-handle-file-local-copy)
(tramp-handle-insert-file-contents, tramp-handle-write-region)
(tramp-delete-temp-file-function): Use null TRASH arg in
tramp-compat-delete-file call.
2010-05-27 23:30:11 +00:00
|
|
|
trash)))
|
|
|
|
(delete-file filename)))))
|
Add FORCE argument to `delete-file'.
* net/ange-ftp.el (ange-ftp-del-tmp-name): Make it a defun,
forcing to delete the temporary file.
(ange-ftp-delete-file): Add FORCE arg.
(ange-ftp-rename-remote-to-remote)
(ange-ftp-rename-local-to-remote, ange-ftp-rename-remote-to-local)
(ange-ftp-load, ange-ftp-compress, ange-ftp-uncompress): Force
file deletion.
* net/tramp-compat.el (tramp-compat-delete-file): New defun.
* net/tramp.el (tramp-handle-delete-file): Add FORCE arg.
(tramp-handle-make-symbolic-link, tramp-handle-load)
(tramp-do-copy-or-rename-file-via-buffer)
(tramp-do-copy-or-rename-file-directly)
(tramp-do-copy-or-rename-file-out-of-band)
(tramp-handle-process-file, tramp-handle-call-process-region)
(tramp-handle-shell-command, tramp-handle-file-local-copy)
(tramp-handle-insert-file-contents, tramp-handle-write-region)
(tramp-delete-temp-file-function): Use `tramp-compat-delete-file'.
* net/tramp-fish.el (tramp-fish-handle-delete-file): Add FORCE arg.
(tramp-fish-handle-make-symbolic-link)
(tramp-fish-handle-process-file): Use `tramp-compat-delete-file'.
* net/tramp-ftp.el (tramp-ftp-file-name-handler): Use
`tramp-compat-delete-file'.
* net/tramp-gvfs.el (tramp-gvfs-handle-delete-file): Add FORCE arg.
(tramp-gvfs-handle-write-region): Use `tramp-compat-delete-file'.
* net/tramp-imap.el (tramp-imap-handle-delete-file): Add FORCE arg.
(tramp-imap-do-copy-or-rename-file): Use `tramp-compat-delete-file'.
* net/tramp-smb.el (tramp-smb-handle-delete-file): Add FORCE arg.
(tramp-smb-handle-copy-file, tramp-smb-handle-file-local-copy)
(tramp-smb-handle-rename-file, tramp-smb-handle-write-region): Use
`tramp-compat-delete-file'.
2010-05-05 10:20:23 +00:00
|
|
|
|
2009-11-07 23:51:17 +00:00
|
|
|
;; RECURSIVE has been introduced with Emacs 23.2.
|
|
|
|
(defun tramp-compat-delete-directory (directory &optional recursive)
|
|
|
|
"Like `delete-directory' for Tramp files (compat function)."
|
2010-04-10 12:50:31 +00:00
|
|
|
(if (null recursive)
|
|
|
|
(delete-directory directory)
|
|
|
|
(condition-case nil
|
* net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if
not bound.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p)
* net/tramp.el (top, with-progress-reporter)
(tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp)
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers)
* net/tramp-gvfs.el (tramp-gvfs-handle-file-selinux-context): Use it.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
2010-05-09 19:57:55 +00:00
|
|
|
(tramp-compat-funcall 'delete-directory directory recursive)
|
2010-04-10 12:50:31 +00:00
|
|
|
;; This Emacs version does not support the RECURSIVE flag. We
|
|
|
|
;; use the implementation from Emacs 23.2.
|
2010-05-06 08:40:06 +00:00
|
|
|
(wrong-number-of-arguments
|
2010-04-10 12:50:31 +00:00
|
|
|
(setq directory (directory-file-name (expand-file-name directory)))
|
|
|
|
(if (not (file-symlink-p directory))
|
|
|
|
(mapc (lambda (file)
|
|
|
|
(if (eq t (car (file-attributes file)))
|
|
|
|
(tramp-compat-delete-directory file recursive)
|
|
|
|
(delete-file file)))
|
|
|
|
(directory-files
|
|
|
|
directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")))
|
|
|
|
(delete-directory directory)))))
|
|
|
|
|
|
|
|
;; `number-sequence' does not exist in XEmacs. Implementation is
|
|
|
|
;; taken from Emacs 23.
|
2009-09-02 11:15:56 +00:00
|
|
|
(defun tramp-compat-number-sequence (from &optional to inc)
|
|
|
|
"Return a sequence of numbers from FROM to TO as a list (compat function)."
|
|
|
|
(if (or (subrp 'number-sequence) (symbol-file 'number-sequence))
|
* net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if
not bound.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p)
* net/tramp.el (top, with-progress-reporter)
(tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp)
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers)
* net/tramp-gvfs.el (tramp-gvfs-handle-file-selinux-context): Use it.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
2010-05-09 19:57:55 +00:00
|
|
|
(tramp-compat-funcall 'number-sequence from to inc)
|
2009-09-02 11:15:56 +00:00
|
|
|
(if (or (not to) (= from to))
|
|
|
|
(list from)
|
|
|
|
(or inc (setq inc 1))
|
|
|
|
(when (zerop inc) (error "The increment can not be zero"))
|
|
|
|
(let (seq (n 0) (next from))
|
|
|
|
(if (> inc 0)
|
|
|
|
(while (<= next to)
|
|
|
|
(setq seq (cons next seq)
|
|
|
|
n (1+ n)
|
|
|
|
next (+ from (* n inc))))
|
|
|
|
(while (>= next to)
|
|
|
|
(setq seq (cons next seq)
|
|
|
|
n (1+ n)
|
|
|
|
next (+ from (* n inc)))))
|
|
|
|
(nreverse seq)))))
|
|
|
|
|
2009-06-22 21:07:27 +00:00
|
|
|
(defun tramp-compat-split-string (string pattern)
|
|
|
|
"Like `split-string' but omit empty strings.
|
|
|
|
In Emacs, (split-string \"/foo/bar\" \"/\") returns (\"foo\" \"bar\").
|
|
|
|
This is, the first, empty, element is omitted. In XEmacs, the first
|
|
|
|
element is not omitted."
|
|
|
|
(delete "" (split-string string pattern)))
|
|
|
|
|
|
|
|
(defun tramp-compat-process-running-p (process-name)
|
|
|
|
"Returns `t' if system process PROCESS-NAME is running for `user-login-name'."
|
|
|
|
(when (stringp process-name)
|
|
|
|
(cond
|
|
|
|
;; GNU Emacs 22 on w32.
|
|
|
|
((fboundp 'w32-window-exists-p)
|
* net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if
not bound.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p)
* net/tramp.el (top, with-progress-reporter)
(tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp)
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers)
* net/tramp-gvfs.el (tramp-gvfs-handle-file-selinux-context): Use it.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
2010-05-09 19:57:55 +00:00
|
|
|
(tramp-compat-funcall 'w32-window-exists-p process-name process-name))
|
2009-06-22 21:07:27 +00:00
|
|
|
|
|
|
|
;; GNU Emacs 23.
|
|
|
|
((and (fboundp 'list-system-processes) (fboundp 'process-attributes))
|
|
|
|
(let (result)
|
* net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if
not bound.
(tramp-compat-copy-file): Add PRESERVE-SELINUX-CONTEXT.
(tramp-compat-funcall): New defmacro.
(tramp-compat-line-beginning-position)
(tramp-compat-line-end-position)
(tramp-compat-temporary-file-directory)
(tramp-compat-make-temp-file, tramp-compat-file-attributes)
(tramp-compat-copy-file, tramp-compat-copy-directory)
(tramp-compat-delete-file, tramp-compat-delete-directory)
(tramp-compat-number-sequence, tramp-compat-process-running-p)
* net/tramp.el (top, with-progress-reporter)
(tramp-rfn-eshadow-setup-minibuffer)
(tramp-rfn-eshadow-update-overlay, tramp-handle-set-file-times)
(tramp-handle-dired-compress-file, tramp-handle-shell-command)
(tramp-completion-mode-p, tramp-check-for-regexp)
(tramp-open-connection-setup-interactive-shell)
(tramp-compute-multi-hops, tramp-read-passwd, tramp-clear-passwd)
(tramp-time-diff, tramp-coding-system-change-eol-conversion)
(tramp-set-process-query-on-exit-flag, tramp-unload-tramp)
* net/tramp-cmds.el (tramp-cleanup-all-connections)
(tramp-reporter-dump-variable, tramp-load-report-modules)
(tramp-append-tramp-buffers)
* net/tramp-gvfs.el (tramp-gvfs-handle-file-selinux-context): Use it.
* net/tramp-imap.el (top): Autoload `epg-make-context'.
2010-05-09 19:57:55 +00:00
|
|
|
(dolist (pid (tramp-compat-funcall 'list-system-processes) result)
|
|
|
|
(let ((attributes (tramp-compat-funcall 'process-attributes pid)))
|
2009-10-06 19:52:15 +00:00
|
|
|
(when (and (string-equal
|
|
|
|
(cdr (assoc 'user attributes)) (user-login-name))
|
|
|
|
(let ((comm (cdr (assoc 'comm attributes))))
|
|
|
|
;; The returned command name could be truncated
|
|
|
|
;; to 15 characters. Therefore, we cannot check
|
|
|
|
;; for `string-equal'.
|
|
|
|
(and comm (string-match
|
|
|
|
(concat "^" (regexp-quote comm))
|
|
|
|
process-name))))
|
2009-06-22 21:07:27 +00:00
|
|
|
(setq result t))))))
|
|
|
|
|
|
|
|
;; Fallback, if there is no Lisp support yet.
|
|
|
|
(t (let ((default-directory
|
|
|
|
(if (file-remote-p default-directory)
|
|
|
|
(tramp-compat-temporary-file-directory)
|
|
|
|
default-directory))
|
|
|
|
(unix95 (getenv "UNIX95"))
|
|
|
|
result)
|
|
|
|
(setenv "UNIX95" "1")
|
|
|
|
(when (member
|
|
|
|
(user-login-name)
|
|
|
|
(tramp-compat-split-string
|
|
|
|
(shell-command-to-string
|
|
|
|
(format "ps -C %s -o user=" process-name))
|
|
|
|
"[ \f\t\n\r\v]+"))
|
|
|
|
(setq result t))
|
|
|
|
(setenv "UNIX95" unix95)
|
|
|
|
result)))))
|
|
|
|
|
2007-09-30 16:43:07 +00:00
|
|
|
(provide 'tramp-compat)
|
|
|
|
|
|
|
|
;;; TODO:
|
|
|
|
|
2007-10-01 00:14:23 +00:00
|
|
|
;; arch-tag: 0e724b18-6699-4f87-ad96-640b272e5c85
|
2007-09-30 16:43:07 +00:00
|
|
|
;;; tramp-compat.el ends here
|