emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 9ac7dcc: Offer non-aligned indentation in lists in


From: Ingo Lohmar
Subject: [Emacs-diffs] master 9ac7dcc: Offer non-aligned indentation in lists in js-mode (Bug#27503)
Date: Mon, 3 Jul 2017 14:12:49 -0400 (EDT)

branch: master
commit 9ac7dccc51ee834b06cdabf6a5746eb375f984f0
Author: Ingo Lohmar <address@hidden>
Commit: Ingo Lohmar <address@hidden>

    Offer non-aligned indentation in lists in js-mode (Bug#27503)
    
    * lisp/progmodes/js.el (js--proper-indentation):
    New customization option 'js-indent-align-list-continuation'.
    Affects argument lists as well as arrays and object properties.
    * test/manual/indent/js-indent-align-list-continuation-nil.js:
    Test the change.
---
 etc/NEWS                                             |  9 ++++++++-
 lisp/progmodes/js.el                                 |  8 +++++++-
 .../indent/js-indent-align-list-continuation-nil.js  | 20 ++++++++++++++++++++
 3 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 2afed2d..a766642 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -839,8 +839,15 @@ initialization files.
 ---
 ** 'auto-revert-use-notify' is set back to t in 'global-auto-revert-mode'.
 
+** JS mode
+
+---
+*** JS mode now sets 'comment-multi-line' to t.
+
 ---
-** JS mode now sets 'comment-multi-line' to t.
+*** New variable 'js-indent-align-list-continuation', when set to nil,
+will not align continuations of bracketed lists, but will indent them
+by the fixed width 'js-indent-level'.
 
 ** CSS mode
 
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index bae9e52..e6ffe4d 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -475,6 +475,11 @@ This applies to function movement, marking, and so on."
   :type 'boolean
   :group 'js)
 
+(defcustom js-indent-align-list-continuation t
+  "Align continuation of non-empty ([{ lines in `js-mode'."
+  :type 'boolean
+  :group 'js)
+
 (defcustom js-comment-lineup-func #'c-lineup-C-comments
   "Lineup function for `cc-mode-style', for C comments in `js-mode'."
   :type 'function
@@ -2092,7 +2097,8 @@ indentation is aligned to that column."
                  (switch-keyword-p (looking-at "default\\_>\\|case\\_>[^:]"))
                  (continued-expr-p (js--continued-expression-p)))
              (goto-char (nth 1 parse-status)) ; go to the opening char
-             (if (looking-at "[({[]\\s-*\\(/[/*]\\|$\\)")
+             (if (or (not js-indent-align-list-continuation)
+                     (looking-at "[({[]\\s-*\\(/[/*]\\|$\\)"))
                  (progn ; nothing following the opening paren/bracket
                    (skip-syntax-backward " ")
                    (when (eq (char-before) ?\)) (backward-list))
diff --git a/test/manual/indent/js-indent-align-list-continuation-nil.js 
b/test/manual/indent/js-indent-align-list-continuation-nil.js
new file mode 100644
index 0000000..383b253
--- /dev/null
+++ b/test/manual/indent/js-indent-align-list-continuation-nil.js
@@ -0,0 +1,20 @@
+const funcAssignment = function (arg1,
+    arg2,
+    arg3) {
+    return { test: this,
+        which: "would",
+        align: "as well with the default setting"
+    };
+}
+
+function funcDeclaration(arg1,
+    arg2
+) {
+    return [arg1,
+        arg2];
+}
+
+// Local Variables:
+// indent-tabs-mode: nil
+// js-indent-align-list-continuation: nil
+// End:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]