[erlang-patches] [PATCH] Inhibit electric newline after "->" when inside a type spec
Henrik Nord
henrik@REDACTED
Fri Apr 15 09:50:22 CEST 2011
On 04/14/2011 05:49 PM, Magnus Henoch wrote:
> The Erlang mode for Emacs inserts a newline after every "->", which
> saves you one keystroke when writing a function, but that is
> inappropriate when writing a type spec, as you'd normally keep the
> spec on one line. This change inhibits the automatic insertion when
> the current line starts with "-spec" or "-type".
> ---
> lib/tools/emacs/erlang.el | 13 ++++++++++++-
> 1 files changed, 12 insertions(+), 1 deletions(-)
>
> diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el
> index e1c0d31..6728bef 100644
> --- a/lib/tools/emacs/erlang.el
> +++ b/lib/tools/emacs/erlang.el
> @@ -386,7 +386,8 @@ then no prototype is inserted.
> The test is performed by the function `erlang-test-criteria-list'.")
>
> (defvar erlang-electric-arrow-criteria
> - '(erlang-next-lines-empty-p
> + '(erlang-stop-when-in-type-spec
> + erlang-next-lines-empty-p
> erlang-at-end-of-function-p)
> "*List of functions controlling the arrow aspect of `erlang-electric-gt'.
> The functions in this list are called, in order, whenever a `>'
> @@ -4045,6 +4046,16 @@ This function is designed to be a member of a criteria list."
> nil)))
>
>
> +(defun erlang-stop-when-in-type-spec ()
> + "Return `stop' when in a type spec line.
> +
> +This function is designed to be a member of a criteria list."
> + (save-excursion
> + (beginning-of-line)
> + (when (save-match-data (looking-at "-\\(spec\\|type\\)"))
> + 'stop)))
> +
> +
> (defun erlang-next-lines-empty-p ()
> "Return non-nil if next lines are empty.
>
Hi
I have included this into 'pu'
Thank you for the contribution!
--
/Henrik Nord Erlang/OTP
More information about the erlang-patches
mailing list