From 819d7f6ea51d9b1b52b3f283e6b9193dcd5f46e6 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 24 Apr 2017 19:34:02 +0200 Subject: Emacs: Simplify project opening logic Use ghq to do the heavy lifting --- emacs/.emacs.d/init.org | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org index 5830055..84609ac 100644 --- a/emacs/.emacs.d/init.org +++ b/emacs/.emacs.d/init.org @@ -479,22 +479,6 @@ based upon some folder conventions I use. (projectile-global-mode) (add-to-list 'projectile-globally-ignored-directories ".stversions") - (defun directory-directories (dir) - (seq-filter #'file-directory-p - (directory-files dir t (rx string-start - (char alnum))))) - - (defun project-directories (start-dir) - (seq-map (lambda (x) (file-relative-name x start-dir)) - (seq-mapcat #'directory-directories - (seq-mapcat #'directory-directories - (directory-directories start-dir))))) - - (defun ap/open-subfolder-project (from-dir &optional arg) - (let ((project-dir (projectile-completing-read "Open project: " - (project-directories from-dir)))) - (projectile-switch-project-by-name (expand-file-name project-dir from-dir) arg))) - (defun yarn-install (&optional arg) (interactive "P") (projectile-with-default-dir (projectile-project-root) @@ -517,7 +501,11 @@ based upon some folder conventions I use. (defun ap/open-project (&optional arg) (interactive "P") - (ap/open-subfolder-project projects-root-directory arg)) + (let ((project-dir (projectile-completing-read + "Open project: " + (ghq--find-projects)))) + (projectile-switch-project-by-name + (expand-file-name project-dir (ghq--find-root)) arg))) (setq projectile-switch-project-action #'projectile-commander projectile-completion-system 'ivy))) -- cgit 1.4.1