New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Making the projectile-add-known-project interactive #364
Comments
Why would you want to add a project manually? Opening a file in the project's dir is pretty much the same as interactively adding the project, so it doesn't make a lot of sense to me. |
I had accidentally removed a project from the list of known projects and was confused as how to add it again. It may also confuse other people that don't systematically open a file but the project root directory. Making the function interactive would help this (the first thing I did was list all the projectile functions, and I found how to remove a project but not how to add it). Or maybe instead hooking the jump-dired function. |
This is a function that lets me ensure that a bunch of directories are known projects. (defun projectile-add-magit-repo-dirs-to-known-projects ()
"Add `magit-repo-dirs' to `projectile-known-projects'."
(interactive)
(--each (mapcar 'cdr (magit-list-repos magit-repo-dirs))
(projectile-add-known-project (file-name-as-directory
(file-truename it))))) Since it is currenlty using magit it is for git repositoreies only. These are the customizations: (defcustom magit-repo-dirs nil
"Directories containing Git repositories.
Magit will look into these directories for Git repositories and
offer them as choices for `magit-status'."
:group 'magit
:type '(repeat string))
(defcustom magit-repo-dirs-depth 3
"The maximum depth to look for Git repos.
When looking for a Git repository below the directories in
`magit-repo-dirs', Magit will only descend this many levels
deep."
:group 'magit
:type 'integer)
Not what you asked for but it solves the same problem you are describing for me. That sometimes a folder that should always be in the known projects isnt there. |
At work I have projects to which I have read-only access. I would like to be able to browse those projects using projectile. However, the projects do not have a |
You can create functions and add them to I have something along the lines of what you are asking for in my init.el.. It allows for regular expressions to be used.. In my case to allow python virtual environments in ~/.virtualenvs/ to be identified as projects. (setq projectile-project-root-files-child-of
'("~/\.virtualenvs/[^/]+/\\(local/\\)?lib/python[^/]*/site-packages/?$"
"~/\.virtualenvs/[^/]+/?$"))
(defun projectile-root-child-of (dir &optional list)
(projectile-locate-dominating-file
dir
(lambda (dir)
(--first
(if (and
(s-equals? (file-remote-p it) (file-remote-p dir))
(string-match-p (expand-file-name it) (expand-file-name dir)))
dir)
(or list projectile-project-root-files-child-of (list))))))
(setq projectile-project-root-files-functions
'(projectile-root-bottom-up
projectile-root-top-down
projectile-root-top-down-recurring
projectile-root-child-of))
|
@thomasf That works great, thank you. I copied your code as an answer to my question on Emacs.SE. |
You can remove projects with "M-x projectile-remove-known-project" but as far as I know the only way to add a project to known projects is by a hook in find-file functions.
Is it possible to make the function interactive ?
The text was updated successfully, but these errors were encountered: