perlbrew PATH in Emacs.app
作者:gugod 發佈於:Emacs.app on Mac is not launched with the same $PATH
set from bashrc/cshrc, which means perlbrew cannot work without some special treatments. One common problem is that cperl-perldoc
will not be able to find the module document correctly. If you're experiencing it, keep reading.
To get cperl-perldoc
working, set the environment variable PATH inside .emacs
:
(load "cl-seq")
;;; Prepend perlbrew paths to exec-path
(mapc (lambda (x) (add-to-list 'exec-path x))
(mapcar (lambda (x) (concat (getenv "HOME") x))
(list "/perl5/perlbrew/bin" "/perl5/perlbrew/perls/current/bin")))
;;; set PATH to be the same as exec-path, clobber the old PATH value.
(setenv "PATH"
(reduce
(lambda (a b) (concatenate 'string a ":" b))
exec-path))
cperl-perldoc
should correctly invoke the perldoc
program in PATH
from now.
To verify that exec-path
setting is also working, try eval (C-x C-e
) this sexp in *scratch*
buffer:
(call-process "perl" nil t nil "-E" "say $^X")
The full path of current perl executable should be appeared in the *scratch*
buffer.