Command: srefactor-lisp-format-buffer
In the demo, the whole Emacs Lisp code is all messed. It is totally gibberish. However, the command srefactor-lisp-format-buffer can rearrange the code back into readable manner. If there are s-expressions that are split into multiple lines or all in one line, you can easily use the command `srefactor-lisp-one-line` or srefactor-lisp-multi-line to format such s-expressions to fit your need. In general, Srefactor try to be as smart about sexp as it could. For example, when it encounters a “defun” form, it skips the first three s-expressions (the “defun” keyword, the function name and argument list) and insert a newline after that, when splitting into multiple lines. A user can customize such behaviour for each symbol with the variable srefactor-lisp-symbol-to-skip.
Clojure formatting demo:
Command: srefactor-lisp-format-defun
This command only formats the current function point is in.
Command: srefactor-lisp-one-line Command: srefactor-lisp-format-sexp
In this demo, you will see that you can effortlessly transform current s-expression whether the cursor is inside the s-expression or at the beginning of its opening parenthesis, without moving it anywhere. Let’s see it in action:
You can recursively turn a s-expression all of its inner s-expressions into one line with prefix argument.
Sexp formatting command actually works similar to srefactor-lisp-format-defun, except it formats current s-expression cursor is in.