multi-line everything from function invocations and definitions to array and map literals in a wide variety of languages
#+HTML_HEAD: #+HTML_HEAD:
#+HTML_HEAD: #+HTML_HEAD: #+HTML_HEAD: #+HTML_HEAD:
[[https://travis-ci.org/IvanMalison/multi-line][file:https://travis-ci.org/IvanMalison/multi-line.svg?branch=master]] [[http://melpa.org/#/multi-line][file:https://melpa.org/packages/multi-line-badge.svg]] [[https://stable.melpa.org/#/multi-line][file:https://stable.melpa.org/packages/multi-line-badge.svg]]
Demo [[https://asciinema.org/a/dwft2l94f75x9l46wmdhbm5lh?t=4][https://asciinema.org/a/dwft2l94f75x9l46wmdhbm5lh.png]]
About multi-line aims to provide a flexible framework for automatically multi-lining and single-lining function invocations and definitions, array and map literals and more. It relies on functions that are defined on a per major mode basis wherever it can so that it operates correctly across many different programming languages.
Supported Languages The following languages are officially supported by multi-line
It is likely that multi-line will function pretty well in any language using
typical brace/parenthesis/comma syntax, provided that the major mode has
properly defined forward-sexp and indent-line. If you find that multi-line
works well without modification in your language of choice please file an issue
or submit a pull request to have it added to the list of officially supported
languages.
When invoked with a prefix argument (C-u), multi-line will "single-line" the
expression at point, removing all new lines and replacing them with spaces (or
the character configured for single lining).
In the following example we set the default multi-lining behavior for the clojure programming language.
#+BEGIN_SRC emacs-lisp (multi-line-defhook clojure (make-instance multi-line-strategy :find (make-instance multi-line-forward-sexp-find-strategy :split-regex "[[:space:]\n]+" :done-regex "[[:space:]]*)]}" :split-advance-fn 'multi-line-lisp-advance-fn) :respace multi-line-lisp-respacer)) #+END_SRC
This expands to
#+BEGIN_SRC emacs-lisp (eval-and-compile (defvar multi-line-clojure-strategy) (setq multi-line-clojure-strategy (make-instance multi-line-strategy :find (make-instance multi-line-forward-sexp-find-strategy :split-regex "[[:space:]]+" :done-regex "[[:space:]]*)]}" :split-advance-fn 'multi-line-lisp-advance-fn) :respace multi-line-lisp-respacer)) (defun multi-line-clojure-mode-hook nil (setq-local multi-line-current-strategy multi-line-clojure-strategy)) (add-hook 'clojure-mode-hook 'multi-line-clojure-mode-hook t)) #+END_SRC
Users will most often want to configure the respacing portion of the multi-line strategy. If you prefer to always add a newline at every available split point you might set up the default multi-line strategy as follows:
#+BEGIN_SRC emacs-lisp
(setq-default multi-line-current-strategy
(multi-line-strategy
:respace (multi-line-default-respacers
(make-instance multi-line-always-newline))))
#+END_SRC
** Built-in Mode Specific Behavior
multi-line has some built in mode specific behavior that is enabled by default.
The interactive function multi-line-disable-mode-hooks disables this mode
specific behavior.