File: trampcache.el

package info (click to toggle)
xemacs21-packages 2009.02.17.dfsg.1-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 116,928 kB
  • ctags: 88,975
  • sloc: lisp: 1,232,060; ansic: 16,570; java: 13,514; xml: 6,477; sh: 4,611; makefile: 4,036; asm: 3,007; perl: 839; cpp: 500; ruby: 257; csh: 96; haskell: 93; awk: 49; python: 47
file content (98 lines) | stat: -rw-r--r-- 3,407 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
;;; trampcache.el --- file information caching for tramp

;; Copyright (C) 2000 by Free Software Foundation, Inc.

;; Author: Daniel Pittman <daniel@inanna.danann.net>
;; Keywords: comm, processes

;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;; An implementation of file information caching for remote files.

;; Each connection (host, user) has a unique cache.
;; Each file has a unique set of properties associated with it.

;;; Code:

;; The internal interface to the cache system.
(defun tramp-cache-set (file key value)
  "Within the current tramp cache, set the property KEY to VALUE,
for FILE.

This must be run with the current cache context set."
  ;; do we have an entry for the file?
  (let* ((info (or (assoc file tramp-cache-data)
		   (assoc file (setq tramp-cache-data
				     (cons (list file (cons nil nil)) tramp-cache-data)))))
	 (prop (or (assoc key (cdr info))
		   (assoc key (setcdr info
				      (cons (cons key nil) (cdr info)))))))
	 (setcdr prop value)))

(defun tramp-cache-get (file key)
  "Within the current tramp cache, return the property KEY of FILE."
  (cdr-safe (assoc key (cdr-safe (assoc file tramp-cache-data)))))






;; The public interface to the cache system.
(defun tramp-cache-setup (multi method user host)
  "Initialise the cache system for a new tramp connection."
  (with-current-buffer (tramp-get-buffer multi method user host)
    (set (make-local-variable 'tramp-cached-data) nil)))


;; REVISIT: These should only key on (user . host), not the method.
;;  --daniel@danann.net, 2000-06-01
(defun tramp-cache-get-file-property (file key multi method user host)
  "Get the property KEY of FILE from the cache context of the
user USER on the remote machine HOST."
  (with-current-buffer (tramp-get-buffer multi method user host)
    (tramp-cache-get file key)))


(defun tramp-cache-set-file-property (file key value multi method user host)
  "Set the property KEY of FILE to VALUE, in the cache context of the
user USER on the remote machine HOST."
  (with-current-buffer (tramp-get-buffer multi method user host)
    (tramp-cache-set file key value)))


(defun tramp-cache-flush-file (file multi method user host)
  "Remove all properties of FILE in the cache context of USER on HOST."
  (with-current-buffer (tramp-get-buffer multi method user host)
    ;; REVISIT: Implement me. --daniel@danann.net, 2000-06-01
    ))


(defun tramp-cache-flush (multi method user host)
  "Remove all information from the cache context of USER on HOST."
  (with-current-buffer (tramp-get-buffer multi method user host)
    ;; REVISIT: Implement me. --daniel@danann.net, 2000-06-01
    ))



(provide 'trampcache)

;;; trampcache.el ends here