1

I noticed spacemacs puts things like autosave and backup files in ~/.emacs.d/.cache/ and I'd like to use that idea in my own setup.

From spacemacs/core/core-load-paths.el

(defconst spacemacs-cache-directory
  (expand-file-name (concat user-emacs-directory ".cache/"))

I considered adding this to my own init.el,

(defconst cache-directory
  (expand-file-name (concat user-emacs-directory ".cache/"))

but without the "spacemacs" prefix, "cache-directory" seems like a dangerously generic name, likely to collide with something at some point.

I'm still new to emacs, and I don't know enough about scoping in elisp to say whether this is a serious concern. Should I name it something silly like "ivan-cache-directory", or is there a best practice people stick to? Or is this not actually worth worrying about?

3

Using a should-be-unique prefix is recommended.

For init file code I like to use my- because:

  1. it is suitably unlikely to conflict with anything.
  2. it's short, but meaningful.
  3. it's not my name -- so when I share code with other people it reads just as well in their init file as it does in my own.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.