changeset 65304:379e08762d65

* net/tramp.el (tramp-handle-make-auto-save-file-name): Deactivate temporarily advice if active (not needed for Emacs 22, but for backwards compatibility). (tramp-exists-file-name-handler): Rewrite. First implementation was too simple. (tramp-advice-make-auto-save-file-name): Call `tramp-handle-make-auto-save-file-name' (again, just for backwards compatibility).
author Michael Albinus <michael.albinus@gmx.de>
date Wed, 31 Aug 2005 20:28:48 +0000
parents e9432d41359d
children f91648b9f8b1
files lisp/ChangeLog lisp/net/tramp.el
diffstat 2 files changed, 39 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Wed Aug 31 19:56:30 2005 +0000
+++ b/lisp/ChangeLog	Wed Aug 31 20:28:48 2005 +0000
@@ -1,3 +1,14 @@
+2005-08-31  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-handle-make-auto-save-file-name): Deactivate
+	temporarily advice if active (not needed for Emacs 22, but for
+	backwards compatibility).
+	(tramp-exists-file-name-handler): Rewrite.  First implementation
+	was too simple.
+	(tramp-advice-make-auto-save-file-name): Call
+	`tramp-handle-make-auto-save-file-name' (again, just for backwards
+	compatibility).
+
 2005-08-31  Reto Zimmermann  <reto@gnu.org>
 
 	* progmodes/vhdl-mode.el
--- a/lisp/net/tramp.el	Wed Aug 31 19:56:30 2005 +0000
+++ b/lisp/net/tramp.el	Wed Aug 31 20:28:48 2005 +0000
@@ -3829,12 +3829,19 @@
 		 ("]" . "_r"))
 	       (buffer-file-name))
 	      tramp-auto-save-directory)
-	   (buffer-file-name)))
-	;; We set it to nil because `make-auto-save-file-name' shouldn't
-	;; recurse infinitely.
-	tramp-auto-save-directory)
-      (tramp-run-real-handler
-       'make-auto-save-file-name nil)))
+	   (buffer-file-name))))
+    ;; Run plain `make-auto-save-file-name'.  There might be an advice when
+    ;; it is not a magic file name operation (since Emacs 22).
+    ;; We must deactivate it temporarily.
+    (if (not (ad-is-active 'make-auto-save-file-name))
+	(tramp-run-real-handler
+	 'make-auto-save-file-name nil)
+      ;; else
+      (ad-deactivate 'make-auto-save-file-name)
+      (prog1
+       (tramp-run-real-handler
+	'make-auto-save-file-name nil)
+       (ad-activate 'make-auto-save-file-name)))))
 
 
 ;; CCC grok APPEND, LOCKNAME, CONFIRM
@@ -6935,16 +6942,27 @@
 
 ;; Auto saving to a special directory.
 
-(defun tramp-exists-file-name-handler (operation)
-  (let ((file-name-handler-alist (list (cons "/" 'identity))))
-    (eq (find-file-name-handler "/" operation) 'identity)))
+(defun tramp-exists-file-name-handler (operation &rest args)
+  (let ((buffer-file-name "/")
+	(fnha file-name-handler-alist)
+	(check-file-name-operation operation)
+	(file-name-handler-alist
+	 (list
+	  (cons "/"
+		'(lambda (operation &rest args)
+		   "Returns OPERATION if it is the one to be checked"
+		   (if (equal check-file-name-operation operation)
+		       operation
+		     (let ((file-name-handler-alist fnha))
+		       (apply operation args))))))))
+    (eq (apply operation args) operation)))
 
 (unless (tramp-exists-file-name-handler 'make-auto-save-file-name)
   (defadvice make-auto-save-file-name
     (around tramp-advice-make-auto-save-file-name () activate)
     "Invoke `tramp-handle-make-auto-save-file-name' for tramp files."
     (if (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)))
-	(setq ad-return-value (tramp-make-auto-save-file-name))
+	(setq ad-return-value (tramp-handle-make-auto-save-file-name))
       ad-do-it)))
 
 ;; In Emacs < 22 and XEmacs < 21.5 autosaved remote files have