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: Sun, 7 Nov 2021 21:04:42 -0600 Message-ID: References: <83sfwp1c27.fsf@gnu.org> <83sfwnyi65.fsf@gnu.org> <83k0hzydcg.fsf@gnu.org> <83wnlj7ng4.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="26340"; 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 Mon Nov 08 04:05:51 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 1mjuyk-0006i8-L4 for ged-emacs-devel@m.gmane-mx.org; Mon, 08 Nov 2021 04:05:50 +0100 Original-Received: from [::1] (port=38472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mjuyi-0001GJ-7t for ged-emacs-devel@m.gmane-mx.org; Sun, 07 Nov 2021 22:05:48 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:38666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mjuxi-0000Um-Vn for emacs-devel@gnu.org; Sun, 07 Nov 2021 22:04:47 -0500 Original-Received: from mail-pj1-f43.google.com ([209.85.216.43]:50741) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mjuxg-0002xR-Un; Sun, 07 Nov 2021 22:04:46 -0500 Original-Received: by mail-pj1-f43.google.com with SMTP id gn3so7059109pjb.0; Sun, 07 Nov 2021 19:04:44 -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=4ZBqd2tNXilbO2rKZD1t92e1zTN5O/M+LxcIyBYPc3k=; b=iZpVU7uBzA/kwtDJ2vsI9ddO52z4xITHEQ+FNKUbTAmI2Xge28td5/ML2Ssppuk8Z2 rtaZSd+U00VZA3nkoXqaVfnk1+A2BwkrAAEU2wvQ3x/ARMndfhkNWwIyDJyjSjcUkYcl 5A3lKvj+mH38WmSQdq3lpHTjXtdjx9g0jIle2hyJc9QhiYsNod8VAMCXoNMnK/dMNfW+ 6nwOz7FDwL8kGj7XH4r2llTYPo5wOgv5OrGfhjWnZEivnh4kGXM/ly08J/JmZLtB0MQ3 mpZ1xn4u+CVaH/1pG4KzfeHoOpO8S049f8FWx0TX155rDhj99Ns3OmF+88EvEonV3XMZ Aa3g== X-Gm-Message-State: AOAM532WWNdjr+rr//YoXWcR12auvVxSRN+U1mNmt8dWoogyKIeppoq2 GSRs84NWw2acE+S7vkyq9KxMLY68Qm9xqTdtGOO7tshX X-Google-Smtp-Source: ABdhPJxmxt8BDul6B2PSDTQPKyKfJhf9h2wIN+2ixx4AtFTLclGIkgQleB+drqPJr+BX1+4A0bz41Ki/vb0GS954mw0= X-Received: by 2002:a17:90b:1e0e:: with SMTP id pg14mr48195523pjb.143.1636340683054; Sun, 07 Nov 2021 19:04:43 -0800 (PST) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 7 Nov 2021 21:04:42 -0600 In-Reply-To: <83wnlj7ng4.fsf@gnu.org> Received-SPF: pass client-ip=209.85.216.43; envelope-from=stefankangas@gmail.com; helo=mail-pj1-f43.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.248, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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:279004 Archived-At: Eli Zaretskii writes: >> Note that on GNU/Linux, even if the user has their configuration file in >> "~/.emacs.d/", the library currently prefers the XDG paths here: >> >> (user-file 'cache "image-dired") >> => "~/.cache/emacs/image-dired" > > This contradicts how Emacs by default finds the init file: its > preference is the other way around, and it sets user-emacs-directory > according to the directory from which it loaded the init file. I > don't think I understand why this package should behave differently by > default (it could do that as an opt-in option, of course, if that is > considered useful to someone). It should because it is a change for the better. We have a chance to decide what this should look like for the foreseeable future, and I don't think we are bound by past decisions if they do not produce optimal (or even good) results. Here's my take on it: The `user-emacs-directory' directory currently contains a grab-bag of, well, everything, which among other things makes it hard for a user to know what is safe to delete and what is not, which files you would need to backup, etc. You basically need to manually inspect the files and consider their content one by one. The big use-case here, though, is that we want to be able to easily synchronize our Emacs configuration file between several machines. You don't want to synchronize things like your completion history or recently opened files, because it is not very useful, and you will have an infinite amounts of conflicts. (It's somewhat easier with version control, which is what I use, but less so if you want to use rsync or unison.) The solution is to proscribe that: The categories data, cache and state files belong in specific `data', `state' and `cache' directories. This means that e.g. my bookmarks file goes to the data directory, the recentf and saveplace file goes to `state', while my image-dired thumbnails go to `cache'. As for runtime files, I note that `server-socket-dir' already uses XDG_RUNTIME_DIR (but gets it manually). IOW, all this should be orthogonal to where your init file is placed. You can put it in any of the accepted locations, including the XDG one if you like. (Personally, I keep mine in "~/.emacs.d/init.el" and will continue to do so.) You should still be able to get all of the above, by default and with no hassle. What I propose is obviously inspired by the XDG BDS, but with the Emacs twist that its interface is not tied to that standard, it's completely customizable, and it can easily grow to be platform independent. 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. 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.