all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
	Emacs developers <emacs-devel@gnu.org>
Subject: Re: user-directory: New library to find user {conf, data, state, ...} files
Date: Mon, 8 Nov 2021 16:26:15 +0100	[thread overview]
Message-ID: <CADwFkmnEphKdrL=gP+n74qDg0dPkwfm8iqcJedDX6CxBJwW6xA@mail.gmail.com> (raw)
In-Reply-To: <83fss67nvw.fsf@gnu.org>

Eli Zaretskii <eliz@gnu.org> writes:

> The problem is that changes which break users' configurations will not
> be appreciated.

Correct, and fully agreed.  I believe we can avoid this.

> > With all that being said, we must take great care not to cause
> > unnecessary churn.  In particular, we should absolutely not break
> > anything that's currently working.  This means that we should respect
> > locations of already existing files, and ensure they continue working
> > seamlessly.
>
> That is fine, but I'm not sure how you can achieve that goal and still
> prefer the XDG directories.

This is the key point, indeed.

The new name will be preferred only when there is no old file.  If it
exists, the old name will be used.  (This is based on how
'locate-user-emacs-file' works.)  See below.

> > PS. Note that (user-directory 'config) in particular already just falls
> >     back to use whatever `user-emacs-directory' was set to.  There is no
> >     need to duplicate what is happening in startup.el, or to try to
> >     outsmart it.
>
> What do you mean by "falls back"?  To respect the current behavior,
> the value of user-emacs-directory should be used in preference to
> everything else.

Sorry, I should have said "use", not "falls back": it returns the
value of 'user-emacs-directory' and does nothing else.

> But if we do that, then in which cases will the XDG
> directories be used, since user-emacs-directory always exists and is
> defined.

The 'config case is different from the 'cache, 'state and 'data cases,
where the XDG directories will be preferred instead.  To be more
precise, they will be preferred _only_ if we don't specify an old
name, or if we did specify an old name but no such file exists.

To give an example, let's assume that 'user-emacs-directory' is "~/.emacs.d/".

1. If "~/.emacs.d/old" exists, then we get:

    (user-file 'config "new" "old")
    => "~/.emacs.d/old"

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

2. However, if "~/.emacs.d/old" does not exist:

    (user-file 'config "new" old")
    => "~/.emacs.d/new"

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

3. Finally, let's consider the bookmark case, where a user might be
using the very old name "~/.emacs.bmk":

    (user-file 'data "bookmarks" (locate-user-emacs-file "bookmarks"
".emacs.bmk"))
    => "~/.emacs.bmk"

It's true that this requires discipline on behalf of application
developers when calling 'user-directory': they need to provide an "old
name" in addition to a "new name".  I don't see any way around that.
(See my separate email about the state of the API so far, and some
possible simplifications, especially for the third example above.)

I'd consider any failure to use a previously existing file as a bug.
Bugs will inevitably exist, but I don't believe fixing them will be
fundamentally impossible, or necessarily even hard.

Another consideration is that the interface of course has to be
helpful: it has to be easy to use correctly, and hard to use
incorrectly.  I think what it looks like now is not too bad in that
sense, but I'm very open to suggestions about how to do better.



  reply	other threads:[~2021-11-08 15:26 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 [this message]
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
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

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

  git send-email \
    --in-reply-to='CADwFkmnEphKdrL=gP+n74qDg0dPkwfm8iqcJedDX6CxBJwW6xA@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.