From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ingo Lohmar Newsgroups: gmane.emacs.bugs Subject: bug#27503: 26.0.50; Not lining up Javascript arguments Date: Sat, 01 Jul 2017 13:23:20 +0200 Message-ID: <877ezs7653.fsf@acer.localhost.com> References: <87FF3D96-DBCF-4EBD-8E72-3F796AB89FF1@fastmail.com> <87fuel70up.fsf@acer.localhost.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1498908263 17059 195.159.176.226 (1 Jul 2017 11:24:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 1 Jul 2017 11:24:23 +0000 (UTC) Cc: 27503@debbugs.gnu.org, James Nguyen , james@jojojames.com To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jul 01 13:24:17 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dRGVZ-0003uM-SO for geb-bug-gnu-emacs@m.gmane.org; Sat, 01 Jul 2017 13:24:14 +0200 Original-Received: from localhost ([::1]:53770 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dRGVe-0006QT-FD for geb-bug-gnu-emacs@m.gmane.org; Sat, 01 Jul 2017 07:24:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dRGVT-0006QC-TJ for bug-gnu-emacs@gnu.org; Sat, 01 Jul 2017 07:24:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dRGVP-00016j-07 for bug-gnu-emacs@gnu.org; Sat, 01 Jul 2017 07:24:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44272) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dRGVO-00016L-RD for bug-gnu-emacs@gnu.org; Sat, 01 Jul 2017 07:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dRGVO-0004LW-Ft for bug-gnu-emacs@gnu.org; Sat, 01 Jul 2017 07:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ingo Lohmar Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 01 Jul 2017 11:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27503 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27503-submit@debbugs.gnu.org id=B27503.149890821016659 (code B ref 27503); Sat, 01 Jul 2017 11:24:02 +0000 Original-Received: (at 27503) by debbugs.gnu.org; 1 Jul 2017 11:23:30 +0000 Original-Received: from localhost ([127.0.0.1]:46949 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dRGUs-0004Kc-89 for submit@debbugs.gnu.org; Sat, 01 Jul 2017 07:23:30 -0400 Original-Received: from mail-wm0-f68.google.com ([74.125.82.68]:34240) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dRGUp-0004KP-Sf for 27503@debbugs.gnu.org; Sat, 01 Jul 2017 07:23:28 -0400 Original-Received: by mail-wm0-f68.google.com with SMTP id p204so12095613wmg.1 for <27503@debbugs.gnu.org>; Sat, 01 Jul 2017 04:23:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=YICGvbNetsaoItDau+5T+/RZW3p43yXpp2QFGr1pa7U=; b=cgab5/VnhQEeQWl5jJkgW4oVWwUgVcRN7ch4mVMaIYr9SRilE1wgWwreHLyzUIrncm vz3jxot9XO4Gz5cw4+taVsTgegdG1ZA757JrKm7npXo9h5vRTwQeDuULNQyOxbjuefpW X/431tk4csJw/+LNemC0pkiv6N5HNs2E+0tS30E/N6UQFvEMuD86+oaxLr7Sx2E1/XSr PBl/sfaNFLjMJqWds961ndD9x2wh2ICK+e6lOefqBdZbgZarC34YAoHRCzlsYUtncgEA 0WrpnkUtGGLTYFKE3ZvxqTKCqQe0VPWp/W0RkZ5G8ieNF2IDvhhPyzS/JQuussMbvZUU OMgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=YICGvbNetsaoItDau+5T+/RZW3p43yXpp2QFGr1pa7U=; b=U/HgLp36lzMdt4VD5YFzmJJPocKCpj6adqAWg8D6wDY6oPvR4+Ll4kUkjg8kpwF56d HUioeR32I/DJF5vSrx32/ZdaxlSpsBNVS5LoJCLdqe7pp++SsH+8nKTxmM5llB5u3BkG 6Tp7zGp0RKVRKWVso9z7Fiwj9IUfmyciWmTjSepUEVG3UxyYn5Ltk0zkXFmOLQOgMUHR W+bqiWd4WcVExd9NtcH62FeLEExnGFDIVDDwZnLwciWPYXpTbLI5Yr1vh4O2ekALf0a2 9ywg3PZMH4nRGjfZ/HeQALEsJpy1diPu08oxSYqqk+rH/k7uoe/9db/FxusJ12dWrqEa GwFg== X-Gm-Message-State: AKS2vOz+pxrjnuDMxsdkENEFT3zybHvIrlII9aghkNwOO8As2BWuACeN JGUaWOdGDpP91w== X-Received: by 10.80.224.2 with SMTP id e2mr8661207edl.21.1498908201870; Sat, 01 Jul 2017 04:23:21 -0700 (PDT) Original-Received: from localhost (xdsl-87-79-227-74.netcologne.de. [87.79.227.74]) by smtp.gmail.com with ESMTPSA id g38sm4098039edc.7.2017.07.01.04.23.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Jul 2017 04:23:21 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:134068 Archived-At: 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 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