Function: tramp-append-tramp-buffers

tramp-append-tramp-buffers is a byte-compiled function defined in tramp-cmds.el.gz.

Signature

(tramp-append-tramp-buffers)

Documentation

Append Tramp buffers and buffer local variables into the bug report.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-cmds.el.gz
(defun tramp-append-tramp-buffers ()
  "Append Tramp buffers and buffer local variables into the bug report."
  (goto-char (point-max))

  ;; Dump buffer local variables.
  (insert "\nlocal variables:\n================")
  (dolist (buffer (tramp-compat-seq-keep
		   (lambda (b)
		     (when (string-match-p "\\*tramp/" (buffer-name b)) b))
		   (buffer-list)))
    (let ((reporter-eval-buffer buffer)
	  (elbuf (get-buffer-create " *tmp-reporter-buffer*")))
      (with-current-buffer elbuf
	(emacs-lisp-mode)
	(erase-buffer)
	(insert (format "\n;; %s\n(setq-local\n" (buffer-name buffer)))
	(lisp-indent-line)
	(dolist (varsym
		 (sort
		  (append
		   (mapcar
		    #'intern
		    (all-completions "tramp-" (buffer-local-variables buffer)))
		   ;; Non-tramp variables of interest.
		   '(connection-local-variables-alist default-directory))
		  #'string<))
	  (reporter-dump-variable varsym elbuf))
	(lisp-indent-line)
	(insert ")\n"))
      (insert-buffer-substring elbuf)))

  ;; Beautify encoded values.
  (goto-char (point-min))
  (while (search-forward-regexp
	  (rx "'" (group "(decode-coding-string")) nil 'noerror)
    (replace-match "\\1"))
  (goto-char (point-max))

  ;; Dump load-path shadows.
  (insert "\nload-path shadows:\n==================\n")
  (ignore-errors
    (mapc
     (lambda (x) (when (tramp-compat-string-search "tramp" x) (insert x "\n")))
     (split-string (list-load-path-shadows t) "\n")))

  ;; Append buffers only when we are in message mode.
  (when (and
	 (eq major-mode 'message-mode)
	 (bound-and-true-p mml-mode))

    (let ((tramp-buf-regexp (rx "*" (? "debug ") "tramp/"))
	  (buffer-list (tramp-list-tramp-buffers))
	  (curbuf (current-buffer)))

      ;; There is at least one Tramp buffer.
      (when buffer-list
	(switch-to-buffer (list-buffers-noselect nil))
	(delete-other-windows)
	(setq buffer-read-only nil)
	(goto-char (point-min))
	(while (not (eobp))
	  (if (search-forward-regexp tramp-buf-regexp (line-end-position) t)
	      (forward-line 1)
	    (forward-line 0)
	    (let ((start (point)))
	      (forward-line 1)
	      (kill-region start (point)))))
	(insert "
The buffer(s) above will be appended to this message.  If you
don't want to append a buffer because it contains sensitive data,
or because the buffer is too large, you should delete the
respective buffer.  The buffer(s) will contain user and host
names.  Passwords will never be included there.")

	(when (>= tramp-verbose 6)
	  (insert "\n\n")
	  (let ((start (point)))
	    (insert "\
Please note that you have set `tramp-verbose' to a value of at
least 6.  Therefore, the contents of files might be included in
the debug buffer(s).")
	    (add-text-properties start (point) '(face italic))))

	(set-buffer-modified-p nil)
	(setq buffer-read-only t)
	(goto-char (point-min))

	(when (y-or-n-p "Do you want to append the buffer(s)?")
	  ;; OK, let's send.  First we delete the buffer list.
	  (kill-buffer)
	  (switch-to-buffer curbuf)
	  (goto-char (point-max))
	  (insert (propertize "\n" 'display "\n\
This is a special notion of the `gnus/message' package.  If you
use another mail agent (by copying the contents of this buffer)
please ensure that the buffers are attached to your email.\n\n"))
	  (dolist (buffer buffer-list)
	    (mml-insert-empty-tag
	     'part 'type "text/plain"
	     'encoding "base64" 'disposition "attachment" 'buffer buffer
	     'description buffer))
	  (set-buffer-modified-p nil))))))