]> Cypherpunks repositories - gostls13.git/commitdiff
misc/emacs: handle empty "import ()" in go-goto-imports
authorDominik Honnef <dominik.honnef@gmail.com>
Tue, 22 Oct 2013 16:35:04 +0000 (12:35 -0400)
committerAlan Donovan <adonovan@google.com>
Tue, 22 Oct 2013 16:35:04 +0000 (12:35 -0400)
R=adonovan
CC=golang-dev
https://golang.org/cl/14454058

misc/emacs/go-mode.el

index f5d504d37785a5ebb5d8e1591cb57cc571aff8e7..6cc03edb06022d2c5085b1c8a46da992c2d29304 100644 (file)
@@ -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 (")