[Python-mode] interpreter selection with CarbonEmacs on OSX
Dan Davison
dandavison7 at gmail.com
Tue Feb 22 04:27:18 CET 2011
Eric Holbrook <eric.holbrook.3rd at gmail.com> writes:
> What's the best way to tell python-mode to use, say,
> /opt/local/bin/python, instead of what OS X thinks is the right
> version?
>
> The problem is that when i launch /Applications/Emacs.app from
> Quicksilver it knows nothing about what i have set up in my .bashrc,
> so it picks the first (only) python that it finds from the system
> global environment.plist. Is there a safe way to tell emacs about all
> the $PATH stuff i have in my .bashrc w/o editing the env vars in my
> ~/.MacOS/environment.plist?
Hi Eric,
Fwiw I have the code below in my .emacs to make sure that emacs picks up
the executables I want it to pick up. Basically the game is that you
want both (getenv "PATH") and the emacs variable `exec-path' to have the
correct paths. You'd need to modify this to suit your needs, but it
should be straightforward (reply here if not).
Dan
#+begin_src emacs-lisp
(defvar ded/operating-system
(intern (downcase
(replace-regexp-in-string
"\n" ""
(shell-command-to-string "uname"))))
"The current OS")
(require 'cl)
(defun ded/set-executable-paths ()
"Set $PATH and `exec-path'."
(interactive)
(let* (($HOME (getenv "HOME"))
($HOME/bin (concat $HOME "/" "bin"))
($PATH
(delete-dups
(split-string (getenv "PATH") path-separator)))
(paths
(case ded/operating-system
('darwin
(list $HOME/bin
"/usr/local/Cellar/python2.6/2.6.5/bin/"
"/usr/local/bin"
"/usr/texbin"))
(t (list $HOME/bin)))))
(setenv
"PATH"
(mapconcat 'identity
(append
(remove-if (lambda (p) (member p $PATH)) paths)
$PATH)
path-separator))
(setq exec-path
(append
(remove-if (lambda (p) (member p exec-path)) paths)
(delete-dups exec-path)))))
(ded/set-executable-paths)
#+end_src
>
> thanks in advance,
> Eric
More information about the Python-mode
mailing list