From 6667c6187753d476611282524148fd239309d3eb Mon Sep 17 00:00:00 2001 From: Steve Vinoski Date: Fri, 20 Dec 2013 16:03:51 -0500 Subject: fix erlang-mode erlang-get-function-arity In the emacs erlang-mode the function erlang-get-function-arity failed to return a correct arity value for functions with literal binaries as parameters, for example: function(<>) -> Bin. Fix erlang-get-function-arity to recognize binary parameters correctly. --- lib/tools/emacs/erlang.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el index c395d22356..b9a05572f7 100644 --- a/lib/tools/emacs/erlang.el +++ b/lib/tools/emacs/erlang.el @@ -3645,6 +3645,10 @@ Normally used in conjunction with `erlang-beginning-of-clause', e.g.: (setq cont nil)) ((looking-at "\\s *\\($\\|%\\)") (forward-line 1)) + ((looking-at "\\s *<<[^>]*?>>") + (when (zerop res) + (setq res (+ 1 res))) + (goto-char (match-end 0))) ((looking-at "\\s *,") (setq res (+ 1 res)) (goto-char (match-end 0))) -- cgit v1.2.3 From a94be31b40aa5505366b07ba7c8212b869453522 Mon Sep 17 00:00:00 2001 From: Steve Vinoski Date: Tue, 7 Jan 2014 23:12:19 -0500 Subject: prevent errors from erlang.el In erlang.el, add a line to evaluate the cl package at compile time so that the use of the block macro (such as on line 3750), which is an alias for cl-block, is evaluated correctly when erlang.el is compiled. Also modify comparisons against (point) in functions erlang-electric-lt and erlang-after-bitsyntax-close so that typing the characters '<' and '>' (without the quotes) at the beginning of a buffer does not cause errors. Thanks to user leo2007 in the #erlang channel on IRC for reporting these problems and providing fixes. --- lib/tools/emacs/erlang.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el index c395d22356..767d086c61 100644 --- a/lib/tools/emacs/erlang.el +++ b/lib/tools/emacs/erlang.el @@ -73,6 +73,8 @@ ;; M-x set-variable RET debug-on-error RET t RET ;;; Code: +(eval-when-compile (require 'cl)) + ;; Variables: (defconst erlang-version "2.7" @@ -3926,7 +3928,7 @@ non-whitespace characters following the point on the current line." (self-insert-command arg) ;; Was this the second char in bit-syntax open (`<<')? - (unless (< (point) 2) + (unless (<= (point) 2) (save-excursion (backward-char 2) (when (and (eq (char-after (point)) ?<) @@ -3947,7 +3949,7 @@ non-whitespace characters following the point on the current line." (defun erlang-after-bitsyntax-close () "Return t if point is immediately after a bit-syntax close parenthesis (`>>')." - (and (>= (point) 2) + (and (>= (point) 3) (save-excursion (backward-char 2) (and (eq (char-after (point)) ?>) -- cgit v1.2.3 From fbefef025128e65fdfb562b485820dcb1ab04e99 Mon Sep 17 00:00:00 2001 From: Steve Vinoski Date: Fri, 10 Jan 2014 19:57:58 -0500 Subject: fix indentation error from scan-sexp in erlang.el Fix an indentation error being returned by scan-sexp, and add a new indentation test case for the error. --- lib/tools/emacs/erlang.el | 2 +- lib/tools/emacs/test.erl.indented | 5 +++++ lib/tools/emacs/test.erl.orig | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el index c395d22356..3ab73dca86 100644 --- a/lib/tools/emacs/erlang.el +++ b/lib/tools/emacs/erlang.el @@ -3038,7 +3038,7 @@ This assumes that the preceding expression is either simple \(i.e. an atom) or parenthesized." (save-excursion (or arg (setq arg 1)) - (forward-sexp (- arg)) + (ignore-errors (forward-sexp (- arg))) (let ((col (current-column))) (skip-chars-backward " \t") ;; Special hack to handle: (note line break) diff --git a/lib/tools/emacs/test.erl.indented b/lib/tools/emacs/test.erl.indented index 7e61bcc45b..ba173a8cc2 100644 --- a/lib/tools/emacs/test.erl.indented +++ b/lib/tools/emacs/test.erl.indented @@ -731,3 +731,8 @@ commas_first() -> ] } ] }. + + +%% this used to result in a scan-sexp error +[{ + }]. diff --git a/lib/tools/emacs/test.erl.orig b/lib/tools/emacs/test.erl.orig index 932758997d..cb3d1f94dc 100644 --- a/lib/tools/emacs/test.erl.orig +++ b/lib/tools/emacs/test.erl.orig @@ -731,3 +731,8 @@ commas_first() -> ] } ] }. + + +%% this used to result in a scan-sexp error +[{ +}]. -- cgit v1.2.3 From a5dcc18a9ed1fd197a164a2671839689f66777b9 Mon Sep 17 00:00:00 2001 From: Steve Vinoski Date: Thu, 16 Jan 2014 11:07:25 -0500 Subject: fix emacs erlang skeleton indentation When inserting skeletons in emacs, some Erlang language elements such as case, receive, and if statements, are not indented properly. This patch, written by Leo Liu, corrects the indentation problems. --- lib/tools/emacs/erlang-skels.el | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/tools/emacs/erlang-skels.el b/lib/tools/emacs/erlang-skels.el index 527e812444..7379215d68 100644 --- a/lib/tools/emacs/erlang-skels.el +++ b/lib/tools/emacs/erlang-skels.el @@ -109,32 +109,32 @@ include separators of the form %%--...") ;; Expression templates: (defvar erlang-skel-case '((erlang-skel-skip-blank) o > - "case " p " of" n> p "_ ->" n> p "ok" n> "end" p) + "case " p " of" n> p "_ ->" n> p "ok" n "end" > p) "*The skeleton of a `case' expression. Please see the function `tempo-define-template'.") (defvar erlang-skel-if '((erlang-skel-skip-blank) o > - "if" n> p " ->" n> p "ok" n> "end" p) + "if" n> p " ->" n> p "ok" n "end" > p) "The skeleton of an `if' expression. Please see the function `tempo-define-template'.") (defvar erlang-skel-receive '((erlang-skel-skip-blank) o > - "receive" n> p "_ ->" n> p "ok" n> "end" p) + "receive" n> p "_ ->" n> p "ok" n "end" > p) "*The skeleton of a `receive' expression. Please see the function `tempo-define-template'.") (defvar erlang-skel-receive-after '((erlang-skel-skip-blank) o > - "receive" n> p "_ ->" n> p "ok" n> "after " p "T ->" n> - p "ok" n> "end" p) + "receive" n> p "_ ->" n> p "ok" n "after " > p "T ->" n> + p "ok" n "end" > p) "*The skeleton of a `receive' expression with an `after' clause. Please see the function `tempo-define-template'.") (defvar erlang-skel-receive-loop '(& o "loop(" p ") ->" n> "receive" n> p "_ ->" n> - "loop(" p ")" n> "end.") + "loop(" p ")" n "end." >) "*The skeleton of a simple `receive' loop. Please see the function `tempo-define-template'.") @@ -256,8 +256,8 @@ Please see the function `tempo-define-template'.") "loop(From) ->" n> "receive" n> p "_ ->" n> - "loop(From)" n> - "end." n + "loop(From)" n + "end." > n ) "*Template of a small server. Please see the function `tempo-define-template'.") @@ -291,8 +291,8 @@ Please see the function `tempo-define-template'.") "{ok, Pid} ->" n> "{ok, Pid};" n> "Error ->" n> - "Error" n> - "end." n + "Error" n + "end." > n n (erlang-skel-separator-start 2) "%% @private" n @@ -421,8 +421,8 @@ Please see the function `tempo-define-template'.") "{ok, Pid} ->" n> "{ok, Pid, #state{}};" n> "Error ->" n> - "Error" n> - "end." n + "Error" n + "end." > n n (erlang-skel-separator-start 2) "%% @private" n -- cgit v1.2.3