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: Ludovic Courtès
Subject: Re: indent with emacs batch mode
Date: Thu, 12 Jan 2017 15:01:38 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Alex Kost <address@hidden> skribis:

> Ricardo Wurmus (2017-01-07 08:25 +0100) wrote:
>
>> Alex Kost wrote:
>>
>>> 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.
>>
>> Guix still comes with a “.dir-locals.el” that specifies the indentation
>> rules, doesn’t it?  Can we use that?
>
> Oof, it took me some time to figure it out :-)
>
> So here is the version that requires only emacs and ".dir-locals.el"
> file from the git repo:
>
> ;; Load Scheme indentation rules from "~/src/guix/.dir-locals.el".
> (with-temp-buffer
>   (scheme-mode)
>   (let ((default-directory (file-name-as-directory "~/src/guix"))
>         (enable-local-variables :all))
>     (hack-dir-local-variables)
>     (hack-local-variables-apply)))
>
> (pcase command-line-args-left
>   (`(,file-name ,package-name)
>    (find-file file-name)
>    (goto-char (point-min))
>    (if (re-search-forward (concat "^(define\\(-public\\) +"
>                                   package-name)
>                           nil t)
>        (progn
>          (beginning-of-defun)
>          (indent-sexp)
>          (save-buffer)
>          (message "Done!"))
>      (error "Package '%s' not found in '%s'"
>             package-name file-name))))
>
>
> Emacs can be run like this:
>
>   emacs -Q --batch -l indent-package-expr.el package-file.scm package-name

I’ve pushed it as 7bb2b10cd01a076d7d5e964ed433e62846042859 along with
some doc.

Thanks!

Ludo’.



reply via email to

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