I try to create an own portable installation (in USB pen drive). The first problem is to cancel the "old" values looks in exec-path stored. When I insert the command C-h v, I see together "exec-path is a variable defined in C source code" followed by current exec path settings, the sentences "the old value was". Is there a way to remove the last entry from the path?

3 Answers 3


You can get rid of the "original value" with (put 'exec-path 'standard-value nil). To discover this, I looked at the source of describe-variable:

(defun describe-variable (variable &optional buffer frame)
          (let* ((sv (get variable 'standard-value))
                 (origval (and (consp sv)
                               (condition-case nil
                                   (eval (car sv))
                                 (error :help-eval-error)))))
            (when (and (consp sv)
                       (not (equal origval val))
                       (not (equal origval :help-eval-error)))
              (princ "\nOriginal value was \n")
              (setq from (point))
              (pp origval)

Use M-x customize-option RET exec-path RET to change the value. You can change it just for the current session, or you can change it and save the change for future Emacs sessions also.

Consider also defining variable custom-file, so that Customize writes settings to a different file from your init file.


A different approach, from this tutorial: "By default, emacs copies the value of (getenv "PATH") to exec-path. So, their values should be identical."

You could also try to change the PATH environment variable, prior to running emacs, to remove the executable directory you don't want. The exec-path would be free of the directories you don't want. This is just a little ugly since you would need a launch script, batch file, or Windows link on the portable drive to have it prune all the default executable directories in PATH you don't want. But then, things like grep and shell commands stop working from emacs without a sufficient exec-path, so it seems you might want to leave some things in your PATH alone.

To cherry pick in your startup file you could write a little Elisp like:

(setq exec-path (delete "/usr/bin" exec-path))
  • Hello and thank you for your answer.Try to explain well my problem.I use a bat file to run my Emacs in USB pen drive so I wrote on batch the Emacs %PATH% variable. (It needs to load the correct unit letter). After, I modified on init.el file the "exec-path" variable adding the executable files for pdf/ps reader and TeXlive directory. When I check the "exec-path" within Emacs, I find in addition to NEW actual values , the OLD setting that are the windows hd %PATH%. What is the way to clean them and remain without Emacs sentences "the old value is..." Is this for previous batch %PATH% setting?
    – Alex
    Commented Jan 30, 2016 at 0:20
  • @Alessandro, why don't you update your question with such details?
    – Emacs User
    Commented Jun 23, 2016 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.