help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PATH Variable


From: Anupam Sengupta
Subject: Re: PATH Variable
Date: Sun, 15 Jul 2007 22:39:46 -0700
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (darwin)

>>>>> "Srandby" == srandby  <srandby@gmail.com> writes:

    Srandby> Hi: Would somebody please tell me how to change the PATH variable
    Srandby> used by Emacs? I want to use a shell command, but Emacs can't find
    Srandby> the command. I've tried a bunch of stuff, but so far nothing works.

Try adding this code fragment in your .emacs file:

(setenv "PATH"
              (concat (expand-file-name <<YOUR PATH HERE>>)
                      path-separator (getenv "PATH")))

You may want to make this a function and invoke it for each path-element you
want to be accessible from within Emacs.

E.g.,

;;; Define a function to setup additional path
(defun my-add-path (path-element)
  "Add the specified path element to the Emacs PATH"
  (interactive "DEnter directory to be added to path: ")
  (if (file-directory-p path-element)
      (setenv "PATH"
              (concat (expand-file-name path-element)
                      path-separator (getenv "PATH")))))

and then:

;;; Set localized PATH for Emacs.
;;; Example only
(if (fboundp 'my-add-path)
    (let ((my-paths (list
                     "/opt/local/bin"
                     "/usr/local/bin"
                     "/usr/local/sbin"
                     "/usr/local/mysql/bin"
                     "~/bin")))
      (dolist (path-to-add my-paths (getenv "PATH"))
        (my-add-path path-to-add))))

BTW, this needs the cl package for the `dolist', which is present in Emacs 22
and /possibly/ on V21 as well. If not present in your Emacs version, just
replace the `dolist' with an alternate looping mechanism.

HTH,
-- 
Anupam


reply via email to

[Prev in Thread] Current Thread [Next in Thread]