[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode 63929d2 085/495: get rid of go--flatten
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode 63929d2 085/495: get rid of go--flatten |
Date: |
Sat, 7 Aug 2021 09:04:48 -0400 (EDT) |
branch: elpa/go-mode
commit 63929d2cd6a9875a6459c9fc33ea8baf351239d9
Author: Dominik Honnef <dominikh@fork-bomb.org>
Commit: Dominik Honnef <dominikh@fork-bomb.org>
get rid of go--flatten
We can (and should) use mapcan instead. go--flatten is (very)
recursive and will break in most cases because of stack level.
Closes gh-18
---
go-mode.el | 49 ++++++++++++++-----------------------------------
1 file changed, 14 insertions(+), 35 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index d4521e0..417a82d 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -631,26 +631,6 @@ uncommented, otherwise a new import will be added."
('single (insert "import " line "\n"))
('none (insert "\nimport (\n\t" line "\n)\n")))))))
-(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-root-and-paths ()
(let* ((output (process-lines "go" "env" "GOROOT" "GOPATH"))
(root (car output))
@@ -660,21 +640,20 @@ uncommented, otherwise a new import will be added."
(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
"/")) "/")
- )
- ))
- (if (file-directory-p dir)
- (directory-files dir t "\\.a$"))))
- (find-lisp-find-files-internal pkgdir
'find-lisp-file-predicate-is-directory
'find-lisp-default-directory-predicate))))
- (go-root-and-paths)))) 'string<))
+ (mapcan
+ (lambda (topdir)
+ (let ((pkgdir (concat topdir "/pkg/")))
+ (mapcan (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
"/")) "/")
+ )
+ ))
+ (if (file-directory-p dir)
+ (directory-files dir t "\\.a$"))))
+ (find-lisp-find-files-internal pkgdir
'find-lisp-file-predicate-is-directory
'find-lisp-default-directory-predicate))))
+ (go-root-and-paths))) 'string<))
(defun go-unused-imports-lines ()
(let (cmd)
- [nongnu] elpa/go-mode 8e413db 035/495: require diff-mode during compilation, (continued)
- [nongnu] elpa/go-mode 8e413db 035/495: require diff-mode during compilation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 572c754 042/495: For continuation lines, do not assume the indentation of a multiline raw string, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 087f58f 043/495: don't expect a line end after labels or cases, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 54a102e 046/495: do not move cursor to beginning of line after indentation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 1128e71 052/495: do not try to turn off flymake if flymake isn't loaded, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 903768b 053/495: tweak godoc to behave more like help in emacs, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode e78baea 054/495: do not leave point at beginning of line when (not) indenting a comment, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode a5164ac 055/495: Fix indentation for code after multi-line function signature, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 72cf126 056/495: fix indentation for multi-line if expressions, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode cfc3d50 058/495: add more test cases, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 63929d2 085/495: get rid of go--flatten,
ELPA Syncer <=
- [nongnu] elpa/go-mode 850986e 022/495: Do not loop forever in go-beginning-of-defun if point is in comment and there's no function definition before point, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b91c53e 025/495: save buffer before trying to remove unused imports, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 4371669 029/495: Merge branch 'feature/remove_unused_imports', ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode cd13093 034/495: use inhibit-read-only instead of toggle-read-only, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b6dfdd4 037/495: Closes gh-5, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 9dbdf22 041/495: Do not skip over strings when checking for dangling operator, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 95c9519 049/495: when searching for anchor for indentation, do not limit search to one line, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 399393a 057/495: remove dead code, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode ee10287 059/495: Revert "Fix indentation for code after multi-line function signature", ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 79d5860 073/495: improve fontification, ELPA Syncer, 2021/08/07