Skip to content
This repository has been archived by the owner on Feb 4, 2021. It is now read-only.

Latest commit

 

History

History
39 lines (32 loc) · 1.35 KB

HOW_TO_WRAP_SEXP.org

File metadata and controls

39 lines (32 loc) · 1.35 KB

How to wrap sexp.

I will do like this.

For example, I have the code like this:

(defn greetings [name]
  (str "hello"
       name))

I want:

(defn greetings [name]
  (print (vec (str "hello"
                   name))))
  • Move the cursor to the point before (str.
  • Switch to Paren Mode.
  • Type (print_(vec_ (underscore stands for white space).
  • Press C-M-f (builtin command, forward sexp), this will lead my cursor to point after name).
  • Type )) to close parens, code will be auto indent after this.
  • Switch back to Ident Mode (or using (setq parinfer-auto-switch-indent-mode t) to skip this step).

More ideas.

To simplify these steps, I’m trying to combine Indent Mode & Paren Mode into One Mode.

IMO, the strategy will be:

Rule 1
When inserting before an open parens, insert close parens and call Paren Mode.
Rule 2
When cursor is between two open parens ((<cursor>() and backspace is pressed, delete the corresponding close parens and call Paren Mode.
Rule 3
When modifying indentation, call Indent Mode.
Rule 4
When Insert/Delete parens(except Rule 1 & 2), call Ident Mode.
Rule 5
Otherwise, call Paren Mode.

This is a demo, this feature is WIP, very experimental. You can try by add one to parinfer-extensions. images/one_demo.gif