guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: indent with emacs batch mode


From: Alex Kost
Subject: Re: indent with emacs batch mode
Date: Sat, 07 Jan 2017 08:59:17 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Ricardo Wurmus (2017-01-06 16:29 +0100) wrote:

> Hi Guix,
>
> here’s how people who don’t use Emacs can indent package expressions
> nicely.

Interesting idea!

> Save this file somewhere:
>
> ;; indent expression for given packages

I would also add the following line here:

  (add-hook 'scheme-mode-hook 'guix-devel-mode)

to add Guix-specific indentation rules (particularly to indent
'modify-phases' properly).

> (require 'guix-location)
> (dolist (name command-line-args-left)
>   (let ((location (guix-package-location name)))
>     (when location
>       (guix-find-location location)
>       (beginning-of-defun)
>       (indent-sexp)
>       (save-buffer))))

I think this works for you because your "~/.config/guix/latest" is a
symlink to your git checkout.  But by default this can open a package
file from store, and emacs will fail to modify it, so it is better to
specify a guix checkout directory explicitly like this:

  (guix-find-location location "~/src/guix")

> Enter an environment where Emacs and emacs-guix are available:
>
>     guix environment --ad-hoc emacs emacs-guix
>
> Then run:
>
>     emacs -q --batch -l indent-package-expr.el  bowtie bla blast+

Actually this works for you only by chance: emacs doesn't load packages
from the guix environment, it loads packages from your system and user
profiles, so it works because you already have 'emacs-guix' installed.

> This will properly indent the package expressions for “bowtie” and
> “blast+”, and it will ignore “bla”, because that package doesn’t exist.
>
> This is probably a little heavy-weight because it depends on emacs-guix,
> which starts a Guile REPL, but other than that it seems to work fine.

Since a user knows what file (s)he wants modify, I think it is better to
avoid starting the REPL, so it will be *much faster*.  After all, I
would do it like this:

Attachment: indent-package-expr.el
Description: application/emacs-lisp

And here are the lines for the environment and running emacs (I used
'emacs-no-x' as it is not so heavy as 'emacs'):

  guix environment --ad-hoc emacs-no-x emacs-guix

  emacs -q --no-site-file --batch -l indent-package-expr.el 
/path/to/package-file.scm package-name

All that stuff can work without 'emacs-guix' (if the line with
'guix-devel-mode' scheme hook will be removed), but in this case the
package may not be indented properly.

-- 
Alex

reply via email to

[Prev in Thread] Current Thread [Next in Thread]