Function: with-tramp-local-environment

with-tramp-local-environment is a macro defined in tramp.el.gz.

Signature

(with-tramp-local-environment &rest BODY)

Documentation

Set environment for local processes and run BODY.

Beside some global variables, it let-binds also the connection-local variables defined in tramp-connection-local-default-system-variables. If the current buffer is a remote one, these connection-local variables might have improper values.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
;;; Compatibility functions section:

(defmacro with-tramp-local-environment (&rest body)
  "Set environment for local processes and run BODY.
Beside some global variables, it let-binds also the connection-local
variables defined in `tramp-connection-local-default-system-variables'.
If the current buffer is a remote one, these connection-local variables
might have improper values."
  (declare (debug t))
  (let ((bindings
         (mapcar
	  (lambda (elem) `(,elem (default-value ',elem)))
	  (mapcar #'car tramp-connection-local-default-system-variables))))
    `(let* ((default-directory tramp-compat-temporary-file-directory)
	    (temporary-file-directory tramp-compat-temporary-file-directory)
            ,@bindings)
       (setenv "TERM" tramp-terminal-type)
       (setenv "PROMPT_COMMAND")
       (setenv "PS1" tramp-initial-end-of-output)
       (setenv "INSIDE_EMACS" (tramp-inside-emacs))
       ,@body)))