all repos — nixfiles @ 819d7f6ea51d9b1b52b3f283e6b9193dcd5f46e6

System and user configuration, managed by nix and home-manager

Emacs: Simplify project opening logic

Use ghq to do the heavy lifting
Alan Pearce alan@alanpearce.uk
Mon, 24 Apr 2017 19:34:02 +0200
commit

819d7f6ea51d9b1b52b3f283e6b9193dcd5f46e6

parent

7f7087d808a6e441e6c3aa36aa8328e93f63d256

1 files changed, 5 insertions(+), 17 deletions(-)

jump to
M emacs/.emacs.d/init.orgemacs/.emacs.d/init.org
@@ -479,22 +479,6 @@ :config (progn             (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 @@ (cmd-to-echo "yarn" (concat "run " cmd)))) 
             (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)))