aboutsummaryrefslogtreecommitdiff
path: root/projectile.el
diff options
context:
space:
mode:
authorLaurence Warne <laurencewarne@gmail.com>2022-10-01 14:39:21 +0100
committerBozhidar Batsov <bozhidar@batsov.dev>2022-10-04 15:27:14 +0200
commit3d7a3196141d61d8a25c78da4fb20f5673503fd7 (patch)
tree57026e8e49f7c0ccb8b3696b6a520316030c0fd2 /projectile.el
parent383b3bf47d34ca60c24cd73ea9c335936d0b70be (diff)
Make all project type attributes locally overridable
Add local overrides for the project type attributes test-prefix, test-suffix, related-files-fn, src-dir and test-dir. Add tests for this new behaviour.
Diffstat (limited to 'projectile.el')
-rw-r--r--projectile.el44
1 files changed, 37 insertions, 7 deletions
diff --git a/projectile.el b/projectile.el
index 995df72..8bcb396 100644
--- a/projectile.el
+++ b/projectile.el
@@ -822,6 +822,31 @@ If the value is nil, there is no limit to the opend buffers count."
:type 'integer
:package-version '(projectile . "2.2.0"))
+(defvar projectile-project-test-suffix nil
+ "Use this variable to override the current project's test-suffix property.
+It takes precedence over the test-suffix for the project type when set.
+Should be set via .dir-locals.el.")
+
+(defvar projectile-project-test-prefix nil
+ "Use this variable to override the current project's test-prefix property.
+It takes precedence over the test-prefix for the project type when set.
+Should be set via .dir-locals.el.")
+
+(defvar projectile-project-related-files-fn nil
+ "Use this variable to override the current project's related-files-fn property.
+It takes precedence over the related-files-fn attribute for the project type
+when set. Should be set via .dir-locals.el.")
+
+(defvar projectile-project-src-dir nil
+ "Use this variable to override the current project's src-dir property.
+It takes precedence over the src-dir for the project type when set.
+Should be set via .dir-locals.el.")
+
+(defvar projectile-project-test-dir nil
+ "Use this variable to override the current project's test-dir property.
+It takes precedence over the test-dir for the project type when set.
+Should be set via .dir-locals.el.")
+
;;; Version information
@@ -3652,25 +3677,30 @@ Fallback to DEFAULT-VALUE for missing attributes."
(defun projectile-test-prefix (project-type)
"Find default test files prefix based on PROJECT-TYPE."
- (projectile-project-type-attribute project-type 'test-prefix))
+ (or projectile-project-test-prefix
+ (projectile-project-type-attribute project-type 'test-prefix)))
(defun projectile-test-suffix (project-type)
"Find default test files suffix based on PROJECT-TYPE."
- (projectile-project-type-attribute project-type 'test-suffix))
+ (or projectile-project-test-suffix
+ (projectile-project-type-attribute project-type 'test-suffix)))
(defun projectile-related-files-fn (project-type)
"Find relative file based on PROJECT-TYPE."
- (projectile-project-type-attribute project-type 'related-files-fn))
+ (or projectile-project-related-files-fn
+ (projectile-project-type-attribute project-type 'related-files-fn)))
(defun projectile-src-directory (project-type)
"Find default src directory based on PROJECT-TYPE."
- (projectile-project-type-attribute
- project-type 'src-dir projectile-default-src-directory))
+ (or projectile-project-src-dir
+ (projectile-project-type-attribute
+ project-type 'src-dir projectile-default-src-directory)))
(defun projectile-test-directory (project-type)
"Find default test directory based on PROJECT-TYPE."
- (projectile-project-type-attribute
- project-type 'test-dir projectile-default-test-directory))
+ (or projectile-project-test-dir
+ (projectile-project-type-attribute
+ project-type 'test-dir projectile-default-test-directory)))
(defun projectile-dirname-matching-count (a b)
"Count matching dirnames ascending file paths in A and B."