2017-12-09 13:34:30 +00:00
|
|
|
|
;;; tramp-archive.el --- Tramp archive manager -*- lexical-binding:t -*-
|
|
|
|
|
|
2021-01-01 09:13:56 +00:00
|
|
|
|
;; Copyright (C) 2017-2021 Free Software Foundation, Inc.
|
2017-12-09 13:34:30 +00:00
|
|
|
|
|
|
|
|
|
;; Author: Michael Albinus <michael.albinus@gmx.de>
|
|
|
|
|
;; Keywords: comm, processes
|
|
|
|
|
;; Package: tramp
|
|
|
|
|
|
|
|
|
|
;; 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 of the License, 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. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; Access functions for file archives. This is possible only on
|
|
|
|
|
;; machines which have installed the virtual file system for the Gnome
|
|
|
|
|
;; Desktop (GVFS). Internally, file archives are mounted via the GVFS
|
|
|
|
|
;; "archive" method.
|
|
|
|
|
|
|
|
|
|
;; A file archive is a regular file of kind "/path/to/dir/file.EXT".
|
|
|
|
|
;; The extension ".EXT" identifies the type of the file archive. A
|
|
|
|
|
;; file inside a file archive, called archive file name, has the name
|
|
|
|
|
;; "/path/to/dir/file.EXT/dir/file".
|
|
|
|
|
|
|
|
|
|
;; Most of the magic file name operations are implemented for archive
|
|
|
|
|
;; file names, exceptions are all operations which write into a file
|
|
|
|
|
;; archive, and process related operations. Therefore, functions like
|
|
|
|
|
|
|
|
|
|
;; (copy-file "/path/to/dir/file.tar/dir/file" "/somewhere/else")
|
|
|
|
|
|
|
|
|
|
;; work out of the box. This is also true for file name completion,
|
|
|
|
|
;; and for libraries like `dired' or `ediff', which accept archive
|
|
|
|
|
;; file names as well.
|
|
|
|
|
|
|
|
|
|
;; File archives are identified by the file name extension ".EXT".
|
|
|
|
|
;; Since GVFS uses internally the library libarchive(3), all suffixes,
|
|
|
|
|
;; which are accepted by this library, work also for archive file
|
|
|
|
|
;; names. Accepted suffixes are listed in the constant
|
|
|
|
|
;; `tramp-archive-suffixes'. They are
|
|
|
|
|
|
|
|
|
|
;; * ".7z" - 7-Zip archives
|
|
|
|
|
;; * ".apk" - Android package kits
|
|
|
|
|
;; * ".ar" - UNIX archiver formats
|
|
|
|
|
;; * ".cab", ".CAB" - Microsoft Windows cabinets
|
|
|
|
|
;; * ".cpio" - CPIO archives
|
|
|
|
|
;; * ".deb" - Debian packages
|
|
|
|
|
;; * ".depot" - HP-UX SD depots
|
|
|
|
|
;; * ".exe" - Self extracting Microsoft Windows EXE files
|
|
|
|
|
;; * ".iso" - ISO 9660 images
|
|
|
|
|
;; * ".jar" - Java archives
|
2018-02-27 14:26:09 +00:00
|
|
|
|
;; * ".lzh", ".LZH" - Microsoft Windows compressed LHA archives
|
|
|
|
|
;; * ".msu", ".MSU" - Microsoft Windows Update packages
|
2017-12-09 13:34:30 +00:00
|
|
|
|
;; * ".mtree" - BSD mtree format
|
2018-03-08 13:09:38 +00:00
|
|
|
|
;; * ".odb" ".odf" ".odg" ".odp" ".ods" ".odt" - OpenDocument formats
|
2017-12-09 13:34:30 +00:00
|
|
|
|
;; * ".pax" - Posix archives
|
|
|
|
|
;; * ".rar" - RAR archives
|
|
|
|
|
;; * ".rpm" - Red Hat packages
|
|
|
|
|
;; * ".shar" - Shell archives
|
2018-02-27 14:26:09 +00:00
|
|
|
|
;; * ".tar", ".tbz", ".tgz", ".tlz", ".txz" - (Compressed) tape archives
|
2017-12-09 13:34:30 +00:00
|
|
|
|
;; * ".warc" - Web archives
|
|
|
|
|
;; * ".xar" - macOS XAR archives
|
2018-02-19 18:44:57 +00:00
|
|
|
|
;; * ".xpi" - XPInstall Mozilla addons
|
2017-12-09 13:34:30 +00:00
|
|
|
|
;; * ".xps" - Open XML Paper Specification (OpenXPS) documents
|
|
|
|
|
;; * ".zip", ".ZIP" - ZIP archives
|
|
|
|
|
|
|
|
|
|
;; File archives could also be compressed, identified by an additional
|
|
|
|
|
;; compression suffix. Valid compression suffixes are listed in the
|
|
|
|
|
;; constant `tramp-archive-compression-suffixes'. They are ".bz2",
|
2019-06-24 14:02:46 +00:00
|
|
|
|
;; ".gz", ".lrz", ".lz", ".lz4", ".lzma", ".lzo", ".uu", ".xz", ".Z",
|
|
|
|
|
;; and ".zst". A valid archive file name would be
|
2017-12-09 13:34:30 +00:00
|
|
|
|
;; "/path/to/dir/file.tar.gz/dir/file". Even several suffixes in a
|
|
|
|
|
;; row are possible, like "/path/to/dir/file.tar.gz.uu/dir/file".
|
|
|
|
|
|
|
|
|
|
;; An archive file name could be a remote file name, as in
|
|
|
|
|
;; "/ftp:anonymous@ftp.gnu.org:/gnu/tramp/tramp-2.3.2.tar.gz/INSTALL".
|
|
|
|
|
;; Since all file operations are mapped internally to GVFS operations,
|
|
|
|
|
;; remote file names supported by tramp-gvfs.el perform better,
|
|
|
|
|
;; because no local copy of the file archive must be downloaded first.
|
|
|
|
|
;; For example, "/sftp:user@host:..." performs better than the similar
|
|
|
|
|
;; "/scp:user@host:...". See the constant
|
|
|
|
|
;; `tramp-archive-all-gvfs-methods' for a complete list of
|
|
|
|
|
;; tramp-gvfs.el supported method names.
|
|
|
|
|
|
|
|
|
|
;; If `url-handler-mode' is enabled, archives could be visited via
|
|
|
|
|
;; URLs, like "https://ftp.gnu.org/gnu/tramp/tramp-2.3.2.tar.gz/INSTALL".
|
|
|
|
|
;; This allows complex file operations like
|
|
|
|
|
|
|
|
|
|
;; (ediff-directories
|
|
|
|
|
;; "https://ftp.gnu.org/gnu/tramp/tramp-2.3.1.tar.gz/tramp-2.3.1"
|
|
|
|
|
;; "https://ftp.gnu.org/gnu/tramp/tramp-2.3.2.tar.gz/tramp-2.3.2" "")
|
|
|
|
|
|
|
|
|
|
;; It is even possible to access file archives in file archives, as
|
|
|
|
|
|
|
|
|
|
;; (find-file
|
|
|
|
|
;; "http://ftp.debian.org/debian/pool/main/c/coreutils/coreutils_8.28-1_amd64.deb/control.tar.gz/control")
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
Explicitly require cl-lib where needed
Rather than relying on the byte-compiler happening to use it.
* lisp/completion.el, lisp/ffap.el, lisp/loadhist.el:
* lisp/userlock.el, lisp/emacs-lisp/debug.el, lisp/emacs-lisp/rx.el:
* lisp/emacs-lisp/testcover.el, lisp/mail/rfc2231.el:
* lisp/net/newst-treeview.el, lisp/net/puny.el:
* lisp/net/tramp-archive.el, lisp/net/tramp-gvfs.el:
* lisp/net/tramp-sh.el, lisp/net/tramp-smb.el, lisp/org/org-ctags.el:
* lisp/org/org-macs.el, lisp/progmodes/grep.el:
* lisp/progmodes/perl-mode.el, lisp/progmodes/ruby-mode.el:
* lisp/textmodes/dns-mode.el, lisp/textmodes/mhtml-mode.el:
* lisp/vc/pcvs-parse.el: Explicitly require cl-lib as needed.
2018-03-17 00:41:17 +00:00
|
|
|
|
(eval-when-compile (require 'cl-lib))
|
2019-01-29 16:25:36 +00:00
|
|
|
|
;; Sometimes, compilation fails with "Variable binding depth exceeds
|
2020-05-20 16:01:06 +00:00
|
|
|
|
;; max-specpdl-size". Shall be fixed in Emacs 27.
|
2019-01-29 16:25:36 +00:00
|
|
|
|
(eval-and-compile
|
|
|
|
|
(let ((max-specpdl-size (* 2 max-specpdl-size))) (require 'tramp-gvfs)))
|
2017-12-09 13:34:30 +00:00
|
|
|
|
|
|
|
|
|
(autoload 'dired-uncache "dired")
|
|
|
|
|
(autoload 'url-tramp-convert-url-to-tramp "url-tramp")
|
|
|
|
|
(defvar url-handler-mode-hook)
|
|
|
|
|
(defvar url-handler-regexp)
|
|
|
|
|
(defvar url-tramp-protocols)
|
|
|
|
|
|
2018-02-03 17:49:56 +00:00
|
|
|
|
;; We cannot check `tramp-gvfs-enabled' in loaddefs.el, because this
|
2018-05-15 09:06:18 +00:00
|
|
|
|
;; would load Tramp. So we make a cheaper check.
|
2018-02-03 17:49:56 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defvar tramp-archive-enabled (featurep 'dbusbind)
|
2018-02-04 12:25:10 +00:00
|
|
|
|
"Non-nil when file archive support is available.")
|
2018-02-03 17:49:56 +00:00
|
|
|
|
|
2018-02-04 12:25:10 +00:00
|
|
|
|
;; After loading tramp-gvfs.el, we know it better.
|
2018-02-03 17:49:56 +00:00
|
|
|
|
(setq tramp-archive-enabled tramp-gvfs-enabled)
|
|
|
|
|
|
2017-12-09 13:34:30 +00:00
|
|
|
|
;; <https://github.com/libarchive/libarchive/wiki/LibarchiveFormats>
|
2019-05-18 09:11:23 +00:00
|
|
|
|
;; Note: "arc" and "zoo" are supported by `archive-mode', but they
|
|
|
|
|
;; don't work here.
|
2018-02-03 12:22:56 +00:00
|
|
|
|
;;;###autoload
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(defconst tramp-archive-suffixes
|
2018-03-08 13:09:38 +00:00
|
|
|
|
;; "cab", "lzh", "msu" and "zip" are included with lower and upper
|
|
|
|
|
;; letters, because Microsoft Windows provides them often with
|
|
|
|
|
;; capital letters.
|
2017-12-09 13:34:30 +00:00
|
|
|
|
'("7z" ;; 7-Zip archives.
|
|
|
|
|
"apk" ;; Android package kits. Not in libarchive testsuite.
|
|
|
|
|
"ar" ;; UNIX archiver formats.
|
|
|
|
|
"cab" "CAB" ;; Microsoft Windows cabinets.
|
|
|
|
|
"cpio" ;; CPIO archives.
|
|
|
|
|
"deb" ;; Debian packages. Not in libarchive testsuite.
|
|
|
|
|
"depot" ;; HP-UX SD depot. Not in libarchive testsuite.
|
|
|
|
|
"exe" ;; Self extracting Microsoft Windows EXE files.
|
|
|
|
|
"iso" ;; ISO 9660 images.
|
|
|
|
|
"jar" ;; Java archives. Not in libarchive testsuite.
|
|
|
|
|
"lzh" "LZH" ;; Microsoft Windows compressed LHA archives.
|
2018-02-27 14:26:09 +00:00
|
|
|
|
"msu" "MSU" ;; Microsoft Windows Update packages. Not in testsuite.
|
2017-12-09 13:34:30 +00:00
|
|
|
|
"mtree" ;; BSD mtree format.
|
2018-03-08 13:09:38 +00:00
|
|
|
|
"odb" "odf" "odg" "odp" "ods" "odt" ;; OpenDocument formats. Not in testsuite.
|
2017-12-09 13:34:30 +00:00
|
|
|
|
"pax" ;; Posix archives.
|
|
|
|
|
"rar" ;; RAR archives.
|
|
|
|
|
"rpm" ;; Red Hat packages.
|
|
|
|
|
"shar" ;; Shell archives. Not in libarchive testsuite.
|
2019-06-24 14:02:46 +00:00
|
|
|
|
"tar" "tbz" "tgz" "tlz" "txz" "tzst" ;; (Compressed) tape archives.
|
2017-12-09 13:34:30 +00:00
|
|
|
|
"warc" ;; Web archives.
|
|
|
|
|
"xar" ;; macOS XAR archives. Not in libarchive testsuite.
|
2018-02-19 18:44:57 +00:00
|
|
|
|
"xpi" ;; XPInstall Mozilla addons. Not in libarchive testsuite.
|
2017-12-09 13:34:30 +00:00
|
|
|
|
"xps" ;; Open XML Paper Specification (OpenXPS) documents.
|
|
|
|
|
"zip" "ZIP") ;; ZIP archives.
|
|
|
|
|
"List of suffixes which indicate a file archive.
|
|
|
|
|
It must be supported by libarchive(3).")
|
|
|
|
|
|
2020-10-24 18:22:33 +00:00
|
|
|
|
;; <https://unix-memo.readthedocs.io/en/latest/vfs.html>
|
2018-02-03 12:22:56 +00:00
|
|
|
|
;; read and write: tar, cpio, pax , gzip , zip, bzip2, xz, lzip, lzma, ar, mtree, iso9660, compress.
|
|
|
|
|
;; read only: 7-Zip, mtree, xar, lha/lzh, rar, microsoft cab.
|
2017-12-09 13:34:30 +00:00
|
|
|
|
|
2018-02-03 12:22:56 +00:00
|
|
|
|
;;;###autoload
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(defconst tramp-archive-compression-suffixes
|
2019-06-24 13:57:33 +00:00
|
|
|
|
'("bz2" "gz" "lrz" "lz" "lz4" "lzma" "lzo" "uu" "xz" "Z" "zst")
|
2017-12-09 13:34:30 +00:00
|
|
|
|
"List of suffixes which indicate a compressed file.
|
|
|
|
|
It must be supported by libarchive(3).")
|
|
|
|
|
|
2018-02-03 12:22:56 +00:00
|
|
|
|
;; The definition of `tramp-archive-file-name-regexp' contains calls
|
|
|
|
|
;; to `regexp-opt', which cannot be autoloaded while loading
|
|
|
|
|
;; loaddefs.el. So we use a macro, which is evaluated only when needed.
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(progn (defmacro tramp-archive-autoload-file-name-regexp ()
|
|
|
|
|
"Regular expression matching archive file names."
|
2018-11-05 00:22:15 +00:00
|
|
|
|
'(concat
|
2017-12-09 13:34:30 +00:00
|
|
|
|
"\\`" "\\(" ".+" "\\."
|
2018-11-25 20:49:41 +00:00
|
|
|
|
;; Default suffixes ...
|
|
|
|
|
(regexp-opt tramp-archive-suffixes)
|
|
|
|
|
;; ... with compression.
|
|
|
|
|
"\\(?:" "\\." (regexp-opt tramp-archive-compression-suffixes) "\\)*"
|
2017-12-09 13:34:30 +00:00
|
|
|
|
"\\)" ;; \1
|
2018-02-03 12:22:56 +00:00
|
|
|
|
"\\(" "/" ".*" "\\)" "\\'"))) ;; \2
|
|
|
|
|
|
2018-02-04 12:25:10 +00:00
|
|
|
|
;; In older Emacsen (prior 27.1), `tramp-archive-autoload-file-name-regexp'
|
|
|
|
|
;; is not autoloaded. So we cannot expect it to be known in
|
2021-09-16 14:50:24 +00:00
|
|
|
|
;; tramp-loaddefs.el. But it exists, when tramp-archive.el is loaded.
|
2018-02-03 12:22:56 +00:00
|
|
|
|
;;;###tramp-autoload
|
|
|
|
|
(defconst tramp-archive-file-name-regexp
|
2018-02-03 17:49:56 +00:00
|
|
|
|
(ignore-errors (tramp-archive-autoload-file-name-regexp))
|
2017-12-09 13:34:30 +00:00
|
|
|
|
"Regular expression matching archive file names.")
|
|
|
|
|
|
|
|
|
|
;;;###tramp-autoload
|
|
|
|
|
(defconst tramp-archive-method "archive"
|
|
|
|
|
"Method name for archives in GVFS.")
|
|
|
|
|
|
|
|
|
|
(defconst tramp-archive-all-gvfs-methods
|
|
|
|
|
(cons tramp-archive-method
|
|
|
|
|
(let ((values (cdr (cadr (get 'tramp-gvfs-methods 'custom-type)))))
|
2019-02-28 09:33:05 +00:00
|
|
|
|
(setq values (mapcar #'last values)
|
|
|
|
|
values (mapcar #'car values))))
|
2017-12-09 13:34:30 +00:00
|
|
|
|
"List of all methods `tramp-gvfs-methods' offers.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; New handlers should be added here.
|
|
|
|
|
;;;###tramp-autoload
|
|
|
|
|
(defconst tramp-archive-file-name-handler-alist
|
2019-02-19 13:00:17 +00:00
|
|
|
|
'((access-file . tramp-archive-handle-access-file)
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(add-name-to-file . tramp-archive-handle-not-implemented)
|
|
|
|
|
;; `byte-compiler-base-file-name' performed by default handler.
|
|
|
|
|
;; `copy-directory' performed by default handler.
|
|
|
|
|
(copy-file . tramp-archive-handle-copy-file)
|
2017-12-15 07:21:50 +00:00
|
|
|
|
(delete-directory . tramp-archive-handle-not-implemented)
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(delete-file . tramp-archive-handle-not-implemented)
|
|
|
|
|
;; `diff-latest-backup-file' performed by default handler.
|
|
|
|
|
(directory-file-name . tramp-archive-handle-directory-file-name)
|
|
|
|
|
(directory-files . tramp-handle-directory-files)
|
|
|
|
|
(directory-files-and-attributes
|
|
|
|
|
. tramp-handle-directory-files-and-attributes)
|
|
|
|
|
(dired-compress-file . tramp-archive-handle-not-implemented)
|
|
|
|
|
(dired-uncache . tramp-archive-handle-dired-uncache)
|
2018-06-20 10:13:56 +00:00
|
|
|
|
(exec-path . ignore)
|
2017-12-09 13:34:30 +00:00
|
|
|
|
;; `expand-file-name' performed by default handler.
|
|
|
|
|
(file-accessible-directory-p . tramp-handle-file-accessible-directory-p)
|
|
|
|
|
(file-acl . ignore)
|
|
|
|
|
(file-attributes . tramp-archive-handle-file-attributes)
|
|
|
|
|
(file-directory-p . tramp-handle-file-directory-p)
|
|
|
|
|
(file-equal-p . tramp-handle-file-equal-p)
|
|
|
|
|
(file-executable-p . tramp-archive-handle-file-executable-p)
|
|
|
|
|
(file-exists-p . tramp-handle-file-exists-p)
|
|
|
|
|
(file-in-directory-p . tramp-handle-file-in-directory-p)
|
|
|
|
|
(file-local-copy . tramp-archive-handle-file-local-copy)
|
Implement file locks for remote files (Bug#49261)
* doc/lispref/files.texi (Magic File Names): Add file-locked-p,
lock-file and unlock-file.
* etc/NEWS: Tramp supports file locks now.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-adb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
* lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-crypt-handle-file-locked-p, tramp-crypt-handle-lock-file)
(tramp-crypt-handle-unlock-file): New defun.
* lisp/net/tramp-fuse.el (tramp-fuse-mounted-p): Simplify.
(tramp-fuse-unmount): New defun.
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-gvfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-rclone-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sh-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-smb-handle-copy-directory): Use `sleep-for'.
(tramp-smb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sshfs-handle-write-region): Handle LOCKNAME.
(tramp-sshfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sudoedit-maybe-open-connection):
Set "lock-pid" connection property.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-make-lock-name, tramp-get-lock-file, tramp-get-lock-pid)
(tramp-handle-file-locked-p, tramp-handle-lock-file)
(tramp-handle-unlock-file): New defuns.
(tramp-lock-file-contents-regexp): New regexp.
(tramp-handle-write-region): Handle LOCKNAME.
* src/filelock.c (lock_file, unlock_file_body, Ffile_locked_p):
Call handler if exists.
(Flock_file, Funlock_file): New defuns.
(Qlock_file, Qunlock_file, Qfile_locked_p): Declare symbols.
(Slock_file, Sunlock_file): Declare subroutines.
* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test40-make-nearby-temp-file)
(tramp-archive-test43-file-system-info): Rename.
* test/lisp/net/tramp-tests.el (top): Set `create-lockfiles' to nil.
(tramp--test-fuse-p): New defun.
(tramp-test14-delete-directory): Use it.
(tramp-test39-lock-file): New test.
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters)
(tramp-test41-special-characters-with-stat)
(tramp-test41-special-characters-with-perl)
(tramp-test41-special-characters-with-ls, tramp-test42-utf8)
(tramp-test42-utf8-with-stat, tramp-test42-utf8-with-perl)
(tramp-test42-utf8-with-ls, tramp-test43-file-system-info)
(tramp-test44-asynchronous-requests, tramp-test45-auto-load)
(tramp-test45-delay-load, tramp-test45-recursive-load)
(tramp-test45-remote-load-path, tramp-test46-unload): Rename.
(tramp--test-special-characters, tramp--test-utf8)
(tramp--test-asynchronous-requests-timeout): Modify docstring.
2021-07-07 16:36:53 +00:00
|
|
|
|
(file-locked-p . ignore)
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(file-modes . tramp-handle-file-modes)
|
|
|
|
|
(file-name-all-completions . tramp-archive-handle-file-name-all-completions)
|
|
|
|
|
;; `file-name-as-directory' performed by default handler.
|
|
|
|
|
(file-name-case-insensitive-p . ignore)
|
|
|
|
|
(file-name-completion . tramp-handle-file-name-completion)
|
|
|
|
|
;; `file-name-directory' performed by default handler.
|
|
|
|
|
;; `file-name-nondirectory' performed by default handler.
|
|
|
|
|
;; `file-name-sans-versions' performed by default handler.
|
|
|
|
|
(file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
|
|
|
|
|
(file-notify-add-watch . ignore)
|
|
|
|
|
(file-notify-rm-watch . ignore)
|
|
|
|
|
(file-notify-valid-p . ignore)
|
|
|
|
|
(file-ownership-preserved-p . ignore)
|
|
|
|
|
(file-readable-p . tramp-archive-handle-file-readable-p)
|
|
|
|
|
(file-regular-p . tramp-handle-file-regular-p)
|
|
|
|
|
;; `file-remote-p' performed by default handler.
|
|
|
|
|
(file-selinux-context . tramp-handle-file-selinux-context)
|
|
|
|
|
(file-symlink-p . tramp-handle-file-symlink-p)
|
|
|
|
|
(file-system-info . tramp-archive-handle-file-system-info)
|
|
|
|
|
(file-truename . tramp-archive-handle-file-truename)
|
|
|
|
|
(file-writable-p . ignore)
|
|
|
|
|
(find-backup-file-name . ignore)
|
|
|
|
|
;; `get-file-buffer' performed by default handler.
|
|
|
|
|
(insert-directory . tramp-archive-handle-insert-directory)
|
|
|
|
|
(insert-file-contents . tramp-archive-handle-insert-file-contents)
|
|
|
|
|
(load . tramp-archive-handle-load)
|
Implement file locks for remote files (Bug#49261)
* doc/lispref/files.texi (Magic File Names): Add file-locked-p,
lock-file and unlock-file.
* etc/NEWS: Tramp supports file locks now.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-adb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
* lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-crypt-handle-file-locked-p, tramp-crypt-handle-lock-file)
(tramp-crypt-handle-unlock-file): New defun.
* lisp/net/tramp-fuse.el (tramp-fuse-mounted-p): Simplify.
(tramp-fuse-unmount): New defun.
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-gvfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-rclone-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sh-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-smb-handle-copy-directory): Use `sleep-for'.
(tramp-smb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sshfs-handle-write-region): Handle LOCKNAME.
(tramp-sshfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sudoedit-maybe-open-connection):
Set "lock-pid" connection property.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-make-lock-name, tramp-get-lock-file, tramp-get-lock-pid)
(tramp-handle-file-locked-p, tramp-handle-lock-file)
(tramp-handle-unlock-file): New defuns.
(tramp-lock-file-contents-regexp): New regexp.
(tramp-handle-write-region): Handle LOCKNAME.
* src/filelock.c (lock_file, unlock_file_body, Ffile_locked_p):
Call handler if exists.
(Flock_file, Funlock_file): New defuns.
(Qlock_file, Qunlock_file, Qfile_locked_p): Declare symbols.
(Slock_file, Sunlock_file): Declare subroutines.
* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test40-make-nearby-temp-file)
(tramp-archive-test43-file-system-info): Rename.
* test/lisp/net/tramp-tests.el (top): Set `create-lockfiles' to nil.
(tramp--test-fuse-p): New defun.
(tramp-test14-delete-directory): Use it.
(tramp-test39-lock-file): New test.
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters)
(tramp-test41-special-characters-with-stat)
(tramp-test41-special-characters-with-perl)
(tramp-test41-special-characters-with-ls, tramp-test42-utf8)
(tramp-test42-utf8-with-stat, tramp-test42-utf8-with-perl)
(tramp-test42-utf8-with-ls, tramp-test43-file-system-info)
(tramp-test44-asynchronous-requests, tramp-test45-auto-load)
(tramp-test45-delay-load, tramp-test45-recursive-load)
(tramp-test45-remote-load-path, tramp-test46-unload): Rename.
(tramp--test-special-characters, tramp--test-utf8)
(tramp--test-asynchronous-requests-timeout): Modify docstring.
2021-07-07 16:36:53 +00:00
|
|
|
|
(lock-file . ignore)
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(make-auto-save-file-name . ignore)
|
|
|
|
|
(make-directory . tramp-archive-handle-not-implemented)
|
|
|
|
|
(make-directory-internal . tramp-archive-handle-not-implemented)
|
2021-07-08 19:13:40 +00:00
|
|
|
|
(make-lock-file-name . ignore)
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
|
2018-12-23 08:48:05 +00:00
|
|
|
|
(make-process . ignore)
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(make-symbolic-link . tramp-archive-handle-not-implemented)
|
|
|
|
|
(process-file . ignore)
|
|
|
|
|
(rename-file . tramp-archive-handle-not-implemented)
|
|
|
|
|
(set-file-acl . ignore)
|
|
|
|
|
(set-file-modes . tramp-archive-handle-not-implemented)
|
|
|
|
|
(set-file-selinux-context . ignore)
|
|
|
|
|
(set-file-times . tramp-archive-handle-not-implemented)
|
|
|
|
|
(set-visited-file-modtime . tramp-handle-set-visited-file-modtime)
|
|
|
|
|
(shell-command . tramp-archive-handle-not-implemented)
|
|
|
|
|
(start-file-process . tramp-archive-handle-not-implemented)
|
|
|
|
|
;; `substitute-in-file-name' performed by default handler.
|
2017-12-17 10:31:23 +00:00
|
|
|
|
(temporary-file-directory . tramp-archive-handle-temporary-file-directory)
|
2020-06-14 13:31:17 +00:00
|
|
|
|
(tramp-get-remote-gid . ignore)
|
|
|
|
|
(tramp-get-remote-uid . ignore)
|
|
|
|
|
(tramp-set-file-uid-gid . ignore)
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(unhandled-file-name-directory . ignore)
|
Implement file locks for remote files (Bug#49261)
* doc/lispref/files.texi (Magic File Names): Add file-locked-p,
lock-file and unlock-file.
* etc/NEWS: Tramp supports file locks now.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-adb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
* lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-crypt-handle-file-locked-p, tramp-crypt-handle-lock-file)
(tramp-crypt-handle-unlock-file): New defun.
* lisp/net/tramp-fuse.el (tramp-fuse-mounted-p): Simplify.
(tramp-fuse-unmount): New defun.
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-gvfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-rclone-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sh-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-smb-handle-copy-directory): Use `sleep-for'.
(tramp-smb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sshfs-handle-write-region): Handle LOCKNAME.
(tramp-sshfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sudoedit-maybe-open-connection):
Set "lock-pid" connection property.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-make-lock-name, tramp-get-lock-file, tramp-get-lock-pid)
(tramp-handle-file-locked-p, tramp-handle-lock-file)
(tramp-handle-unlock-file): New defuns.
(tramp-lock-file-contents-regexp): New regexp.
(tramp-handle-write-region): Handle LOCKNAME.
* src/filelock.c (lock_file, unlock_file_body, Ffile_locked_p):
Call handler if exists.
(Flock_file, Funlock_file): New defuns.
(Qlock_file, Qunlock_file, Qfile_locked_p): Declare symbols.
(Slock_file, Sunlock_file): Declare subroutines.
* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test40-make-nearby-temp-file)
(tramp-archive-test43-file-system-info): Rename.
* test/lisp/net/tramp-tests.el (top): Set `create-lockfiles' to nil.
(tramp--test-fuse-p): New defun.
(tramp-test14-delete-directory): Use it.
(tramp-test39-lock-file): New test.
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters)
(tramp-test41-special-characters-with-stat)
(tramp-test41-special-characters-with-perl)
(tramp-test41-special-characters-with-ls, tramp-test42-utf8)
(tramp-test42-utf8-with-stat, tramp-test42-utf8-with-perl)
(tramp-test42-utf8-with-ls, tramp-test43-file-system-info)
(tramp-test44-asynchronous-requests, tramp-test45-auto-load)
(tramp-test45-delay-load, tramp-test45-recursive-load)
(tramp-test45-remote-load-path, tramp-test46-unload): Rename.
(tramp--test-special-characters, tramp--test-utf8)
(tramp--test-asynchronous-requests-timeout): Modify docstring.
2021-07-07 16:36:53 +00:00
|
|
|
|
(unlock-file . ignore)
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(vc-registered . ignore)
|
|
|
|
|
(verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)
|
|
|
|
|
(write-region . tramp-archive-handle-not-implemented))
|
2018-02-04 12:25:10 +00:00
|
|
|
|
"Alist of handler functions for file archive method.
|
2017-12-09 13:34:30 +00:00
|
|
|
|
Operations not mentioned here will be handled by the default Emacs primitives.")
|
|
|
|
|
|
2018-01-31 14:02:46 +00:00
|
|
|
|
(defsubst tramp-archive-file-name-for-operation (operation &rest args)
|
|
|
|
|
"Like `tramp-file-name-for-operation', but for archive file name syntax."
|
2019-02-28 09:33:05 +00:00
|
|
|
|
(cl-letf (((symbol-function #'tramp-tramp-file-p)
|
|
|
|
|
#'tramp-archive-file-name-p))
|
|
|
|
|
(apply #'tramp-file-name-for-operation operation args)))
|
2018-01-31 14:02:46 +00:00
|
|
|
|
|
2018-02-01 07:40:46 +00:00
|
|
|
|
(defun tramp-archive-run-real-handler (operation args)
|
|
|
|
|
"Invoke normal file name handler for OPERATION.
|
Adapt Tramp docstrings according to checkdoc
* lisp/net/tramp.el (tramp-backup-directory-alist)
(tramp-echoed-echo-mark-regexp, tramp-syntax-values)
(tramp-lookup-syntax, tramp-build-prefix-format)
(tramp-build-prefix-regexp, tramp-build-method-regexp)
(tramp-build-postfix-method-format)
(tramp-build-postfix-method-regexp)
(tramp-build-prefix-ipv6-format, tramp-build-prefix-ipv6-regexp)
(tramp-build-postfix-ipv6-format)
(tramp-build-postfix-ipv6-regexp)
(tramp-build-postfix-host-format)
(tramp-build-postfix-host-regexp, tramp-unknown-id-string)
(tramp-unknown-id-integer, tramp-build-file-name-regexp)
(tramp-build-completion-file-name-regexp, tramp-chunksize)
(tramp-find-method, tramp-find-user, tramp-find-host)
(tramp-dissect-file-name, tramp-get-buffer)
(tramp-get-connection-buffer, tramp-debug-message, tramp-error)
(with-tramp-connection-property, tramp-run-real-handler)
(tramp-file-name-for-operation, tramp-file-name-handler)
(tramp-completion-file-name-handler)
(tramp-completion-handle-file-name-completion)
(tramp-completion-dissect-file-name)
(tramp-completion-dissect-file-name1)
(tramp-handle-file-name-as-directory)
(tramp-handle-file-name-directory)
(tramp-handle-file-name-nondirectory, tramp-mode-string-to-int)
(tramp-file-mode-from-int):
* lisp/net/tramp-adb.el (tramp-adb-file-name-p):
* lisp/net/tramp-archive.el (tramp-archive-run-real-handler)
(tramp-archive-file-name-handler)
(tramp-archive-dissect-file-name)
(with-parsed-tramp-archive-file-name)
(tramp-archive-gvfs-file-name, tramp-archive-handle-access-file):
* lisp/net/tramp-cmds.el (tramp-list-remote-buffers):
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-compat-funcall, tramp-compat-tramp-file-name-slots):
* lisp/net/tramp-ftp.el (tramp-ftp-file-name-handler)
(tramp-ftp-file-name-p):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-p)
(tramp-gvfs-file-name-handler)
(tramp-gvfs-stringify-dbus-message)
(tramp-gvfs-monitor-process-filter)
(tramp-gvfs-handler-mounted-unmounted):
* lisp/net/tramp-integration.el
(tramp-rfn-eshadow-update-overlay-regexp):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-p)
(tramp-rclone-file-name-handler, tramp-rclone-send-command):
* lisp/net/tramp-sh.el (tramp-sh--quoting-style-options)
(tramp-sh-gio-monitor-process-filter)
(tramp-sh-gvfs-monitor-dir-process-filter)
(tramp-sh-inotifywait-process-filter, tramp-find-executable)
(tramp-set-remote-path, tramp-open-shell, tramp-find-shell)
(tramp-send-command-and-check, tramp-shell-case-fold)
(tramp-get-remote-path):
* lisp/net/tramp-smb.el (tramp-smb-file-name-p)
(tramp-smb-file-name-handler)
(tramp-smb-do-file-attributes-with-stat)
(tramp-smb-handle-substitute-in-file-name)
(tramp-smb-get-stat-capability, tramp-smb-shell-quote-argument):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-p)
(tramp-sudoedit-file-name-handler)
(tramp-sudoedit-send-command-string):
* test/lisp/net/tramp-archive-tests.el (tramp-archive-test-all):
* test/lisp/net/tramp-tests.el (tramp--test-gvfs-p)
(tramp--test-with-proper-process-name-and-buffer)
(tramp-test-all): Adapt docstrings according to `checkdoc'.
2019-11-13 12:10:58 +00:00
|
|
|
|
First arg specifies the OPERATION, second arg ARGS is a list of
|
|
|
|
|
arguments to pass to the OPERATION."
|
2018-02-01 07:40:46 +00:00
|
|
|
|
(let* ((inhibit-file-name-handlers
|
|
|
|
|
`(tramp-archive-file-name-handler
|
|
|
|
|
.
|
|
|
|
|
,(and (eq inhibit-file-name-operation operation)
|
|
|
|
|
inhibit-file-name-handlers)))
|
|
|
|
|
(inhibit-file-name-operation operation))
|
|
|
|
|
(apply operation args)))
|
|
|
|
|
|
2017-12-09 13:34:30 +00:00
|
|
|
|
;;;###tramp-autoload
|
|
|
|
|
(defun tramp-archive-file-name-handler (operation &rest args)
|
2018-02-04 12:25:10 +00:00
|
|
|
|
"Invoke the file archive related OPERATION.
|
Adapt Tramp docstrings according to checkdoc
* lisp/net/tramp.el (tramp-backup-directory-alist)
(tramp-echoed-echo-mark-regexp, tramp-syntax-values)
(tramp-lookup-syntax, tramp-build-prefix-format)
(tramp-build-prefix-regexp, tramp-build-method-regexp)
(tramp-build-postfix-method-format)
(tramp-build-postfix-method-regexp)
(tramp-build-prefix-ipv6-format, tramp-build-prefix-ipv6-regexp)
(tramp-build-postfix-ipv6-format)
(tramp-build-postfix-ipv6-regexp)
(tramp-build-postfix-host-format)
(tramp-build-postfix-host-regexp, tramp-unknown-id-string)
(tramp-unknown-id-integer, tramp-build-file-name-regexp)
(tramp-build-completion-file-name-regexp, tramp-chunksize)
(tramp-find-method, tramp-find-user, tramp-find-host)
(tramp-dissect-file-name, tramp-get-buffer)
(tramp-get-connection-buffer, tramp-debug-message, tramp-error)
(with-tramp-connection-property, tramp-run-real-handler)
(tramp-file-name-for-operation, tramp-file-name-handler)
(tramp-completion-file-name-handler)
(tramp-completion-handle-file-name-completion)
(tramp-completion-dissect-file-name)
(tramp-completion-dissect-file-name1)
(tramp-handle-file-name-as-directory)
(tramp-handle-file-name-directory)
(tramp-handle-file-name-nondirectory, tramp-mode-string-to-int)
(tramp-file-mode-from-int):
* lisp/net/tramp-adb.el (tramp-adb-file-name-p):
* lisp/net/tramp-archive.el (tramp-archive-run-real-handler)
(tramp-archive-file-name-handler)
(tramp-archive-dissect-file-name)
(with-parsed-tramp-archive-file-name)
(tramp-archive-gvfs-file-name, tramp-archive-handle-access-file):
* lisp/net/tramp-cmds.el (tramp-list-remote-buffers):
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-compat-funcall, tramp-compat-tramp-file-name-slots):
* lisp/net/tramp-ftp.el (tramp-ftp-file-name-handler)
(tramp-ftp-file-name-p):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-p)
(tramp-gvfs-file-name-handler)
(tramp-gvfs-stringify-dbus-message)
(tramp-gvfs-monitor-process-filter)
(tramp-gvfs-handler-mounted-unmounted):
* lisp/net/tramp-integration.el
(tramp-rfn-eshadow-update-overlay-regexp):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-p)
(tramp-rclone-file-name-handler, tramp-rclone-send-command):
* lisp/net/tramp-sh.el (tramp-sh--quoting-style-options)
(tramp-sh-gio-monitor-process-filter)
(tramp-sh-gvfs-monitor-dir-process-filter)
(tramp-sh-inotifywait-process-filter, tramp-find-executable)
(tramp-set-remote-path, tramp-open-shell, tramp-find-shell)
(tramp-send-command-and-check, tramp-shell-case-fold)
(tramp-get-remote-path):
* lisp/net/tramp-smb.el (tramp-smb-file-name-p)
(tramp-smb-file-name-handler)
(tramp-smb-do-file-attributes-with-stat)
(tramp-smb-handle-substitute-in-file-name)
(tramp-smb-get-stat-capability, tramp-smb-shell-quote-argument):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-p)
(tramp-sudoedit-file-name-handler)
(tramp-sudoedit-send-command-string):
* test/lisp/net/tramp-archive-tests.el (tramp-archive-test-all):
* test/lisp/net/tramp-tests.el (tramp--test-gvfs-p)
(tramp--test-with-proper-process-name-and-buffer)
(tramp-test-all): Adapt docstrings according to `checkdoc'.
2019-11-13 12:10:58 +00:00
|
|
|
|
First arg specifies the OPERATION, second arg ARGS is a list of
|
|
|
|
|
arguments to pass to the OPERATION."
|
2018-05-15 09:06:18 +00:00
|
|
|
|
(if (not tramp-archive-enabled)
|
|
|
|
|
;; Unregister `tramp-archive-file-name-handler'.
|
|
|
|
|
(progn
|
|
|
|
|
(tramp-register-file-name-handlers)
|
|
|
|
|
(tramp-archive-run-real-handler operation args))
|
|
|
|
|
|
2019-02-28 09:33:05 +00:00
|
|
|
|
(let* ((filename (apply #'tramp-archive-file-name-for-operation
|
2018-05-15 09:06:18 +00:00
|
|
|
|
operation args))
|
2020-05-20 09:09:44 +00:00
|
|
|
|
(archive (tramp-archive-file-name-archive filename))
|
|
|
|
|
;; Sometimes, it fails with "Variable binding depth exceeds
|
2020-05-20 16:01:06 +00:00
|
|
|
|
;; max-specpdl-size". Shall be fixed in Emacs 27.
|
2020-05-20 09:09:44 +00:00
|
|
|
|
(max-specpdl-size (* 2 max-specpdl-size)))
|
2018-05-15 09:06:18 +00:00
|
|
|
|
|
2019-04-26 10:31:50 +00:00
|
|
|
|
;; `filename' could be a quoted file name. Or the file
|
|
|
|
|
;; archive could be a directory, see Bug#30293.
|
|
|
|
|
(if (or (null archive)
|
2021-06-19 16:11:50 +00:00
|
|
|
|
(not (tramp-archive-run-real-handler
|
|
|
|
|
#'file-exists-p (list archive)))
|
2019-04-26 10:31:50 +00:00
|
|
|
|
(tramp-archive-run-real-handler
|
|
|
|
|
#'file-directory-p (list archive)))
|
2018-05-15 09:06:18 +00:00
|
|
|
|
(tramp-archive-run-real-handler operation args)
|
|
|
|
|
;; Now run the handler.
|
|
|
|
|
(let ((tramp-methods (cons `(,tramp-archive-method) tramp-methods))
|
|
|
|
|
(tramp-gvfs-methods tramp-archive-all-gvfs-methods)
|
|
|
|
|
;; Set uid and gid. gvfsd-archive could do it, but it doesn't.
|
|
|
|
|
(tramp-unknown-id-integer (user-uid))
|
|
|
|
|
(tramp-unknown-id-string (user-login-name))
|
|
|
|
|
(fn (assoc operation tramp-archive-file-name-handler-alist)))
|
2019-02-28 09:33:05 +00:00
|
|
|
|
(when (eq (cdr fn) #'tramp-archive-handle-not-implemented)
|
2018-05-15 09:06:18 +00:00
|
|
|
|
(setq args (cons operation args)))
|
|
|
|
|
(if fn
|
|
|
|
|
(save-match-data (apply (cdr fn) args))
|
|
|
|
|
(tramp-archive-run-real-handler operation args)))))))
|
2017-12-09 13:34:30 +00:00
|
|
|
|
|
2018-10-12 11:41:12 +00:00
|
|
|
|
;;;###autoload
|
2021-05-22 15:51:07 +00:00
|
|
|
|
(progn (defun tramp-archive-autoload-file-name-handler (operation &rest args)
|
|
|
|
|
"Load Tramp archive file name handler, and perform OPERATION."
|
2021-05-23 10:34:36 +00:00
|
|
|
|
(when tramp-archive-enabled
|
|
|
|
|
;; We cannot use `tramp-compat-temporary-file-directory' here due
|
|
|
|
|
;; to autoload. When installing Tramp's GNU ELPA package, there
|
|
|
|
|
;; might be an older, incompatible version active. We try to
|
|
|
|
|
;; overload this.
|
|
|
|
|
(let ((default-directory temporary-file-directory)
|
|
|
|
|
(tramp-archive-autoload t))
|
|
|
|
|
tramp-archive-autoload ; Silence byte compiler.
|
|
|
|
|
(apply #'tramp-autoload-file-name-handler operation args)))))
|
2018-10-12 11:41:12 +00:00
|
|
|
|
|
2018-02-03 12:22:56 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(progn (defun tramp-register-archive-file-name-handler ()
|
|
|
|
|
"Add archive file name handler to `file-name-handler-alist'."
|
2018-02-03 17:49:56 +00:00
|
|
|
|
(when tramp-archive-enabled
|
|
|
|
|
(add-to-list 'file-name-handler-alist
|
|
|
|
|
(cons (tramp-archive-autoload-file-name-regexp)
|
2019-02-28 09:33:05 +00:00
|
|
|
|
#'tramp-archive-autoload-file-name-handler))
|
Sync with Tramp 2.5.0-pre
* doc/misc/tramp.texi: Protext Tramp x.y and Emacs x.y by @w{}.
(GVFS-based methods): Move "GNOME Online Accounts" index.
(Customizing Methods, Android shell setup, File name completion)
(Frequently Asked Questions): Fix typos.
* doc/misc/trampver.texi: Change version to "2.5.0-pre".
* lisp/net/trampver.el: Change version to "2.5.0-pre".
(inhibit-message): Don't declare.
* lisp/net/tramp.el: Bump version to 2.5.0-pre. Require Emacs 25.1.
(tramp-debug-message): Simplify.
(tramp-message): Don't use `tramp-message-show-message'.
(tramp-with-demoted-errors, with-parsed-tramp-file-name)
(with-tramp-file-property, with-tramp-connection-property):
Adapt `declare' form.
(with-tramp-progress-reporter): Suppress progress reporter when
noninteractive.
(tramp-completion-mode, tramp-completion-mode-p): Remove.
* lisp/net/tramp-compat.el (tramp-compat-process-running-p)
(format-message): Remove compatibility code.
(tramp-compat-directory-name-p)
(tramp-compat-tramp-file-name-slots): Remove.
* lisp/net/tramp.el (tramp-debug-message, tramp-message)
(tramp-backtrace, tramp-error, tramp-error-with-buffer)
(tramp-user-error, tramp-with-demoted-errors)
(tramp-signal-hook-function):
* lisp/net/tramp-compat.el (tramp-compat-funcall)
* lisp/net/tramp-gvfs.el (tramp-dbus-function):
Add `tramp-suppress-trace' property.
* lisp/net/tramp.el (tramp-get-method-parameter)
(tramp-dissect-file-name, tramp-error, tramp-error-with-buffer)
(tramp-user-error, with-parsed-tramp-file-name)
(with-tramp-progress-reporter, tramp-file-name-handler)
(tramp-completion-file-name-handler, tramp-autoload-file-name-handler)
(tramp-register-file-name-handlers, tramp-connectable-p)
(tramp-handle-file-modes, tramp-handle-file-regular-p)
(tramp-handle-file-truename, tramp-handle-insert-directory)
(tramp-handle-load, tramp-set-file-uid-gid):
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler)
(tramp-adb-handle-file-truename, tramp-adb-handle-copy-file)
(tramp-adb-handle-rename-file):
* lisp/net/tramp-archive.el (with-parsed-tramp-archive-file-name):
* lisp/net/tramp-cache.el (tramp-get-file-property, tramp-cache-print):
* lisp/net/tramp-compat.el (tramp-compat-process-running-p)
(tramp-compat-exec-path):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler)
(tramp-gvfs-dbus-byte-array-to-string)
(tramp-gvfs-do-copy-or-rename-file):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler)
(tramp-rclone-do-copy-or-rename-file):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename)
(tramp-sh-handle-copy-directory, tramp-do-copy-or-rename-file)
(tramp-sh-handle-insert-directory, tramp-sh-file-name-handler)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler)
(tramp-smb-handle-copy-file, tramp-smb-handle-copy-directory)
(tramp-smb-handle-copy-file, tramp-smb-handle-insert-directory)
(tramp-smb-handle-rename-file, tramp-smb-maybe-open-connection):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler)
(tramp-sudoedit-do-copy-or-rename-file)
(tramp-sudoedit-handle-file-truename):
Use `if-let', `when-let', `directory-name-p', `inhibit-message',
`non-essential and `cl-struct-slot-info'. Don't use `seconds-to-time'.
* test/lisp/net/tramp-archive-tests.el (tramp-message-show-message):
Don't set.
* test/lisp/net/tramp-tests.el (inhibit-message): Don't declare.
(tramp-message-show-message): Don't set.
(tramp-test06-directory-file-name): Use `non-essential'.
(tramp-test10-write-region): Use `inhibit-message'.
(tramp-test36-vc-registered): No special handling for old Emacsen.
(tramp--test-emacs25-p): Remove.
(tramp-test45-unload): Special case of `tramp-completion-mode'.
2020-01-19 13:11:07 +00:00
|
|
|
|
(put #'tramp-archive-autoload-file-name-handler 'safe-magic t))))
|
2018-02-03 12:22:56 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2018-02-04 12:25:10 +00:00
|
|
|
|
(progn
|
2019-02-28 09:33:05 +00:00
|
|
|
|
(add-hook 'after-init-hook #'tramp-register-archive-file-name-handler)
|
2018-02-04 12:25:10 +00:00
|
|
|
|
(add-hook
|
|
|
|
|
'tramp-archive-unload-hook
|
|
|
|
|
(lambda ()
|
|
|
|
|
(remove-hook
|
2019-02-28 09:33:05 +00:00
|
|
|
|
'after-init-hook #'tramp-register-archive-file-name-handler))))
|
2018-02-04 12:25:10 +00:00
|
|
|
|
|
|
|
|
|
;; In older Emacsen (prior 27.1), the autoload above does not exist.
|
|
|
|
|
;; So we call it again; it doesn't hurt.
|
2018-02-03 17:49:56 +00:00
|
|
|
|
(tramp-register-archive-file-name-handler)
|
|
|
|
|
|
2017-12-09 13:34:30 +00:00
|
|
|
|
;; Mark `operations' the handler is responsible for.
|
Sync with Tramp 2.5.0-pre
* doc/misc/tramp.texi: Protext Tramp x.y and Emacs x.y by @w{}.
(GVFS-based methods): Move "GNOME Online Accounts" index.
(Customizing Methods, Android shell setup, File name completion)
(Frequently Asked Questions): Fix typos.
* doc/misc/trampver.texi: Change version to "2.5.0-pre".
* lisp/net/trampver.el: Change version to "2.5.0-pre".
(inhibit-message): Don't declare.
* lisp/net/tramp.el: Bump version to 2.5.0-pre. Require Emacs 25.1.
(tramp-debug-message): Simplify.
(tramp-message): Don't use `tramp-message-show-message'.
(tramp-with-demoted-errors, with-parsed-tramp-file-name)
(with-tramp-file-property, with-tramp-connection-property):
Adapt `declare' form.
(with-tramp-progress-reporter): Suppress progress reporter when
noninteractive.
(tramp-completion-mode, tramp-completion-mode-p): Remove.
* lisp/net/tramp-compat.el (tramp-compat-process-running-p)
(format-message): Remove compatibility code.
(tramp-compat-directory-name-p)
(tramp-compat-tramp-file-name-slots): Remove.
* lisp/net/tramp.el (tramp-debug-message, tramp-message)
(tramp-backtrace, tramp-error, tramp-error-with-buffer)
(tramp-user-error, tramp-with-demoted-errors)
(tramp-signal-hook-function):
* lisp/net/tramp-compat.el (tramp-compat-funcall)
* lisp/net/tramp-gvfs.el (tramp-dbus-function):
Add `tramp-suppress-trace' property.
* lisp/net/tramp.el (tramp-get-method-parameter)
(tramp-dissect-file-name, tramp-error, tramp-error-with-buffer)
(tramp-user-error, with-parsed-tramp-file-name)
(with-tramp-progress-reporter, tramp-file-name-handler)
(tramp-completion-file-name-handler, tramp-autoload-file-name-handler)
(tramp-register-file-name-handlers, tramp-connectable-p)
(tramp-handle-file-modes, tramp-handle-file-regular-p)
(tramp-handle-file-truename, tramp-handle-insert-directory)
(tramp-handle-load, tramp-set-file-uid-gid):
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler)
(tramp-adb-handle-file-truename, tramp-adb-handle-copy-file)
(tramp-adb-handle-rename-file):
* lisp/net/tramp-archive.el (with-parsed-tramp-archive-file-name):
* lisp/net/tramp-cache.el (tramp-get-file-property, tramp-cache-print):
* lisp/net/tramp-compat.el (tramp-compat-process-running-p)
(tramp-compat-exec-path):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler)
(tramp-gvfs-dbus-byte-array-to-string)
(tramp-gvfs-do-copy-or-rename-file):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler)
(tramp-rclone-do-copy-or-rename-file):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename)
(tramp-sh-handle-copy-directory, tramp-do-copy-or-rename-file)
(tramp-sh-handle-insert-directory, tramp-sh-file-name-handler)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler)
(tramp-smb-handle-copy-file, tramp-smb-handle-copy-directory)
(tramp-smb-handle-copy-file, tramp-smb-handle-insert-directory)
(tramp-smb-handle-rename-file, tramp-smb-maybe-open-connection):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler)
(tramp-sudoedit-do-copy-or-rename-file)
(tramp-sudoedit-handle-file-truename):
Use `if-let', `when-let', `directory-name-p', `inhibit-message',
`non-essential and `cl-struct-slot-info'. Don't use `seconds-to-time'.
* test/lisp/net/tramp-archive-tests.el (tramp-message-show-message):
Don't set.
* test/lisp/net/tramp-tests.el (inhibit-message): Don't declare.
(tramp-message-show-message): Don't set.
(tramp-test06-directory-file-name): Use `non-essential'.
(tramp-test10-write-region): Use `inhibit-message'.
(tramp-test36-vc-registered): No special handling for old Emacsen.
(tramp--test-emacs25-p): Remove.
(tramp-test45-unload): Special case of `tramp-completion-mode'.
2020-01-19 13:11:07 +00:00
|
|
|
|
(put #'tramp-archive-file-name-handler 'operations
|
2019-02-28 09:33:05 +00:00
|
|
|
|
(mapcar #'car tramp-archive-file-name-handler-alist))
|
2017-12-09 13:34:30 +00:00
|
|
|
|
|
|
|
|
|
;; `tramp-archive-file-name-handler' must be placed before `url-file-handler'.
|
|
|
|
|
(when url-handler-mode (tramp-register-file-name-handlers))
|
|
|
|
|
|
2019-06-28 14:32:12 +00:00
|
|
|
|
(with-eval-after-load 'url-handler
|
2019-06-29 10:18:59 +00:00
|
|
|
|
(add-hook 'url-handler-mode-hook #'tramp-register-file-name-handlers)
|
|
|
|
|
(add-hook
|
|
|
|
|
'tramp-archive-unload-hook
|
|
|
|
|
(lambda ()
|
|
|
|
|
(remove-hook
|
|
|
|
|
'url-handler-mode-hook #'tramp-register-file-name-handlers))))
|
2017-12-09 13:34:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; File name conversions.
|
|
|
|
|
|
|
|
|
|
(defun tramp-archive-file-name-p (name)
|
|
|
|
|
"Return t if NAME is a string with archive file name syntax."
|
|
|
|
|
(and (stringp name)
|
2019-04-26 10:31:50 +00:00
|
|
|
|
;; `tramp-archive-file-name-regexp' does not suppress quoted file names.
|
|
|
|
|
(not (tramp-compat-file-name-quoted-p name t))
|
Rework Tramp wrt string-match-p, looking-at-p, save-match-data
* lisp/net/tramp.el (tramp-find-method, tramp-find-user)
(tramp-find-host, tramp-dissect-file-name, tramp-make-tramp-file-name)
(tramp-completion-make-tramp-file-name, tramp-debug-message)
(tramp-message, tramp-progress-reporter-update)
(tramp-set-completion-function)
(tramp-rfn-eshadow-update-overlay)
(tramp-find-file-name-coding-system-alist)
(tramp-file-name-for-operation)
(tramp-use-absolute-autoload-file-names)
(tramp-get-completion-methods, tramp-get-completion-user-host)
(tramp-handle-directory-files)
(tramp-handle-file-name-case-insensitive-p)
(tramp-handle-file-name-completion, tramp-handle-file-truename)
(tramp-handle-insert-directory, tramp-handle-load)
(tramp-handle-shell-command, tramp-action-yesno)
(tramp-action-yn, tramp-process-actions)
(tramp-mode-string-to-int, tramp-get-local-locale)
(tramp-local-host-p):
* lisp/net/tramp-adb.el (tramp-adb-handle-file-system-info)
(tramp-adb-handle-directory-files-and-attributes)
(tramp-adb--gnu-switches-to-ash, tramp-adb-sh-fix-ls-output)
(tramp-adb-handle-file-name-all-completions)
(tramp-adb-handle-shell-command)
(tramp-adb-handle-start-file-process):
* lisp/net/tramp-archive.el (tramp-archive-dissect-file-name):
* lisp/net/tramp-cache.el (tramp-get-hash-table)
(tramp-flush-directory-properties, tramp-flush-file-function):
* lisp/net/tramp-cmds.el (tramp-reporter-dump-variable)
(tramp-append-tramp-buffers):
* lisp/net/tramp-compat.el (tramp-compat-process-running-p):
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-expand-file-name)
(tramp-gvfs-get-file-attributes)
(tramp-gvfs-handle-file-attributes)
(tramp-gvfs-monitor-process-filter)
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p, tramp-gvfs-mount-spec-entry)
(tramp-gvfs-mount-spec, tramp-gvfs-maybe-open-connection):
* lisp/net/tramp-sh.el (tramp-do-file-attributes-with-ls)
(tramp-do-file-attributes-with-stat)
(tramp-sh-handle-file-selinux-context)
(tramp-sh-handle-directory-files-and-attributes)
(tramp-do-directory-files-and-attributes-with-stat)
(tramp-sh-handle-file-name-all-completions)
(tramp-sh-handle-dired-compress-file)
(tramp-sh-handle-insert-directory)
(tramp-sh-handle-expand-file-name)
(tramp-sh-handle-start-file-process)
(tramp-sh-handle-process-file, tramp-sh-handle-write-region)
(tramp-sh-handle-file-notify-add-watch)
(tramp-sh-gio-monitor-process-filter)
(tramp-sh-gvfs-monitor-dir-process-filter)
(tramp-sh-inotifywait-process-filter)
(tramp-sh-handle-file-system-info, tramp-maybe-send-script)
(tramp-find-executable, tramp-open-shell, tramp-find-shell)
(tramp-open-connection-setup-interactive-shell)
(tramp-find-inline-encoding, tramp-call-local-coding-command)
(tramp-compute-multi-hops, tramp-maybe-open-connection)
(tramp-convert-file-attributes)
(tramp-make-copy-program-file-name, tramp-get-remote-locale)
(tramp-get-test-nt-command, tramp-get-remote-stat)
(tramp-get-inline-coding):
* lisp/net/tramp-smb.el (tramp-smb-handle-directory-files)
(tramp-smb-action-get-acl, tramp-smb-handle-file-attributes)
(tramp-smb-handle-file-name-all-completions)
(tramp-smb-handle-file-system-info)
(tramp-smb-handle-file-writable-p)
(tramp-smb-handle-insert-directory)
(tramp-smb-handle-make-directory)
(tramp-smb-handle-make-directory-internal)
(tramp-smb-handle-start-file-process, tramp-smb-get-localname)
(tramp-smb-read-file-entry): Use `string-match-p' and
`looking-at-p'. Remove superfluous `save-match-data'. Apply
`eval-when-compile' on constant concat data.
* lisp/net/tramp-compat.el (tramp-compat-file-name-quoted-p-p):
Use `string-prefix-p'.
(tramp-compat-file-name-unquote): Do not use match data.
2018-12-06 15:00:05 +00:00
|
|
|
|
;; We cannot use `string-match-p', the matches are used.
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(string-match tramp-archive-file-name-regexp name)
|
|
|
|
|
t))
|
|
|
|
|
|
2018-01-31 14:02:46 +00:00
|
|
|
|
(defun tramp-archive-file-name-archive (name)
|
|
|
|
|
"Return archive part of NAME."
|
|
|
|
|
(and (tramp-archive-file-name-p name)
|
|
|
|
|
(match-string 1 name)))
|
|
|
|
|
|
|
|
|
|
(defun tramp-archive-file-name-localname (name)
|
|
|
|
|
"Return localname part of NAME."
|
|
|
|
|
(and (tramp-archive-file-name-p name)
|
|
|
|
|
(match-string 2 name)))
|
|
|
|
|
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(defvar tramp-archive-hash (make-hash-table :test 'equal)
|
2018-01-30 16:34:02 +00:00
|
|
|
|
"Hash table for archive local copies.
|
|
|
|
|
The hash key is the archive name. The value is a cons of the
|
|
|
|
|
used `tramp-file-name' structure for tramp-gvfs, and the file
|
|
|
|
|
name of a local copy, if any.")
|
|
|
|
|
|
2018-02-04 12:25:10 +00:00
|
|
|
|
(defsubst tramp-archive-gvfs-host (archive)
|
2019-10-11 11:50:34 +00:00
|
|
|
|
"Return host name of ARCHIVE as used in GVFS for mounting."
|
2018-02-04 12:25:10 +00:00
|
|
|
|
(url-hexify-string (tramp-gvfs-url-file-name archive)))
|
|
|
|
|
|
2018-01-30 16:34:02 +00:00
|
|
|
|
(defun tramp-archive-dissect-file-name (name)
|
Adapt Tramp docstrings according to checkdoc
* lisp/net/tramp.el (tramp-backup-directory-alist)
(tramp-echoed-echo-mark-regexp, tramp-syntax-values)
(tramp-lookup-syntax, tramp-build-prefix-format)
(tramp-build-prefix-regexp, tramp-build-method-regexp)
(tramp-build-postfix-method-format)
(tramp-build-postfix-method-regexp)
(tramp-build-prefix-ipv6-format, tramp-build-prefix-ipv6-regexp)
(tramp-build-postfix-ipv6-format)
(tramp-build-postfix-ipv6-regexp)
(tramp-build-postfix-host-format)
(tramp-build-postfix-host-regexp, tramp-unknown-id-string)
(tramp-unknown-id-integer, tramp-build-file-name-regexp)
(tramp-build-completion-file-name-regexp, tramp-chunksize)
(tramp-find-method, tramp-find-user, tramp-find-host)
(tramp-dissect-file-name, tramp-get-buffer)
(tramp-get-connection-buffer, tramp-debug-message, tramp-error)
(with-tramp-connection-property, tramp-run-real-handler)
(tramp-file-name-for-operation, tramp-file-name-handler)
(tramp-completion-file-name-handler)
(tramp-completion-handle-file-name-completion)
(tramp-completion-dissect-file-name)
(tramp-completion-dissect-file-name1)
(tramp-handle-file-name-as-directory)
(tramp-handle-file-name-directory)
(tramp-handle-file-name-nondirectory, tramp-mode-string-to-int)
(tramp-file-mode-from-int):
* lisp/net/tramp-adb.el (tramp-adb-file-name-p):
* lisp/net/tramp-archive.el (tramp-archive-run-real-handler)
(tramp-archive-file-name-handler)
(tramp-archive-dissect-file-name)
(with-parsed-tramp-archive-file-name)
(tramp-archive-gvfs-file-name, tramp-archive-handle-access-file):
* lisp/net/tramp-cmds.el (tramp-list-remote-buffers):
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-compat-funcall, tramp-compat-tramp-file-name-slots):
* lisp/net/tramp-ftp.el (tramp-ftp-file-name-handler)
(tramp-ftp-file-name-p):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-p)
(tramp-gvfs-file-name-handler)
(tramp-gvfs-stringify-dbus-message)
(tramp-gvfs-monitor-process-filter)
(tramp-gvfs-handler-mounted-unmounted):
* lisp/net/tramp-integration.el
(tramp-rfn-eshadow-update-overlay-regexp):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-p)
(tramp-rclone-file-name-handler, tramp-rclone-send-command):
* lisp/net/tramp-sh.el (tramp-sh--quoting-style-options)
(tramp-sh-gio-monitor-process-filter)
(tramp-sh-gvfs-monitor-dir-process-filter)
(tramp-sh-inotifywait-process-filter, tramp-find-executable)
(tramp-set-remote-path, tramp-open-shell, tramp-find-shell)
(tramp-send-command-and-check, tramp-shell-case-fold)
(tramp-get-remote-path):
* lisp/net/tramp-smb.el (tramp-smb-file-name-p)
(tramp-smb-file-name-handler)
(tramp-smb-do-file-attributes-with-stat)
(tramp-smb-handle-substitute-in-file-name)
(tramp-smb-get-stat-capability, tramp-smb-shell-quote-argument):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-p)
(tramp-sudoedit-file-name-handler)
(tramp-sudoedit-send-command-string):
* test/lisp/net/tramp-archive-tests.el (tramp-archive-test-all):
* test/lisp/net/tramp-tests.el (tramp--test-gvfs-p)
(tramp--test-with-proper-process-name-and-buffer)
(tramp-test-all): Adapt docstrings according to `checkdoc'.
2019-11-13 12:10:58 +00:00
|
|
|
|
"Return a `tramp-file-name' structure for NAME.
|
2018-01-30 16:34:02 +00:00
|
|
|
|
The structure consists of the `tramp-archive-method' method, the
|
2018-02-11 09:26:57 +00:00
|
|
|
|
hexified archive name as host, and the localname. The archive
|
2018-01-30 16:34:02 +00:00
|
|
|
|
name is kept in slot `hop'"
|
|
|
|
|
(save-match-data
|
|
|
|
|
(unless (tramp-archive-file-name-p name)
|
2018-03-29 13:59:11 +00:00
|
|
|
|
(tramp-user-error nil "Not an archive file name: \"%s\"" name))
|
2018-01-31 14:02:46 +00:00
|
|
|
|
(let* ((localname (tramp-archive-file-name-localname name))
|
|
|
|
|
(archive (file-truename (tramp-archive-file-name-archive name)))
|
2018-01-30 19:09:20 +00:00
|
|
|
|
(vec (make-tramp-file-name
|
|
|
|
|
:method tramp-archive-method :hop archive)))
|
2018-01-30 16:34:02 +00:00
|
|
|
|
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(cond
|
2018-01-30 16:34:02 +00:00
|
|
|
|
;; The value is already in the hash table.
|
2018-01-30 19:09:20 +00:00
|
|
|
|
((gethash archive tramp-archive-hash)
|
|
|
|
|
(setq vec (car (gethash archive tramp-archive-hash))))
|
2018-01-30 16:34:02 +00:00
|
|
|
|
|
2017-12-09 13:34:30 +00:00
|
|
|
|
;; File archives inside file archives.
|
|
|
|
|
((tramp-archive-file-name-p archive)
|
|
|
|
|
(let ((archive
|
|
|
|
|
(tramp-make-tramp-file-name
|
|
|
|
|
(tramp-archive-dissect-file-name archive) nil 'noarchive)))
|
2018-02-04 12:25:10 +00:00
|
|
|
|
(setf (tramp-file-name-host vec) (tramp-archive-gvfs-host archive)))
|
2018-01-30 16:34:02 +00:00
|
|
|
|
(puthash archive (list vec) tramp-archive-hash))
|
|
|
|
|
|
2017-12-09 13:34:30 +00:00
|
|
|
|
;; http://...
|
|
|
|
|
((and url-handler-mode
|
|
|
|
|
tramp-compat-use-url-tramp-p
|
Rework Tramp wrt string-match-p, looking-at-p, save-match-data
* lisp/net/tramp.el (tramp-find-method, tramp-find-user)
(tramp-find-host, tramp-dissect-file-name, tramp-make-tramp-file-name)
(tramp-completion-make-tramp-file-name, tramp-debug-message)
(tramp-message, tramp-progress-reporter-update)
(tramp-set-completion-function)
(tramp-rfn-eshadow-update-overlay)
(tramp-find-file-name-coding-system-alist)
(tramp-file-name-for-operation)
(tramp-use-absolute-autoload-file-names)
(tramp-get-completion-methods, tramp-get-completion-user-host)
(tramp-handle-directory-files)
(tramp-handle-file-name-case-insensitive-p)
(tramp-handle-file-name-completion, tramp-handle-file-truename)
(tramp-handle-insert-directory, tramp-handle-load)
(tramp-handle-shell-command, tramp-action-yesno)
(tramp-action-yn, tramp-process-actions)
(tramp-mode-string-to-int, tramp-get-local-locale)
(tramp-local-host-p):
* lisp/net/tramp-adb.el (tramp-adb-handle-file-system-info)
(tramp-adb-handle-directory-files-and-attributes)
(tramp-adb--gnu-switches-to-ash, tramp-adb-sh-fix-ls-output)
(tramp-adb-handle-file-name-all-completions)
(tramp-adb-handle-shell-command)
(tramp-adb-handle-start-file-process):
* lisp/net/tramp-archive.el (tramp-archive-dissect-file-name):
* lisp/net/tramp-cache.el (tramp-get-hash-table)
(tramp-flush-directory-properties, tramp-flush-file-function):
* lisp/net/tramp-cmds.el (tramp-reporter-dump-variable)
(tramp-append-tramp-buffers):
* lisp/net/tramp-compat.el (tramp-compat-process-running-p):
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-expand-file-name)
(tramp-gvfs-get-file-attributes)
(tramp-gvfs-handle-file-attributes)
(tramp-gvfs-monitor-process-filter)
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p, tramp-gvfs-mount-spec-entry)
(tramp-gvfs-mount-spec, tramp-gvfs-maybe-open-connection):
* lisp/net/tramp-sh.el (tramp-do-file-attributes-with-ls)
(tramp-do-file-attributes-with-stat)
(tramp-sh-handle-file-selinux-context)
(tramp-sh-handle-directory-files-and-attributes)
(tramp-do-directory-files-and-attributes-with-stat)
(tramp-sh-handle-file-name-all-completions)
(tramp-sh-handle-dired-compress-file)
(tramp-sh-handle-insert-directory)
(tramp-sh-handle-expand-file-name)
(tramp-sh-handle-start-file-process)
(tramp-sh-handle-process-file, tramp-sh-handle-write-region)
(tramp-sh-handle-file-notify-add-watch)
(tramp-sh-gio-monitor-process-filter)
(tramp-sh-gvfs-monitor-dir-process-filter)
(tramp-sh-inotifywait-process-filter)
(tramp-sh-handle-file-system-info, tramp-maybe-send-script)
(tramp-find-executable, tramp-open-shell, tramp-find-shell)
(tramp-open-connection-setup-interactive-shell)
(tramp-find-inline-encoding, tramp-call-local-coding-command)
(tramp-compute-multi-hops, tramp-maybe-open-connection)
(tramp-convert-file-attributes)
(tramp-make-copy-program-file-name, tramp-get-remote-locale)
(tramp-get-test-nt-command, tramp-get-remote-stat)
(tramp-get-inline-coding):
* lisp/net/tramp-smb.el (tramp-smb-handle-directory-files)
(tramp-smb-action-get-acl, tramp-smb-handle-file-attributes)
(tramp-smb-handle-file-name-all-completions)
(tramp-smb-handle-file-system-info)
(tramp-smb-handle-file-writable-p)
(tramp-smb-handle-insert-directory)
(tramp-smb-handle-make-directory)
(tramp-smb-handle-make-directory-internal)
(tramp-smb-handle-start-file-process, tramp-smb-get-localname)
(tramp-smb-read-file-entry): Use `string-match-p' and
`looking-at-p'. Remove superfluous `save-match-data'. Apply
`eval-when-compile' on constant concat data.
* lisp/net/tramp-compat.el (tramp-compat-file-name-quoted-p-p):
Use `string-prefix-p'.
(tramp-compat-file-name-unquote): Do not use match data.
2018-12-06 15:00:05 +00:00
|
|
|
|
(string-match-p url-handler-regexp archive)
|
|
|
|
|
(string-match-p
|
|
|
|
|
"https?" (url-type (url-generic-parse-url archive))))
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(let* ((url-tramp-protocols
|
|
|
|
|
(cons
|
|
|
|
|
(url-type (url-generic-parse-url archive))
|
|
|
|
|
url-tramp-protocols))
|
|
|
|
|
(archive (url-tramp-convert-url-to-tramp archive)))
|
2018-02-04 12:25:10 +00:00
|
|
|
|
(setf (tramp-file-name-host vec) (tramp-archive-gvfs-host archive)))
|
2018-01-30 19:09:20 +00:00
|
|
|
|
(puthash archive (list vec) tramp-archive-hash))
|
2018-01-30 16:34:02 +00:00
|
|
|
|
|
2017-12-09 13:34:30 +00:00
|
|
|
|
;; GVFS supported schemes.
|
|
|
|
|
((or (tramp-gvfs-file-name-p archive)
|
|
|
|
|
(not (file-remote-p archive)))
|
2018-02-04 12:25:10 +00:00
|
|
|
|
(setf (tramp-file-name-host vec) (tramp-archive-gvfs-host archive))
|
2018-01-30 16:34:02 +00:00
|
|
|
|
(puthash archive (list vec) tramp-archive-hash))
|
|
|
|
|
|
2017-12-09 13:34:30 +00:00
|
|
|
|
;; Anything else. Here we call `file-local-copy', which we
|
|
|
|
|
;; have avoided so far.
|
2019-02-28 09:33:05 +00:00
|
|
|
|
(t (let* ((inhibit-file-name-operation #'file-local-copy)
|
2018-01-30 19:09:20 +00:00
|
|
|
|
(inhibit-file-name-handlers
|
2019-02-28 09:33:05 +00:00
|
|
|
|
(cons #'jka-compr-handler inhibit-file-name-handlers))
|
2018-01-30 19:09:20 +00:00
|
|
|
|
(copy (file-local-copy archive)))
|
2018-02-04 12:25:10 +00:00
|
|
|
|
(setf (tramp-file-name-host vec) (tramp-archive-gvfs-host copy))
|
2018-01-30 19:09:20 +00:00
|
|
|
|
(puthash archive (cons vec copy) tramp-archive-hash))))
|
|
|
|
|
|
|
|
|
|
;; So far, `vec' handles just the mount point. Add `localname',
|
|
|
|
|
;; which shouldn't be pushed to the hash.
|
2018-01-30 16:34:02 +00:00
|
|
|
|
(setf (tramp-file-name-localname vec) localname)
|
|
|
|
|
vec)))
|
2017-12-09 13:34:30 +00:00
|
|
|
|
|
|
|
|
|
(defun tramp-archive-cleanup-hash ()
|
|
|
|
|
"Remove local copies of archives, used by GVFS."
|
2019-06-15 09:46:04 +00:00
|
|
|
|
;; Don't check for a proper method.
|
|
|
|
|
(let ((non-essential t))
|
|
|
|
|
(maphash
|
|
|
|
|
(lambda (key value)
|
|
|
|
|
;; Unmount local copy.
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(tramp-message (car value) 3 "Unmounting %s" (or (cdr value) key))
|
|
|
|
|
(tramp-gvfs-unmount (car value)))
|
|
|
|
|
;; Delete local copy.
|
|
|
|
|
(ignore-errors (delete-file (cdr value)))
|
|
|
|
|
(remhash key tramp-archive-hash))
|
|
|
|
|
tramp-archive-hash)
|
|
|
|
|
(clrhash tramp-archive-hash)))
|
2017-12-09 13:34:30 +00:00
|
|
|
|
|
2019-02-28 09:33:05 +00:00
|
|
|
|
(add-hook 'tramp-cleanup-all-connections-hook #'tramp-archive-cleanup-hash)
|
|
|
|
|
(add-hook 'kill-emacs-hook #'tramp-archive-cleanup-hash)
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(add-hook 'tramp-archive-unload-hook
|
|
|
|
|
(lambda ()
|
2019-02-25 10:59:52 +00:00
|
|
|
|
(remove-hook 'tramp-cleanup-all-connections-hook
|
2019-02-28 09:33:05 +00:00
|
|
|
|
#'tramp-archive-cleanup-hash)
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(remove-hook 'kill-emacs-hook
|
2019-02-28 09:33:05 +00:00
|
|
|
|
#'tramp-archive-cleanup-hash)))
|
2017-12-09 13:34:30 +00:00
|
|
|
|
|
|
|
|
|
(defsubst tramp-file-name-archive (vec)
|
|
|
|
|
"Extract the archive file name from VEC.
|
|
|
|
|
VEC is expected to be a `tramp-file-name', with the method being
|
|
|
|
|
`tramp-archive-method', and the host being a coded URL. The
|
|
|
|
|
archive name is extracted from the hop part of the VEC structure."
|
|
|
|
|
(and (tramp-file-name-p vec)
|
|
|
|
|
(string-equal (tramp-file-name-method vec) tramp-archive-method)
|
|
|
|
|
(tramp-file-name-hop vec)))
|
|
|
|
|
|
|
|
|
|
(defmacro with-parsed-tramp-archive-file-name (filename var &rest body)
|
Adapt Tramp docstrings according to checkdoc
* lisp/net/tramp.el (tramp-backup-directory-alist)
(tramp-echoed-echo-mark-regexp, tramp-syntax-values)
(tramp-lookup-syntax, tramp-build-prefix-format)
(tramp-build-prefix-regexp, tramp-build-method-regexp)
(tramp-build-postfix-method-format)
(tramp-build-postfix-method-regexp)
(tramp-build-prefix-ipv6-format, tramp-build-prefix-ipv6-regexp)
(tramp-build-postfix-ipv6-format)
(tramp-build-postfix-ipv6-regexp)
(tramp-build-postfix-host-format)
(tramp-build-postfix-host-regexp, tramp-unknown-id-string)
(tramp-unknown-id-integer, tramp-build-file-name-regexp)
(tramp-build-completion-file-name-regexp, tramp-chunksize)
(tramp-find-method, tramp-find-user, tramp-find-host)
(tramp-dissect-file-name, tramp-get-buffer)
(tramp-get-connection-buffer, tramp-debug-message, tramp-error)
(with-tramp-connection-property, tramp-run-real-handler)
(tramp-file-name-for-operation, tramp-file-name-handler)
(tramp-completion-file-name-handler)
(tramp-completion-handle-file-name-completion)
(tramp-completion-dissect-file-name)
(tramp-completion-dissect-file-name1)
(tramp-handle-file-name-as-directory)
(tramp-handle-file-name-directory)
(tramp-handle-file-name-nondirectory, tramp-mode-string-to-int)
(tramp-file-mode-from-int):
* lisp/net/tramp-adb.el (tramp-adb-file-name-p):
* lisp/net/tramp-archive.el (tramp-archive-run-real-handler)
(tramp-archive-file-name-handler)
(tramp-archive-dissect-file-name)
(with-parsed-tramp-archive-file-name)
(tramp-archive-gvfs-file-name, tramp-archive-handle-access-file):
* lisp/net/tramp-cmds.el (tramp-list-remote-buffers):
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-compat-funcall, tramp-compat-tramp-file-name-slots):
* lisp/net/tramp-ftp.el (tramp-ftp-file-name-handler)
(tramp-ftp-file-name-p):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-p)
(tramp-gvfs-file-name-handler)
(tramp-gvfs-stringify-dbus-message)
(tramp-gvfs-monitor-process-filter)
(tramp-gvfs-handler-mounted-unmounted):
* lisp/net/tramp-integration.el
(tramp-rfn-eshadow-update-overlay-regexp):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-p)
(tramp-rclone-file-name-handler, tramp-rclone-send-command):
* lisp/net/tramp-sh.el (tramp-sh--quoting-style-options)
(tramp-sh-gio-monitor-process-filter)
(tramp-sh-gvfs-monitor-dir-process-filter)
(tramp-sh-inotifywait-process-filter, tramp-find-executable)
(tramp-set-remote-path, tramp-open-shell, tramp-find-shell)
(tramp-send-command-and-check, tramp-shell-case-fold)
(tramp-get-remote-path):
* lisp/net/tramp-smb.el (tramp-smb-file-name-p)
(tramp-smb-file-name-handler)
(tramp-smb-do-file-attributes-with-stat)
(tramp-smb-handle-substitute-in-file-name)
(tramp-smb-get-stat-capability, tramp-smb-shell-quote-argument):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-p)
(tramp-sudoedit-file-name-handler)
(tramp-sudoedit-send-command-string):
* test/lisp/net/tramp-archive-tests.el (tramp-archive-test-all):
* test/lisp/net/tramp-tests.el (tramp--test-gvfs-p)
(tramp--test-with-proper-process-name-and-buffer)
(tramp-test-all): Adapt docstrings according to `checkdoc'.
2019-11-13 12:10:58 +00:00
|
|
|
|
"Parse an archive filename and make components available in the BODY.
|
2017-12-09 13:34:30 +00:00
|
|
|
|
This works exactly as `with-parsed-tramp-file-name' for the Tramp
|
|
|
|
|
file name structure returned by `tramp-archive-dissect-file-name'.
|
|
|
|
|
A variable `foo-archive' (or `archive') will be bound to the
|
|
|
|
|
archive name part of FILENAME, assuming `foo' (or nil) is the
|
|
|
|
|
value of VAR. OTOH, the variable `foo-hop' (or `hop') won't be
|
|
|
|
|
offered."
|
|
|
|
|
(declare (debug (form symbolp body))
|
|
|
|
|
(indent 2))
|
|
|
|
|
(let ((bindings
|
Sync with Tramp 2.5.0-pre
* doc/misc/tramp.texi: Protext Tramp x.y and Emacs x.y by @w{}.
(GVFS-based methods): Move "GNOME Online Accounts" index.
(Customizing Methods, Android shell setup, File name completion)
(Frequently Asked Questions): Fix typos.
* doc/misc/trampver.texi: Change version to "2.5.0-pre".
* lisp/net/trampver.el: Change version to "2.5.0-pre".
(inhibit-message): Don't declare.
* lisp/net/tramp.el: Bump version to 2.5.0-pre. Require Emacs 25.1.
(tramp-debug-message): Simplify.
(tramp-message): Don't use `tramp-message-show-message'.
(tramp-with-demoted-errors, with-parsed-tramp-file-name)
(with-tramp-file-property, with-tramp-connection-property):
Adapt `declare' form.
(with-tramp-progress-reporter): Suppress progress reporter when
noninteractive.
(tramp-completion-mode, tramp-completion-mode-p): Remove.
* lisp/net/tramp-compat.el (tramp-compat-process-running-p)
(format-message): Remove compatibility code.
(tramp-compat-directory-name-p)
(tramp-compat-tramp-file-name-slots): Remove.
* lisp/net/tramp.el (tramp-debug-message, tramp-message)
(tramp-backtrace, tramp-error, tramp-error-with-buffer)
(tramp-user-error, tramp-with-demoted-errors)
(tramp-signal-hook-function):
* lisp/net/tramp-compat.el (tramp-compat-funcall)
* lisp/net/tramp-gvfs.el (tramp-dbus-function):
Add `tramp-suppress-trace' property.
* lisp/net/tramp.el (tramp-get-method-parameter)
(tramp-dissect-file-name, tramp-error, tramp-error-with-buffer)
(tramp-user-error, with-parsed-tramp-file-name)
(with-tramp-progress-reporter, tramp-file-name-handler)
(tramp-completion-file-name-handler, tramp-autoload-file-name-handler)
(tramp-register-file-name-handlers, tramp-connectable-p)
(tramp-handle-file-modes, tramp-handle-file-regular-p)
(tramp-handle-file-truename, tramp-handle-insert-directory)
(tramp-handle-load, tramp-set-file-uid-gid):
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler)
(tramp-adb-handle-file-truename, tramp-adb-handle-copy-file)
(tramp-adb-handle-rename-file):
* lisp/net/tramp-archive.el (with-parsed-tramp-archive-file-name):
* lisp/net/tramp-cache.el (tramp-get-file-property, tramp-cache-print):
* lisp/net/tramp-compat.el (tramp-compat-process-running-p)
(tramp-compat-exec-path):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler)
(tramp-gvfs-dbus-byte-array-to-string)
(tramp-gvfs-do-copy-or-rename-file):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler)
(tramp-rclone-do-copy-or-rename-file):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename)
(tramp-sh-handle-copy-directory, tramp-do-copy-or-rename-file)
(tramp-sh-handle-insert-directory, tramp-sh-file-name-handler)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler)
(tramp-smb-handle-copy-file, tramp-smb-handle-copy-directory)
(tramp-smb-handle-copy-file, tramp-smb-handle-insert-directory)
(tramp-smb-handle-rename-file, tramp-smb-maybe-open-connection):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler)
(tramp-sudoedit-do-copy-or-rename-file)
(tramp-sudoedit-handle-file-truename):
Use `if-let', `when-let', `directory-name-p', `inhibit-message',
`non-essential and `cl-struct-slot-info'. Don't use `seconds-to-time'.
* test/lisp/net/tramp-archive-tests.el (tramp-message-show-message):
Don't set.
* test/lisp/net/tramp-tests.el (inhibit-message): Don't declare.
(tramp-message-show-message): Don't set.
(tramp-test06-directory-file-name): Use `non-essential'.
(tramp-test10-write-region): Use `inhibit-message'.
(tramp-test36-vc-registered): No special handling for old Emacsen.
(tramp--test-emacs25-p): Remove.
(tramp-test45-unload): Special case of `tramp-completion-mode'.
2020-01-19 13:11:07 +00:00
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (elem)
|
|
|
|
|
`(,(if var (intern (format "%s-%s" var elem)) elem)
|
|
|
|
|
(,(intern (format "tramp-file-name-%s" elem))
|
|
|
|
|
,(or var 'v))))
|
|
|
|
|
(cons
|
|
|
|
|
'archive
|
|
|
|
|
(delete
|
|
|
|
|
'hop
|
|
|
|
|
(cdr (mapcar #'car (cl-struct-slot-info 'tramp-file-name))))))))
|
2017-12-09 13:34:30 +00:00
|
|
|
|
`(let* ((,(or var 'v) (tramp-archive-dissect-file-name ,filename))
|
|
|
|
|
,@bindings)
|
|
|
|
|
;; We don't know which of those vars will be used, so we bind them all,
|
|
|
|
|
;; and then add here a dummy use of all those variables, so we don't get
|
|
|
|
|
;; flooded by warnings about those vars `body' didn't use.
|
|
|
|
|
(ignore ,@(mapcar #'car bindings))
|
|
|
|
|
,@body)))
|
|
|
|
|
|
|
|
|
|
(defun tramp-archive-gvfs-file-name (name)
|
Adapt Tramp docstrings according to checkdoc
* lisp/net/tramp.el (tramp-backup-directory-alist)
(tramp-echoed-echo-mark-regexp, tramp-syntax-values)
(tramp-lookup-syntax, tramp-build-prefix-format)
(tramp-build-prefix-regexp, tramp-build-method-regexp)
(tramp-build-postfix-method-format)
(tramp-build-postfix-method-regexp)
(tramp-build-prefix-ipv6-format, tramp-build-prefix-ipv6-regexp)
(tramp-build-postfix-ipv6-format)
(tramp-build-postfix-ipv6-regexp)
(tramp-build-postfix-host-format)
(tramp-build-postfix-host-regexp, tramp-unknown-id-string)
(tramp-unknown-id-integer, tramp-build-file-name-regexp)
(tramp-build-completion-file-name-regexp, tramp-chunksize)
(tramp-find-method, tramp-find-user, tramp-find-host)
(tramp-dissect-file-name, tramp-get-buffer)
(tramp-get-connection-buffer, tramp-debug-message, tramp-error)
(with-tramp-connection-property, tramp-run-real-handler)
(tramp-file-name-for-operation, tramp-file-name-handler)
(tramp-completion-file-name-handler)
(tramp-completion-handle-file-name-completion)
(tramp-completion-dissect-file-name)
(tramp-completion-dissect-file-name1)
(tramp-handle-file-name-as-directory)
(tramp-handle-file-name-directory)
(tramp-handle-file-name-nondirectory, tramp-mode-string-to-int)
(tramp-file-mode-from-int):
* lisp/net/tramp-adb.el (tramp-adb-file-name-p):
* lisp/net/tramp-archive.el (tramp-archive-run-real-handler)
(tramp-archive-file-name-handler)
(tramp-archive-dissect-file-name)
(with-parsed-tramp-archive-file-name)
(tramp-archive-gvfs-file-name, tramp-archive-handle-access-file):
* lisp/net/tramp-cmds.el (tramp-list-remote-buffers):
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-compat-funcall, tramp-compat-tramp-file-name-slots):
* lisp/net/tramp-ftp.el (tramp-ftp-file-name-handler)
(tramp-ftp-file-name-p):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-p)
(tramp-gvfs-file-name-handler)
(tramp-gvfs-stringify-dbus-message)
(tramp-gvfs-monitor-process-filter)
(tramp-gvfs-handler-mounted-unmounted):
* lisp/net/tramp-integration.el
(tramp-rfn-eshadow-update-overlay-regexp):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-p)
(tramp-rclone-file-name-handler, tramp-rclone-send-command):
* lisp/net/tramp-sh.el (tramp-sh--quoting-style-options)
(tramp-sh-gio-monitor-process-filter)
(tramp-sh-gvfs-monitor-dir-process-filter)
(tramp-sh-inotifywait-process-filter, tramp-find-executable)
(tramp-set-remote-path, tramp-open-shell, tramp-find-shell)
(tramp-send-command-and-check, tramp-shell-case-fold)
(tramp-get-remote-path):
* lisp/net/tramp-smb.el (tramp-smb-file-name-p)
(tramp-smb-file-name-handler)
(tramp-smb-do-file-attributes-with-stat)
(tramp-smb-handle-substitute-in-file-name)
(tramp-smb-get-stat-capability, tramp-smb-shell-quote-argument):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-p)
(tramp-sudoedit-file-name-handler)
(tramp-sudoedit-send-command-string):
* test/lisp/net/tramp-archive-tests.el (tramp-archive-test-all):
* test/lisp/net/tramp-tests.el (tramp--test-gvfs-p)
(tramp--test-with-proper-process-name-and-buffer)
(tramp-test-all): Adapt docstrings according to `checkdoc'.
2019-11-13 12:10:58 +00:00
|
|
|
|
"Return NAME in GVFS syntax."
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(tramp-make-tramp-file-name
|
|
|
|
|
(tramp-archive-dissect-file-name name) nil 'nohop))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; File name primitives.
|
|
|
|
|
|
2019-02-19 13:00:17 +00:00
|
|
|
|
(defun tramp-archive-handle-access-file (filename string)
|
Adapt Tramp docstrings according to checkdoc
* lisp/net/tramp.el (tramp-backup-directory-alist)
(tramp-echoed-echo-mark-regexp, tramp-syntax-values)
(tramp-lookup-syntax, tramp-build-prefix-format)
(tramp-build-prefix-regexp, tramp-build-method-regexp)
(tramp-build-postfix-method-format)
(tramp-build-postfix-method-regexp)
(tramp-build-prefix-ipv6-format, tramp-build-prefix-ipv6-regexp)
(tramp-build-postfix-ipv6-format)
(tramp-build-postfix-ipv6-regexp)
(tramp-build-postfix-host-format)
(tramp-build-postfix-host-regexp, tramp-unknown-id-string)
(tramp-unknown-id-integer, tramp-build-file-name-regexp)
(tramp-build-completion-file-name-regexp, tramp-chunksize)
(tramp-find-method, tramp-find-user, tramp-find-host)
(tramp-dissect-file-name, tramp-get-buffer)
(tramp-get-connection-buffer, tramp-debug-message, tramp-error)
(with-tramp-connection-property, tramp-run-real-handler)
(tramp-file-name-for-operation, tramp-file-name-handler)
(tramp-completion-file-name-handler)
(tramp-completion-handle-file-name-completion)
(tramp-completion-dissect-file-name)
(tramp-completion-dissect-file-name1)
(tramp-handle-file-name-as-directory)
(tramp-handle-file-name-directory)
(tramp-handle-file-name-nondirectory, tramp-mode-string-to-int)
(tramp-file-mode-from-int):
* lisp/net/tramp-adb.el (tramp-adb-file-name-p):
* lisp/net/tramp-archive.el (tramp-archive-run-real-handler)
(tramp-archive-file-name-handler)
(tramp-archive-dissect-file-name)
(with-parsed-tramp-archive-file-name)
(tramp-archive-gvfs-file-name, tramp-archive-handle-access-file):
* lisp/net/tramp-cmds.el (tramp-list-remote-buffers):
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-compat-funcall, tramp-compat-tramp-file-name-slots):
* lisp/net/tramp-ftp.el (tramp-ftp-file-name-handler)
(tramp-ftp-file-name-p):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-p)
(tramp-gvfs-file-name-handler)
(tramp-gvfs-stringify-dbus-message)
(tramp-gvfs-monitor-process-filter)
(tramp-gvfs-handler-mounted-unmounted):
* lisp/net/tramp-integration.el
(tramp-rfn-eshadow-update-overlay-regexp):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-p)
(tramp-rclone-file-name-handler, tramp-rclone-send-command):
* lisp/net/tramp-sh.el (tramp-sh--quoting-style-options)
(tramp-sh-gio-monitor-process-filter)
(tramp-sh-gvfs-monitor-dir-process-filter)
(tramp-sh-inotifywait-process-filter, tramp-find-executable)
(tramp-set-remote-path, tramp-open-shell, tramp-find-shell)
(tramp-send-command-and-check, tramp-shell-case-fold)
(tramp-get-remote-path):
* lisp/net/tramp-smb.el (tramp-smb-file-name-p)
(tramp-smb-file-name-handler)
(tramp-smb-do-file-attributes-with-stat)
(tramp-smb-handle-substitute-in-file-name)
(tramp-smb-get-stat-capability, tramp-smb-shell-quote-argument):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-p)
(tramp-sudoedit-file-name-handler)
(tramp-sudoedit-send-command-string):
* test/lisp/net/tramp-archive-tests.el (tramp-archive-test-all):
* test/lisp/net/tramp-tests.el (tramp--test-gvfs-p)
(tramp--test-with-proper-process-name-and-buffer)
(tramp-test-all): Adapt docstrings according to `checkdoc'.
2019-11-13 12:10:58 +00:00
|
|
|
|
"Like `access-file' for file archives."
|
2019-02-19 13:00:17 +00:00
|
|
|
|
(access-file (tramp-archive-gvfs-file-name filename) string))
|
|
|
|
|
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(defun tramp-archive-handle-copy-file
|
|
|
|
|
(filename newname &optional ok-if-already-exists keep-date
|
|
|
|
|
preserve-uid-gid preserve-extended-attributes)
|
|
|
|
|
"Like `copy-file' for file archives."
|
|
|
|
|
(when (tramp-archive-file-name-p newname)
|
|
|
|
|
(tramp-error
|
|
|
|
|
(tramp-archive-dissect-file-name newname) 'file-error
|
|
|
|
|
"Permission denied: %s" newname))
|
|
|
|
|
(copy-file
|
|
|
|
|
(tramp-archive-gvfs-file-name filename) newname ok-if-already-exists
|
|
|
|
|
keep-date preserve-uid-gid preserve-extended-attributes))
|
|
|
|
|
|
|
|
|
|
(defun tramp-archive-handle-directory-file-name (directory)
|
|
|
|
|
"Like `directory-file-name' for file archives."
|
|
|
|
|
(with-parsed-tramp-archive-file-name directory nil
|
|
|
|
|
(if (and (not (zerop (length localname)))
|
|
|
|
|
(eq (aref localname (1- (length localname))) ?/)
|
|
|
|
|
(not (string= localname "/")))
|
|
|
|
|
(substring directory 0 -1)
|
|
|
|
|
;; We do not want to leave the file archive. This would require
|
|
|
|
|
;; unnecessary download of http-based file archives, for
|
|
|
|
|
;; example. So we return `directory'.
|
|
|
|
|
directory)))
|
|
|
|
|
|
|
|
|
|
(defun tramp-archive-handle-dired-uncache (dir)
|
|
|
|
|
"Like `dired-uncache' for file archives."
|
|
|
|
|
(dired-uncache (tramp-archive-gvfs-file-name dir)))
|
|
|
|
|
|
|
|
|
|
(defun tramp-archive-handle-file-attributes (filename &optional id-format)
|
|
|
|
|
"Like `file-attributes' for file archives."
|
|
|
|
|
(file-attributes (tramp-archive-gvfs-file-name filename) id-format))
|
|
|
|
|
|
|
|
|
|
(defun tramp-archive-handle-file-executable-p (filename)
|
|
|
|
|
"Like `file-executable-p' for file archives."
|
|
|
|
|
(file-executable-p (tramp-archive-gvfs-file-name filename)))
|
|
|
|
|
|
|
|
|
|
(defun tramp-archive-handle-file-local-copy (filename)
|
|
|
|
|
"Like `file-local-copy' for file archives."
|
|
|
|
|
(file-local-copy (tramp-archive-gvfs-file-name filename)))
|
|
|
|
|
|
|
|
|
|
(defun tramp-archive-handle-file-name-all-completions (filename directory)
|
|
|
|
|
"Like `file-name-all-completions' for file archives."
|
|
|
|
|
(file-name-all-completions filename (tramp-archive-gvfs-file-name directory)))
|
|
|
|
|
|
|
|
|
|
(defun tramp-archive-handle-file-readable-p (filename)
|
|
|
|
|
"Like `file-readable-p' for file archives."
|
2019-04-08 11:34:54 +00:00
|
|
|
|
(file-readable-p (tramp-archive-gvfs-file-name filename)))
|
2017-12-09 13:34:30 +00:00
|
|
|
|
|
|
|
|
|
(defun tramp-archive-handle-file-system-info (filename)
|
|
|
|
|
"Like `file-system-info' for file archives."
|
|
|
|
|
(with-parsed-tramp-archive-file-name filename nil
|
|
|
|
|
(list (tramp-compat-file-attribute-size (file-attributes archive)) 0 0)))
|
|
|
|
|
|
|
|
|
|
(defun tramp-archive-handle-file-truename (filename)
|
|
|
|
|
"Like `file-truename' for file archives."
|
|
|
|
|
(with-parsed-tramp-archive-file-name filename nil
|
|
|
|
|
(let ((local (or (file-symlink-p filename) localname)))
|
|
|
|
|
(unless (file-name-absolute-p local)
|
|
|
|
|
(setq local (expand-file-name local (file-name-directory localname))))
|
|
|
|
|
(concat (file-truename archive) local))))
|
|
|
|
|
|
|
|
|
|
(defun tramp-archive-handle-insert-directory
|
|
|
|
|
(filename switches &optional wildcard full-directory-p)
|
|
|
|
|
"Like `insert-directory' for file archives."
|
|
|
|
|
(insert-directory
|
|
|
|
|
(tramp-archive-gvfs-file-name filename) switches wildcard full-directory-p)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (search-forward (tramp-archive-gvfs-file-name filename) nil 'noerror)
|
|
|
|
|
(replace-match filename)))
|
|
|
|
|
|
|
|
|
|
(defun tramp-archive-handle-insert-file-contents
|
|
|
|
|
(filename &optional visit beg end replace)
|
|
|
|
|
"Like `insert-file-contents' for file archives."
|
|
|
|
|
(let ((result
|
|
|
|
|
(insert-file-contents
|
|
|
|
|
(tramp-archive-gvfs-file-name filename) visit beg end replace)))
|
2021-04-28 20:00:55 +00:00
|
|
|
|
(when visit (setq buffer-file-name filename))
|
|
|
|
|
(cons (expand-file-name filename) (cdr result))))
|
2017-12-09 13:34:30 +00:00
|
|
|
|
|
|
|
|
|
(defun tramp-archive-handle-load
|
|
|
|
|
(file &optional noerror nomessage nosuffix must-suffix)
|
|
|
|
|
"Like `load' for file archives."
|
|
|
|
|
(load
|
|
|
|
|
(tramp-archive-gvfs-file-name file) noerror nomessage nosuffix must-suffix))
|
|
|
|
|
|
2017-12-17 10:31:23 +00:00
|
|
|
|
(defun tramp-archive-handle-temporary-file-directory ()
|
2018-01-04 11:58:42 +00:00
|
|
|
|
"Like `temporary-file-directory' for file archives."
|
2017-12-17 10:31:23 +00:00
|
|
|
|
;; If the default directory, the file archive, is located on a
|
|
|
|
|
;; mounted directory, it is returned as it. Not what we want.
|
|
|
|
|
(with-parsed-tramp-archive-file-name default-directory nil
|
|
|
|
|
(let ((default-directory (file-name-directory archive)))
|
Fix tramp-compat-temporary-file-directory implementation
* lisp/net/tramp-archive.el
(tramp-archive-handle-temporary-file-directory):
Use `tramp-compat-temporary-file-directory-function'.
* lisp/net/tramp-compat.el (tramp-compat-temporary-file-directory):
Make it a defconst.
* lisp/net/tramp.el (tramp-get-debug-buffer, tramp-get-debug-file-name)
(tramp-debug-message, tramp-file-name-handler, tramp-parse-file)
(tramp-parse-shostkeys-sknownhosts)
(tramp-handle-expand-file-name, tramp-handle-make-process)
(tramp-local-host-p, tramp-call-process)
(tramp-call-process-region, tramp-process-lines)
(tramp-read-passwd):
* lisp/net/tramp-adb.el (tramp-adb-maybe-open-connection):
* lisp/net/tramp-compat.el (tramp-compat-make-temp-name)
(tramp-compat-make-temp-file);
* lisp/net/tramp-crypt.el (tramp-crypt-file-name-for-operation)
(tramp-crypt-maybe-open-connection, tramp-crypt-send-command)
(tramp-crypt-do-encrypt-or-decrypt-file-name):
* lisp/net/tramp-fuse.el (tramp-fuse-mount-point, tramp-fuse-mounted-p)
(tramp-fuse-unmount):
* lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band)
(tramp-sh-handle-expand-file-name)
(tramp-sh-handle-file-local-copy, )
(tramp-sh-handle-write-region, tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection): Use it.
2021-09-21 18:26:59 +00:00
|
|
|
|
(tramp-compat-temporary-file-directory-function))))
|
2017-12-17 10:31:23 +00:00
|
|
|
|
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(defun tramp-archive-handle-not-implemented (operation &rest args)
|
|
|
|
|
"Generic handler for operations not implemented for file archives."
|
|
|
|
|
(let ((v (ignore-errors
|
|
|
|
|
(tramp-archive-dissect-file-name
|
2019-02-28 09:33:05 +00:00
|
|
|
|
(apply #'tramp-archive-file-name-for-operation operation args)))))
|
2017-12-09 13:34:30 +00:00
|
|
|
|
(tramp-message v 10 "%s" (cons operation args))
|
|
|
|
|
(tramp-error
|
|
|
|
|
v 'file-error
|
|
|
|
|
"Operation `%s' not implemented for file archives" operation)))
|
|
|
|
|
|
|
|
|
|
(add-hook 'tramp-unload-hook
|
|
|
|
|
(lambda ()
|
|
|
|
|
(unload-feature 'tramp-archive 'force)))
|
|
|
|
|
|
|
|
|
|
(provide 'tramp-archive)
|
|
|
|
|
|
|
|
|
|
;;; TODO:
|
|
|
|
|
|
2018-02-02 16:06:22 +00:00
|
|
|
|
;; * Check, whether we could retrieve better file attributes like uid,
|
|
|
|
|
;; gid, permissions. See gvfsbackendarchive.c
|
|
|
|
|
;; (archive_file_set_info_from_entry), where it is commented out.
|
2017-12-09 13:34:30 +00:00
|
|
|
|
;;
|
|
|
|
|
;; * Implement write access, when possible.
|
2018-02-02 16:06:22 +00:00
|
|
|
|
;; https://bugzilla.gnome.org/show_bug.cgi?id=589617
|
2017-12-09 13:34:30 +00:00
|
|
|
|
|
|
|
|
|
;;; tramp-archive.el ends here
|