Function: tramp-reporter-dump-variable

tramp-reporter-dump-variable is a byte-compiled function defined in tramp-cmds.el.gz.

Signature

(tramp-reporter-dump-variable VARSYM MAILBUF)

Documentation

Pretty-print the value of the variable in symbol VARSYM.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-cmds.el.gz
(defun tramp-reporter-dump-variable (varsym mailbuf)
  "Pretty-print the value of the variable in symbol VARSYM."
  (when-let* ((reporter-eval-buffer reporter-eval-buffer)
	      (val (buffer-local-value varsym reporter-eval-buffer)))

    (if (hash-table-p val)
	;; Pretty print the cache.
	(set varsym (read (format "(%s)" (tramp-cache-print val))))
      ;; There are non-7bit characters to be masked.
      (when (and (stringp val)
		 (string-match-p
		  (rx-to-string `(not (any ,mm-7bit-chars))) val))
	(with-current-buffer reporter-eval-buffer
	  (set varsym
	       `(decode-coding-string
		 (base64-decode-string
		  ,(base64-encode-string (encode-coding-string val 'raw-text)))
		 'raw-text)))))

    ;; Dump variable.
    (goto-char (point-max))
    (save-excursion
      (reporter-dump-variable varsym mailbuf))

    (unless (hash-table-p val)
      ;; Remove string quotation.
      (when (looking-at
	     (rx
	      bol (group (* anychar)) "\""          ;; \1 "
	      (group "(base64-decode-string ") "\\" ;; \2 \
	      (group "\"" (* anychar)) "\\"         ;; \3 \
	      (group "\")") "\"" eol))              ;; \4 "
	(replace-match "\\1\\2\\3\\4")
	(beginning-of-line)
	(insert " ;; Variable encoded due to non-printable characters.\n")))
    (goto-char (point-max))

    ;; Reset VARSYM to old value.
    (with-current-buffer reporter-eval-buffer
      (set varsym val))))