From 6c0dd5b147dd0fdc113399dfe392ab5a542b0fa1 Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 3 Aug 2020 03:03:12 +0200 Subject: [PATCH] Emacs: Only enable caching for .emacs.d, better workaround. --- .dir-locals.el | 4 ---- init.d/programming/common.el | 19 ++++++++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) delete mode 100644 .dir-locals.el diff --git a/.dir-locals.el b/.dir-locals.el deleted file mode 100644 index 233770d..0000000 --- a/.dir-locals.el +++ /dev/null @@ -1,4 +0,0 @@ -;;; Directory Local Variables -;;; For more information see (info "(emacs) Directory Variables") - -((nil . ((projectile-enable-caching . t)))) diff --git a/init.d/programming/common.el b/init.d/programming/common.el index 8d06082..cf0a7d7 100644 --- a/init.d/programming/common.el +++ b/init.d/programming/common.el @@ -1,6 +1,6 @@ ;;; common.el --- Common programming settings. -*- lexical-binding: t; -*- -;; Time-stamp: <2020-08-03T01:31:35+0200> +;; Time-stamp: <2020-08-03T02:56:38+0200> ;;; Commentary: @@ -106,9 +106,26 @@ (substring (shell-command-to-string "nproc --ignore=1") 0 -1))) + (defun my/projectile-enable-caching? (&rest args) + "Turn on caching for certain projects. +Ignores ARGS." + (if (string= (projectile-project-name) ".emacs.d") + (progn + (message "Turning on caching for \"%s\"." + (projectile-project-name)) + (setq-local projectile-enable-caching t)) + (kill-local-variable 'projectile-enable-caching))) + (advice-add 'projectile-find-file + :before #'my/projectile-enable-caching?) + (advice-add 'counsel-projectile-find-file + :before #'my/projectile-enable-caching?) + (defun my/switch-project () "Find file in project, add project to `treemacs' and collapse other projects." + ; Enable caching maybe before listing files. + (my/projectile-enable-caching?) + (if (member 'counsel-projectile-mode minor-mode-list) (counsel-projectile-find-file) (projectile-find-file))