John Kitchin
John Kitchin

Reputation: 2433

Is it possible to format lisp code in different ways, e.g. very dense, vs. properly indented?

I want to write some lisp code for a clickable link in org-mode in Emacs. While writing the code, I like it to be properly indented and on multiple lines, but in the link it must be dense, and one single line. It would be nice to switch between these representations with M-x commands.

For example, I need this form of lisp for the link: (progn (when t (do this)(then this)(finally this)))

but while editing I like it this way

(progn (when t (do this) (then this) (finally this)))

I can see how to go from the second to first, just by removing line endings, but not an easy way to go back. Any ideas?

Upvotes: 2

Views: 73

Answers (1)

abo-abo
abo-abo

Reputation: 20342

lispy can do this:

  • press O while on list boundary to fit it on one line
  • press M to make it multi-line

Note that there's no single best way to decide where to put the line breaks with M, so a simple rule was used instead, with a small correction for let bindings.

Here's the gif:

gif.

Upvotes: 1

Related Questions