Skip to content

Instantly share code, notes, and snippets.

@hlissner
Last active August 16, 2022 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hlissner/938c84c236dc0d4a7e768f56c63f27b5 to your computer and use it in GitHub Desktop.
Save hlissner/938c84c236dc0d4a7e768f56c63f27b5 to your computer and use it in GitHub Desktop.
(defconst doom-cache-dir
(if IS-WINDOWS
(path! (getenv-internal "APPDATA") "doomemacs" "cache")
(path! (or (getenv-internal "XDG_CACHE_HOME") "~/.cache")
"doom"))
"Where Doom stores its global cache files.
Cache files represent non-essential data that ought to cause no issues if
deleted (besides, perhaps, a one-time performance hit), lack portability (and so
shouldn't be copied to other systems/configs), and are regenerated when needed,
without user input (e.g. a 'doom sync').
Some examples: images/data caches, elisp bytecode, natively compiled elisp,
session files, ELPA archives, authinfo files, org-persist, etc.
For profile-local cache files, use `doom-profile-cache-dir' instead.")
(defconst doom-data-dir
(if IS-WINDOWS
(path! (getenv-internal "APPDATA") "doomemacs" "data")
(path! (or (getenv-internal "XDG_DATA_HOME") "~/.local/share")
"doom"))
"Where Doom stores its global data files.
Data files contain shared and long-lived data that Doom, Emacs, and their
packages require to function correctly or at all. Deleting them by hand will
cause breakage, and require user intervention (e.g. a 'doom sync' or 'doom env')
to restore.
Use this for: server binaries, package source, pulled module libraries,
generated files for profiles, profiles themselves, autoloads/loaddefs, etc.
For profile-local data files, use `doom-profile-data-dir' instead.")
(defconst doom-state-dir
(if IS-WINDOWS
(path! (getenv-internal "APPDATA") "doomemacs" "state")
(path! (or (getenv-internal "XDG_STATE_HOME") "~/.local/state")
"doom"))
"Where Doom stores its global state files.
State files contain non-essential, unportable, but persistent data which, if
lost won't cause breakage, but may be inconvenient as they cannot be
automatically regenerated or restored. For example, a recently-opened file list
is not essential, but losing it means losing this record, and restoring it
requires revisiting all those files.
Use this for: history, logs, user-saved data, autosaves/backup files, known
projects, recent files, bookmarks.
For profile-local state files, use `doom-profile-state-dir' instead.")
;;; Profile variables
(defconst doom-profile
(if-let (profile (getenv-internal "DOOMPROFILE"))
(save-match-data
(if (string-match "^\\([^@]+\\)@\\(.+\\)$" profile)
(cons (match-string 1 profile)
(match-string 2 profile))
(cons profile "latest")))
(cons "default" "latest"))
"A cons cell referring to the active Doom profile.
The CAR is the name of the profile. The CDR is the desired version of the
profile (defaults to \\=\"latest\").")
(defconst doom-profile-cache-dir
(file-name-concat doom-cache-dir (car doom-profile))
"For profile-local cache files under `doom-cache-dir'.")
(defconst doom-profile-data-dir
(file-name-concat doom-data-dir (car doom-profile))
"For profile-local data files under `doom-data-dir'."
(defconst doom-profile-state-dir
(file-name-concat doom-state-dir (car doom-profile))
"For profile-local state files under `doom-state-dir'."
(defconst doom-profile-init-dir
(file-name-concat doom-profile-data-dir "@" (cdr doom-profile))
"Where generated files for the active profile are kept.")
(defconst doom-profile-init-file
(file-name-concat doom-profile-init-dir (format "init.%d.elc" emacs-major-version))
"Where the init file for this profile lives.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment