aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2014-11-16 14:19:16 +0200
committerDmitry Gutov2014-11-16 14:19:16 +0200
commitc613f4d6c12ad7a8ebbc88dcef48949c6a775996 (patch)
tree7fba3c7867dedc72fd47227700a99edb22605f80
parent202f4941dc13c82aea36258421351420a34b7133 (diff)
downloademacs-c613f4d6c12ad7a8ebbc88dcef48949c6a775996.tar.gz
emacs-c613f4d6c12ad7a8ebbc88dcef48949c6a775996.zip
Fix indentation before `!=' and after `+='
Originally reported in https://github.com/mooz/js2-mode/issues/174. * lisp/progmodes/js.el (js--indent-operator-re): Make assignments and (in)equality operator a separate case. (js--continued-expression-p): Escape the second `+' in the regexp.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/progmodes/js.el4
-rw-r--r--test/indent/js.js8
3 files changed, 18 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ea9c8c6b2cb..442b8f69e59 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12014-11-16 Dmitry Gutov <dgutov@yandex.ru>
2
3 Fix indentation before `!=' and after `+='. Originally reported
4 in https://github.com/mooz/js2-mode/issues/174.
5 * progmodes/js.el (js--indent-operator-re): Make assignments and
6 (in)equality operator a separate case.
7 (js--continued-expression-p): Escape the second `+' in the regexp.
8
12014-11-16 Stefan Monnier <monnier@iro.umontreal.ca> 92014-11-16 Stefan Monnier <monnier@iro.umontreal.ca>
2 10
3 * window.el (handle-select-window): Deactivate shift-region (bug#19003). 11 * window.el (handle-select-window): Deactivate shift-region (bug#19003).
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index a8f0d556ec4..56569e1f972 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1685,7 +1685,7 @@ This performs fontification according to `js--class-styles'."
1685 "Regular expression matching variable declaration keywords.") 1685 "Regular expression matching variable declaration keywords.")
1686 1686
1687(defconst js--indent-operator-re 1687(defconst js--indent-operator-re
1688 (concat "[-+*/%<>=&^|?:.]\\([^-+*/]\\|$\\)\\|" 1688 (concat "[-+*/%<>&^|?:.]\\([^-+*/]\\|$\\)\\|!?=\\|"
1689 (js--regexp-opt-symbol '("in" "instanceof"))) 1689 (js--regexp-opt-symbol '("in" "instanceof")))
1690 "Regexp matching operators that affect indentation of continued expressions.") 1690 "Regexp matching operators that affect indentation of continued expressions.")
1691 1691
@@ -1712,7 +1712,7 @@ This performs fontification according to `js--class-styles'."
1712 (save-excursion (backward-char) (not (looking-at "[/*]/"))) 1712 (save-excursion (backward-char) (not (looking-at "[/*]/")))
1713 (js--looking-at-operator-p) 1713 (js--looking-at-operator-p)
1714 (and (progn (backward-char) 1714 (and (progn (backward-char)
1715 (not (looking-at "++\\|--\\|/[/*]")))))))))) 1715 (not (looking-at "+\\+\\|--\\|/[/*]"))))))))))
1716 1716
1717 1717
1718(defun js--end-of-do-while-loop-p () 1718(defun js--end-of-do-while-loop-p ()
diff --git a/test/indent/js.js b/test/indent/js.js
index d623a0dc5bc..1924094e9d8 100644
--- a/test/indent/js.js
+++ b/test/indent/js.js
@@ -47,3 +47,11 @@ var p = {
47 47
48var evens = [e for each (e in range(0, 21)) 48var evens = [e for each (e in range(0, 21))
49 if (ed % 2 == 0)]; 49 if (ed % 2 == 0)];
50
51!b
52 !=b
53 !==b
54
55a++
56b +=
57 c