Using modules with Emacs
Manage your shell environment variables and aliases
Brought to you by:
leomania,
xdelaruelle
|
From: Johan P. <eu...@ua...> - 1997-01-02 13:29:49
|
(Tried to retrieve the modules-interest archive from majordomo but
with no success, so I don't know if this question has popped up
before).
I'm using version 2.2BETA (is this the latest version, it seems to be
dated 1 July 1994?). It says in the man page that emacs "shell" is
supported, although no init file is provided. Indeed running modulecmd
with emacs as first argument does produce Emacs-Lisp code.
Now to the problem. It seems like Emacs (I'm using XEmacs 19.14)
modifies the PATH variable so that each component contains a trailing
slash. This is a big problem e.g. when starting shells from within
Emacs, since modules will not recognize the PATH elements with a
trailing `/' as the same as those without the `/'. Therefore things
get loaded twice. What I do to work around this problem is to clear
the PATH from everything I don't need inside Emacs, and to provide a
`module-cmd' function which removes the trailing slashes from PATH
before calling modulecmd. Here is how it looks:
(defun remove-slash (x)
(let ((len (length x)))
(if (char-equal ?/ (aref x (- len 1)))
(substring x 0 (- len 1))
x)))
;; Modules stuff
(defun module-cmd (&rest args)
(save-excursion
(set-buffer (get-buffer-create "*modules-temp*"))
(erase-buffer)
;; We must remove trailing slashes, otherwise comparison fails in Module
;; package's hash tables and stuff gets loaded twice
(setenv "PATH"
(mapconcat 'identity
(mapcar 'remove-slash
(split-string (getenv "PATH") ":"))
":"))
;; stderr should probably go to a temp file instead which is then inserted
;; into another buffer.
(apply 'call-process (concat (getenv "MODULESHOME") "/bin/modulecmd")
nil '(t nil) nil (append (list "emacs") args))
(goto-char (point-min))
(eval-buffer (current-buffer))))
;; Make sure the pbmplus programs are in the path so we can display X-Faces
;; etc. Also, get rid of all the CAD tool garbage to avoid problems with too
;; long PATH.
(when (getenv "MODULESHOME")
(module-cmd "load" "pbmplus")
(module-cmd "unload" "hdslsa" "runway" "verilog" "vcs" "visual_ver"
"signalscan" "speedsim" "synopsys" "sms" "synopsys_doc")
You out there who are using Emacs, how do you use it with modules?
One solution to the trailing-slash problem would of course be for the
module package to strip trailing slashes from each PATH component
before doing the comparison.
BTW except for this, I'm very happy with the package. Modules is
great!
Johan Parin
Ericsson AXE Research & Development
Stockholm, SWEDEN
email: Joh...@ua...
|