From 97b3c64c88c0fc538d59723200108b189f1ed023 Mon Sep 17 00:00:00 2001 From: Matt DeBoard Date: Mon, 18 Aug 2014 11:45:41 -0500 Subject: [PATCH 1/7] Fix incorrect syntax of defrecord test. --- test/elixir-mode-indentation-tests.el | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/elixir-mode-indentation-tests.el b/test/elixir-mode-indentation-tests.el index 6d05f1cd..200efaa8 100644 --- a/test/elixir-mode-indentation-tests.el +++ b/test/elixir-mode-indentation-tests.el @@ -176,13 +176,19 @@ end (elixir-def-indentation-test indents-records-correctly () " -defrecord Money, [:currency_unit, :amount] do -foo +defmodule MyModule do +require Record +Record.defrecord :money, [:currency_unit, :amount] + +Record.defrecord :animal, [:species, :name] end " " -defrecord Money, [:currency_unit, :amount] do - foo +defmodule MyModule do + require Record + Record.defrecord :money, [:currency_unit, :amount] + + Record.defrecord :animal, [:species, :name] end ") From 2d570b1c6a8418adece19f77265842f08516d2c1 Mon Sep 17 00:00:00 2001 From: Matt DeBoard Date: Mon, 18 Aug 2014 13:46:01 -0500 Subject: [PATCH 2/7] Rewrite of forward/backward token functionality. The previous incarnation of this is quite slow and very hard to follow. In this commit I am trying to see how concise I can make the forward- and backward-token functions. --- elixir-mode-tests.el | 1 - elixir-smie.el | 254 ++++++++----------------- test/elixir-mode-indentation-tests.el | 14 +- test/elixir-mode-tokenizer-hl-tests.el | 34 ---- 4 files changed, 85 insertions(+), 218 deletions(-) delete mode 100644 test/elixir-mode-tokenizer-hl-tests.el diff --git a/elixir-mode-tests.el b/elixir-mode-tests.el index e8ba7a8a..b3a63782 100644 --- a/elixir-mode-tests.el +++ b/elixir-mode-tests.el @@ -21,7 +21,6 @@ ,@body)) (load "test/elixir-mode-indentation-tests.el") -(load "test/elixir-mode-tokenizer-hl-tests.el") (load "test/elixir-mode-font-tests.el") (provide 'elixir-mode-tests) diff --git a/elixir-smie.el b/elixir-smie.el index 31fa7ca4..aa3013c6 100644 --- a/elixir-smie.el +++ b/elixir-smie.el @@ -53,7 +53,7 @@ ,regexp) (pushnew `(,',regex-name . ,(upcase (symbol-name ',name))) elixir-syntax-class-names)))) - (elixir-smie-define-regexp-opt op "&&" "||" "!") + ;(elixir-smie-define-regexp-opt op "&&" "||" "!") (elixir-smie-define-regexp dot "\\.") (elixir-smie-define-regexp comma ",") (elixir-smie-define-regexp -> "->") @@ -65,182 +65,81 @@ '(do else catch after rescue -> OP) "Keywords in which newlines cause confusion for the parser.") -(defun elixir-skip-comment-backward () - "Skip backwards over all whitespace and comments. +(defvar elixir-smie--operator-regexp + (regexp-opt '("<<<" ">>>" "^^^" "~~~" "&&&" "|||" "===" "!==" "==" "!=" "<=" + ">=" "<" ">" "&&" "||" "<>" "++" "--" "//" + "/>" "=~" "|>" "->"))) -Return non-nil if any line breaks were skipped." - (let ((start-line-no (line-number-at-pos (point)))) - (forward-comment (- (point))) - (/= start-line-no (line-number-at-pos (point))))) - -(defun elixir-skip-comment-forward () - "Skip forward over any whitespace and comments. - -Return non-nil if any line breaks were skipped." - (let ((start-line-no (line-number-at-pos (point)))) - (forward-comment (buffer-size)) - (/= start-line-no (line-number-at-pos (point))))) - -(defun elixir-smie-next-token-no-lookaround (forwardp) - (block elixir-smie-next-token-no-lookaround - ;; First, skip comments; but if any comments / newlines were - ;; skipped, the upper level needs to check if they were significant: - (when (if forwardp - (elixir-skip-comment-forward) - (elixir-skip-comment-backward)) - (return-from elixir-smie-next-token-no-lookaround "\n")) - (let* ((found-token-class (find-if - (lambda (class-def) - (let ((regex (symbol-value (car class-def)))) - (if forwardp - (looking-at regex) - (looking-back regex nil t)))) - elixir-syntax-class-names)) - (maybe-token - (let ((current-char (if forwardp - (following-char) - (preceding-char)))) - (cond ((member current-char - '(?\n ?\;)) - (if forwardp - (forward-comment (point-max)) - (forward-comment (- (point)))) - (string current-char)) - (found-token-class - (goto-char (if forwardp - (match-end 0) - (match-beginning 0))) - (if (string= "PARENS" (cdr found-token-class)) - (buffer-substring-no-properties (match-beginning 0) (match-end 0)) - (cdr found-token-class))) - ((when (= ?\" (char-syntax (if forwardp - (following-char) - (preceding-char)))) - (if forwardp - (forward-sexp) - (backward-sexp)) - "STRING")))))) - (or maybe-token - (downcase - (buffer-substring-no-properties - (point) - (if forwardp - (progn (skip-syntax-forward "'w_") - (point)) - (progn (skip-syntax-backward "'w_") - (point))))))))) - -(defun elixir-smie-next-token (forwardp) - (block elixir-smie-next-token - (let ((current-token (elixir-smie-next-token-no-lookaround forwardp))) - (when (string= "\n" current-token) - ;; This is a newline; if the previous token isn't an OP2, this - ;; means the line end marks the end of a statement & we get to - ;; scan forward until there's a non-newline token; otherwise, - ;; make this line ending something that probably ends the - ;; statement (but see below). - (if (save-excursion - (block nil - (let ((token (elixir-smie-next-token-no-lookaround nil))) - (while (and (not (= (point) (point-min))) - (string= "\n" token)) - (setq token (elixir-smie-next-token-no-lookaround nil))) - (when (member (intern token) elixir-smie-block-intro-keywords) - (return t))))) - ;; it's a continuation line, return the next token after the newline: - (return-from elixir-smie-next-token (elixir-smie-next-token forwardp)) - (setq current-token ";"))) +(defun elixir-smie--at-dot-call () + (and (eq ?w (char-syntax (following-char))) + (eq (char-before) ?.) + (not (eq (char-before (1- (point))) ?.)))) - ;; When reading match statements (the ones with expr -> statements), - ;; we need to drop non-; delimiters so the parser knows when a - ;; match statement ends and another begins, so scan around point to - ;; see if there are any -> within the current block's scope. - - ;; If the current token is a ";", scan forward to see if the current - ;; potential statement contains a "->". If so, scan back to find a - ;; "do". If there is a -> there, emit a match-statement-delimiter - ;; instead of the ";". - (if (and (string= ";" current-token) - ;; Scan ahead: - (let ((level 0) - token) - (save-excursion - (block nil - (while - (and - ;; Cursor is not at the end of the buffer... - (not (= (point) (point-max))) - ;; ...and the current token is not an empty string... - (not (string= "" token)) - ;; ...nor a newline nor a semicolon. - (not (or (string= "\n" token) (string= ";" token)))) - (setq token (elixir-smie-next-token-no-lookaround t)) - ;; If we're at the top level and the token is "->", - ;; return t - (cond ((and (= level 0) (string= "->" token)) - (return t)) - ;; If token is "do" or "fn", increment level - ((find token '("do" "fn") :test 'string=) - (incf level)) - ;; If token is "end", decrement level - ((string= token "end") - (decf level))))))) - ;; Scan behind: - (let (token) - (save-excursion - (block nil - (while - (and - ;; Cursor is not at the beginning of buffer... - (not (= (point) (point-min))) - ;; ...and token is neither empty string, nor "do"/"fn" - (not (string= "" token)) - (not (string= "do" token)) - (not (string= "fn" token))) - (setq token (elixir-smie-next-token-no-lookaround nil)) - (when (string= "->" token) - (return t))) - (when (string= token "do") t))))) - "MATCH-STATEMENT-DELIMITER" - current-token)))) +(defun elixir-smie--implicit-semi-p () + (not (or (memq (char-before) '(?\{ ?\[ ?\,)) + (looking-back elixir-smie--operator-regexp (- (point) 3) t)))) (defun elixir-smie-forward-token () - (elixir-smie-next-token t)) + (cond + ((and (looking-at "\n") (elixir-smie--implicit-semi-p)) + (if (eolp) (forward-char 1) (forward-comment 1)) + ";") + ((looking-at elixir-smie--operator-regexp) + (goto-char (match-end 0)) + "OP") + (t (smie-default-forward-token)))) (defun elixir-smie-backward-token () - (elixir-smie-next-token nil)) + (let ((pos (point))) + (forward-comment (- (point))) + (cond + ((and (> pos (line-end-position)) + (elixir-smie--implicit-semi-p)) + ";") + ((looking-back elixir-smie--operator-regexp (- (point) 3) t) + (goto-char (match-beginning 0)) + "OP") + (t (smie-default-backward-token))))) (defconst elixir-smie-grammar (smie-prec2->grammar - (smie-bnf->prec2 - '((id) - (statements (statement) - (statement ";" statements)) - (statement ("def" non-block-expr "do" statements "end") - (non-block-expr "fn" match-statement "end") - (non-block-expr "do" statements "end") - ("if" non-block-expr "do" statements "else" statements "end") - ("if" non-block-expr "do" statements "end") - ("if" non-block-expr "COMMA" "do:" non-block-expr) - ("if" non-block-expr "COMMA" - "do:" non-block-expr "COMMA" - "else:" non-block-expr) - ("try" "do" statements "after" statements "end") - ("try" "do" statements "catch" match-statements "end") - ("try" "do" statements "end") - ("case" non-block-expr "do" match-statements "end")) - (non-block-expr (non-block-expr "OP" non-block-expr) - (non-block-expr "COMMA" non-block-expr) - ("(" statements ")") - ("{" statements "}") - ("[" statements "]") - ("STRING")) - (match-statements (match-statement "MATCH-STATEMENT-DELIMITER" match-statements) - (match-statement)) - (match-statement (non-block-expr "->" statements))) - '((assoc "if" "do:" "else:") - (assoc "COMMA") - (left "OP"))))) + (smie-merge-prec2s + (smie-bnf->prec2 + '((id) + (statements (statement) + (statement ";" statements)) + (statement ("def" non-block-expr "do" statements "end") + (non-block-expr "fn" match-statement "end") + (non-block-expr "do" statements "end") + ("if" non-block-expr "do" statements "else" statements "end") + ("if" non-block-expr "do" statements "end") + ("if" non-block-expr "COMMA" "do:" non-block-expr) + ("if" non-block-expr "COMMA" + "do:" non-block-expr "COMMA" + "else:" non-block-expr) + ("try" "do" statements "after" statements "end") + ("try" "do" statements "catch" match-statements "end") + ("try" "do" statements "end") + ("case" non-block-expr "do" match-statements "end")) + (non-block-expr (non-block-expr "OP" non-block-expr) + (non-block-expr "COMMA" non-block-expr) + ("(" non-block-expr ")") + ("{" non-block-expr "}") + ("[" non-block-expr "]") + ("STRING")) + (match-statements (match-statement "MATCH-STATEMENT-DELIMITER" match-statements) + (match-statement)) + (match-statement (non-block-expr "->" statements))) + '((assoc "if" "do:" "else:") + (assoc "COMMA") + (left "OP"))) + + (smie-precs->prec2 + '((left "||") + (left "&&") + (nonassoc "=~" "===" "!==" "==" "!=" "<=" ">=" "<" ">") + (left "+" "-" "<<<" ">>>" "^^^" "~~~" "&&&" "|||") + (left "*" "/")))))) (defvar elixir-smie-indent-basic 2) @@ -265,26 +164,25 @@ Return non-nil if any line breaks were skipped." 0 elixir-smie-indent-basic)) (`(:after . "OP") - (unless (smie-rule-sibling-p) - elixir-smie-indent-basic)) + (cond + ((smie-rule-sibling-p) nil) + ((smie-rule-hanging-p) (smie-rule-parent elixir-smie-indent-basic)) + (t elixir-smie-indent-basic))) (`(:before . "def") elixir-smie-indent-basic) ;; If the parent token of `->' is `fn', then we want to align to the ;; parent, and offset by `elixir-smie-indent-basic'. Otherwise, indent ;; normally. This helps us work with/indent anonymous function blocks ;; correctly. - (`(:after . "->") - (when (smie-rule-hanging-p) - (if (smie-rule-parent-p "fn") - (smie-rule-parent elixir-smie-indent-basic) - elixir-smie-indent-basic))) - (`(:after . "do") - elixir-smie-indent-basic) (`(:list-intro . ,(or `"do" `";")) t) + (`(:before . ";") + (cond + ((smie-rule-parent-p "after" "catch" "def" "defmodule" "defp" "do" "else" + "fn" "if" "rescue" "try" "unless") + (smie-rule-parent elixir-smie-indent-basic)))) (`(:after . ";") (if (smie-rule-parent-p "if") (smie-rule-parent 0))))) - (define-minor-mode elixir-smie-mode "SMIE-based indentation and syntax for Elixir" nil nil nil nil diff --git a/test/elixir-mode-indentation-tests.el b/test/elixir-mode-indentation-tests.el index 200efaa8..b638c738 100644 --- a/test/elixir-mode-indentation-tests.el +++ b/test/elixir-mode-indentation-tests.el @@ -194,14 +194,18 @@ end (elixir-def-indentation-test indents-continuation-lines () " -has_something(x) && -has_something(y) || -has_something(z) -" - " +def foo do has_something(x) && has_something(y) || has_something(z) +end +" + " +def foo do + has_something(x) && + has_something(y) || + has_something(z) +end ") (elixir-def-indentation-test indents-continuation-lines-with-comments/1 diff --git a/test/elixir-mode-tokenizer-hl-tests.el b/test/elixir-mode-tokenizer-hl-tests.el deleted file mode 100644 index bf77ed9d..00000000 --- a/test/elixir-mode-tokenizer-hl-tests.el +++ /dev/null @@ -1,34 +0,0 @@ -;;; High-level Tokenizer tests: - -(elixir-deftest skip-forwards-over-comments () - (elixir-ert-with-test-buffer () - "foo # comment\nbar" - (goto-char (point-min)) - (should (equal "foo" (elixir-smie-next-token t))) - (should (equal ";" (elixir-smie-next-token t))) - (should (equal "bar" (elixir-smie-next-token t))) - (should (equal (point-max) (point))))) - -(elixir-deftest skip-backwards-over-comments () - (elixir-ert-with-test-buffer () - "foo # comment\nbar" - (goto-char (point-max)) - (should (equal "bar" (elixir-smie-next-token nil))) - (should (equal ";" (elixir-smie-next-token nil))) - (should (equal "foo" (elixir-smie-next-token nil))) - (should (equal (point-min) (point))))) - -(elixir-deftest treat-comments-the-same-as-whitespace-backwards () - (let ((skipped-to-posn)) - (elixir-ert-with-test-buffer (:name "With comment") - "function do # test\n bar\nend" - (goto-char (point-min)) - (forward-line 1) - (should (equal "do" (elixir-smie-next-token nil))) - (setq skipped-to-posn (point))) - (elixir-ert-with-test-buffer (:name "Without comment") - "function do \n bar\nend" - (goto-char (point-min)) - (forward-line 1) - (should (equal "do" (elixir-smie-next-token nil))) - (should (equal skipped-to-posn (point)))))) From ae60c356db2fb6ed0cb60ffe7c84f10727de59cb Mon Sep 17 00:00:00 2001 From: Matt DeBoard Date: Mon, 18 Aug 2014 13:53:56 -0500 Subject: [PATCH 3/7] Remove unused rules & warehoused code. Also, broke up 80+ lines. --- elixir-smie.el | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/elixir-smie.el b/elixir-smie.el index aa3013c6..a042a51d 100644 --- a/elixir-smie.el +++ b/elixir-smie.el @@ -51,9 +51,9 @@ `(progn (defconst ,regex-name ,regexp) - (pushnew `(,',regex-name . ,(upcase (symbol-name ',name))) elixir-syntax-class-names)))) + (pushnew `(,',regex-name . ,(upcase (symbol-name ',name))) + elixir-syntax-class-names)))) - ;(elixir-smie-define-regexp-opt op "&&" "||" "!") (elixir-smie-define-regexp dot "\\.") (elixir-smie-define-regexp comma ",") (elixir-smie-define-regexp -> "->") @@ -127,7 +127,8 @@ ("{" non-block-expr "}") ("[" non-block-expr "]") ("STRING")) - (match-statements (match-statement "MATCH-STATEMENT-DELIMITER" match-statements) + (match-statements (match-statement "MATCH-STATEMENT-DELIMITER" + match-statements) (match-statement)) (match-statement (non-block-expr "->" statements))) '((assoc "if" "do:" "else:") @@ -155,14 +156,6 @@ (defun elixir-smie-rules (kind token) (pcase (cons kind token) - (`(:after . "STRING") - (if (smie-rule-prev-p "do:") - (smie-rule-parent 0) - nil)) - (`(:elem . basic) - (if (smie-rule-hanging-p) - 0 - elixir-smie-indent-basic)) (`(:after . "OP") (cond ((smie-rule-sibling-p) nil) @@ -173,7 +166,6 @@ ;; parent, and offset by `elixir-smie-indent-basic'. Otherwise, indent ;; normally. This helps us work with/indent anonymous function blocks ;; correctly. - (`(:list-intro . ,(or `"do" `";")) t) (`(:before . ";") (cond ((smie-rule-parent-p "after" "catch" "def" "defmodule" "defp" "do" "else" From 1f605e3b8ea296249c5c2c90a852ff4cd24d4655 Mon Sep 17 00:00:00 2001 From: Matt DeBoard Date: Mon, 18 Aug 2014 13:54:20 -0500 Subject: [PATCH 4/7] Remove logic to emit ';' after a hanging comma. --- elixir-smie.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elixir-smie.el b/elixir-smie.el index a042a51d..d42141b9 100644 --- a/elixir-smie.el +++ b/elixir-smie.el @@ -76,7 +76,7 @@ (not (eq (char-before (1- (point))) ?.)))) (defun elixir-smie--implicit-semi-p () - (not (or (memq (char-before) '(?\{ ?\[ ?\,)) + (not (or (memq (char-before) '(?\{ ?\[)) (looking-back elixir-smie--operator-regexp (- (point) 3) t)))) (defun elixir-smie-forward-token () From ae86f70bc3239f41bcec37fcd0433ce91a7fbc3d Mon Sep 17 00:00:00 2001 From: Matt DeBoard Date: Mon, 18 Aug 2014 13:57:10 -0500 Subject: [PATCH 5/7] Remove unnecessary regexps. --- elixir-smie.el | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/elixir-smie.el b/elixir-smie.el index d42141b9..167af0f7 100644 --- a/elixir-smie.el +++ b/elixir-smie.el @@ -40,27 +40,6 @@ (message (format ,message ,@format-args))) nil)) -(progn - (setq elixir-syntax-class-names nil) - - (defmacro elixir-smie-define-regexp-opt (name &rest table) - `(elixir-smie-define-regexp ,name (regexp-opt (list ,@table)))) - - (defmacro elixir-smie-define-regexp (name regexp &optional flag) - (let ((regex-name (intern (format "elixir-smie-%s" name)))) - `(progn - (defconst ,regex-name - ,regexp) - (pushnew `(,',regex-name . ,(upcase (symbol-name ',name))) - elixir-syntax-class-names)))) - - (elixir-smie-define-regexp dot "\\.") - (elixir-smie-define-regexp comma ",") - (elixir-smie-define-regexp -> "->") - (elixir-smie-define-regexp << "<<") - (elixir-smie-define-regexp >> ">>") - (elixir-smie-define-regexp-opt parens "(" ")" "{" "}" "[" "]" "<<" ">>")) - (defconst elixir-smie-block-intro-keywords '(do else catch after rescue -> OP) "Keywords in which newlines cause confusion for the parser.") From 43f0a06ac7793d2406ed596f45041b1341aaa691 Mon Sep 17 00:00:00 2001 From: Matt DeBoard Date: Mon, 18 Aug 2014 13:58:31 -0500 Subject: [PATCH 6/7] Rearrange code a bit. --- elixir-smie.el | 88 ++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 46 deletions(-) diff --git a/elixir-smie.el b/elixir-smie.el index 167af0f7..093521bf 100644 --- a/elixir-smie.el +++ b/elixir-smie.el @@ -34,52 +34,6 @@ table) "Elixir mode syntax table.") -(defmacro elixir-smie-debug (message &rest format-args) - `(progn - (when elixir-smie-verbose-p - (message (format ,message ,@format-args))) - nil)) - -(defconst elixir-smie-block-intro-keywords - '(do else catch after rescue -> OP) - "Keywords in which newlines cause confusion for the parser.") - -(defvar elixir-smie--operator-regexp - (regexp-opt '("<<<" ">>>" "^^^" "~~~" "&&&" "|||" "===" "!==" "==" "!=" "<=" - ">=" "<" ">" "&&" "||" "<>" "++" "--" "//" - "/>" "=~" "|>" "->"))) - -(defun elixir-smie--at-dot-call () - (and (eq ?w (char-syntax (following-char))) - (eq (char-before) ?.) - (not (eq (char-before (1- (point))) ?.)))) - -(defun elixir-smie--implicit-semi-p () - (not (or (memq (char-before) '(?\{ ?\[)) - (looking-back elixir-smie--operator-regexp (- (point) 3) t)))) - -(defun elixir-smie-forward-token () - (cond - ((and (looking-at "\n") (elixir-smie--implicit-semi-p)) - (if (eolp) (forward-char 1) (forward-comment 1)) - ";") - ((looking-at elixir-smie--operator-regexp) - (goto-char (match-end 0)) - "OP") - (t (smie-default-forward-token)))) - -(defun elixir-smie-backward-token () - (let ((pos (point))) - (forward-comment (- (point))) - (cond - ((and (> pos (line-end-position)) - (elixir-smie--implicit-semi-p)) - ";") - ((looking-back elixir-smie--operator-regexp (- (point) 3) t) - (goto-char (match-beginning 0)) - "OP") - (t (smie-default-backward-token))))) - (defconst elixir-smie-grammar (smie-prec2->grammar (smie-merge-prec2s @@ -121,8 +75,50 @@ (left "+" "-" "<<<" ">>>" "^^^" "~~~" "&&&" "|||") (left "*" "/")))))) +(defvar elixir-smie--operator-regexp + (regexp-opt '("<<<" ">>>" "^^^" "~~~" "&&&" "|||" "===" "!==" "==" "!=" "<=" + ">=" "<" ">" "&&" "||" "<>" "++" "--" "//" + "/>" "=~" "|>" "->"))) + (defvar elixir-smie-indent-basic 2) +(defmacro elixir-smie-debug (message &rest format-args) + `(progn + (when elixir-smie-verbose-p + (message (format ,message ,@format-args))) + nil)) + +(defun elixir-smie--at-dot-call () + (and (eq ?w (char-syntax (following-char))) + (eq (char-before) ?.) + (not (eq (char-before (1- (point))) ?.)))) + +(defun elixir-smie--implicit-semi-p () + (not (or (memq (char-before) '(?\{ ?\[)) + (looking-back elixir-smie--operator-regexp (- (point) 3) t)))) + +(defun elixir-smie-forward-token () + (cond + ((and (looking-at "\n") (elixir-smie--implicit-semi-p)) + (if (eolp) (forward-char 1) (forward-comment 1)) + ";") + ((looking-at elixir-smie--operator-regexp) + (goto-char (match-end 0)) + "OP") + (t (smie-default-forward-token)))) + +(defun elixir-smie-backward-token () + (let ((pos (point))) + (forward-comment (- (point))) + (cond + ((and (> pos (line-end-position)) + (elixir-smie--implicit-semi-p)) + ";") + ((looking-back elixir-smie--operator-regexp (- (point) 3) t) + (goto-char (match-beginning 0)) + "OP") + (t (smie-default-backward-token))))) + (defun verbose-elixir-smie-rules (kind token) (let ((value (elixir-smie-rules kind token))) (elixir-smie-debug "%s '%s'; sibling-p:%s parent:%s prev-is-OP:%s hanging:%s == %s" kind token From aecec4553ec267744c5553202ac2938c1b32747d Mon Sep 17 00:00:00 2001 From: Matt DeBoard Date: Mon, 18 Aug 2014 14:26:35 -0500 Subject: [PATCH 7/7] Make sure comments are handled correctly when pressing return. --- elixir-smie.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elixir-smie.el b/elixir-smie.el index 093521bf..2c414e51 100644 --- a/elixir-smie.el +++ b/elixir-smie.el @@ -99,7 +99,7 @@ (defun elixir-smie-forward-token () (cond - ((and (looking-at "\n") (elixir-smie--implicit-semi-p)) + ((and (looking-at "[\n#]") (elixir-smie--implicit-semi-p)) (if (eolp) (forward-char 1) (forward-comment 1)) ";") ((looking-at elixir-smie--operator-regexp)