unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#15956: 24.3.50; js.el: Indentation for control statements
@ 2013-11-22 22:14 Mihir Rege
  2013-11-24 22:03 ` Dmitry Gutov
  0 siblings, 1 reply; 2+ messages in thread
From: Mihir Rege @ 2013-11-22 22:14 UTC (permalink / raw)
  To: 15956


[-- Attachment #1.1: Type: text/plain, Size: 407 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 725 bytes --]

[-- Attachment #2: 0001-Fix-indentation-for-control-statements.patch --]
[-- Type: text/x-patch, Size: 1352 bytes --]

From e7ad799f7360eebc9b93176c3ce321967afc535e Mon Sep 17 00:00:00 2001
From: Mihir Rege <mihirrege@gmail.com>
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  <mihirrege@gmail.com>
+
+	* progmodes/js.el (js--ctrl-statement-indentation): Fix indent
+	if control-statement is first statement in buffer.
+
 2013-11-22  Leo Liu  <sdl.web@gmail.com>
 
 	* 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#15956: 24.3.50; js.el: Indentation for control statements
  2013-11-22 22:14 bug#15956: 24.3.50; js.el: Indentation for control statements Mihir Rege
@ 2013-11-24 22:03 ` Dmitry Gutov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Gutov @ 2013-11-24 22:03 UTC (permalink / raw)
  To: Mihir Rege; +Cc: 15956-done

Version: 24.4

Applied, thanks!





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-11-24 22:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-22 22:14 bug#15956: 24.3.50; js.el: Indentation for control statements Mihir Rege
2013-11-24 22:03 ` Dmitry Gutov

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).