unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Eli Zaretskii <eliz@gnu.org>
Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: user-directory: New library to find user {conf, data, state, ...} files
Date: Tue, 9 Nov 2021 12:38:52 -0800	[thread overview]
Message-ID: <CADwFkmkV2uBGCMnxZw7gBfTeYt0+EEPWU5HHKfR=iDUPfOD2sg@mail.gmail.com> (raw)
In-Reply-To: <83lf1x428l.fsf@gnu.org>

Eli Zaretskii <eliz@gnu.org> writes:

>> When looking for the directory, the new one will always be preferred.
>> The old name in all cases is just `user-emacs-directory', so it doesn't
>> make sense to look for it.
>
> That's not true, unless we are mis-communicating.  I have quite a few
> directories under ~/.emacs.d/, and most of them are important.  Are
> you saying we will now look for them all according to the XDG spec?

Aha, yes we are talking about two different things.

If you need some file in `user-emacs-directory' ("file" in the Unix
sense here, i.e. it could also be a directory) you would use
`user-file'.  So to get "~/.emacs.d/auto-save-list/" you would say:

    (user-file 'state "auto-save-list")
    => "~/.local/state/emacs/auto-save-list"

`user-directory' only returns the top-level directory.  There is no way
to give it a name of a file.

    (user-directory 'state)
    => "/home/skangas/.local/state/emacs"

However, your question makes me think that we should make `user-file'
the only public function here, to avoid confusion.  I think it's rare to
need the directory itself, and if someone does they could just use

    user-emacs-directory
    => "~/.emacs.d/"

or

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

So I think we should rename the library to user-file.el, and make
`user-file' the only non-internal and user-facing function.  That makes
it simpler, and more clear.

>>   ./startup.el547:      (push (expand-file-name "eln-cache/"
>> user-emacs-directory)
>
> Isn't that a problem?  It would mean we'd need to preload xdg.el and
> user-file, and all the stuff they need to work, right?  Also, the XDG
> spec says about "cache":

Yes, if we want to move the eln-cache to the cache directory, we need to
do something about preloading.  The relevant XDG code could be moved
from xdg.el and xdg.el could depend on the preloaded location; this is
about 30-40 lines of code.  We would also need to rewrite the code I
have in user-directory.el to not use cl-lib.el.

>   $XDG_CACHE_HOME defines the base directory relative to which
>   user-specific non-essential data files should be stored.
>
> I don't think files in eln-cache can be classified as "non-essential".
> They are important for using Emacs; removing them will make Emacs slow
> and sluggish for quite some time after startup.

Removing anything from a cache will always make performance worse until
you can recache it, but the character of a cache is that it can always
be recreated from some original data.

So my understanding is that "non-essential" here is provided to contrast
with the data file, and simply means that it is not (highly) important
not to lose those files.  I.e. it is just a way to further specify that
this is the directory for cached files.

> And you are saying we will redirect all those to the XDG tree?  Users
> have files in these places, and they need to trust Emacs to find those
> files when it is restarted.  How can we change where we look for them
> without breaking configurations?

For each file NAME: (1) look for NAME in the XDG directory, if NAME
exists there and is readable return it, otherwise (2) look for it in
`user-emacs-directory', if NAME exists there and is readable return it,
otherwise (3) return the file name of NAME in the XDG directory.  This
is the same basic approach that we also use in `locate-user-emacs-file'.

Is that what you mean?

>>     (user-file 'data "bookmarks" "~/.emacs.bmk")
>
> Once again, why not just one argument?

For backwards compatibility.  The "bookmarks" file used to be in
"~/.emacs.bmk" (before 2010 or so?).

We currently locate it using this call:

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



  reply	other threads:[~2021-11-09 20:38 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-25 13:14 master f8fed41 2/3: image-dired: Improve XDG compliance Eli Zaretskii
2021-10-25 16:14 ` Philip Kaludercic
2021-10-25 16:39   ` Eli Zaretskii
2021-10-25 17:52     ` Philip Kaludercic
2021-10-25 18:30       ` Eli Zaretskii
2021-10-26 10:24         ` Stefan Kangas
2021-10-26 13:09           ` Eli Zaretskii
2021-10-26 13:28             ` Stefan Kangas
2021-10-26 14:11               ` Eli Zaretskii
2021-10-26 14:35                 ` Stefan Kangas
2021-10-27  4:37                   ` Po Lu
2021-10-26 16:47         ` Philip Kaludercic
2021-10-26  2:07       ` Po Lu
2021-10-25 17:48   ` Stefan Monnier
2021-10-25 17:55     ` Philip Kaludercic
2021-10-25 17:58       ` Gregory Heytings
2021-10-25 18:04       ` Stefan Monnier
2021-10-26 10:25 ` Default for image-dired-main-image-directory Stefan Kangas
2021-10-26 13:12   ` Eli Zaretskii
2021-10-26 13:42     ` Ihor Radchenko
2021-10-26 14:15       ` Eli Zaretskii
2021-10-26 14:22         ` Stefan Kangas
2021-10-26 14:58         ` Ihor Radchenko
2021-10-26 16:15           ` Eli Zaretskii
2021-10-27 13:04             ` Ihor Radchenko
2021-10-27 13:26               ` Eli Zaretskii
2021-10-27 13:42                 ` Ihor Radchenko
2021-10-27 16:53                   ` XDG config dir [Was: Re: Default for image-dired-main-image-directory] Alexandre Garreau
2021-10-28  3:45                     ` Ihor Radchenko
2021-10-28  3:48                     ` Phil Sainty
2021-10-28  5:57                       ` Alexandre Garreau
2021-10-28  6:46                         ` Stefan Kangas
2021-10-26 14:14     ` Default for image-dired-main-image-directory Stefan Kangas
2021-10-26 15:37       ` Eli Zaretskii
2021-10-26 14:01 ` master f8fed41 2/3: image-dired: Improve XDG compliance Stefan Kangas
2021-10-26 14:19   ` Eli Zaretskii
2021-10-26 14:24     ` Stefan Kangas
2021-10-26 16:00       ` Eli Zaretskii
2021-10-26 16:13         ` Stefan Kangas
2021-10-26 16:21           ` Eli Zaretskii
2021-10-26 14:28   ` Eli Zaretskii
2021-10-26 14:45     ` Stefan Kangas
2021-10-26 16:12       ` Eli Zaretskii
2021-10-26 16:31         ` Eli Zaretskii
2021-10-26 19:17         ` Stefan Monnier
2021-10-26 19:28           ` Eli Zaretskii
2021-11-06  1:38           ` user-directory: New library to find user {conf,data,state,...} files Stefan Kangas
2021-11-06  1:52             ` Lars Ingebrigtsen
2021-11-06  2:56               ` user-directory: New library to find user {conf, data, state, ...} files Stefan Kangas
2021-11-06  3:11             ` Stefan Kangas
2021-11-07 19:31             ` Stefan Kangas
2021-11-07 19:52               ` Eli Zaretskii
2021-11-08  3:04                 ` Stefan Kangas
2021-11-08 12:19                   ` Eric S Fraga
2021-11-08 13:55                   ` Eli Zaretskii
2021-11-08 15:26                     ` Stefan Kangas
2021-11-08 18:31                       ` Eli Zaretskii
2021-11-09  7:05                         ` Stefan Kangas
2021-11-09 18:23                           ` Eli Zaretskii
2021-11-09 20:38                             ` Stefan Kangas [this message]
2021-11-11 10:34                               ` Eli Zaretskii
2021-11-08  3:35               ` Stefan Kangas
2021-11-08 15:40                 ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADwFkmkV2uBGCMnxZw7gBfTeYt0+EEPWU5HHKfR=iDUPfOD2sg@mail.gmail.com' \
    --to=stefan@marxist.se \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).