From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: jaseemabid@gmail.com Newsgroups: gmane.emacs.bugs Subject: bug#8576: 23.2; , js-mode doesn't support multi-line variable declarations Date: Thu, 5 Jul 2012 18:23:07 -0700 (PDT) Message-ID: <98492e27-9d98-4a92-9704-3d0ea14e7795@googlegroups.com> References: <4DB915B0.7010605@ubercode.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1341537857 25149 80.91.229.3 (6 Jul 2012 01:24:17 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 6 Jul 2012 01:24:17 +0000 (UTC) Cc: 8576@debbugs.gnu.org To: gnu.emacs.bug@googlegroups.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 06 03:24:16 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 1SmxHJ-00053d-OC for geb-bug-gnu-emacs@m.gmane.org; Fri, 06 Jul 2012 03:24:13 +0200 Original-Received: from localhost ([::1]:42401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmxHI-0002c2-OJ for geb-bug-gnu-emacs@m.gmane.org; Thu, 05 Jul 2012 21:24:12 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:39656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmxHF-0002bx-8w for bug-gnu-emacs@gnu.org; Thu, 05 Jul 2012 21:24:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SmxHD-0002cm-56 for bug-gnu-emacs@gnu.org; Thu, 05 Jul 2012 21:24:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41618) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SmxHD-0002cf-0o for bug-gnu-emacs@gnu.org; Thu, 05 Jul 2012 21:24:07 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SmxLx-0003FZ-Qn for bug-gnu-emacs@gnu.org; Thu, 05 Jul 2012 21:29:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: jaseemabid@gmail.com Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 06 Jul 2012 01:29: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.134153808612429 (code B ref 8576); Fri, 06 Jul 2012 01:29:01 +0000 Original-Received: (at 8576) by debbugs.gnu.org; 6 Jul 2012 01:28:06 +0000 Original-Received: from localhost ([127.0.0.1]:51164 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SmxL3-0003EP-VB for submit@debbugs.gnu.org; Thu, 05 Jul 2012 21:28:06 -0400 Original-Received: from mail-pb0-f64.google.com ([209.85.160.64]:53905) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SmxL1-0003EH-PF for 8576@debbugs.gnu.org; Thu, 05 Jul 2012 21:28:04 -0400 Original-Received: by pbbrp2 with SMTP id rp2so9244591pbb.9 for <8576@debbugs.gnu.org>; Thu, 05 Jul 2012 18:23:07 -0700 (PDT) Original-Received: by 10.68.222.197 with SMTP id qo5mr1009601pbc.13.1341537787449; Thu, 05 Jul 2012 18:23:07 -0700 (PDT) Original-Path: glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.bug In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=202.164.150.205; posting-account=qlHYbgoAAADiP6UEkngAlD5wgmBJBKVL Original-NNTP-Posting-Host: 202.164.150.205 User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 202.164.150.205 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:61633 Archived-At: On Friday, 6 July 2012 06:22:23 UTC+5:30, Dmitry Gutov wrote: > > When the first var is staring with an offset, like inside a nested > > function or something, this is failing. It feels like the second line > > is indented wrt to coloumn 0 and not wrt to the "var" statement. > > Reproduced when `indent-tabs-mode' is t. > > Here's the updated patch for trunk. > > -- Dmitry > > > diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el > index 2e943be..98883a9 100644 > --- a/lisp/progmodes/js.el > +++ b/lisp/progmodes/js.el > @@ -1680,6 +1680,9 @@ This performs fontification according to `js--class-styles'." > (js--regexp-opt-symbol '("in" "instanceof"))) > "Regexp matching operators that affect indentation of continued expressions.") > > +(defconst js--declaration-keyword-re > + (regexp-opt '("var" "let" "const") 'words) > + "Regular matching variable declaration keywords.") > > (defun js--looking-at-operator-p () > "Return non-nil if point is on a JavaScript operator, other than a comma." > @@ -1759,6 +1762,42 @@ nil." > (list (cons 'c js-comment-lineup-func)))) > (c-get-syntactic-indentation (list (cons symbol anchor))))) > > +(defun js--multiline-decl-indentation () > + "Returns the declaration indentation column if the current line belongs > +to a multiline declaration statement. All declarations are lined up vertically: > + > +var a = 10, > + b = 20, > + c = 30; > +" > + (let (at-opening-bracket) > + (save-excursion > + (back-to-indentation) > + (when (not (looking-at js--declaration-keyword-re)) > + (when (looking-at js--indent-operator-re) > + (goto-char (match-end 0))) > + (while (and (not at-opening-bracket) > + (not (bobp)) > + (let ((pos (point))) > + (save-excursion > + (js--backward-syntactic-ws) > + (or (eq (char-before) ?,) > + (and (not (eq (char-before) ?\;)) > + (and > + (prog2 > + (skip-chars-backward "[[:punct:]]") > + (looking-at js--indent-operator-re) > + (js--backward-syntactic-ws)) > + (not (eq (char-before) ?\;)))) > + (and (>= pos (point-at-bol)) > + (<= pos (point-at-eol))))))) > + (condition-case err > + (backward-sexp) > + (scan-error (setq at-opening-bracket t)))) > + (when (looking-at js--declaration-keyword-re) > + (goto-char (match-end 0)) > + (1+ (current-column))))))) > + > (defun js--proper-indentation (parse-status) > "Return the proper indentation for the current line." > (save-excursion > @@ -1769,6 +1808,7 @@ nil." > ((js--ctrl-statement-indentation)) > ((eq (char-after) ?#) 0) > ((save-excursion (js--beginning-of-macro)) 4) > + ((js--multiline-decl-indentation)) > ((nth 1 parse-status) > ;; A single closing paren/bracket should be indented at the > ;; same level as the opening statement. Same goes for In the mean while, I tried js2-mode. Reported the same issue there. Fixed it here : https://github.com/mooz/js2-mode/commit/3ee849316253121ec4ee51268bc814ab60d63b2f