Mercurial > emacs
annotate lisp/net/tramp-cache.el @ 110410:f2e111723c3a
Merge changes made in Gnus trunk.
Reimplement nnimap, and do tweaks to the rest of the code to support that.
* gnus-int.el (gnus-finish-retrieve-group-infos)
(gnus-retrieve-group-data-early): New functions.
* gnus-range.el (gnus-range-nconcat): New function.
* gnus-start.el (gnus-get-unread-articles): Support early retrieval of
data.
(gnus-read-active-for-groups): Support finishing the early retrieval of
data.
* gnus-sum.el (gnus-summary-move-article): Pass the move-to group name
if the move is internal, so that nnimap can do fast internal moves.
* gnus.el (gnus-article-special-mark-lists): Add uid/active tuples, for
nnimap usage.
* nnimap.el: Rewritten.
* nnmail.el (nnmail-inhibit-default-split-group): New internal variable
to allow the mail splitting to not return a default group. This is
useful for nnimap, which will leave unmatched mail in the inbox.
* utf7.el (utf7-encode): Autoload.
Implement shell connection.
* nnimap.el (nnimap-open-shell-stream): New function.
(nnimap-open-connection): Use it.
Get the number of lines by using BODYSTRUCTURE.
(nnimap-transform-headers): Get the number of lines in each message.
(nnimap-retrieve-headers): Query for BODYSTRUCTURE so that we get the
number of lines.
Not all servers return UIDNEXT. Work past this problem.
Remove junk from end of file.
Fix typo in "bogus" section.
Make capabilties be case-insensitive.
Require cl when compiling.
Don't bug out if the LIST command doesn't have any parameters.
2010-09-17 Knut Anders Hatlen <kahatlen@gmail.com> (tiny change)
* nnimap.el (nnimap-get-groups): Don't bug out if the LIST command
doesn't have any parameters.
(mm-text-html-renderer): Document gnus-article-html.
2010-09-17 Julien Danjou <julien@danjou.info> (tiny fix)
* mm-decode.el (mm-text-html-renderer): Document gnus-article-html.
* dgnushack.el: Define netrc-credentials.
If the user doesn't have a /etc/services, supply some sensible port defaults.
Have `unseen-or-unread' select an unread unseen article first.
(nntp-open-server): Return whether the open was successful or not.
Throughout all files, replace (save-excursion (set-buffer ...)) with (with-current-buffer ... ).
Save result so that it doesn't say "failed" all the time.
Add ~/.authinfo to the default, since that's probably most useful for users.
Don't use the "finish" method when we're reading from the agent.
Add some more nnimap-relevant agent stuff to nnagent.el.
* nnimap.el (nnimap-with-process-buffer): Removed.
Revert one line that was changed by mistake in the last checkin.
(nnimap-open-connection): Don't error out when we can't make a connection
nnimap-related changes to avoid bugging out if we can't contact a server.
* gnus-start.el (gnus-get-unread-articles): Don't try to scan groups
from methods that are denied.
* nnimap.el (nnimap-possibly-change-group): Return nil if we can't log
in.
(nnimap-finish-retrieve-group-infos): Make sure we're not waiting for
nothing.
* gnus-sum.el (gnus-select-newsgroup): Indent.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Sat, 18 Sep 2010 10:02:19 +0000 |
parents | 932697ced7aa |
children | 4e901a2d3669 |
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 |
107151
7e66e7efd47d
* net/tramp.el (tramp-process-actions, tramp-read-passwd):
Michael Albinus <michael.albinus@gmx.de>
parents:
106815
diff
changeset
|
3 ;; Copyright (C) 2000, 2005, 2006, 2007, 2008, 2009, |
7e66e7efd47d
* net/tramp.el (tramp-process-actions, tramp-read-passwd):
Michael Albinus <michael.albinus@gmx.de>
parents:
106815
diff
changeset
|
4 ;; 2010 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 |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
107151
diff
changeset
|
9 ;; Package: tramp |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
10 |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
11 ;; 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
|
12 |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94404
diff
changeset
|
13 ;; 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
|
14 ;; 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
|
15 ;; 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
|
16 ;; (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
|
17 |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
18 ;; 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
|
19 ;; 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
|
20 ;; 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
|
21 ;; 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
|
22 |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
23 ;; 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
|
24 ;; 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
|
25 |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
26 ;;; Commentary: |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
27 |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
28 ;; 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
|
29 |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
30 ;; 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
|
31 ;; 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
|
32 ;; 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
|
33 ;; |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
34 ;; - 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
|
35 ;; "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
|
36 ;; 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
|
37 ;; 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
|
38 ;; 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
|
39 ;; |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
40 ;; - 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
|
41 ;; 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
|
42 ;; "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
|
43 ;; "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
|
44 ;; `file-attributes'. |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
45 ;; |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
46 ;; - 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
|
47 ;; 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
|
48 ;; 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
|
49 ;; 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
|
50 |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
51 ;;; Code: |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
52 |
110264
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
53 (require 'tramp) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
54 (autoload 'time-stamp-string "time-stamp") |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
55 |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
56 ;;; -- Cache -- |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
57 |
110264
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
58 ;;;###tramp-autoload |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
59 (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
|
60 "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
|
61 |
104124
05be2b60df7a
* net/tramp-cache.el (tramp-cache-inhibit-cache ): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
102906
diff
changeset
|
62 (defvar tramp-cache-inhibit-cache nil |
104643
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
63 "Inhibit cache read access, when `t'. |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
64 `nil' means to accept cache entries unconditionally. If the |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
65 value is a timestamp (as returned by `current-time'), cache |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
66 entries are not used when they have been written before this |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
67 time.") |
104124
05be2b60df7a
* net/tramp-cache.el (tramp-cache-inhibit-cache ): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
102906
diff
changeset
|
68 |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
69 (defcustom tramp-persistency-file-name |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
70 (cond |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
71 ;; GNU Emacs. |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
72 ((and (boundp 'user-emacs-directory) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
73 (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
|
74 (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
|
75 (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
|
76 ((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
|
77 "~/.emacs.d/tramp") |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
78 ;; XEmacs. |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
79 ((and (boundp 'user-init-directory) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
80 (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
|
81 (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
|
82 (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
|
83 ((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
|
84 "~/.xemacs/tramp") |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
85 ;; 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
|
86 (t "~/.tramp")) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
87 "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
|
88 :group 'tramp |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
89 :type 'file) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
90 |
100088
cc6585cecaaf
* net/tramp-cache.el (tramp-cache-data-changed): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
97980
diff
changeset
|
91 (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
|
92 "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
|
93 |
110264
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
94 ;;;###tramp-autoload |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
95 (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
|
96 "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
|
97 Returns DEFAULT if not set." |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
98 ;; Unify localname. |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
99 (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
|
100 (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
|
101 (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
|
102 (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
|
103 tramp-cache-data))) |
104643
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
104 (value (when (hash-table-p hash) (gethash property hash)))) |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
105 (if |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
106 ;; We take the value only if there is any, and |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
107 ;; `tramp-cache-inhibit-cache' indicates that it is still |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
108 ;; valid. Otherwise, DEFAULT is set. |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
109 (and (consp value) |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
110 (or (null tramp-cache-inhibit-cache) |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
111 (and (consp tramp-cache-inhibit-cache) |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
112 (tramp-time-less-p |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
113 tramp-cache-inhibit-cache (car value))))) |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
114 (setq value (cdr value)) |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
115 (setq value default)) |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
116 |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
117 (if (consp tramp-cache-inhibit-cache) |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
118 (tramp-message vec 1 "%s %s %s" file property value)) |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
119 (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
|
120 value)) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
121 |
110264
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
122 ;;;###tramp-autoload |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
123 (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
|
124 "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
|
125 Returns VALUE." |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
126 ;; Unify localname. |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
127 (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
|
128 (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
|
129 (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
|
130 (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
|
131 tramp-cache-data)))) |
104643
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
132 ;; We put the timestamp there. |
09a9c0ad9b90
* net/tramp-cache.el (top): Autoload `tramp-time-less-p'.
Michael Albinus <michael.albinus@gmx.de>
parents:
104124
diff
changeset
|
133 (puthash property (cons (current-time) value) hash) |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
134 (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
|
135 value)) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
136 |
110264
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
137 ;;;###tramp-autoload |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
138 (defmacro with-file-property (vec file property &rest body) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
139 "Check in Tramp cache for PROPERTY, otherwise execute BODY and set cache. |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
140 FILE must be a local file name on a connection identified via VEC." |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
141 `(if (file-name-absolute-p ,file) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
142 (let ((value (tramp-get-file-property ,vec ,file ,property 'undef))) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
143 (when (eq value 'undef) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
144 ;; We cannot pass @body as parameter to |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
145 ;; `tramp-set-file-property' because it mangles our |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
146 ;; debug messages. |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
147 (setq value (progn ,@body)) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
148 (tramp-set-file-property ,vec ,file ,property value)) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
149 value) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
150 ,@body)) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
151 |
110321
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
152 ;;;###tramp-autoload |
110264
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
153 (put 'with-file-property 'lisp-indent-function 3) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
154 (put 'with-file-property 'edebug-form-spec t) |
110374
932697ced7aa
* net/tramp-compat.el (tramp-compat-with-temp-message)
Michael Albinus <michael.albinus@gmx.de>
parents:
110321
diff
changeset
|
155 (tramp-compat-font-lock-add-keywords |
932697ced7aa
* net/tramp-compat.el (tramp-compat-with-temp-message)
Michael Albinus <michael.albinus@gmx.de>
parents:
110321
diff
changeset
|
156 'emacs-lisp-mode '("\\<with-file-property\\>")) |
110264
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
157 |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
158 ;;;###tramp-autoload |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
159 (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
|
160 "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
|
161 ;; Unify localname. |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
162 (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
|
163 (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
|
164 (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
|
165 (remhash vec tramp-cache-data)) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
166 |
110264
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
167 ;;;###tramp-autoload |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
168 (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
|
169 "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
|
170 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
|
171 (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
|
172 '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
|
173 (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
|
174 (maphash |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
175 '(lambda (key value) |
102906
dafde9e3d72b
* tramp-cache.el (tramp-flush-directory-property): Use the
Michael Albinus <michael.albinus@gmx.de>
parents:
101728
diff
changeset
|
176 (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
|
177 (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
|
178 (remhash key tramp-cache-data))) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
179 tramp-cache-data))) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
180 |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
181 ;; 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
|
182 ;; 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
|
183 ;; 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
|
184 ;; deleted before. |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
185 (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
|
186 "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
|
187 (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
|
188 (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
|
189 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
|
190 (when (tramp-tramp-file-p bfn) |
110264
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
191 (with-parsed-tramp-file-name bfn nil |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
192 (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
|
193 |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
194 (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
|
195 (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
|
196 (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
|
197 (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
|
198 '(lambda () |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
199 (remove-hook 'before-revert-hook |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
200 '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
|
201 (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
|
202 'tramp-flush-file-function) |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
203 (remove-hook 'kill-buffer-hook |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
204 'tramp-flush-file-function))) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
205 |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
206 ;;; -- Properties -- |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
207 |
110264
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
208 ;;;###tramp-autoload |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
209 (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
|
210 "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
|
211 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
|
212 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
|
213 ;; 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
|
214 ;; order to avoid side effects. |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
215 (when (vectorp key) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
216 (setq key (copy-sequence key)) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
217 (aset key 3 nil)) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
218 (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
|
219 (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
|
220 (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
|
221 default))) |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
222 (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
|
223 value)) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
224 |
110264
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
225 ;;;###tramp-autoload |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
226 (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
|
227 "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
|
228 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
|
229 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
|
230 ;; 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
|
231 ;; order to avoid side effects. |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
232 (when (vectorp key) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
233 (setq key (copy-sequence key)) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
234 (aset key 3 nil)) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
235 (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
|
236 (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
|
237 tramp-cache-data)))) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
238 (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
|
239 (setq tramp-cache-data-changed t) |
110321
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
240 (tramp-message key 7 "%s %s" property value) |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
241 value)) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
242 |
110264
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
243 ;;;###tramp-autoload |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
244 (defmacro with-connection-property (key property &rest body) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
245 "Check in Tramp for property PROPERTY, otherwise executes BODY and set." |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
246 `(let ((value (tramp-get-connection-property ,key ,property 'undef))) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
247 (when (eq value 'undef) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
248 ;; We cannot pass ,@body as parameter to |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
249 ;; `tramp-set-connection-property' because it mangles our debug |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
250 ;; messages. |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
251 (setq value (progn ,@body)) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
252 (tramp-set-connection-property ,key ,property value)) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
253 value)) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
254 |
110321
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
255 ;;;###tramp-autoload |
110264
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
256 (put 'with-connection-property 'lisp-indent-function 2) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
257 (put 'with-connection-property 'edebug-form-spec t) |
110374
932697ced7aa
* net/tramp-compat.el (tramp-compat-with-temp-message)
Michael Albinus <michael.albinus@gmx.de>
parents:
110321
diff
changeset
|
258 (tramp-compat-font-lock-add-keywords |
932697ced7aa
* net/tramp-compat.el (tramp-compat-with-temp-message)
Michael Albinus <michael.albinus@gmx.de>
parents:
110321
diff
changeset
|
259 'emacs-lisp-mode '("\\<with-connection-property\\>")) |
110264
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
260 |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
261 ;;;###tramp-autoload |
91485
202f9737703b
* net/tramp-cache.el (tramp-flush-connection-property): Remove EVENT.
Michael Albinus <michael.albinus@gmx.de>
parents:
87747
diff
changeset
|
262 (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
|
263 "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
|
264 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
|
265 ;; 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
|
266 ;; order to avoid side effects. |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
267 (when (vectorp key) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
268 (setq key (copy-sequence key)) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
269 (aset key 3 nil)) |
105508
3b3d1d59e375
* net/tramp-cache.el (tramp-flush-connection-property): Add trace message.
Michael Albinus <michael.albinus@gmx.de>
parents:
104643
diff
changeset
|
270 (tramp-message |
3b3d1d59e375
* net/tramp-cache.el (tramp-flush-connection-property): Add trace message.
Michael Albinus <michael.albinus@gmx.de>
parents:
104643
diff
changeset
|
271 key 7 "%s %s" key |
105550
42674c5ffbe7
* net/tramp-cache.el (tramp-flush-connection-property): The hash
Michael Albinus <michael.albinus@gmx.de>
parents:
105508
diff
changeset
|
272 (let ((hash (gethash key tramp-cache-data)) |
42674c5ffbe7
* net/tramp-cache.el (tramp-flush-connection-property): The hash
Michael Albinus <michael.albinus@gmx.de>
parents:
105508
diff
changeset
|
273 properties) |
42674c5ffbe7
* net/tramp-cache.el (tramp-flush-connection-property): The hash
Michael Albinus <michael.albinus@gmx.de>
parents:
105508
diff
changeset
|
274 (if (hash-table-p hash) |
42674c5ffbe7
* net/tramp-cache.el (tramp-flush-connection-property): The hash
Michael Albinus <michael.albinus@gmx.de>
parents:
105508
diff
changeset
|
275 (maphash |
42674c5ffbe7
* net/tramp-cache.el (tramp-flush-connection-property): The hash
Michael Albinus <michael.albinus@gmx.de>
parents:
105508
diff
changeset
|
276 (lambda (x y) (add-to-list 'properties x 'append)) |
42674c5ffbe7
* net/tramp-cache.el (tramp-flush-connection-property): The hash
Michael Albinus <michael.albinus@gmx.de>
parents:
105508
diff
changeset
|
277 (gethash key tramp-cache-data))) |
105508
3b3d1d59e375
* net/tramp-cache.el (tramp-flush-connection-property): Add trace message.
Michael Albinus <michael.albinus@gmx.de>
parents:
104643
diff
changeset
|
278 properties)) |
100088
cc6585cecaaf
* net/tramp-cache.el (tramp-cache-data-changed): New defvar.
Michael Albinus <michael.albinus@gmx.de>
parents:
97980
diff
changeset
|
279 (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
|
280 (remhash key tramp-cache-data)) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
281 |
110264
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
282 ;;;###tramp-autoload |
85943
85b6f7d4aca8
* net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents:
85802
diff
changeset
|
283 (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
|
284 "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
|
285 (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
|
286 (let (result) |
85b6f7d4aca8
* net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents:
85802
diff
changeset
|
287 (maphash |
85b6f7d4aca8
* net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents:
85802
diff
changeset
|
288 '(lambda (key value) |
85b6f7d4aca8
* net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents:
85802
diff
changeset
|
289 (let ((tmp (format |
85b6f7d4aca8
* net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents:
85802
diff
changeset
|
290 "(%s %s)" |
85b6f7d4aca8
* net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents:
85802
diff
changeset
|
291 (if (processp key) |
85b6f7d4aca8
* net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents:
85802
diff
changeset
|
292 (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
|
293 (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
|
294 (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
|
295 (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
|
296 (if (bufferp value) |
85b6f7d4aca8
* net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents:
85802
diff
changeset
|
297 (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
|
298 (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
|
299 (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
|
300 table) |
85b6f7d4aca8
* net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents:
85802
diff
changeset
|
301 result))) |
85b6f7d4aca8
* net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents:
85802
diff
changeset
|
302 |
110264
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
303 ;;;###tramp-autoload |
85962
7f134b676a0c
* net/tramp.el (tramp-handle-substitute-in-file-name): Don't
Michael Albinus <michael.albinus@gmx.de>
parents:
85943
diff
changeset
|
304 (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
|
305 "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
|
306 (let (result) |
85b6f7d4aca8
* net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents:
85802
diff
changeset
|
307 (maphash |
85b6f7d4aca8
* net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents:
85802
diff
changeset
|
308 '(lambda (key value) |
85b6f7d4aca8
* net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents:
85802
diff
changeset
|
309 (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
|
310 (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
|
311 tramp-cache-data) |
85b6f7d4aca8
* net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents:
85802
diff
changeset
|
312 result)) |
85b6f7d4aca8
* net/tramp.el (top): Don't autoload `tramp-cache-print'.
Michael Albinus <michael.albinus@gmx.de>
parents:
85802
diff
changeset
|
313 |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
314 (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
|
315 "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
|
316 ;; We shouldn't fail, otherwise (X)Emacs might not be able to be closed. |
110321
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
317 (ignore-errors |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
318 (when (and (hash-table-p tramp-cache-data) |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
319 (not (zerop (hash-table-count tramp-cache-data))) |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
320 tramp-cache-data-changed |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
321 (stringp tramp-persistency-file-name)) |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
322 (let ((cache (copy-hash-table tramp-cache-data))) |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
323 ;; Remove temporary data. |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
324 (maphash |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
325 '(lambda (key value) |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
326 (if (and (vectorp key) (not (tramp-file-name-localname key))) |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
327 (progn |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
328 (remhash "process-name" value) |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
329 (remhash "process-buffer" value) |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
330 (remhash "first-password-request" value)) |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
331 (remhash key cache))) |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
332 cache) |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
333 ;; Dump it. |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
334 (with-temp-buffer |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
335 (insert |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
336 ";; -*- emacs-lisp -*-" |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
337 ;; `time-stamp-string' might not exist in all (X)Emacs flavors. |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
338 (condition-case nil |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
339 (progn |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
340 (format |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
341 " <%s %s>\n" |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
342 (time-stamp-string "%02y/%02m/%02d %02H:%02M:%02S") |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
343 tramp-persistency-file-name)) |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
344 (error "\n")) |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
345 ";; Tramp connection history. Don't change this file.\n" |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
346 ";; You can delete it, forcing Tramp to reapply the checks.\n\n" |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
347 (with-output-to-string |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
348 (pp (read (format "(%s)" (tramp-cache-print cache)))))) |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
349 (write-region |
4b26adbef9a2
Major code cleanup. Split tramp.el into tramp.el and tramp-sh.el.
Michael Albinus <michael.albinus@gmx.de>
parents:
110319
diff
changeset
|
350 (point-min) (point-max) tramp-persistency-file-name)))))) |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
351 |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
352 (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
|
353 (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
|
354 '(lambda () |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
355 (remove-hook 'kill-emacs-hook |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
356 'tramp-dump-connection-properties))) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
357 |
110292
3afdbf4cdf4b
* net/tramp-cache.el (tramp-parse-connection-properties): Set
Michael Albinus <michael.albinus@gmx.de>
parents:
110264
diff
changeset
|
358 ;;;###tramp-autoload |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
359 (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
|
360 "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
|
361 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
|
362 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
|
363 (let (res) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
364 (maphash |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
365 '(lambda (key value) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
366 (if (and (vectorp key) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
367 (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
|
368 (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
|
369 (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
|
370 (tramp-file-name-host key)) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
371 res))) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
372 tramp-cache-data) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
373 res)) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
374 |
82324
5399c02bfd07
* net/tramp.el (tramp-wrong-passwd-regexp): Make the regexp more
Michael Albinus <michael.albinus@gmx.de>
parents:
82201
diff
changeset
|
375 ;; 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
|
376 (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
|
377 (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
|
378 (condition-case err |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
379 (with-temp-buffer |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
380 (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
|
381 (let ((list (read (current-buffer))) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
382 element key item) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
383 (while (setq element (pop list)) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
384 (setq key (pop element)) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
385 (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
|
386 (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
|
387 (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
|
388 (file-error |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
389 ;; 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
|
390 (clrhash tramp-cache-data)) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
391 (error |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
392 ;; 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
|
393 (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
|
394 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
|
395 (clrhash tramp-cache-data)))) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
396 |
110264
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
397 (add-hook 'tramp-unload-hook |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
398 (lambda () |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
399 (unload-feature 'tramp-cache 'force))) |
ec526909f60b
Migrate to Tramp 2.2. Rearrange load dependencies.
Michael Albinus <michael.albinus@gmx.de>
parents:
110015
diff
changeset
|
400 |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
401 (provide 'tramp-cache) |
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
diff
changeset
|
402 |
81769 | 403 ;; 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
|
404 ;;; tramp-cache.el ends here |