[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode 366ada1 011/495: add tab completion for go-import-
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode 366ada1 011/495: add tab completion for go-import-add |
Date: |
Sat, 7 Aug 2021 09:04:33 -0400 (EDT) |
branch: elpa/go-mode
commit 366ada187cce335b878c11374ecaebba12e2daa1
Author: Dominik Honnef <dominikh@fork-bomb.org>
Commit: Dominik Honnef <dominikh@fork-bomb.org>
add tab completion for go-import-add
---
go-mode.el | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 55 insertions(+), 2 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index 95d8410..3a2e864 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -556,7 +556,10 @@ When called with a prefix argument asks for an alternative
name
to import the package as.
If no list exists yet, one will be created if possible."
- (interactive "P\nMPackage: ")
+ (interactive
+ (list
+ current-prefix-arg
+ (completing-read "Package: " (go-packages))))
(save-excursion
(let (as line)
(if arg
@@ -570,5 +573,55 @@ If no list exists yet, one will be created if possible."
('single (insert "import " line "\n"))
('none (insert "\nimport (\n\t" line "\n)\n"))))))
-(provide 'go-mode)
+(defun go-directory-dirs (dir)
+ (unless (file-directory-p dir)
+ (error "Not a directory `%s'" dir))
+ (let ((dir (directory-file-name dir))
+ (dirs '())
+ (files (directory-files dir nil nil t)))
+ (dolist (file files)
+ (unless (member file '("." ".."))
+ (let ((file (concat dir "/" file)))
+ (when (file-directory-p file)
+ (setq dirs (append (cons file
+ (go-directory-dirs file))
+ dirs))))))
+ dirs))
+
+(defun go-flatten (lst)
+ (if (atom lst)
+ (list lst)
+ (let ((item (car lst))
+ (rest (cdr lst)))
+ (if (not (atom item))
+ (if rest
+ (append (go-flatten item) (go-flatten rest))
+ (let ((item-rest (cdr item)))
+ (if item-rest
+ (append (go-flatten (car item))(go-flatten item-rest))
+ (go-flatten (car item)))))
+ (if rest
+ (if item
+ (append (list item) (go-flatten rest))
+ (go-flatten rest))
+ (if item
+ (list item)
+ nil))))))
+
+(defun go-packages ()
+ (sort (delete-dups (go-flatten (mapcar (lambda (topdir)
+ (let ((pkgdir (concat topdir "/pkg/")))
+ (mapcar (lambda (dir)
+ (mapcar (lambda (file)
+ (let ((sub (substring file (length
pkgdir) -2)))
+ (unless (or (string-prefix-p
"obj/" sub) (string-prefix-p "tool/" sub))
+ (mapconcat 'identity (cdr
(split-string sub "/")) "/")
+ )
+ ))
+ (directory-files dir t "\\.a$")))
+ (go-directory-dirs pkgdir))
+ ))
+ (list (getenv "GOROOT") (getenv "GOPATH"))))) 'string<))
+
+(provide 'go-mode)
- [nongnu] branch elpa/go-mode created (now 3497434), ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 1db78fd 001/495: initial commit, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 9af89df 006/495: add docstrings to go-goto-imports, go-play-region and go-play-buffer, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 366ada1 011/495: add tab completion for go-import-add,
ELPA Syncer <=
- [nongnu] elpa/go-mode 9536e6b 010/495: go-import-add, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode fd0c117 012/495: move list of improvements to readme, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode ca48fc5 009/495: add return values to go-goto-imports that tell which kind of import has been jumped to, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode db41787 015/495: if line has been indented with spaces, replace them with tabs, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d942d4f 013/495: add links to further extensions for editting go in emacs, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 5af4f4d 019/495: mention imenu in readme, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 4f3befb 003/495: add go-play-buffer and go-play-region, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 61467ee 004/495: add readme, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 2835258 007/495: support `import foo "bar"` syntax in go-goto-imports, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 0a570b1 014/495: use `go env` to determine goroot and gopath, support multiple gopath entries and skip over ones with no pkg dir, ELPA Syncer, 2021/08/07