From: Alex Kost <alezost@gmail.com>
To: Ricardo Wurmus <rekado@elephly.net>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Re: indent with emacs batch mode
Date: Sat, 07 Jan 2017 08:59:17 +0300 [thread overview]
Message-ID: <87inpr8l6y.fsf@gmail.com> (raw)
In-Reply-To: <87y3yocil2.fsf@elephly.net> (Ricardo Wurmus's message of "Fri, 06 Jan 2017 16:29:45 +0100")
[-- Attachment #1: Type: text/plain, Size: 1934 bytes --]
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 #2: indent-package-expr.el --]
[-- Type: application/emacs-lisp, Size: 909 bytes --]
[-- Attachment #3: Type: text/plain, Size: 450 bytes --]
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
next prev parent reply other threads:[~2017-01-07 5:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-06 15:29 indent with emacs batch mode Ricardo Wurmus
2017-01-07 5:59 ` Alex Kost [this message]
2017-01-07 7:25 ` Ricardo Wurmus
2017-01-08 13:32 ` Alex Kost
2017-01-12 14:01 ` Ludovic Courtès
2017-05-28 16:54 ` Andreas Enge
2017-01-07 21:17 ` Ludovic Courtès
2017-01-07 21:21 ` Ricardo Wurmus
2017-01-08 13:48 ` Alex Kost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87inpr8l6y.fsf@gmail.com \
--to=alezost@gmail.com \
--cc=guix-devel@gnu.org \
--cc=rekado@elephly.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.