Subject: bug#15956: closed (Re: bug#15956: 24.3.50; js.el: Indentation for control statements)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 24 Nov 2013 22:04:03 +0000

Your bug report

#15956: 24.3.50; js.el: Indentation for control statements

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
15956: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15956
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#15956: 24.3.50; js.el: Indentation for control statements
From: Dmitry Gutov <[email-masked]>
To: Mihir Rege <[email-masked]>
Cc: [email-masked]
Date: Mon, 25 Nov 2013 00:03:07 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Version: 24.4

Applied, thanks!

Subject: 24.3.50; js.el: Indentation for control statements
From: Mihir Rege <[email-masked]>
To: [email-masked]
Date: Sat, 23 Nov 2013 03:44:39 +0530
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

If a control statement is the first statement in the source but is not on
the first line, the indentation keeps on increasing with each call.

For example:

---------------------------
//comment
if ( cond )
---------------------------

will indent to

---------------------------
//comment
        if (cond)
---------------------------

I have enclosed a patch that fixes the problem.

-- 
Mihir Rege
From e7ad799f7360eebc9b93176c3ce321967afc535e Mon Sep 17 00:00:00 2001
From: Mihir Rege <[email-masked]>
Date: Sat, 23 Nov 2013 03:14:27 +0530
Subject: [PATCH] Fix indentation for control statements

---
 lisp/ChangeLog       | 5 +++++
 lisp/progmodes/js.el | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 50e2ff6..ec356a5 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2013-11-22  Mihir Rege  <[email-masked]>
+
+	* progmodes/js.el (js--ctrl-statement-indentation): Fix indent
+	if control-statement is first statement in buffer.
+
 2013-11-22  Leo Liu  <[email-masked]>
 
 	* progmodes/octave.el (inferior-octave-startup): Spit out error
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 49a2193..17c1360 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1749,8 +1749,8 @@ nil."
     (when (save-excursion
             (and (not (eq (point-at-bol) (point-min)))
                  (not (looking-at "[{]"))
+                 (js--re-search-backward "[[:graph:]]" nil t)
                  (progn
-                   (js--re-search-backward "[[:graph:]]" nil t)
                    (or (eobp) (forward-char))
                    (when (= (char-before) ?\)) (backward-list))
                    (skip-syntax-backward " ")
-- 
1.8.1.2