#StackBounty: #shell #comint #subprocess #environment How can Emacs set an environment/shell variable in a subordinate shell?

Bounty: 50

I often use subordinate shells within Emacs. (I instantiate these shells with M-x shell.)

I put all these shells under auto-save-mode (through my shell-mode-hook; see below).

Is there some way that I can have Emacs set an environment variable in a subordinate shell equal to the value of buffer-auto-save-file-name?

For what it’s worth, below is the hook code I use to put my subordinate shells under auto-save-mode:

;; NB: I define the global variable auto-saves-dir elsewhere in my init file.

(defun cd-to-auto-saves-dir ()
  (unless (file-directory-p auto-saves-dir)
    (make-directory auto-saves-dir t))
  (cd auto-saves-dir))

    (lambda ()    
        ;; the silliness with cd-ing to/fro auto-saves-dir is the
        ;; only way I've found to trick Emacs into putting the
        ;; auto-save'd file in auto-saves-dir
        (let ((orig-dir default-directory))
           (cd orig-dir))

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.