From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: user-directory: New library to find user {conf, data, state, ...} files Date: Tue, 09 Nov 2021 20:23:38 +0200 Message-ID: <83lf1x428l.fsf@gnu.org> References: <83sfwp1c27.fsf@gnu.org> <83sfwnyi65.fsf@gnu.org> <83k0hzydcg.fsf@gnu.org> <83wnlj7ng4.fsf@gnu.org> <83fss67nvw.fsf@gnu.org> <835yt27b4a.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17539"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Stefan Kangas Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 09 19:24:22 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mkVnB-0004L1-98 for ged-emacs-devel@m.gmane-mx.org; Tue, 09 Nov 2021 19:24:21 +0100 Original-Received: from localhost ([::1]:51654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mkVn9-0001rU-PC for ged-emacs-devel@m.gmane-mx.org; Tue, 09 Nov 2021 13:24:19 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:52650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkVmc-0001C1-Ez for emacs-devel@gnu.org; Tue, 09 Nov 2021 13:23:46 -0500 Original-Received: from [2001:470:142:3::e] (port=51240 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkVmb-0007rf-N9; Tue, 09 Nov 2021 13:23:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=DUpRbiS1pAKsHgcoStV/lba8Qb4TdIOKIRg+tUxzynM=; b=oPHlfqAzpLFt OFIk1OagKd9/t2Ojgp4FybvURP1EAHQFrd3HnWiWU802A/m+97+EOxQi9S+d+L+a5vyBHdu9reTPN 7vh225oqPBa8ni5UIQ1JYcRpqV4AE8xw3+6GDURB7NV8QjIR+PWLIP+vpJHDE0LadQJt5ua0v8Zhj pxCqioQWyRx6Oppb+wEmcZtSUMfo13cgcz3lxKZuDLyDlBi2Ni/6hO0aqPjaSTxMEqWrfdrvzh1Rv DTeBfYGKQ0xblt2Q23uqjFHB8Hb2cglbfxaw6TsnKP4sAcRUKKKJGnBRH75+yNjKM5sUN9SEoy1BC vGqIaIDiMMGPurGlzL9+dw==; Original-Received: from [87.69.77.57] (port=4381 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkVmb-00007A-AS; Tue, 09 Nov 2021 13:23:45 -0500 In-Reply-To: (message from Stefan Kangas on Mon, 8 Nov 2021 23:05:57 -0800) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:279120 Archived-At: > From: Stefan Kangas > Date: Mon, 8 Nov 2021 23:05:57 -0800 > Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org > > Eli Zaretskii 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. 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? > I expect that most application code will use `user-file' rather than > `user-directory'. If some Lisp program needs to ensure a sub-directory of user-emacs-directory exists, it will want to use user-directory, I think. > > 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) 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": $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. > 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 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? > (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.) No, desktop.el is explicitly programmed to be able to use a "path", i.e. a list of directories. You can have several different desktop files in several different directories, and use each one for its own project or type of activity. > >> 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. I see no reason not to. We are not going to change the base names as well, are we? > (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") Once again, why not just one argument?