annotate lisp/net/tramp-cache.el @ 104433:77f14bf50035

Directory eieio removed.
author Chong Yidong <cyd@stupidchicken.com>
date Sun, 30 Aug 2009 02:04:33 +0000
parents 05be2b60df7a
children 09a9c0ad9b90
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
1 ;;; tramp-cache.el --- file information caching for Tramp
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
2
101728
0e77ae8c6b45 * net/tramp-cache.el (top): Autoload `tramp-run-real-handler'.
Michael Albinus <michael.albinus@gmx.de>
parents: 100908
diff changeset
3 ;; Copyright (C) 2000, 2005, 2006, 2007, 2008,
0e77ae8c6b45 * net/tramp-cache.el (top): Autoload `tramp-run-real-handler'.
Michael Albinus <michael.albinus@gmx.de>
parents: 100908
diff changeset
4 ;; 2009 Free Software Foundation, Inc.
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
5
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
6 ;; Author: Daniel Pittman <daniel@inanna.danann.net>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
7 ;; Michael Albinus <michael.albinus@gmx.de>
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
8 ;; Keywords: comm, processes
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
9
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
11
94677
91e5880a36c1 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94404
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
94677
91e5880a36c1 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94404
diff changeset
14 ;; the Free Software Foundation, either version 3 of the License, or
91e5880a36c1 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94404
diff changeset
15 ;; (at your option) any later version.
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
16
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
20 ;; GNU General Public License for more details.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
21
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
94677
91e5880a36c1 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94404
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
24
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
25 ;;; Commentary:
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
26
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
27 ;; An implementation of information caching for remote files.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
28
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
29 ;; Each connection, identified by a vector [method user host
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
30 ;; localname] or by a process, has a unique cache. We distinguish 3
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
31 ;; kind of caches, depending on the key:
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
32 ;;
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
33 ;; - localname is NIL. This are reusable properties. Examples:
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
34 ;; "remote-shell" identifies the POSIX shell to be called on the
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
35 ;; remote host, or "perl" is the command to be called on the remote
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
36 ;; host, when starting a Perl script. These properties are saved in
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
37 ;; the file `tramp-persistency-file-name'.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
38 ;;
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
39 ;; - localname is a string. This are temporary properties, which are
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
40 ;; related to the file localname is referring to. Examples:
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
41 ;; "file-exists-p" is t or nile, depending on the file existence, or
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
42 ;; "file-attributes" caches the result of the function
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
43 ;; `file-attributes'.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
44 ;;
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
45 ;; - The key is a process. This are temporary properties related to
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
46 ;; an open connection. Examples: "scripts" keeps shell script
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
47 ;; definitions already sent to the remote shell, "last-cmd-time" is
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
48 ;; the time stamp a command has been sent to the remote process.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
49
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
50 ;;; Code:
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
51
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
52 ;; Pacify byte-compiler.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
53 (eval-when-compile
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
54 (require 'cl)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
55 (autoload 'tramp-message "tramp")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
56 (autoload 'tramp-tramp-file-p "tramp")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
57 ;; We cannot autoload macro `with-parsed-tramp-file-name', it
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
58 ;; results in problems of byte-compiled code.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
59 (autoload 'tramp-dissect-file-name "tramp")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
60 (autoload 'tramp-file-name-method "tramp")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
61 (autoload 'tramp-file-name-user "tramp")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
62 (autoload 'tramp-file-name-host "tramp")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
63 (autoload 'tramp-file-name-localname "tramp")
101728
0e77ae8c6b45 * net/tramp-cache.el (top): Autoload `tramp-run-real-handler'.
Michael Albinus <michael.albinus@gmx.de>
parents: 100908
diff changeset
64 (autoload 'tramp-run-real-handler "tramp")
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
65 (autoload 'time-stamp-string "time-stamp"))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
66
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
67 ;;; -- Cache --
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
68
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
69 (defvar tramp-cache-data (make-hash-table :test 'equal)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
70 "Hash table for remote files properties.")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
71
104124
05be2b60df7a * net/tramp-cache.el (tramp-cache-inhibit-cache ): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 102906
diff changeset
72 (defvar tramp-cache-inhibit-cache nil
05be2b60df7a * net/tramp-cache.el (tramp-cache-inhibit-cache ): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 102906
diff changeset
73 "Inhibit cache read access, when non-nil.")
05be2b60df7a * net/tramp-cache.el (tramp-cache-inhibit-cache ): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 102906
diff changeset
74
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
75 (defcustom tramp-persistency-file-name
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
76 (cond
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
77 ;; GNU Emacs.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
78 ((and (boundp 'user-emacs-directory)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
79 (stringp (symbol-value 'user-emacs-directory))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
80 (file-directory-p (symbol-value 'user-emacs-directory)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
81 (expand-file-name "tramp" (symbol-value 'user-emacs-directory)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
82 ((and (not (featurep 'xemacs)) (file-directory-p "~/.emacs.d/"))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
83 "~/.emacs.d/tramp")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
84 ;; XEmacs.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
85 ((and (boundp 'user-init-directory)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
86 (stringp (symbol-value 'user-init-directory))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
87 (file-directory-p (symbol-value 'user-init-directory)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
88 (expand-file-name "tramp" (symbol-value 'user-init-directory)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
89 ((and (featurep 'xemacs) (file-directory-p "~/.xemacs/"))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
90 "~/.xemacs/tramp")
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
91 ;; For users without `~/.emacs.d/' or `~/.xemacs/'.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
92 (t "~/.tramp"))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
93 "File which keeps connection history for Tramp connections."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
94 :group 'tramp
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
95 :type 'file)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
96
100088
cc6585cecaaf * net/tramp-cache.el (tramp-cache-data-changed): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 97980
diff changeset
97 (defvar tramp-cache-data-changed nil
cc6585cecaaf * net/tramp-cache.el (tramp-cache-data-changed): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 97980
diff changeset
98 "Whether persistent cache data have been changed.")
cc6585cecaaf * net/tramp-cache.el (tramp-cache-data-changed): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 97980
diff changeset
99
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
100 (defun tramp-get-file-property (vec file property default)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
101 "Get the PROPERTY of FILE from the cache context of VEC.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
102 Returns DEFAULT if not set."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
103 ;; Unify localname.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
104 (setq vec (copy-sequence vec))
94404
9ce39a6373c9 * net/tramp.el (tramp-handle-make-symbolic-link)
Michael Albinus <michael.albinus@gmx.de>
parents: 91485
diff changeset
105 (aset vec 3 (tramp-run-real-handler 'directory-file-name (list file)))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
106 (let* ((hash (or (gethash vec tramp-cache-data)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
107 (puthash vec (make-hash-table :test 'equal)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
108 tramp-cache-data)))
104124
05be2b60df7a * net/tramp-cache.el (tramp-cache-inhibit-cache ): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 102906
diff changeset
109 (value (if (and (null tramp-cache-inhibit-cache) (hash-table-p hash))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
110 (gethash property hash default)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
111 default)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
112 (tramp-message vec 8 "%s %s %s" file property value)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
113 value))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
114
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
115 (defun tramp-set-file-property (vec file property value)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
116 "Set the PROPERTY of FILE to VALUE, in the cache context of VEC.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
117 Returns VALUE."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
118 ;; Unify localname.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
119 (setq vec (copy-sequence vec))
94404
9ce39a6373c9 * net/tramp.el (tramp-handle-make-symbolic-link)
Michael Albinus <michael.albinus@gmx.de>
parents: 91485
diff changeset
120 (aset vec 3 (tramp-run-real-handler 'directory-file-name (list file)))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
121 (let ((hash (or (gethash vec tramp-cache-data)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
122 (puthash vec (make-hash-table :test 'equal)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
123 tramp-cache-data))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
124 (puthash property value hash)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
125 (tramp-message vec 8 "%s %s %s" file property value)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
126 value))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
127
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
128 (defun tramp-flush-file-property (vec file)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
129 "Remove all properties of FILE in the cache context of VEC."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
130 ;; Unify localname.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
131 (setq vec (copy-sequence vec))
94404
9ce39a6373c9 * net/tramp.el (tramp-handle-make-symbolic-link)
Michael Albinus <michael.albinus@gmx.de>
parents: 91485
diff changeset
132 (aset vec 3 (tramp-run-real-handler 'directory-file-name (list file)))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
133 (tramp-message vec 8 "%s" file)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
134 (remhash vec tramp-cache-data))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
135
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
136 (defun tramp-flush-directory-property (vec directory)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
137 "Remove all properties of DIRECTORY in the cache context of VEC.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
138 Remove also properties of all files in subdirectories."
94404
9ce39a6373c9 * net/tramp.el (tramp-handle-make-symbolic-link)
Michael Albinus <michael.albinus@gmx.de>
parents: 91485
diff changeset
139 (let ((directory (tramp-run-real-handler
9ce39a6373c9 * net/tramp.el (tramp-handle-make-symbolic-link)
Michael Albinus <michael.albinus@gmx.de>
parents: 91485
diff changeset
140 'directory-file-name (list directory))))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
141 (tramp-message vec 8 "%s" directory)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
142 (maphash
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
143 '(lambda (key value)
102906
dafde9e3d72b * tramp-cache.el (tramp-flush-directory-property): Use the
Michael Albinus <michael.albinus@gmx.de>
parents: 101728
diff changeset
144 (when (and (stringp (tramp-file-name-localname key))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
145 (string-match directory (tramp-file-name-localname key)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
146 (remhash key tramp-cache-data)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
147 tramp-cache-data)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
148
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
149 ;; Reverting or killing a buffer should also flush file properties.
85802
a69014d11d95 * net/tramp.el (tramp-maybe-open-connection): Set $LC_ALL to "C".
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
150 ;; They could have been changed outside Tramp. In eshell, "ls" would
a69014d11d95 * net/tramp.el (tramp-maybe-open-connection): Set $LC_ALL to "C".
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
151 ;; not show proper directory contents when a file has been copied or
a69014d11d95 * net/tramp.el (tramp-maybe-open-connection): Set $LC_ALL to "C".
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
152 ;; deleted before.
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
153 (defun tramp-flush-file-function ()
97980
2570e504f856 * net/tramp-cache.el (tramp-flush-file-function): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 94677
diff changeset
154 "Flush all Tramp cache properties from `buffer-file-name'."
85802
a69014d11d95 * net/tramp.el (tramp-maybe-open-connection): Set $LC_ALL to "C".
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
155 (let ((bfn (if (stringp (buffer-file-name))
a69014d11d95 * net/tramp.el (tramp-maybe-open-connection): Set $LC_ALL to "C".
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
156 (buffer-file-name)
a69014d11d95 * net/tramp.el (tramp-maybe-open-connection): Set $LC_ALL to "C".
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
157 default-directory)))
a69014d11d95 * net/tramp.el (tramp-maybe-open-connection): Set $LC_ALL to "C".
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
158 (when (tramp-tramp-file-p bfn)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
159 (let* ((v (tramp-dissect-file-name bfn))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
160 (localname (tramp-file-name-localname v)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
161 (tramp-flush-file-property v localname)))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
162
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
163 (add-hook 'before-revert-hook 'tramp-flush-file-function)
85802
a69014d11d95 * net/tramp.el (tramp-maybe-open-connection): Set $LC_ALL to "C".
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
164 (add-hook 'eshell-pre-command-hook 'tramp-flush-file-function)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
165 (add-hook 'kill-buffer-hook 'tramp-flush-file-function)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
166 (add-hook 'tramp-cache-unload-hook
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
167 '(lambda ()
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
168 (remove-hook 'before-revert-hook
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
169 'tramp-flush-file-function)
85802
a69014d11d95 * net/tramp.el (tramp-maybe-open-connection): Set $LC_ALL to "C".
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
170 (remove-hook 'eshell-pre-command-hook
a69014d11d95 * net/tramp.el (tramp-maybe-open-connection): Set $LC_ALL to "C".
Michael Albinus <michael.albinus@gmx.de>
parents: 84966
diff changeset
171 'tramp-flush-file-function)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
172 (remove-hook 'kill-buffer-hook
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
173 'tramp-flush-file-function)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
174
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
175 ;;; -- Properties --
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
176
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
177 (defun tramp-get-connection-property (key property default)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
178 "Get the named PROPERTY for the connection.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
179 KEY identifies the connection, it is either a process or a vector.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
180 If the value is not set for the connection, returns DEFAULT."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
181 ;; Unify key by removing localname from vector. Work with a copy in
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
182 ;; order to avoid side effects.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
183 (when (vectorp key)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
184 (setq key (copy-sequence key))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
185 (aset key 3 nil))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
186 (let* ((hash (gethash key tramp-cache-data))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
187 (value (if (hash-table-p hash)
104124
05be2b60df7a * net/tramp-cache.el (tramp-cache-inhibit-cache ): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 102906
diff changeset
188 (gethash property hash default)
05be2b60df7a * net/tramp-cache.el (tramp-cache-inhibit-cache ): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 102906
diff changeset
189 default)))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
190 (tramp-message key 7 "%s %s" property value)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
191 value))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
192
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
193 (defun tramp-set-connection-property (key property value)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
194 "Set the named PROPERTY of a connection to VALUE.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
195 KEY identifies the connection, it is either a process or a vector.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
196 PROPERTY is set persistent when KEY is a vector."
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
197 ;; Unify key by removing localname from vector. Work with a copy in
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
198 ;; order to avoid side effects.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
199 (when (vectorp key)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
200 (setq key (copy-sequence key))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
201 (aset key 3 nil))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
202 (let ((hash (or (gethash key tramp-cache-data)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
203 (puthash key (make-hash-table :test 'equal)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
204 tramp-cache-data))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
205 (puthash property value hash)
100088
cc6585cecaaf * net/tramp-cache.el (tramp-cache-data-changed): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 97980
diff changeset
206 (setq tramp-cache-data-changed t)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
207 ;; This function is called also during initialization of
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
208 ;; tramp-cache.el. `tramp-message´ is not defined yet at this
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
209 ;; time, so we ignore the corresponding error.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
210 (condition-case nil
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
211 (tramp-message key 7 "%s %s" property value)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
212 (error nil))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
213 value))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
214
91485
202f9737703b * net/tramp-cache.el (tramp-flush-connection-property): Remove EVENT.
Michael Albinus <michael.albinus@gmx.de>
parents: 87747
diff changeset
215 (defun tramp-flush-connection-property (key)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
216 "Remove all properties identified by KEY.
91485
202f9737703b * net/tramp-cache.el (tramp-flush-connection-property): Remove EVENT.
Michael Albinus <michael.albinus@gmx.de>
parents: 87747
diff changeset
217 KEY identifies the connection, it is either a process or a vector."
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
218 ;; Unify key by removing localname from vector. Work with a copy in
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
219 ;; order to avoid side effects.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
220 (when (vectorp key)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
221 (setq key (copy-sequence key))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
222 (aset key 3 nil))
100088
cc6585cecaaf * net/tramp-cache.el (tramp-cache-data-changed): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 97980
diff changeset
223 (setq tramp-cache-data-changed t)
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
224 (remhash key tramp-cache-data))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
225
85943
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
226 (defun tramp-cache-print (table)
85962
7f134b676a0c * net/tramp.el (tramp-handle-substitute-in-file-name): Don't
Michael Albinus <michael.albinus@gmx.de>
parents: 85943
diff changeset
227 "Print hash table TABLE."
85943
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
228 (when (hash-table-p table)
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
229 (let (result)
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
230 (maphash
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
231 '(lambda (key value)
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
232 (let ((tmp (format
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
233 "(%s %s)"
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
234 (if (processp key)
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
235 (prin1-to-string (prin1-to-string key))
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
236 (prin1-to-string key))
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
237 (if (hash-table-p value)
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
238 (tramp-cache-print value)
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
239 (if (bufferp value)
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
240 (prin1-to-string (prin1-to-string value))
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
241 (prin1-to-string value))))))
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
242 (setq result (if result (concat result " " tmp) tmp))))
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
243 table)
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
244 result)))
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
245
85962
7f134b676a0c * net/tramp.el (tramp-handle-substitute-in-file-name): Don't
Michael Albinus <michael.albinus@gmx.de>
parents: 85943
diff changeset
246 (defun tramp-list-connections ()
7f134b676a0c * net/tramp.el (tramp-handle-substitute-in-file-name): Don't
Michael Albinus <michael.albinus@gmx.de>
parents: 85943
diff changeset
247 "Return a list of all known connection vectors according to `tramp-cache'."
85943
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
248 (let (result)
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
249 (maphash
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
250 '(lambda (key value)
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
251 (when (and (vectorp key) (null (aref key 3)))
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
252 (add-to-list 'result key)))
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
253 tramp-cache-data)
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
254 result))
85b6f7d4aca8 * net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents: 85802
diff changeset
255
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
256 (defun tramp-dump-connection-properties ()
85962
7f134b676a0c * net/tramp.el (tramp-handle-substitute-in-file-name): Don't
Michael Albinus <michael.albinus@gmx.de>
parents: 85943
diff changeset
257 "Write persistent connection properties into file `tramp-persistency-file-name'."
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
258 ;; We shouldn't fail, otherwise (X)Emacs might not be able to be closed.
100215
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
259 (condition-case nil
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
260 (when (and (hash-table-p tramp-cache-data)
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
261 (not (zerop (hash-table-count tramp-cache-data)))
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
262 tramp-cache-data-changed
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
263 (stringp tramp-persistency-file-name))
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
264 (let ((cache (copy-hash-table tramp-cache-data)))
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
265 ;; Remove temporary data.
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
266 (maphash
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
267 '(lambda (key value)
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
268 (if (and (vectorp key) (not (tramp-file-name-localname key)))
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
269 (progn
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
270 (remhash "process-name" value)
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
271 (remhash "process-buffer" value))
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
272 (remhash key cache)))
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
273 cache)
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
274 ;; Dump it.
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
275 (with-temp-buffer
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
276 (insert
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
277 ";; -*- emacs-lisp -*-"
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
278 ;; `time-stamp-string' might not exist in all (X)Emacs flavors.
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
279 (condition-case nil
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
280 (progn
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
281 (format
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
282 " <%s %s>\n"
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
283 (time-stamp-string "%02y/%02m/%02d %02H:%02M:%02S")
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
284 tramp-persistency-file-name))
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
285 (error "\n"))
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
286 ";; Tramp connection history. Don't change this file.\n"
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
287 ";; You can delete it, forcing Tramp to reapply the checks.\n\n"
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
288 (with-output-to-string
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
289 (pp (read (format "(%s)" (tramp-cache-print cache))))))
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
290 (write-region
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
291 (point-min) (point-max) tramp-persistency-file-name))))
41af808a3cfa * net/tramp-cache.el (tramp-dump-connection-properties): Polish
Michael Albinus <michael.albinus@gmx.de>
parents: 100088
diff changeset
292 (error nil)))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
293
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
294 (add-hook 'kill-emacs-hook 'tramp-dump-connection-properties)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
295 (add-hook 'tramp-cache-unload-hook
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
296 '(lambda ()
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
297 (remove-hook 'kill-emacs-hook
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
298 'tramp-dump-connection-properties)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
299
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
300 (defun tramp-parse-connection-properties (method)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
301 "Return a list of (user host) tuples allowed to access for METHOD.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
302 This function is added always in `tramp-get-completion-function'
97980
2570e504f856 * net/tramp-cache.el (tramp-flush-file-function): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 94677
diff changeset
303 for all methods. Resulting data are derived from connection history."
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
304 (let (res)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
305 (maphash
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
306 '(lambda (key value)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
307 (if (and (vectorp key)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
308 (string-equal method (tramp-file-name-method key))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
309 (not (tramp-file-name-localname key)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
310 (push (list (tramp-file-name-user key)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
311 (tramp-file-name-host key))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
312 res)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
313 tramp-cache-data)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
314 res))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
315
82324
5399c02bfd07 * net/tramp.el (tramp-wrong-passwd-regexp): Make the regexp more
Michael Albinus <michael.albinus@gmx.de>
parents: 82201
diff changeset
316 ;; Read persistent connection history.
84406
38bcf4ef30c3 * net/tramp.el (top): Remove declarations of `tramp-gw-*' symbols,
Michael Albinus <michael.albinus@gmx.de>
parents: 82324
diff changeset
317 (when (and (stringp tramp-persistency-file-name)
38bcf4ef30c3 * net/tramp.el (top): Remove declarations of `tramp-gw-*' symbols,
Michael Albinus <michael.albinus@gmx.de>
parents: 82324
diff changeset
318 (zerop (hash-table-count tramp-cache-data)))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
319 (condition-case err
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
320 (with-temp-buffer
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
321 (insert-file-contents tramp-persistency-file-name)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
322 (let ((list (read (current-buffer)))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
323 element key item)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
324 (while (setq element (pop list))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
325 (setq key (pop element))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
326 (while (setq item (pop element))
100088
cc6585cecaaf * net/tramp-cache.el (tramp-cache-data-changed): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 97980
diff changeset
327 (tramp-set-connection-property key (pop item) (car item)))))
cc6585cecaaf * net/tramp-cache.el (tramp-cache-data-changed): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents: 97980
diff changeset
328 (setq tramp-cache-data-changed nil))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
329 (file-error
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
330 ;; Most likely because the file doesn't exist yet. No message.
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
331 (clrhash tramp-cache-data))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
332 (error
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
333 ;; File is corrupted.
84406
38bcf4ef30c3 * net/tramp.el (top): Remove declarations of `tramp-gw-*' symbols,
Michael Albinus <michael.albinus@gmx.de>
parents: 82324
diff changeset
334 (message "Tramp persistency file '%s' is corrupted: %s"
38bcf4ef30c3 * net/tramp.el (top): Remove declarations of `tramp-gw-*' symbols,
Michael Albinus <michael.albinus@gmx.de>
parents: 82324
diff changeset
335 tramp-persistency-file-name (error-message-string err))
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
336 (clrhash tramp-cache-data))))
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
337
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
338 (provide 'tramp-cache)
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
339
81769
44b53335982a Add arch tagline
Miles Bader <miles@gnu.org>
parents: 81758
diff changeset
340 ;; arch-tag: ee1739b7-7628-408c-9b96-d11a74b05d26
81758
f03856eb136b * files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff changeset
341 ;;; tramp-cache.el ends here