aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix H. Dahlke2013-01-11 18:24:52 -0500
committerStefan Monnier2013-01-11 18:24:52 -0500
commitf90ff90659871ee5df8408476a3e4b832a21b17c (patch)
treecfe272437725baeba15a1da1643fdbff540c83fe
parent9fc9a531a5938e870339211de6c0ecfedaa1c86b (diff)
downloademacs-f90ff90659871ee5df8408476a3e4b832a21b17c.tar.gz
emacs-f90ff90659871ee5df8408476a3e4b832a21b17c.zip
* lisp/progmodes/js.el: Fix multiline declarations's indentation.
(js--declaration-keyword-re): New var. (js--multi-line-declaration-indentation): New function. (js--proper-indentation): Use it. Fixes: debbugs:8576
-rw-r--r--lisp/ChangeLog107
-rw-r--r--lisp/progmodes/js.el37
2 files changed, 70 insertions, 74 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a2dfb8023b3..c600e37570f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,102 +1,63 @@
12013-01-11 Aaron S. Hawley <Aaron.Hawley@vtinfo.com> 12013-01-11 Felix H. Dahlke <fhd@ubercode.de>
2
3 * calc/calc.el (calc-highlight-selections-with-faces)
4 (calc-dispatch): Fix ambiguous doc string cross-reference(s).
5 2
6 * comint.el (comint-history-isearch-message): Fix ambiguous doc 3 * progmodes/js.el: Fix multiline declarations's indentation (bug#8576).
7 string cross-reference(s). 4 (js--declaration-keyword-re): New var.
5 (js--multi-line-declaration-indentation): New function.
6 (js--proper-indentation): Use it.
8 7
9 * emacs-lisp/edebug.el (edebug-read, edebug-eval-defun): Fix 82013-01-11 Aaron S. Hawley <Aaron.Hawley@vtinfo.com>
10 ambiguous doc string cross-reference(s).
11 9
10 * calc/calc.el (calc-highlight-selections-with-faces)
11 (calc-dispatch):
12 * comint.el (comint-history-isearch-message):
13 * emacs-lisp/edebug.el (edebug-read, edebug-eval-defun):
12 * ffap.el (ffap-string-at-point-region, ffap-next) 14 * ffap.el (ffap-string-at-point-region, ffap-next)
13 (ffap-string-at-point, ffap-string-around) 15 (ffap-string-at-point, ffap-string-around)
14 (ffap-copy-string-as-kill, ffap-highlight-overlay) 16 (ffap-copy-string-as-kill, ffap-highlight-overlay)
15 (ffap-literally): Fix ambiguous doc string cross-reference(s). 17 (ffap-literally):
16
17 * font-lock.el (font-lock-keywords-alist) 18 * font-lock.el (font-lock-keywords-alist)
18 (font-lock-removed-keywords-alist): Fix ambiguous doc string 19 (font-lock-removed-keywords-alist):
19 cross-reference(s). 20 * help-mode.el (help-xref-symbol-regexp):
20 21 * info.el (Info-find-emacs-command-nodes):
21 * help-mode.el (help-xref-symbol-regexp): Add "call" as a hint for 22 * international/mule.el (add-to-coding-system-list):
22 a cross-reference to a function. 23 * isearch.el (isearch-message-function, isearch-fail-pos):
23 24 * misearch.el (multi-isearch-next-buffer-function):
24 * info.el (Info-find-emacs-command-nodes): Fix ambiguous doc 25 * newcomment.el (comment-box):
25 string cross-reference(s).
26
27 * international/mule.el (add-to-coding-system-list): Fix ambiguous
28 doc string cross-reference(s).
29
30 * isearch.el (isearch-message-function, isearch-fail-pos): Fix
31 ambiguous doc string cross-reference(s).
32
33 * misearch.el (multi-isearch-next-buffer-function): Fix ambiguous
34 doc string cross-reference(s).
35
36 * newcomment.el (comment-box): Fix ambiguous doc string
37 cross-reference(s).
38
39 * printing.el (pr-txt-printer-alist, pr-ps-printer-alist) 26 * printing.el (pr-txt-printer-alist, pr-ps-printer-alist)
40 (pr-setting-database): Fix ambiguous doc string 27 (pr-setting-database):
41 cross-reference(s).
42
43 * progmodes/cc-fonts.el (c-font-lock-keywords-3) 28 * progmodes/cc-fonts.el (c-font-lock-keywords-3)
44 (c++-font-lock-keywords-3, objc-font-lock-keywords-3) 29 (c++-font-lock-keywords-3, objc-font-lock-keywords-3)
45 (java-font-lock-keywords-3, idl-font-lock-keywords-3) 30 (java-font-lock-keywords-3, idl-font-lock-keywords-3)
46 (pike-font-lock-keywords-3): Fix ambiguous doc string 31 (pike-font-lock-keywords-3):
47 cross-reference(s). 32 * progmodes/compile.el (compile):
48
49 * progmodes/compile.el (compile): Fix ambiguous doc string
50 cross-reference(s).
51
52 * progmodes/etags.el (tags-table-files) 33 * progmodes/etags.el (tags-table-files)
53 (tags-table-files-function, tags-included-tables-function): Fix 34 (tags-table-files-function, tags-included-tables-function):
54 ambiguous doc string cross-reference(s).
55
56 * progmodes/gdb-mi.el (gdb, gdb-setup-windows) 35 * progmodes/gdb-mi.el (gdb, gdb-setup-windows)
57 (gdb-restore-windows): Fix ambiguous doc string 36 (gdb-restore-windows):
58 cross-reference(s).
59
60 * ps-print.el (ps-even-or-odd-pages, ps-spool-buffer-with-faces) 37 * ps-print.el (ps-even-or-odd-pages, ps-spool-buffer-with-faces)
61 (ps-n-up-filling-database): Fix ambiguous doc string 38 (ps-n-up-filling-database):
62 cross-reference(s). 39 * server.el (server-buffer, server-log):
63
64 * server.el (server-buffer, server-log): Fix ambiguous doc string
65 cross-reference(s).
66
67 * simple.el (newline, delete-backward-char, delete-forward-char) 40 * simple.el (newline, delete-backward-char, delete-forward-char)
68 (minibuffer-history-isearch-message, kill-line, track-eol) 41 (minibuffer-history-isearch-message, kill-line, track-eol)
69 (temporary-goal-column): Fix ambiguous doc string 42 (temporary-goal-column):
70 cross-reference(s).
71
72 * textmodes/flyspell.el (flyspell-mark-duplications-flag) 43 * textmodes/flyspell.el (flyspell-mark-duplications-flag)
73 (flyspell-default-deplacement-commands): Fix ambiguous doc string 44 (flyspell-default-deplacement-commands):
74 cross-reference(s). 45 * textmodes/ispell.el (ispell-accept-output):
75 46 * textmodes/sgml-mode.el (html-tag-help):
76 * textmodes/ispell.el (ispell-accept-output): Fix ambiguous doc
77 string cross-reference(s).
78
79 * textmodes/sgml-mode.el (html-tag-help): Fix ambiguous doc string
80 cross-reference(s).
81
82 * vc/compare-w.el (compare-ignore-whitespace) 47 * vc/compare-w.el (compare-ignore-whitespace)
83 (compare-ignore-case, compare-windows-dehighlight): Fix ambiguous 48 (compare-ignore-case, compare-windows-dehighlight):
84 doc string cross-reference(s). 49 * vc/diff.el (diff):
85
86 * vc/diff.el (diff): Fix ambiguous doc string cross-reference(s).
87
88 * whitespace.el (whitespace-point) 50 * whitespace.el (whitespace-point)
89 (whitespace-font-lock-refontify, whitespace-bob-marker) 51 (whitespace-font-lock-refontify, whitespace-bob-marker)
90 (whitespace-eob-marker): Fix ambiguous doc string 52 (whitespace-eob-marker): Fix ambiguous doc string cross-reference(s).
91 cross-reference(s).
92 53
932013-01-11 Michael Albinus <michael.albinus@gmx.de> 542013-01-11 Michael Albinus <michael.albinus@gmx.de>
94 55
95 * autorevert.el (top): Require 'cl in order to pacify byte compiler. 56 * autorevert.el (top): Require 'cl in order to pacify byte compiler.
96 (auto-revert-notify-rm-watch): Ignore errors. 57 (auto-revert-notify-rm-watch): Ignore errors.
97 (auto-revert-notify-add-watch): Ignore errors. Use '(modify) for 58 (auto-revert-notify-add-watch): Ignore errors. Use '(modify) for
98 inotify, and '(size last-write-time) for w32notify. Set 59 inotify, and '(size last-write-time) for w32notify.
99 buffer-local `auto-revert-use-notify' to nil when adding a file 60 Set buffer-local `auto-revert-use-notify' to nil when adding a file
100 watch fails - this is a fallback to the file modification check. 61 watch fails - this is a fallback to the file modification check.
101 (auto-revert-notify-event-p, auto-revert-notify-event-descriptor) 62 (auto-revert-notify-event-p, auto-revert-notify-event-descriptor)
102 (auto-revert-notify-event-action) 63 (auto-revert-notify-event-action)
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 683b3927ae3..96e6039a8c2 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1680,12 +1680,15 @@ This performs fontification according to `js--class-styles'."
1680 "each")) 1680 "each"))
1681 "Regexp matching keywords optionally followed by an opening brace.") 1681 "Regexp matching keywords optionally followed by an opening brace.")
1682 1682
1683(defconst js--declaration-keyword-re
1684 (regexp-opt '("var" "let" "const") 'words)
1685 "Regular expression matching variable declaration keywords.")
1686
1683(defconst js--indent-operator-re 1687(defconst js--indent-operator-re
1684 (concat "[-+*/%<>=&^|?:.]\\([^-+*/]\\|$\\)\\|" 1688 (concat "[-+*/%<>=&^|?:.]\\([^-+*/]\\|$\\)\\|"
1685 (js--regexp-opt-symbol '("in" "instanceof"))) 1689 (js--regexp-opt-symbol '("in" "instanceof")))
1686 "Regexp matching operators that affect indentation of continued expressions.") 1690 "Regexp matching operators that affect indentation of continued expressions.")
1687 1691
1688
1689(defun js--looking-at-operator-p () 1692(defun js--looking-at-operator-p ()
1690 "Return non-nil if point is on a JavaScript operator, other than a comma." 1693 "Return non-nil if point is on a JavaScript operator, other than a comma."
1691 (save-match-data 1694 (save-match-data
@@ -1764,6 +1767,37 @@ nil."
1764 (list (cons 'c js-comment-lineup-func)))) 1767 (list (cons 'c js-comment-lineup-func))))
1765 (c-get-syntactic-indentation (list (cons symbol anchor))))) 1768 (c-get-syntactic-indentation (list (cons symbol anchor)))))
1766 1769
1770(defun js--multi-line-declaration-indentation ()
1771 "Helper function for `js--proper-indentation'.
1772Return the proper indentation of the current line if it belongs to a declaration
1773statement spanning multiple lines; otherwise, return nil."
1774 (let (at-opening-bracket)
1775 (save-excursion
1776 (back-to-indentation)
1777 (when (not (looking-at js--declaration-keyword-re))
1778 (when (looking-at js--indent-operator-re)
1779 (goto-char (match-end 0)))
1780 (while (and (not at-opening-bracket)
1781 (not (bobp))
1782 (let ((pos (point)))
1783 (save-excursion
1784 (js--backward-syntactic-ws)
1785 (or (eq (char-before) ?,)
1786 (and (not (eq (char-before) ?\;))
1787 (prog2
1788 (skip-chars-backward "[[:punct:]]")
1789 (looking-at js--indent-operator-re)
1790 (js--backward-syntactic-ws))
1791 (not (eq (char-before) ?\;)))
1792 (and (>= pos (point-at-bol))
1793 (<= pos (point-at-eol)))))))
1794 (condition-case err
1795 (backward-sexp)
1796 (scan-error (setq at-opening-bracket t))))
1797 (when (looking-at js--declaration-keyword-re)
1798 (goto-char (match-end 0))
1799 (1+ (current-column)))))))
1800
1767(defun js--proper-indentation (parse-status) 1801(defun js--proper-indentation (parse-status)
1768 "Return the proper indentation for the current line." 1802 "Return the proper indentation for the current line."
1769 (save-excursion 1803 (save-excursion
@@ -1772,6 +1806,7 @@ nil."
1772 (js--get-c-offset 'c (nth 8 parse-status))) 1806 (js--get-c-offset 'c (nth 8 parse-status)))
1773 ((nth 8 parse-status) 0) ; inside string 1807 ((nth 8 parse-status) 0) ; inside string
1774 ((js--ctrl-statement-indentation)) 1808 ((js--ctrl-statement-indentation))
1809 ((js--multi-line-declaration-indentation))
1775 ((eq (char-after) ?#) 0) 1810 ((eq (char-after) ?#) 0)
1776 ((save-excursion (js--beginning-of-macro)) 4) 1811 ((save-excursion (js--beginning-of-macro)) 4)
1777 ((nth 1 parse-status) 1812 ((nth 1 parse-status)