Fork me on GitHub
#emacs
<
2023-02-27
>
otfrom14:02:39

How are people separating their state (things like org-roam.db) from their config in their emacs configs? It makes more a difference when using things like chemacs or --init-directory. Just set the things that appear there to appear somewhere else like ~/.emacs-state?

pavlosmelissinos15:02:44

I'm trying to use https://wiki.archlinux.org/title/XDG_Base_Directory wherever I can, so for instance my org-roam.db is under ~/.local/state/emacs/org-roam.db. It works great for emacs (Apart from that for the most part it works fine but some applications don't really support it (e.g. Mozilla stuff, Java, Kodi))

pavlosmelissinos15:02:23

I have this snippet near the top of my init.el:

(defconst emacs-config-home user-emacs-directory)
(defconst emacs-cache-home (expand-file-name "emacs/" (or (safe-getenv "XDG_CACHE_HOME") "~/.cache")))
(defconst emacs-data-home (expand-file-name "emacs/" (or (safe-getenv "XDG_DATA_HOME") "~/.local/share")))
(defconst emacs-state-home (expand-file-name "emacs/" (or (safe-getenv "XDG_STATE_HOME") "~/.local/state")))
to make sure the correct paths are set Added it a while back, mostly for compatibility purposes; not sure if it's still necessary You obviously need to have the XDG_???_HOME env vars set in your shell

2
otfrom15:02:16

@UEQPKG7HQ I'm guessing that you then need to tell the various things that litter state around to use those directories?

pavlosmelissinos15:02:26

Yes but the changes I had to make were surprisingly limited

👍 2
pavlosmelissinos15:02:19

IME, most packages respect the XDG env vars if they're set (org-roam was an exception). This was like a year ago, the situation should be further improved now.

👍 2
otfrom15:02:56

@UEQPKG7HQ where is safe-getenv from?

pavlosmelissinos16:02:16

oh, that's right, forgot to include the function, sorry :man-facepalming:

(defun safe-getenv (env)
  "Provides a safe way to retrieve environment variables from ENV.

Examples TODO."
  (if (bound-and-true-p exec-path-from-shell-getenv)
    (exec-path-from-shell-getenv env)
    (getenv env)))

👍 2
pavlosmelissinos16:02:07

I had to do this because I was maintaining two versions of emacs on different machines (I think it was 27 and 28) if you're on >=28 you can just use exec-path-from-shell-getenv directly (you don't need the function)

pavlosmelissinos16:02:14

Here's my full init.el too, in case you find it useful (e.g. to see where I had to set the paths explicitly and how): https://github.com/PavlosMelissinos/dotfiles/blob/master/.config/emacs/init.el

❤️ 2
otfrom16:02:37

heh, I like the WIP comment

😅 2
pavlosmelissinos16:02:18

I actually want to do a full rewrite from scratch! Thinking about moving to corgi emacs and maybe getting rid of use-package

otfrom16:02:47

that is what I'm doing atm. I've done a bit of a speed run through corgi, my own evil config https://github.com/MastodonC/kixi-emacs and now a meow based one that works on guix and on ubuntu (as it is the basis of a terminal friendly team shared emacs config)

😍 2
Benjamin18:02:26

I heard a guy on software unscripted podcast talk about an advanced code editor that tries to detect intend of the user. E.g. when you modify the a local symbol it would automatically rename the local for you. For this specific use case I would probably narrow to defun and use iedit. Still, any thoughts on what packages to do be dwim and detect intent? Or thoughts on how to have great refactoring with simple editing tools? For instance consult-grep into wgrep for repo wide renames.

ericdallo19:02:54

I usually rename all my locals with LSP, which makes it renaming all places automatically, there is even a LSP feature called https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_linkedEditingRange which is just like a iedit but using LSP under the hood (`lsp-iedit-linked-ranges`)

2
🙌 2
Cora (she/her)18:02:32

determining intent is hard, too, and I imagine it would get it wrong often enough to be infuriating

😅 4
💯 2
👍 3