From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.devel Subject: Re: user-directory: New library to find user {conf, data, state, ...} files Date: Mon, 8 Nov 2021 23:05:57 -0800 Message-ID: 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> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31701"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 09 08:28:11 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 1mkLYB-0007y3-Co for ged-emacs-devel@m.gmane-mx.org; Tue, 09 Nov 2021 08:28:11 +0100 Original-Received: from localhost ([::1]:42632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mkLY9-0005l8-Fb for ged-emacs-devel@m.gmane-mx.org; Tue, 09 Nov 2021 02:28:09 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkLCm-0002Uz-3R for emacs-devel@gnu.org; Tue, 09 Nov 2021 02:06:04 -0500 Original-Received: from mail-pl1-f174.google.com ([209.85.214.174]:34583) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mkLCi-0002FD-SP; Tue, 09 Nov 2021 02:06:03 -0500 Original-Received: by mail-pl1-f174.google.com with SMTP id r5so19286784pls.1; Mon, 08 Nov 2021 23:05:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:in-reply-to:references:mime-version:date :message-id:subject:to:cc; bh=Wq5d4FODl8d8yYfqi2WasxKvx2kLIXYjBEmCy8xmvx8=; b=YQIxULLkpbmk6dOFjwV8ahuFdVqn1N6em0ZQlnNkLPFoEJOb/7fSBPsO9tTOqGqNOe XEUFiD9/smk20wFYoNhPq8sC9mNg/OrofBbjBy6pimhsw0Lm2ttuWOGlnv/r8gRAopQ2 zJXmL9MSqvqDSCMEDJjXsflMWCC/CeXLKf1FVp4bM+/k1OweDvgyhUJbywCV2gXV+GNw k1e79EvCXv3+fmf1czWPDcXHSSl6O2OoweZ/jd79rEk9QR0uG1l0ki4fXPRI8790f8Xw VbDBiNRcRm7J4fsr7wsLffWC7yrRTJphu9pStxDJRFFJcDkFv/b8J+k7a6R3yYNLGO9V BFmA== X-Gm-Message-State: AOAM530XhNQx2WgvhFj8RV0JVrkCeIVPrla6triZ5OH/m6cS/0YVORN+ Zt2F8YwfKnIjJ3uAKZXmjLDvLxaWxMKCKSxoWP82bCS8 X-Google-Smtp-Source: ABdhPJxqiTqFixeV0OTzsuBxkTdo4uDN+Q9eWjAID4AoTHYINnGK1u/Ah6RXK5Cp0qUrkpRd0LMyy+pHwNORhI+itr8= X-Received: by 2002:a17:90a:be10:: with SMTP id a16mr4695068pjs.133.1636441558856; Mon, 08 Nov 2021 23:05:58 -0800 (PST) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 8 Nov 2021 23:05:57 -0800 In-Reply-To: <835yt27b4a.fsf@gnu.org> Received-SPF: pass client-ip=209.85.214.174; envelope-from=stefankangas@gmail.com; helo=mail-pl1-f174.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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:279082 Archived-At: 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. 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.