From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kenny Ballou Subject: Re: Guix and Emacs Integration for Polyglot Development Date: Mon, 10 Sep 2018 09:25:24 -0600 Message-ID: <87pnxle5nf.fsf@devnulllabs.io> References: <871sbowlws.fsf@devnulllabs.io> <87bmalchr9.fsf@gmail.com> <871sbcpqsy.fsf@devnulllabs.io> <87pnydkylw.fsf@gmail.com> <874lfabt1c.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38062) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fzOBp-0000G4-GQ for help-guix@gnu.org; Mon, 10 Sep 2018 11:33:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fzO4h-0001O0-2a for help-guix@gnu.org; Mon, 10 Sep 2018 11:26:09 -0400 Received: from aibo.runbox.com ([91.220.196.211]:47362) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fzO4g-0001NZ-P7 for help-guix@gnu.org; Mon, 10 Sep 2018 11:26:02 -0400 In-reply-to: <874lfabt1c.fsf@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+gcggh-help-guix=m.gmane.org@gnu.org Sender: "Help-Guix" To: Maxim Cournoyer Cc: help-guix@gnu.org On 2018-08-31 12:49 GMT, Maxim Cournoyer wrote: > Hello! > > I'm reposting Janneke's recent answer here so that it can have all its > context and participants. > > Jan Nieuwenhuizen writes: > >> 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 /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--- > > Thank you, Janneke! > > An alternative if you'd like to also define some variables (say, > PYTHONPATH to add a couple of sources libraries while working on a > Python project) would be to use `direnv'[0] and `emacs-direnv'. > > Christopher Baines detailed the solution in this thread: > https://lists.gnu.org/archive/html/guix-devel/2017-05/msg00475.html. > > I hope this helps! > > Maxim Thank you for posting this, I still haven't had a chance to play around with this yet, but I think this is the kind of solution that is exactly what I'm looking for. However, Named profiles was sorta where I was leaning. I may not use the `emacs-direnv` part. But I if I understand correctly, switching profiles will change the `${HOME}/.guix-profile` symlink, I can just statically add the current profile to any path variables and go from there(?). Again, thank you and apologies for the necrobump because of late replies... -Kenny