From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#8576: 23.2; js-mode doesn't support multi-line variable declarations Date: Tue, 17 Jul 2012 02:32:40 -0400 Message-ID: References: <4DB915B0.7010605@ubercode.de> <5004F15E.9040101@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1342506798 29191 80.91.229.3 (17 Jul 2012 06:33:18 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 17 Jul 2012 06:33:18 +0000 (UTC) Cc: 8576@debbugs.gnu.org, fhd@ubercode.de To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jul 17 08:33:17 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Sr1LM-0001iA-7f for geb-bug-gnu-emacs@m.gmane.org; Tue, 17 Jul 2012 08:33:12 +0200 Original-Received: from localhost ([::1]:33558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sr1LL-0000oO-Ap for geb-bug-gnu-emacs@m.gmane.org; Tue, 17 Jul 2012 02:33:11 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:39623) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sr1LI-0000oH-Aj for bug-gnu-emacs@gnu.org; Tue, 17 Jul 2012 02:33:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sr1LE-0000G6-4j for bug-gnu-emacs@gnu.org; Tue, 17 Jul 2012 02:33:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:35590) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sr1LE-0000EU-1Z for bug-gnu-emacs@gnu.org; Tue, 17 Jul 2012 02:33:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1Sr1Qz-0002mt-RV for bug-gnu-emacs@gnu.org; Tue, 17 Jul 2012 02:39:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Jul 2012 06:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8576 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 8576-submit@debbugs.gnu.org id=B8576.134250712610692 (code B ref 8576); Tue, 17 Jul 2012 06:39:01 +0000 Original-Received: (at 8576) by debbugs.gnu.org; 17 Jul 2012 06:38:46 +0000 Original-Received: from localhost ([127.0.0.1]:45136 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Sr1Qj-0002mP-Go for submit@debbugs.gnu.org; Tue, 17 Jul 2012 02:38:45 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:33155) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Sr1Qh-0002mH-3M for 8576@debbugs.gnu.org; Tue, 17 Jul 2012 02:38:44 -0400 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id q6H6WeLn030936; Tue, 17 Jul 2012 02:32:41 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 17DB6AE508; Tue, 17 Jul 2012 02:32:40 -0400 (EDT) In-Reply-To: <5004F15E.9040101@yandex.ru> (Dmitry Gutov's message of "Tue, 17 Jul 2012 09:00:14 +0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4281=0 X-NAI-Spam-Version: 2.2.0.9309 : core <4281> : streams <786018> : uri <1167317> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:62025 Archived-At: > const a = 5, > b = 6; Yup, that'd be a bug. >>>> The only solution I can think of would be to go back up after >>>> typing a closing brace followed by a comma and indent the >>>> preceeding lines. >>>> Some modes do that, but it would require drastic changes to js.el. >>>> I'd rather get this patch in first and see if the issue annoys me >>>> (or anyone else) enough to work further on this. >>> I don't think this will be much of a problem. >> Probably not, but I fear it's going to be a lot of work - at least >> when I do it. > I meant that nobody will care, most likely. But the implementation > shouldn't be too hard either - add a function to `post-command-hook' > which would check if the command is `self-insert-command', check if we > inserted a comma, skip backward to the previous non-whitespace char, see > if it's } or ], etc. Rather than a post-command-hook, that would be a post-self-insert-hook. And that would need to be conditional on some js-electric-foo variable (or better yet, be made to work with electric-indent-mode). Note that looking forward during indentation, while occasionally annoying, is not that big of a problem in practice: contrary to popular belief, we don't write code quite as linearly as one might think. We at least as frequently edit code in place. BTW, rather than a post-self-insert-hook, you could put a special text-property `js--indent-depends-on-next-line' on the line, and then when indenting a line, you could check if the previous line has that property and if so indent both lines. I'm not claiming it's a better approach, just an alternative one. Stefan