diff options
author | Ondřej Surý <ondrej@sury.org> | 2012-03-26 16:50:58 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2012-03-26 16:50:58 +0200 |
commit | 519725bb3c075ee2462c929f5997cb068e18466a (patch) | |
tree | 5b162e8488ad147a645048c073577821b4a2bee9 /misc/emacs/go-mode.el | |
parent | 842623c5dd2819d980ca9c58048d6bc6ed82475f (diff) | |
download | golang-upstream-weekly/2012.03.22.tar.gz |
Imported Upstream version 2012.03.22upstream-weekly/2012.03.22
Diffstat (limited to 'misc/emacs/go-mode.el')
-rw-r--r-- | misc/emacs/go-mode.el | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/misc/emacs/go-mode.el b/misc/emacs/go-mode.el index 7fe0934ff..1af38e3d0 100644 --- a/misc/emacs/go-mode.el +++ b/misc/emacs/go-mode.el @@ -406,6 +406,22 @@ token on the line." (when (/= (skip-chars-backward "[:word:]_") 0) (not (looking-at go-mode-non-terminating-keywords-regexp))))))) +(defun go-mode-backward-skip-comments () + "Skip backward over comments and whitespace." + (when (not (bobp)) + (backward-char)) + (while (and (not (bobp)) + (or (eq 32 (char-syntax (char-after (point)))) + (go-mode-cs))) + (skip-syntax-backward "-") + (when (and (not (bobp)) (eq 32 (char-syntax (char-after (point))))) + (backward-char)) + (when (go-mode-cs) + (let ((pos (previous-single-property-change (point) 'go-mode-cs))) + (if pos (goto-char pos) (goto-char (point-min)))))) + (when (and (not (go-mode-cs)) (eq 32 (char-syntax (char-after (1+ (point)))))) + (forward-char 1))) + (defun go-mode-indentation () "Compute the ideal indentation level of the current line. @@ -451,7 +467,8 @@ indented one level." (incf indent tab-width)) ((?\() (goto-char (car nest)) - (forward-comment (- (buffer-size))) + (beginning-of-line) + (go-mode-backward-skip-comments) ;; Really just want the token before (when (looking-back "\\<import\\|const\\|var\\|type" (max (- (point) 7) (point-min))) @@ -465,7 +482,8 @@ indented one level." (decf indent tab-width)) ;; Continuation lines are indented 1 level - (forward-comment (- (buffer-size))) + (beginning-of-line) + (go-mode-backward-skip-comments) (when (case (char-before) ((nil ?\{ ?:) ;; At the beginning of a block or the statement |