unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* Re: Guix and Emacs Integration for Polyglot Development
@ 2018-08-29 18:41 Jan Nieuwenhuizen
  2018-09-01 14:41 ` Ludovic Courtès
  0 siblings, 1 reply; 30+ messages in thread
From: Jan Nieuwenhuizen @ 2018-08-29 18:41 UTC (permalink / raw)
  To: help-guix

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 <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Guix and Emacs Integration for Polyglot Development
@ 2018-07-27 18:53 Kenny Ballou
  2018-08-02  8:08 ` Chris Marusich
  2018-09-11  1:10 ` George Clemmer
  0 siblings, 2 replies; 30+ messages in thread
From: Kenny Ballou @ 2018-07-27 18:53 UTC (permalink / raw)
  To: help-guix


This may be the wrong list, but I figure most Guix users/developers are
_probably_ also Emacs users, I figured I would ask here first...

Obviously, there is the [[alezost/guix.el][guix.el]] for interacting
with Guix from within Emacs.  However, what sort of integration is
available for Emacs with the ~guix environment -m
<some-project-manifest.scm>~ command.  I would like to be able to
specify a project's dependencies in a manifest file, add any environment
variables as necessary, and have Emacs be aware of those variables when
entering that environment.  Tools like ~pyflake~ for Python projects, or
~go-fmt~ integration for a Golang project, would have their regular
integration with Emacs when in those environments.  All of this without
having to have some version of the tools installed in either the user
profile or the host OS (regardless if that's GuixSD or some other
foreign distribution), both of which would disallow usage of `--pure`
during development (not my ideal).  Furthermore, to me is it preferable
to only have one Emacs (server) session that is capable of switching
between projects and different ~guix environments~, as opposed to adding
Emacs to the development dependencies of a project and using several
different Emacs instances/sessions.

Understandably, this may be tricky for a number of reasons:

- Keeping many buffers/files that are in a different environments may
  causes issues when the environments switch, causing some buffers to
  lose connections or reference to the tools the buffer expects.

- Global(?) variables everywhere, unless this is easy to add to a buffer
  local or similar?

- (e)Shell or long running process integration and patching.  Similar
  problems for other inferior shells, e.g., ~python~, ~geiser~, ~ghc~,
  etc.

Perhaps a solution is to integrate with a "project" root
~.dir-locals.el~ file for each environment.  However, since I'm not well
versed in what is possible with such a file, I don't know if this is
viable.

Another solution would be to attempt to integrate with something like
~projectile~ for the variables, but this sounds similar to the previous
idea.  Moreover, this forces ~projectile~ onto users and that is perhaps
not appropriate.

Hopefully, what I have described makes sense.  I'm hoping to see what
other users are doing for this kind of setup.

Thanks in advance.

-Kenny

#+LINK: alezost/guix.el https://github.com/alezost/guix.el
#+LINK: bauer-nix-emacs: https://matthewbauer.us/blog/bauer.html

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2018-10-29 16:38 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-29 18:41 Guix and Emacs Integration for Polyglot Development Jan Nieuwenhuizen
2018-09-01 14:41 ` Ludovic Courtès
2018-09-01 15:11   ` Jan Nieuwenhuizen
2018-09-01 17:25     ` Ludovic Courtès
2018-09-13 20:45       ` Jan Nieuwenhuizen
2018-09-14  9:56         ` Ludovic Courtès
2018-09-14 11:53           ` Jan Nieuwenhuizen
2018-09-14 21:34         ` Alex Kost
2018-09-15  5:21           ` Jan Nieuwenhuizen
2018-09-15 19:40             ` Alex Kost
2018-10-26  4:59           ` George Clemmer
2018-10-26 17:04             ` Alex Kost
2018-10-26 18:01               ` George Clemmer
2018-10-26 20:56                 ` George Clemmer
2018-10-27 14:42                   ` Alex Kost
2018-10-27 19:32                     ` George Clemmer
2018-10-28 14:39                       ` Alex Kost
2018-10-28 21:19                         ` George Clemmer
2018-10-29 16:37                           ` Alex Kost
2018-10-26  1:22         ` Maxim Cournoyer
  -- strict thread matches above, loose matches on Subject: below --
2018-07-27 18:53 Kenny Ballou
2018-08-02  8:08 ` Chris Marusich
2018-08-05 19:16   ` Kenny Ballou
2018-08-20 12:32     ` Maxim Cournoyer
2018-08-24 21:55       ` Ludovic Courtès
2018-08-25 19:47         ` Alex Kost
2018-08-25 21:59           ` Ludovic Courtès
2018-08-31 12:49       ` Maxim Cournoyer
2018-09-10 15:25         ` Kenny Ballou
2018-09-11  1:10 ` George Clemmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).