Hi!

Just subscribed to help-guix because of a request on IRC, so hoping that
OP is subscribed here, or someone can notify them.

I have an ugly hack to switch emacs to a profile or environment.  It
parses the <profile>/etc/profile script...using MANIFEST or
`--search-paths' would be much nicer...

Anyway, I'm using some named profiles, eg

    ~/.config/guix/mes

and when starting work on mes i do

    M-x guix-switch-profile RET ~/.config/guix/mes RET

similar for other projects I work on.

A real solution would be nice...

HTH, janneke

--8<---------------cut here---------------start------------->8---
(defun guix-switch-profile (&optional profile)
  "reset Emacs' environment by snarfing PROFILE/etc/profile"

  (defun matches-in-string (regexp string)
    "return a list of matches of REGEXP in STRING."
    (let ((matches))
      (save-match-data
        (string-match "^" "")
        (while (string-match regexp string (match-end 0))
          (push (or (match-string 1 string) (match-string 0 string)) matches)))
      matches))

  (interactive "fprofile: ")
  (let* ((output (shell-command-to-string (concat "GUIX_PROFILE= /bin/sh -x " 
profile "/etc/profile")))
         (exports (matches-in-string "^[+] export \\(.*\\)" output)))
    (mapcar (lambda (line) (apply #'setenv (split-string line "="))) exports )))
--8<---------------cut here---------------end--------------->8---

-- 
Jan Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

Reply via email to