Lisp HUG Maillist Archive

Indenting/formatting Lisp files

Hi there !

Is there a command in LW (or maybe some pre-cooked script that someone would like to share) for auto-indenting a lisp file or buffer ?
I think I know how to do it in the LW editor, but I wonder if this is possible without opening the file in and editor-pane.

I am also interested in removing tabs, trailing white-spaces, etc. in order to apply some consistent lisp formatting over a large Lisp project. 
Thanks,

Jean



_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Re: Indenting/formatting Lisp files

In case anyone else is interested, here is a simple solution I came up with for indenting a Lisp file using LW's editor tools:


(defun indent-lisp-file (path)
  
  (let ((file-buffer (editor::find-file-buffer path)))

    (setf (editor:buffer-major-mode file-buffer) "LISP")

    (editor::lisp-indent-region-for-commands
     (editor:buffers-start file-buffer)
     (editor:buffers-end file-buffer))
   
    (when (editor:buffer-modified file-buffer)
      (editor:save-file-command nil file-buffer))

    (editor::kill-buffer-no-confirm file-buffer))
  )




> On 30 Aug 2020, at 09:39, Jean Bresson <Jean.Bresson@ircam.fr> wrote:
> 
> Hi there !
> 
> Is there a command in LW (or maybe some pre-cooked script that someone would like to share) for auto-indenting a lisp file or buffer ?
> I think I know how to do it in the LW editor, but I wonder if this is possible without opening the file in and editor-pane.
> 
> I am also interested in removing tabs, trailing white-spaces, etc. in order to apply some consistent lisp formatting over a large Lisp project. 
> Thanks,
> 
> Jean
> 
> 
> 
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> lisp-hug@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Updated at: 2020-12-10 08:28 UTC