Skip to content

Latest commit

 

History

History
46 lines (30 loc) · 1.83 KB

demos-elisp.org

File metadata and controls

46 lines (30 loc) · 1.83 KB

Format whole buffer

Command: srefactor-lisp-format-buffer

srefactor-elisp-format-buffer.gif

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:

srefactor-format-buffer-clojure.gif

Format current defun

Command: srefactor-lisp-format-defun

This command only formats the current function point is in.

One line <–> Multiple lines

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:

srefactor-elisp-oneline-multiline.gif

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.