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: monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: user-directory: New library to find user {conf, data, state, ...} files
Date: Mon, 8 Nov 2021 23:05:57 -0800	[thread overview]
Message-ID: <CADwFkmkSTba6G=WtiWkN6oO3BjxiJxUkcPtxBOu48mms8fB59Q@mail.gmail.com> (raw)
In-Reply-To: <835yt27b4a.fsf@gnu.org>

Eli Zaretskii <eliz@gnu.org> writes:

>> 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.
>
> "Old file" or "old directory"?  That's an important difference, IMO.

The above applies to looking for the file name with `user-file'.

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.

I expect that most application code will use `user-file' rather than
`user-directory'.

> Which of the existing files we have in Emacs will be in one of the 3
> latter directories?  Please search the tree for uses of
> user-emacs-directory and tell me whether any of those will/should be
> in one of those 3.  If none of them should be there, then perhaps my
> problem is smaller than I feared, but I'd still want to talk about the
> files which will be in those 3.  And also perhaps we should see if
> some popular 3rd party packages place files under
> user-emacs-directory, and consider those as well.

I have looked over all of `user-emacs-directory' in our tree.  I found
some cases where 'locate-user-emacs-file' was not used, so I fixed them.
Now, if we filter out some irrelevant ones, I see this:

cache

  ./startup.el547:      (push (expand-file-name "eln-cache/"
user-emacs-directory)

data

  ./net/eww.el101:(defcustom eww-bookmarks-directory user-emacs-directory
  ./startup.el401:	 (concat user-emacs-directory "auto-save.list/_s"))
  ./startup.el403:	 (concat user-emacs-directory "auto-save-list/.saves-")))

state

  ./desktop.el259:(defcustom desktop-path (list user-emacs-directory "~")
  ./desktop.el1062:                                 user-emacs-directory)))
  ./desktop.el1255:             user-emacs-directory))))
  ./progmodes/gdb-mi.el654:(defcustom
gdb-window-configuration-directory user-emacs-directory

(The "desktop directory" should probably just be a "desktop file".
Similarly for the eww bookmarks and the gdb variable window
configuration.  But that's a separate issue.)

>> 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"
>
> Not sure I understand why "new" and "old" are different strings.
> Presumably, code which uses user-file will look for a particular
> basename, so why do we need 2 separate arguments?

The handling of them is currently different: "new" (NAME) is only
considered in the new directory, while "old" (OLD-NAME) is considered in
the new directory and in `user-emacs-directory'.

If we don't need to make that distinction, this can indeed be simplified
to just one argument.  I'm starting to lean towards the conclusion that
it is indeed okay to simplify this.

>> 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"
>
> And here I don't understand why the caller need to call
> locate-user-emacs-file explicitly? why couldn't user-file call it
> internally?

I have made a simplification on the branch, so the above is now:

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

With the further simplification of NAME and OLD-NAME discussed above,
this would be just:

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

> Hmm... actually, does the above mean that locate-user-emacs-file will
> forever use the old semantics?  Perhaps it should call user-file
> instead?

Sure, that is definitely something we could consider.  The main idea
here is that application code should use `user-file' directly though, to
be more explicit about what kind of file it is that they want to store.



  reply	other threads:[~2021-11-09  7:05 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 [this message]
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='CADwFkmkSTba6G=WtiWkN6oO3BjxiJxUkcPtxBOu48mms8fB59Q@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.