Function: tramp-dump-connection-properties

tramp-dump-connection-properties is a byte-compiled function defined in tramp-cache.el.gz.

Signature

(tramp-dump-connection-properties)

Documentation

Write persistent connection properties into file tramp-persistency-file-name.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-cache.el.gz
(defun tramp-dump-connection-properties ()
  "Write persistent connection properties into file \
`tramp-persistency-file-name'."
  ;; We shouldn't fail, otherwise Emacs might not be able to be closed.
  (ignore-errors
    (when (and (hash-table-p tramp-cache-data)
	       (not (zerop (hash-table-count tramp-cache-data)))
	       tramp-cache-data-changed
	       (stringp tramp-persistency-file-name))
      (let ((cache (copy-hash-table tramp-cache-data))
	    print-length print-level)
	;; Remove temporary data.  If there is the key "login-as", we
	;; don't save either, because all other properties might
	;; depend on the login name, and we want to give the
	;; possibility to use another login name later on.  Key
	;; "started" exists for the "ftp" method only, which must not
	;; be kept persistent.
	(maphash
	 (lambda (key value)
	   (if (and (tramp-file-name-p key) (hash-table-p value)
		    (not (string-equal
			  (tramp-file-name-method key) tramp-archive-method))
		    (not (tramp-file-name-localname key))
		    (not (gethash "login-as" value))
		    (not (gethash "started" value)))
	       (progn
		 (remhash "process-name" value)
		 (remhash "process-buffer" value)
		 (remhash "first-password-request" value))
	     (remhash key cache)))
	 cache)
	;; Dump it.
	(with-temp-file tramp-persistency-file-name
	  (insert
	   ;; Starting with Emacs 28, we could use `lisp-data'.
	   (format ";; -*- emacs-lisp -*- <%s %s>\n"
		   (time-stamp-string "%02y/%02m/%02d %02H:%02M:%02S")
		   tramp-persistency-file-name)
	   ";; Tramp connection history.  Don't change this file.\n"
	   ";; Run `M-x tramp-cleanup-all-connections' instead.\n\n"
	   (with-output-to-string
	     (pp (read (format "(%s)" (tramp-cache-print cache)))))))))))