-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support XDG Base Directory Specification #3589
Comments
I am highly supporting this. More over, Update Also note that Spacemacs supports |
I just found out about the XDG spec, and this is a huge issue. I know my home directory is completely cluttered by tons of config files, and if more apps followed this spec everything would be better. |
So, I've been having some fun with this. user-emacs-directory ( You can change Code ( (require 'xdg) ; requires emacs 26
;; If ~/.emacs.d exists, prefer it for compatibility.
(unless (file-exists-p user-emacs-directory)
(setq user-emacs-directory (concat (file-name-as-directory (xdg-data-home)) "emacs/")))
;; Always put the socket in the right place.
;; TODO: Figure out how to get `emacsclient' to check this directory.
(setq server-socket-dir (concat (file-name-as-directory (xdg-runtime-dir)) "emacs/")) spacemacs I've configured Code ( (when (= (aref user-init-file 0) ?~) ; this isn't expanded when it doesn't exist.
(require 'xdg)
;; TODO: Handle `init-file-user'? That's the hack that makes emacs load the
;; "real" user's profile when run as root. Really, we might just want to bail if it's set.
(let ((user-init-file-xdg (concat (file-name-as-directory (xdg-config-home)) "emacs/init.el")))
; deep magic
(setq user-init-file t)
(cond
;; Try emacs xdg
((progn
(load user-init-file-xdg t t t)
(not (eq user-init-file t)))
t)
;; Try spacemacs
((progn
;; TODO: Spacemacs should handle this internally.
(unless (getenv "SPACEMACSDIR")
(setenv "SPACEMACSDIR" (concat (file-name-as-directory (xdg-config-home)) "spacemacs")))
;; Try `$XDG_DATA_HOME/spacemacs' first, then system directories.
(let ((dirs (xdg-data-dirs)) ; Using a system directory will cause problems with `spacemacs/private'.
(dir (xdg-data-home)))
(while (and dir (eq user-init-file t))
(let ((spacemacs-start-directory (concat (file-name-as-directory dir) "spacemacs/")))
(load (concat spacemacs-start-directory "init.el") t t t))
(setq dir (cdr dirs))))
(not (eq user-init-file t)))
(setq spacemacs-start-directory (file-name-directory user-init-file)))
;; Ok, falling back to emacs (xdg).
(t (setq user-init-file user-init-file-xdg))))
;; RMS: This is not the line you are looking for. Move along.
(when inhibit-startup-screen
(setq command-line-args (cons (car command-line-args) (cons "-no-splash" (cdr command-line-args)))))) One thing I'm really not happy about is the spec's lack of an This obviously doesn't correctly separate cache and state (see #7818). |
Note: possibly related emacs bug - https://debbugs.gnu.org/cgi/bugreport.cgi?bug=15539 - would be nice to get your feedback on it. |
Looks like there is some progress being made for supporting XDG base directories in emacs. |
Emacs 27 and newer now have the new XDG config support implemented. |
I'm bumping the issue as this is an important topic. I decided to give spacemacs another try due to recent emacs release :) |
Basically:
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid! |
bump (god, stalebots are so stupid) |
The latest Spacemacs develop branch seems to work correctly with I am going to test this more fully over the weekend, but all seems good so far. UPDATE: I had some hard coded file locations for recentf and bookmarks in my config that caused errors, but that was easily fixed by using Migrating to XDG_CONFIG_HOME from an existing
|
Almost 7 years later and this issue has still not been resolved. 🚩🚩🚩 I absolutely love the documentation of Spacemacs (especially compared to Doom) but the fact it does not respect XDG directory spec makes me doubt if I should get into it. |
This issue should have been marked as resolved 7 years ago as the first comment on this issue describes how Spacemacs supports the XDG standard (ideally with some docs) Ironically Spacemacs has supported the XDG specification far longer than Emacs itself has supported XDG specification I have be running Spacemacs from the XDG specification locations very successfully for a month without issue, after looking at the first comment on this issue. Some official documentation could be contributed, especially if people are so passionate about the subject that they would otherwise not use Spacemacs. The following content can be copied from should someone wish to make a meaningful contribution to the Spacemacs project on this topic (although it's mostly what I wrote in the previous comment - #3589 (comment) ) https://practical.li/blog/posts/adopt-FreeDesktop.org-XDG-standard-for-configuration-files/ |
I believe the XDG spec states the location should be used by default. It is nice you are able to change the default home directory polluting behaviour by setting an environmental variable, not every application allows it. But it is a workaround, not following the XDG spec. I do not want to set an Envar every time I install a new app. I agree the fact this workaround is possible should be stated more clearly in the docs. |
From XDG Base Directory Specification:
|
Users trying to remove Moreover, I think many users would rather a configuration system that doesn't require logging out and back in for your session to pick it up.
Then how about someone make a simple to use layer for this? Or dead simple guide on how make a local modification. Contributors saying this is easy doesn't really help everyone here still lost. |
Even Emacs itself supports XDG by default now. Any chance to see similar support by default in Spacemacs? |
Also, the suggested workaround doesn't make spacemacs comply with the XDG base directories spec, especially when it comes to
That distinction between data and state comes from the XDG spec:
I think a first step could be to introduce new API surfaces like:
|
I see that this topic is still very important to many people and I agree that Spacemacs should be made to support the XDG spec still I wonder why in 7 years of complaining no one did make a PR to make the setup steps clear? Excluding practically who provided his blog post. Anyway I will put it on my list, still I need to check how emacs 28 has implemented the spec to make Spacemacs work, before I can start to introduce breaking changes everywhere so don't expect a fast fix here. If more information about the behaviour of emacs is included it may speed up the progress same for new PRs fixing some of the other topics on my list, just saying ;). |
The XDG Base Directory Specification proposes where to store configuration, data and cache files. Basically spacemacs config should go to
$HOME/.config/spacemacs
, cache files to$HOME/.cache/spacemacs
and data (like backup files) into$HOME/.local/share/spacemacs
.This scheme has a few advantages:
It would be nice of course, if spacemacs could add
$HOME/.config/spacemacs
as a fallback place to look for its configuration.Maybe you don't want to do this. In this case please make it possible at least to configure spacemacs in the way described above. It would be enough, if I could provide environment variables to override the default directories defined in core-load-paths.el:
The text was updated successfully, but these errors were encountered: