From f17adc07650a3af1e10cf081764d8c761320e30a Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Fri, 1 Nov 2013 11:12:28 +1100 Subject: [PATCH] [release-branch.go1.2] misc/emacs: handle empty "import ()" in go-goto-imports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ««« CL 14454058 / 6b8f33ab7ca4 misc/emacs: handle empty "import ()" in go-goto-imports R=adonovan CC=golang-dev https://golang.org/cl/14454058 »»» R=golang-dev CC=golang-dev https://golang.org/cl/20590043 --- misc/emacs/go-mode.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/misc/emacs/go-mode.el b/misc/emacs/go-mode.el index f5d504d377..6cc03edb06 100644 --- a/misc/emacs/go-mode.el +++ b/misc/emacs/go-mode.el @@ -749,6 +749,9 @@ declaration." (let ((old-point (point))) (goto-char (point-min)) (cond + ((re-search-forward "^import ()" nil t) + (backward-char 1) + 'block-empty) ((re-search-forward "^import ([^)]+)" nil t) (backward-char 2) 'block) @@ -843,6 +846,8 @@ uncommented, otherwise a new import will be added." (uncomment-region (line-beginning-position) (line-end-position)) (case (go-goto-imports) ('fail (message "Could not find a place to add import.")) + ('block-empty + (insert "\n\t" line "\n")) ('block (save-excursion (re-search-backward "^import (")