aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2008-12-01 06:37:54 +0000
committerMichael Albinus2008-12-01 06:37:54 +0000
commit7c3404ecc23078efc7438243701a9dfc5da0e5b1 (patch)
treee8f802be479d5ad8ee4aafb4bb4f2060b40dff4e
parent78ca4710c521805d69d7de66ecf9d1006e886e3b (diff)
downloademacs-7c3404ecc23078efc7438243701a9dfc5da0e5b1.tar.gz
emacs-7c3404ecc23078efc7438243701a9dfc5da0e5b1.zip
* net/tramp-cache.el (tramp-cache-data-changed): New defvar.
(tramp-set-connection-property, tramp-flush-connection-property) (tramp-dump-connection-properties): Use it.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/net/tramp-cache.el75
2 files changed, 47 insertions, 34 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e22d1d8c475..efb33f53d3f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12008-12-01 Michael Albinus <michael.albinus@gmx.de>
2
3 * net/tramp-cache.el (tramp-cache-data-changed): New defvar.
4 (tramp-set-connection-property, tramp-flush-connection-property)
5 (tramp-dump-connection-properties): Use it.
6
12008-11-30 Chong Yidong <cyd@stupidchicken.com> 72008-11-30 Chong Yidong <cyd@stupidchicken.com>
2 8
3 * wdired.el (wdired-finish-edit): If displaying a single file, 9 * wdired.el (wdired-finish-edit): If displaying a single file,
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el
index e4218808574..466cd7f5a41 100644
--- a/lisp/net/tramp-cache.el
+++ b/lisp/net/tramp-cache.el
@@ -89,6 +89,9 @@
89 :group 'tramp 89 :group 'tramp
90 :type 'file) 90 :type 'file)
91 91
92(defvar tramp-cache-data-changed nil
93 "Whether persistent cache data have been changed.")
94
92(defun tramp-get-file-property (vec file property default) 95(defun tramp-get-file-property (vec file property default)
93 "Get the PROPERTY of FILE from the cache context of VEC. 96 "Get the PROPERTY of FILE from the cache context of VEC.
94Returns DEFAULT if not set." 97Returns DEFAULT if not set."
@@ -195,6 +198,7 @@ PROPERTY is set persistent when KEY is a vector."
195 (puthash key (make-hash-table :test 'equal) 198 (puthash key (make-hash-table :test 'equal)
196 tramp-cache-data)))) 199 tramp-cache-data))))
197 (puthash property value hash) 200 (puthash property value hash)
201 (setq tramp-cache-data-changed t)
198 ;; This function is called also during initialization of 202 ;; This function is called also during initialization of
199 ;; tramp-cache.el. `tramp-message´ is not defined yet at this 203 ;; tramp-cache.el. `tramp-message´ is not defined yet at this
200 ;; time, so we ignore the corresponding error. 204 ;; time, so we ignore the corresponding error.
@@ -211,6 +215,7 @@ KEY identifies the connection, it is either a process or a vector."
211 (when (vectorp key) 215 (when (vectorp key)
212 (setq key (copy-sequence key)) 216 (setq key (copy-sequence key))
213 (aset key 3 nil)) 217 (aset key 3 nil))
218 (setq tramp-cache-data-changed t)
214 (remhash key tramp-cache-data)) 219 (remhash key tramp-cache-data))
215 220
216(defun tramp-cache-print (table) 221(defun tramp-cache-print (table)
@@ -246,39 +251,40 @@ KEY identifies the connection, it is either a process or a vector."
246(defun tramp-dump-connection-properties () 251(defun tramp-dump-connection-properties ()
247 "Write persistent connection properties into file `tramp-persistency-file-name'." 252 "Write persistent connection properties into file `tramp-persistency-file-name'."
248 ;; We shouldn't fail, otherwise (X)Emacs might not be able to be closed. 253 ;; We shouldn't fail, otherwise (X)Emacs might not be able to be closed.
249 (condition-case nil 254 (when tramp-cache-data-changed
250 (when (and (hash-table-p tramp-cache-data) 255 (condition-case nil
251 (not (zerop (hash-table-count tramp-cache-data))) 256 (when (and (hash-table-p tramp-cache-data)
252 (stringp tramp-persistency-file-name)) 257 (not (zerop (hash-table-count tramp-cache-data)))
253 (let ((cache (copy-hash-table tramp-cache-data))) 258 (stringp tramp-persistency-file-name))
254 ;; Remove temporary data. 259 (let ((cache (copy-hash-table tramp-cache-data)))
255 (maphash 260 ;; Remove temporary data.
256 '(lambda (key value) 261 (maphash
257 (if (and (vectorp key) (not (tramp-file-name-localname key))) 262 '(lambda (key value)
258 (progn 263 (if (and (vectorp key) (not (tramp-file-name-localname key)))
259 (remhash "process-name" value) 264 (progn
260 (remhash "process-buffer" value)) 265 (remhash "process-name" value)
261 (remhash key cache))) 266 (remhash "process-buffer" value))
262 cache) 267 (remhash key cache)))
263 ;; Dump it. 268 cache)
264 (with-temp-buffer 269 ;; Dump it.
265 (insert 270 (with-temp-buffer
266 ";; -*- emacs-lisp -*-" 271 (insert
267 ;; `time-stamp-string' might not exist in all (X)Emacs flavors. 272 ";; -*- emacs-lisp -*-"
268 (condition-case nil 273 ;; `time-stamp-string' might not exist in all (X)Emacs flavors.
269 (progn 274 (condition-case nil
270 (format 275 (progn
271 " <%s %s>\n" 276 (format
272 (time-stamp-string "%02y/%02m/%02d %02H:%02M:%02S") 277 " <%s %s>\n"
273 tramp-persistency-file-name)) 278 (time-stamp-string "%02y/%02m/%02d %02H:%02M:%02S")
274 (error "\n")) 279 tramp-persistency-file-name))
275 ";; Tramp connection history. Don't change this file.\n" 280 (error "\n"))
276 ";; You can delete it, forcing Tramp to reapply the checks.\n\n" 281 ";; Tramp connection history. Don't change this file.\n"
277 (with-output-to-string 282 ";; You can delete it, forcing Tramp to reapply the checks.\n\n"
278 (pp (read (format "(%s)" (tramp-cache-print cache)))))) 283 (with-output-to-string
279 (write-region 284 (pp (read (format "(%s)" (tramp-cache-print cache))))))
280 (point-min) (point-max) tramp-persistency-file-name)))) 285 (write-region
281 (error nil))) 286 (point-min) (point-max) tramp-persistency-file-name))))
287 (error nil))))
282 288
283(add-hook 'kill-emacs-hook 'tramp-dump-connection-properties) 289(add-hook 'kill-emacs-hook 'tramp-dump-connection-properties)
284(add-hook 'tramp-cache-unload-hook 290(add-hook 'tramp-cache-unload-hook
@@ -313,7 +319,8 @@ for all methods. Resulting data are derived from connection history."
313 (while (setq element (pop list)) 319 (while (setq element (pop list))
314 (setq key (pop element)) 320 (setq key (pop element))
315 (while (setq item (pop element)) 321 (while (setq item (pop element))
316 (tramp-set-connection-property key (pop item) (car item)))))) 322 (tramp-set-connection-property key (pop item) (car item)))))
323 (setq tramp-cache-data-changed nil))
317 (file-error 324 (file-error
318 ;; Most likely because the file doesn't exist yet. No message. 325 ;; Most likely because the file doesn't exist yet. No message.
319 (clrhash tramp-cache-data)) 326 (clrhash tramp-cache-data))