Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions projectile.el
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,15 @@ Similar to '#' in .gitignore files."
:type 'character
:package-version '(projectile . "2.2.0"))

(defcustom projectile-dirconfig-name-prefix
nil
"Projectile config file (.projectile) name start marker.
If specified, starting a line in a project's .projectile file with
`projectile-dirconfig-name-prefix' followed by this character marks that
line as the name of the project instead of a pattern."
:group 'projectile
:type 'character)

(defcustom projectile-globally-ignored-files
(list projectile-tags-file-name)
"A list of files globally ignored by projectile.
Expand Down Expand Up @@ -1299,7 +1308,19 @@ explicitly."
(defun projectile-default-project-name (project-root)
"Default function used to create the project name.
The project name is based on the value of PROJECT-ROOT."
(file-name-nondirectory (directory-file-name project-root)))
(or (when-let*
((comment-prefix projectile-dirconfig-comment-prefix)
(name-prefix projectile-dirconfig-name-prefix)
(default-directory project-root)
(dirconfig (projectile-dirconfig-file)))
(when (projectile-file-exists-p dirconfig)
(with-temp-buffer
(insert-file-contents dirconfig)
(when (re-search-forward
(format "^%c%c\\(.*\\)$" comment-prefix name-prefix)
nil t)
(match-string 1)))))
(file-name-nondirectory (directory-file-name project-root))))

(defun projectile-project-name (&optional project)
"Return project name.
Expand Down Expand Up @@ -1954,7 +1975,7 @@ Strings starting with + will be added to the list of directories
to keep, and strings starting with - will be added to the list of
directories to ignore. For backward compatibility, without a
prefix the string will be assumed to be an ignore string."
(let (keep ignore ensure (dirconfig (projectile-dirconfig-file)))
(let (name keep ignore ensure (dirconfig (projectile-dirconfig-file)))
(when (projectile-file-exists-p dirconfig)
(with-temp-buffer
(insert-file-contents dirconfig)
Expand All @@ -1965,7 +1986,9 @@ prefix the string will be assumed to be an ignore string."
(and projectile-dirconfig-comment-prefix
(eql leading-char
projectile-dirconfig-comment-prefix))))
nil)
(when (eql projectile-dirconfig-name-prefix
(char-after (1+ (point))))
(setq name (buffer-substring (+ (point) 2) (line-end-position)))))
(?+ (push (buffer-substring (1+ (point)) (line-end-position)) keep))
(?- (push (buffer-substring (1+ (point)) (line-end-position)) ignore))
(?! (push (buffer-substring (1+ (point)) (line-end-position)) ensure))
Expand All @@ -1976,7 +1999,8 @@ prefix the string will be assumed to be an ignore string."
(mapcar #'string-trim
(delete "" (reverse ignore)))
(mapcar #'string-trim
(delete "" (reverse ensure)))))))
(delete "" (reverse ensure)))
name))))

(defun projectile-expand-root (name)
"Expand NAME to project root.
Expand Down
4 changes: 2 additions & 2 deletions test/projectile-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,15 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
"no-prefix"
"left-wspace"
"right-wspace")
nil))
nil nil))
;; same test - but with comment lines enabled using prefix '#'
(let ((projectile-dirconfig-comment-prefix ?#))
(expect (projectile-parse-dirconfig-file) :to-equal '(("include/")
("exclude"
"no-prefix"
"left-wspace"
"right-wspace")
nil)))
nil nil)))
))

(describe "projectile-get-project-directories"
Expand Down