diff options
| author | 813gan <29867887+813gan@users.noreply.github.com> | 2022-10-30 16:10:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-30 17:10:19 +0200 |
| commit | 20e4444dea4baeba332c39ab3c401d9209c62e43 (patch) | |
| tree | 64e2beda310cd2a0e52d4dd0364ed8d253b6c376 /projectile.el | |
| parent | 95134e1ba2f9f1b7a21ccc2c565ffc39cbfcd2f6 (diff) | |
Add helpers for dir-local-variables for 3rd party use (#1737)
Functions `projectile-add-dir-local-variable` and `projectile-delete-dir-local-variable`
wraps their built-in counterparts. They always use `.dir-locals.el` from root of projectile project.
Diffstat (limited to 'projectile.el')
| -rw-r--r-- | projectile.el | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/projectile.el b/projectile.el index ac326e8..0fcdcda 100644 --- a/projectile.el +++ b/projectile.el @@ -2423,6 +2423,32 @@ With a prefix arg INVALIDATE-CACHE invalidates the cache first." (read-only-mode (if val +1 -1)) (message "[%s] read-only-mode is %s" (projectile-project-name) (if val "on" "off"))))) +;;;###autoload +(defun projectile-add-dir-local-variable (mode variable value) + "Run `add-dir-local-variable' with .dir-locals.el in root of project. + +Parameters MODE VARIABLE VALUE are passed directly to `add-dir-local-variable'" + (let ((inhibit-read-only t) + (default-directory (projectile-project-root))) + (unless default-directory + (error "Setting dir-local variable in non-existing projectile project was requested")) + (add-dir-local-variable mode variable value) + (save-buffer) + (kill-buffer) )) + +;;;###autoload +(defun projectile-delete-dir-local-variable (mode variable) + "Run `delete-dir-local-variable' with .dir-locals.el in root of project. + +Parameters MODE VARIABLE VALUE are passed directly to `delete-dir-local-variable'" + (let ((inhibit-read-only t) + (default-directory (projectile-project-root))) + (unless default-directory + (error "Setting dir-local variable in non-existing projectile project was requested")) + (delete-dir-local-variable mode variable) + (save-buffer) + (kill-buffer) )) + ;;;; Sorting project files (defun projectile-sort-files (files) |
