External lisp indenter code

I have a lisp code / scheme similar to that I want to indent. I was looking for tools like GNU indent , but I could not find the command line utility / script. There are many of them for C / C ++ / Java, but for some reason I can not find any option for the lisp / scheme, someone can tell me about any such indentation tools, if available.

Thanks.

+4
source share
4 answers

You can use emacs in batch mode. For example, you can create the indent.el file

 (defun my/indent-file (fPath) (let ((buffer (find-file fPath))) (message (concat "indenting file " fPath)) (indent-region (point-min) (point-max)) (save-buffer) (kill-buffer buffer))) (mapcar 'my/indent-file argv) 

and then call emacs like this to postpone a bunch of files (note that it will work for any emacs language that can recognize and learn how to backtrack):

 emacs --load indent.el --batch MY_LISP_FILES 

See this page for more information on idiomatic ways to use emacs for batch processing.

Edit

Here is a single-line file that works with only one file, but does not use the argv variable (be careful: the order of the arguments is important):

 emacs --batch MY_FILE --eval '(indent-region (point-min) (point-max))' -f 'save-buffer' 
+3
source

Doray Sitharam has the scripts scmindent.scm and lispindent.lisp on this website that will work for this purpose. They were originally designed to let you insert Lisp indent code into vi.

+1
source

If you are using vim, the this message should provide you with a way to run the auto indent command in all files. And if you want (IMO) really good indentation in lisp files in vim, I recommend loading slimv and swank server before running this command.

+1
source

Source: https://habr.com/ru/post/1402913/


All Articles