]> Cypherpunks repositories - gostls13.git/commitdiff
misc/emacs: refine label detection
authorRuss Cox <rsc@golang.org>
Wed, 24 Aug 2011 20:47:12 +0000 (16:47 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 24 Aug 2011 20:47:12 +0000 (16:47 -0400)
Based on idea in
http://patch-tracker.debian.org/patch/series/view/golang/1:59-1/008-emacs-mode-key-literal-indent.patch

Fixes #2174.

R=amdragon, ajmani, amdragon
CC=golang-dev
https://golang.org/cl/4922049

misc/emacs/go-mode.el

index ba7f72397dba8d15979253c87e657c4d042e6074..1c90af865f2a13338cd9c871c439a46b9885c045 100644 (file)
@@ -7,7 +7,6 @@
 ;;; To do:
 
 ;; * Indentation is *almost* identical to gofmt
-;; ** We think struct literal keys are labels and outdent them
 ;; ** We disagree on the indentation of function literals in arguments
 ;; ** There are bugs with the close brace of struct literals
 ;; * Highlight identifiers according to their syntactic context: type,
@@ -401,7 +400,8 @@ indented one level."
                 (setq first nil))))
 
           ;; case, default, and labels are outdented 1 level
-          (when (looking-at "\\<case\\>\\|\\<default\\>\\|\\w+\\s *:\\(\\S.\\|$\\)")
+          ;; assume that labels are alone on the line
+          (when (looking-at "\\<case\\>\\|\\<default\\>\\|\\w+\\s *:\\s *$")
             (decf indent tab-width))
 
           ;; Continuation lines are indented 1 level