Skip to content

Instantly share code, notes, and snippets.

@zakame
Created April 20, 2013 15:50
Show Gist options
  • Save zakame/5426423 to your computer and use it in GitHub Desktop.
Save zakame/5426423 to your computer and use it in GitHub Desktop.
Fragment from my .emacs to get perlbrew working under it.
;; If perlbrew is used, get PERLBREW_PATH to be used in exec-path and PATH
;; Adapted from https://gist.github.com/960214
(require 'cl)
(let ((perlbrew-init "~/.perlbrew/init"))
(if (file-readable-p perlbrew-init)
(dolist (line (with-temp-buffer
(insert-file-contents perlbrew-init)
(split-string (buffer-string) "\n" t)))
(with-temp-buffer
(insert line)
(goto-char (point-min))
(search-forward "export " nil t)
(when (= (point) 8)
(let* ((idx (search-forward "="))
(val (buffer-substring idx (progn (end-of-line) (point))))
(key (buffer-substring 8 (decf idx))))
(if (string-match "PERLBREW_PATH" key)
(dolist (perlbin (parse-colon-path val))
(setq perlbin (substring perlbin 0 -1)) ; remove trailing /
(setenv "PATH" (concat perlbin ":" (getenv "PATH")))
(add-to-list 'exec-path perlbin)))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment