summary refs log tree commit diff stats
path: root/tag-emacs
diff options
context:
space:
mode:
authorAlan Pearce2014-06-25 19:25:25 +0100
committerAlan Pearce2014-06-25 19:27:55 +0100
commitd91dfe6c7766b4b82e886183fc8e50ed9e4cb0bf (patch)
treec5d4863f8f6643d7fd41dd7fb7621c15c74b73b0 /tag-emacs
parent574dcaaf978438e5823bd5422b79d351b4ba73be (diff)
downloaddotfiles-d91dfe6c7766b4b82e886183fc8e50ed9e4cb0bf.tar.lz
dotfiles-d91dfe6c7766b4b82e886183fc8e50ed9e4cb0bf.tar.zst
dotfiles-d91dfe6c7766b4b82e886183fc8e50ed9e4cb0bf.zip
Emacs: Add commands to open a work or home project
Given that the projects are folders under (work|home)-project-directory
which match projectile's own predicates, switch to them with projectile,
even if they're not 'known' to it.
Diffstat (limited to 'tag-emacs')
-rw-r--r--tag-emacs/emacs.d/init.el31
1 files changed, 31 insertions, 0 deletions
diff --git a/tag-emacs/emacs.d/init.el b/tag-emacs/emacs.d/init.el
index 3e24147..00d595f 100644
--- a/tag-emacs/emacs.d/init.el
+++ b/tag-emacs/emacs.d/init.el
@@ -32,6 +32,9 @@
                       (file-name-directory (file-truename init-file))))
   "Where the emacs init file really is, passing through symlinks.")
 
+(defvar work-project-directory "~/work")
+(defvar home-project-directory "~/projects")
+
 ;;;; Package Management
 (add-to-list 'load-path (expand-file-name "elisp/" user-emacs-directory))
 
@@ -657,6 +660,34 @@
   :init (projectile-global-mode)
   :diminish projectile-mode
   :config (progn
+            (defun ap/subfolder-projects (dir)
+              (--map (file-relative-name it dir)
+                     (-filter (lambda (subdir)
+                                (--reduce-from (or acc (funcall it subdir)) nil
+                                               projectile-project-root-files-functions))
+                              (-filter #'file-directory-p (directory-files dir t "\\<")))))
+
+            (defun ap/-add-known-subfolder-projects (dir)
+              (-map #'projectile-add-known-project (ap/subfolder-projects dir)))
+
+            (defun ap/add-known-subfolder-projects ()
+              (interactive)
+              (ap/-add-known-subfolder-projects (ido-read-directory-name "Add projects under: ")))
+
+            (defun ap/open-subfolder-project (from-dir &optional arg)
+              (let ((project-dir (projectile-completing-read "Open project: "
+                                                             (ap/subfolder-projects from-dir))))
+                (projectile-switch-project-by-name (expand-file-name project-dir from-dir) arg)))
+
+            (defun ap/open-work-project (&optional arg)
+              (interactive "P")
+              (ap/open-subfolder-project work-project-directory arg))
+
+            (defun ap/open-home-project (&optional arg)
+              (interactive "P")
+              (ap/open-subfolder-project home-project-directory arg))
+
+
             (setq projectile-switch-project-action #'projectile-dired
                   projectile-remember-window-configs t)))