From: Ingo Lohmar <i.lohmar@gmail.com>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 27503@debbugs.gnu.org, James Nguyen <jamesn@fastmail.com>,
james@jojojames.com
Subject: bug#27503: 26.0.50; Not lining up Javascript arguments
Date: Sat, 01 Jul 2017 13:23:20 +0200 [thread overview]
Message-ID: <877ezs7653.fsf@acer.localhost.com> (raw)
In-Reply-To: <b5e8e60e-98f3-3086-4063-39fc904e92a7@yandex.ru>
On Thu, Jun 29 2017 03:52 (+0300), Dmitry Gutov wrote:
> On 6/28/17 5:56 PM, Ingo Lohmar wrote:
>> Rigidly was just meant as the opposite of the default "aligned"
>> indentation, I am not attached to the variable name *at all*. Maybe
>> ...-indent-aligned and change the default to t?
>
> Sounds good to me. Maybe also add an example file in test/manual/indent?
Hi Dmitry,
I hope I understood the manual/indent idea correctly. Below is the
updated patch including a test file.
I changed the variable name to `js-indent-cont-nonempty-aligned' now
(with "flipped" boolean meaning, as discussed before). This is more
succinct and starts with `js-indent-...' to convey the feature area to
which this setting belongs.
What's the procedure for patches arising from a bug report --- should I
add a NEWS entry (for 26.1, marked +++) and just commit this to master
myself?
From f0ec15d5fa82b0ca9b4c6aa7032262252ab63e40 Mon Sep 17 00:00:00 2001
From: Ingo Lohmar <i.lohmar@gmail.com>
Date: Sat, 1 Jul 2017 13:09:20 +0200
Subject: [PATCH] Offer non-aligned indentation in lists in js-mode (Bug#27503)
* lisp/progmodes/js.el (js--proper-indentation):
New customization option 'js-indent-cont-nonempty-aligned'. Affects
argument lists as well as arrays and object properties.
* test/manual/indent/js-indent-cont-nonempty-aligned-nil.js: Test the change.
---
lisp/progmodes/js.el | 8 +++++++-
.../indent/js-indent-cont-nonempty-aligned-nil.js | 20 ++++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
create mode 100644 test/manual/indent/js-indent-cont-nonempty-aligned-nil.js
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index bae9e52bf0..d284ddae4d 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -475,6 +475,11 @@ js-flat-functions
:type 'boolean
:group 'js)
+(defcustom js-indent-cont-nonempty-aligned 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 @@ js--proper-indentation
(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-cont-nonempty-aligned)
+ (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-cont-nonempty-aligned-nil.js b/test/manual/indent/js-indent-cont-nonempty-aligned-nil.js
new file mode 100644
index 0000000000..428e922fbb
--- /dev/null
+++ b/test/manual/indent/js-indent-cont-nonempty-aligned-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-cont-nonempty-aligned: nil
+// End:
--
2.11.0
next prev parent reply other threads:[~2017-07-01 11:23 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-27 1:49 bug#27503: 26.0.50; Not lining up Javascript arguments James Nguyen
2017-06-27 18:16 ` Ingo Lohmar
2017-06-27 19:42 ` James Nguyen
2017-06-27 20:44 ` Ingo Lohmar
2017-06-28 0:45 ` James Nguyen
2017-06-28 10:36 ` Dmitry Gutov
2017-06-28 10:57 ` Nicolas Petton
2017-06-28 10:35 ` Dmitry Gutov
2017-06-28 14:56 ` Ingo Lohmar
2017-06-29 0:52 ` Dmitry Gutov
2017-07-01 11:23 ` Ingo Lohmar [this message]
2017-07-03 2:11 ` Dmitry Gutov
2017-07-03 18:05 ` Ingo Lohmar
2017-07-03 18:21 ` Ingo Lohmar
2017-07-03 21:01 ` Dmitry Gutov
2017-07-03 23:14 ` James Nguyen
2017-07-03 20:17 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877ezs7653.fsf@acer.localhost.com \
--to=i.lohmar@gmail.com \
--cc=27503@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
--cc=james@jojojames.com \
--cc=jamesn@fastmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).