Extract make clean/clean-cache into elisp; new doom-etc-dir for non-volatile temp files

This commit is contained in:
Henrik Lissner 2017-03-16 23:38:22 -04:00
parent 4ae0513020
commit 923d4585fa
7 changed files with 43 additions and 16 deletions

View file

@ -21,11 +21,10 @@ compile: init.el clean
@$(EMACS) -l core/core.el -f 'doom/recompile'
clean:
@rm -fv init.elc
@find {core,modules} -type f -iname '*.elc' -exec rm \-fv {} \;
@$(EMACS) -l core/core.el -f 'doom/clear-compiled'
clean-cache:
@$(EMACS) -l core/core.el --eval '(delete-directory doom-cache-dir t)'
@$(EMACS) -l core/core.el -f 'doom/clear-cache'
# This is only useful if your emacs.d is somewhere other than ~/.emacs.d (for
# development purposes for instance).

View file

@ -115,7 +115,7 @@ to speed up startup."
package-activated-list nil)
;; Ensure core folders exist
(dolist (dir (list doom-local-dir doom-cache-dir package-user-dir))
(dolist (dir (list doom-local-dir doom-etc-dir doom-cache-dir package-user-dir))
(unless (file-directory-p dir)
(make-directory dir t)))
@ -458,6 +458,22 @@ This may take a while."
(message "\n%s" (mapconcat (lambda (file) (concat "+ ERROR: " (car file)))
(nreverse errors) "\n"))))))
(defun doom/clear-cache ()
"Clear local cache (`doom-cache-dir'). You may need to restart Emacs for some
components to feel its effects."
(delete-directory doom-cache-dir t)
(make-directory doom-cache-dir t))
(defun doom/clear-compiled ()
"Delete all compiled elc files in DOOM emacs, excluding compiled ELPA/QUELPA
package files."
(interactive)
(when-let (elc-files (cl-remove-if (lambda (file) (file-in-directory-p file doom-local-dir))
(directory-files-recursively doom-emacs-dir "\\.elc$")))
(dolist (file elc-files)
(delete-file file)
(message "Deleting %s" (abbreviate-file-name file)))))
;;
;; Package.el modifications

View file

@ -32,17 +32,29 @@ line or use --debug-init to enable this.")
(defvar doom-modules-dir (concat doom-emacs-dir "modules/")
"Where configuration modules are stored.")
;; Multi-host directories: I namespace `doom-etc-dir' and `doom-cache-dir' with
;; host names because I use the same (often symlinked) emacs.d across several
;; computers -- often simultaneously. Cache or other temporary files would
;; conflict otherwise.
(defvar doom-local-dir (concat doom-emacs-dir ".local/")
"Untracked directory for local Emacs files, including the cache
(`doom-cache-dir'), packages (`doom-packages-dir') and autoloads file.")
"Root directory for local Emacs files.")
(defvar doom-packages-dir (concat doom-local-dir "packages/")
"Where package.el and quelpa plugins (and their caches) are kept.")
(defvar doom-etc-dir
(concat doom-local-dir "etc/" (system-name) "/")
"Hostname-based directory for non-volatile temporary files. These are not
deleted or tampored with by DOOM functions. It should not be used for transient
or unstable files.")
(defvar doom-cache-dir
(concat doom-local-dir "cache/" (system-name) "/")
"Hostname-based directory for temporary files.")
(defvar doom-packages-dir
(concat doom-local-dir "packages/")
"Where package.el and quelpa plugins (and their caches) are kept.")
"Hostname-based directory for volatile temporary files. They are deleted when
`doom/clear-cache' is called. For more stable local storage, use
`doom-local-dir'.")
(defvar doom-autoload-file
(concat doom-local-dir "autoloads.el")
@ -71,7 +83,7 @@ line or use --debug-init to enable this.")
compilation-ask-about-save nil ; save all buffers on `compile'
compilation-scroll-output t
confirm-nonexistent-file-or-buffer t
custom-file (concat doom-cache-dir "custom.el")
custom-file (concat doom-etc-dir "custom.el")
enable-recursive-minibuffers nil
debug-on-error (and (not noninteractive) doom-debug-mode)
idle-update-delay 1 ; update ui less often

View file

@ -108,7 +108,7 @@
(def-package! irony
:after cc-mode
:config
(setq irony-server-install-prefix (concat doom-cache-dir "irony-server/"))
(setq irony-server-install-prefix (concat doom-etc-dir "irony-server/"))
(add-hook! 'irony-mode-hook '(irony-eldoc flycheck-mode))
(add-hook! 'c++-mode-hook
(make-local-variable 'irony-additional-clang-options)

View file

@ -8,7 +8,7 @@
(set! :build 'compile-file 'java-mode 'meghanada-compile-file)
(set! :build 'compile-project 'java-mode 'meghanada-compile-project)
(setq meghanada-server-install-dir (expand-file-name "meghanada-server/" doom-cache-dir)
(setq meghanada-server-install-dir (concat doom-etc-dir "meghanada-server/")
meghanada-use-company t
meghanada-use-flycheck t
meghanada-use-auto-start t)

View file

@ -49,7 +49,7 @@
:init
(add-hook 'php-mode-hook 'eldoc-mode)
:config
(setq php-extras-eldoc-functions-file (concat doom-cache-dir "php-extras-eldoc-functions"))
(setq php-extras-eldoc-functions-file (concat doom-etc-dir "php-extras-eldoc-functions"))
;; company will set up itself
(advice-add 'php-extras-company-setup :override 'ignore)

View file

@ -30,7 +30,7 @@
:init
(add-hook 'python-mode-hook 'anaconda-mode)
(add-hook 'anaconda-mode-hook 'anaconda-eldoc-mode)
(setq anaconda-mode-installation-directory (concat doom-cache-dir "anaconda/")
(setq anaconda-mode-installation-directory (concat doom-etc-dir "anaconda/")
anaconda-mode-eldoc-as-single-line t)
:config