aboutsummaryrefslogtreecommitdiff
path: root/projectile.el
diff options
context:
space:
mode:
authorJohn Eivind Helset <jehelset@gmail.com>2022-04-02 07:45:48 +0200
committerBozhidar Batsov <bozhidar@batsov.dev>2022-05-30 09:15:46 +0300
commite60883ff370c1545499b97cf56479de1a58c5b3b (patch)
treef2581e57d927f5e02c049bc6f809845599d77c34 /projectile.el
parent39314925e0813d9042911197b08cfe304baff350 (diff)
Add variable to enable or disable command caching.
Add variable `projectile-project-enable-cmd-caching` to enable or disable command caching which defaults to `t`. Make the project command functions, like `projectile-configure-project`, pass a `nil` command-map to `projectile--run-project-cmd` if caching is disabled. The variable is checked with a function `projectile--cache-project-commands-p` which ensures that directory local variables for the project are loaded.
Diffstat (limited to 'projectile.el')
-rw-r--r--projectile.el40
1 files changed, 28 insertions, 12 deletions
diff --git a/projectile.el b/projectile.el
index ff859a8..bb66f1e 100644
--- a/projectile.el
+++ b/projectile.el
@@ -4599,6 +4599,16 @@ directory to open."
(make-hash-table :test 'equal)
"A mapping between projects and the last run command used on them.")
+(defvar projectile-project-enable-cmd-caching t
+ "Enables command caching for the project. Set to nil to disable.
+Should be set via .dir-locals.el.")
+
+(defun projectile--cache-project-commands-p ()
+ "Whether to cache project commands."
+ (with-temp-buffer
+ (hack-dir-local-variables-non-file-buffer)
+ projectile-project-enable-cmd-caching))
+
(defvar projectile-project-configure-cmd nil
"The command to use with `projectile-configure-project'.
It takes precedence over the default command for the project type when set.
@@ -4925,8 +4935,9 @@ Normally you'll be prompted for a compilation command, unless
variable `compilation-read-command'. You can force the prompt
with a prefix ARG."
(interactive "P")
- (let ((command (projectile-configure-command (projectile-compilation-dir))))
- (projectile--run-project-cmd command projectile-configure-cmd-map
+ (let ((command (projectile-configure-command (projectile-compilation-dir)))
+ (command-map (if (projectile--cache-project-commands-p) projectile-configure-cmd-map)))
+ (projectile--run-project-cmd command command-map
:show-prompt arg
:prompt-prefix "Configure command: "
:save-buffers t
@@ -4940,8 +4951,9 @@ Normally you'll be prompted for a compilation command, unless
variable `compilation-read-command'. You can force the prompt
with a prefix ARG."
(interactive "P")
- (let ((command (projectile-compilation-command (projectile-compilation-dir))))
- (projectile--run-project-cmd command projectile-compilation-cmd-map
+ (let ((command (projectile-compilation-command (projectile-compilation-dir)))
+ (command-map (if (projectile--cache-project-commands-p) projectile-compilation-cmd-map)))
+ (projectile--run-project-cmd command command-map
:show-prompt arg
:prompt-prefix "Compile command: "
:save-buffers t
@@ -4955,8 +4967,9 @@ Normally you'll be prompted for a compilation command, unless
variable `compilation-read-command'. You can force the prompt
with a prefix ARG."
(interactive "P")
- (let ((command (projectile-test-command (projectile-compilation-dir))))
- (projectile--run-project-cmd command projectile-test-cmd-map
+ (let ((command (projectile-test-command (projectile-compilation-dir)))
+ (command-map (if (projectile--cache-project-commands-p) projectile-test-cmd-map)))
+ (projectile--run-project-cmd command command-map
:show-prompt arg
:prompt-prefix "Test command: "
:save-buffers t
@@ -4970,8 +4983,9 @@ Normally you'll be prompted for a compilation command, unless
variable `compilation-read-command'. You can force the prompt
with a prefix ARG."
(interactive "P")
- (let ((command (projectile-install-command (projectile-compilation-dir))))
- (projectile--run-project-cmd command projectile-install-cmd-map
+ (let ((command (projectile-install-command (projectile-compilation-dir)))
+ (command-map (if (projectile--cache-project-commands-p) projectile-install-cmd-map)))
+ (projectile--run-project-cmd command command-map
:show-prompt arg
:prompt-prefix "Install command: "
:save-buffers t
@@ -4985,8 +4999,9 @@ Normally you'll be prompted for a compilation command, unless
variable `compilation-read-command'. You can force the prompt
with a prefix ARG."
(interactive "P")
- (let ((command (projectile-package-command (projectile-compilation-dir))))
- (projectile--run-project-cmd command projectile-package-cmd-map
+ (let ((command (projectile-package-command (projectile-compilation-dir)))
+ (command-map (if (projectile--cache-project-commands-p) projectile-package-cmd-map)))
+ (projectile--run-project-cmd command command-map
:show-prompt arg
:prompt-prefix "Package command: "
:save-buffers t
@@ -5000,8 +5015,9 @@ Normally you'll be prompted for a compilation command, unless
variable `compilation-read-command'. You can force the prompt
with a prefix ARG."
(interactive "P")
- (let ((command (projectile-run-command (projectile-compilation-dir))))
- (projectile--run-project-cmd command projectile-run-cmd-map
+ (let ((command (projectile-run-command (projectile-compilation-dir)))
+ (command-map (if (projectile--cache-project-commands-p) projectile-run-cmd-map)))
+ (projectile--run-project-cmd command command-map
:show-prompt arg
:prompt-prefix "Run command: "
:use-comint-mode projectile-run-use-comint-mode)))