Function: with-tramp-debug-message

with-tramp-debug-message is a macro defined in tramp-message.el.gz.

Signature

(with-tramp-debug-message VEC MESSAGE &rest BODY)

Documentation

Execute BODY, embedded with MESSAGE in the debug buffer of VEC.

If BODY does not raise a debug message, MESSAGE is ignored.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-message.el.gz
;; This is used in `tramp-file-name-handler' and `tramp-*-maybe-open-connection'.
(defmacro with-tramp-debug-message (vec message &rest body)
  "Execute BODY, embedded with MESSAGE in the debug buffer of VEC.
If BODY does not raise a debug message, MESSAGE is ignored."
  (declare (indent 2) (debug t))
  (let ((result (make-symbol "result")))
    `(if tramp-debug-command-messages
	 (save-match-data
	   (let ((tramp-debug-nesting
		  (concat tramp-debug-nesting "#"))
		 (buf (tramp-get-debug-buffer ,vec))
		 beg end ,result)
	     ;; Insert entry message.
	     (with-current-buffer buf
	       (setq beg (point))
	       (tramp-debug-message
		,vec "(4) %s %s ..." tramp-debug-nesting ,message)
	       (setq end (point)))
	     (unwind-protect
		 ;; Run BODY.
		 (setq tramp-debug-message-fnh-function nil
		       ,result (progn ,@body))
	       (with-current-buffer buf
		 (if (= end (point-max))
		     (progn
		       (delete-region beg end)
		       (when (bobp) (kill-buffer)))
		   ;; Insert exit message.
		   (tramp-debug-message
		    ,vec "(5) %s %s ... %s" tramp-debug-nesting ,message ,result)
		   ;; Adapt file name handler function.
		   (dolist (pos (list (point-max) end))
		     (goto-char pos)
		     (when (and tramp-debug-message-fnh-function
				(search-backward
				 "tramp-file-name-handler"
				 (line-beginning-position) t))
		       (replace-match
			(symbol-name tramp-debug-message-fnh-function))
		       (tramp-debug-message-buttonize
			(line-beginning-position))))
		   ;; Link related messages.
		   (goto-char (point-max))
		   (tramp-debug-link-messages beg (line-beginning-position)))))))

       ;; No special messages.
       ,@body)))