Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
fanshi1028 committed Oct 17, 2022
1 parent 6838628 commit bad6306
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions projectile.el
Original file line number Diff line number Diff line change
Expand Up @@ -3401,20 +3401,22 @@ a manual COMMAND-TYPE command is created with
Normally you'd set this from .dir-locals.el.")
(put 'projectile-project-type 'safe-local-variable #'symbolp)

(defun projectile-detect-project-type ()
"Detect the type of the current project.
(defun projectile-detect-project-type (&optional dir)
"Detect the type of the project.
When DIR is specified it detect it, otherwise it acts on the current project.
Fallsback to a generic project type when the type can't be determined."
(let ((project-type
(or (car (cl-find-if
(lambda (project-type-record)
(let ((project-type (car project-type-record))
(let ((default-directory (or dir default-directory))
(project-type (car project-type-record))
(marker (plist-get (cdr project-type-record) 'marker-files)))
(if (functionp marker)
(and (funcall marker) project-type)
(and (projectile-verify-files marker) project-type))))
projectile-project-types))
'generic)))
(puthash (projectile-project-root) project-type projectile-project-type-cache)
(puthash (projectile-project-root dir) project-type projectile-project-type-cache)
project-type))

(defun projectile-project-type (&optional dir)
Expand All @@ -3429,7 +3431,7 @@ The project type is cached for improved performance."
(project-root (projectile-project-root dir)))
(if project-root
(or (gethash project-root projectile-project-type-cache)
(projectile-detect-project-type))
(projectile-detect-project-type dir))
;; if we're not in a project we just return nil
nil))))

Expand Down

0 comments on commit bad6306

Please sign in to comment.