summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorGravatar Andrew J Cosgriff2010-11-09 21:19:02 +1100
committerGravatar Andrew J Cosgriff2010-11-09 21:19:02 +1100
commite60c15e2ebc6c9c5fad00e3a9c935f23cca4157c (patch)
treefbb51ca4e8ca00baa5d9f74c918ea9585c79140b
parent3d193f7e5c1459b1d07b429d5c717a80d8cbdfd5 (diff)
downloadnginx-mode-e60c15e2ebc6c9c5fad00e3a9c935f23cca4157c.tar.gz
nginx-mode-e60c15e2ebc6c9c5fad00e3a9c935f23cca4157c.zip
fix indentation of commented-out blocks, as per https://github.com/ajc/nginx-mode/issues/#issue/1
-rw-r--r--nginx-mode.el26
1 files changed, 8 insertions, 18 deletions
diff --git a/nginx-mode.el b/nginx-mode.el
index 5662f38..2297b40 100644
--- a/nginx-mode.el
+++ b/nginx-mode.el
@@ -97,7 +97,7 @@ of the closing brace of a block."
(save-excursion
(save-match-data
(beginning-of-line)
- (looking-at (format "\\s-*%s" comment-start)))))
+ (looking-at "^\\s-*#"))))
(defun nginx-indent-line ()
"Indent current line as nginx code."
@@ -109,10 +109,10 @@ of the closing brace of a block."
(block-indent (nginx-block-indent))
cur-indent)
(cond
- ((and (looking-at "^\\s-*},?\\s-*$") block-indent)
- ;; This line contains a closing brace or a closing brace followed by a
- ;; comma and we're at the inner block, so we should indent it matching
- ;; the indentation of the opening brace of the block.
+ ((and (looking-at "^\\s-*}\\s-*$") block-indent)
+ ;; This line contains a closing brace and we're at the inner
+ ;; block, so we should indent it matching the indentation of
+ ;; the opening brace of the block.
(setq cur-indent block-indent))
(t
;; Otherwise, we did not start on a block-ending-only line.
@@ -129,7 +129,7 @@ of the closing brace of a block."
;; Brace or paren on a line by itself will already be indented to
;; the right level, so we can cheat and stop there.
- ((looking-at "^\\s-*[\)}]\\s-*")
+ ((looking-at "^\\s-*}\\s-*")
(setq cur-indent (current-indentation))
(setq not-indented nil))
@@ -140,23 +140,13 @@ of the closing brace of a block."
(setq cur-indent (+ (current-indentation) nginx-indent-level))
(setq not-indented nil))
- ;; Indent by one level if the line ends with an open paren.
- ((looking-at "^.*\(\\s-*$")
- (setq cur-indent (+ (current-indentation) nginx-indent-level))
- (setq not-indented nil))
-
;; Start of buffer.
((bobp)
- (setq not-indented nil)))))
-
- ;; If this line contains only a closing paren, we should lose one
- ;; level of indentation.
- (if (looking-at "^\\s-*\)\\s-*$")
- (setq cur-indent (- cur-indent nginx-indent-level)))))
+ (setq not-indented nil)))))))
;; We've figured out the indentation, so do it.
(if (and cur-indent (> cur-indent 0))
- (indent-line-to cur-indent)
+ (indent-line-to cur-indent)
(indent-line-to 0)))))