emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: user-directory: New library to find user {conf, data, state, ...} fi


From: Stefan Kangas
Subject: Re: user-directory: New library to find user {conf, data, state, ...} files
Date: Sun, 7 Nov 2021 11:31:50 -0800

Stefan Kangas <stefan@marxist.se> writes:

> I hacked something quick together and pushed it to
> features/user-directory, mostly so that we can decide on the basic API.
> It needs more work, but the interface should hopefully be clear.
>
> The one I propose is:
>
>     (user-directory 'cache)
>     => "/home/skangas/.cache"
>
>     (user-file 'cache "foo")
>     => "/home/skangas/.cache/foo"
>
> There's also a defcustom `user-directory-alist' for overrides:
>
>     (let ((user-directory-alist '((downloads "/foo"))))
>       (user-directory 'downloads))
>     => "/foo"

OK, I think this is ready for merging to master so that we can start
experimenting with it, obviously based on the assumption that this is
tentative and open for change.  I guess someone will want to look at
adding MS-Windows support to this, for example.

Note that on GNU/Linux, even if the user has their configuration file in
"~/.emacs.d/", the library currently prefers the XDG paths here:

    (user-file 'cache "image-dired")
    => "~/.cache/emacs/image-dired"

This is a feature.  If users prefer not to have a clean "~/.emacs.d/"
they can say:

    (setq user-directory-alist '((cache . user-emacs-directory)
                                 (config . user-emacs-directory)
                                 (data . user-emacs-directory)
                                 (runtime . user-emacs-directory)
                                 (state . user-emacs-directory)))

I also think we should consider adding some heuristics to `user-file' to
be able to find the old name if it exists.  I considered some
alternatives, but I thought I'd see what people think first.  Currently,
application code would say:

    (user-file 'cache "image-dired"
                       (locate-user-emacs-file "image-dired"))

Which could, if we want to be smart, be simplified to:

    (user-file 'cache "image-dired" "image-dired")

Or even:

    (user-file 'cache "image-dired")

Unfortunately, in this case I think it's harder to be smart:

    (user-file 'data "bookmarks"
                     (locate-user-emacs-file "bookmarks" ".emacs.bmk"))

But perhaps we can think of something even for that.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]