Function: with-tramp-saved-file-properties

with-tramp-saved-file-properties is an autoloaded macro defined in tramp-cache.el.gz.

Signature

(with-tramp-saved-file-properties KEY FILE PROPERTIES &rest BODY)

Documentation

Save PROPERTIES, run BODY, reset PROPERTIES.

PROPERTIES is a list of file properties (strings). Preserve timestamps.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-cache.el.gz
;;;###tramp-autoload
(defmacro with-tramp-saved-file-properties (key file properties &rest body)
  "Save PROPERTIES, run BODY, reset PROPERTIES.
PROPERTIES is a list of file properties (strings).
Preserve timestamps."
  (declare (indent 3) (debug t))
  `(progn
     ;; Unify localname.  Remove hop from `tramp-file-name' structure.
     (setf ,key (tramp-file-name-unify ,key ,file))
     (let* ((hash (tramp-get-hash-table ,key))
	    (values
	     (and (hash-table-p hash)
		  (mapcar
		   (lambda (property) (cons property (gethash property hash)))
		   ,properties))))
       (unwind-protect (progn ,@body)
	 ;; Reset PROPERTIES.  Recompute hash, it could have been flushed.
         (setq hash (tramp-get-hash-table ,key))
	 (dolist (value values)
	   (if (consp (cdr value))
	       (puthash (car value) (cdr value) hash)
	     (remhash (car value) hash)))))))