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 11:31:50 -0800 Message-ID: References: <83sfwp1c27.fsf@gnu.org> <83sfwnyi65.fsf@gnu.org> <83k0hzydcg.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="5547"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier , Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 07 20:32:36 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 1mjnu8-0001CX-79 for ged-emacs-devel@m.gmane-mx.org; Sun, 07 Nov 2021 20:32:36 +0100 Original-Received: from [::1] (port=46782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mjnu7-0001P7-7c for ged-emacs-devel@m.gmane-mx.org; Sun, 07 Nov 2021 14:32:35 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:52058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mjntT-0000Oq-HQ for emacs-devel@gnu.org; Sun, 07 Nov 2021 14:31:55 -0500 Original-Received: from mail-pj1-f41.google.com ([209.85.216.41]:45625) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mjntR-000633-P5; Sun, 07 Nov 2021 14:31:55 -0500 Original-Received: by mail-pj1-f41.google.com with SMTP id gb13-20020a17090b060d00b001a674e2c4a8so7165104pjb.4; Sun, 07 Nov 2021 11:31:53 -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=QfSBBi0l6TRUzesr4/lvZRcqSFwHcMdJVRnTc7J9Pmo=; b=qYYNYa9rlrFTLpdIW0PxdwwwMKv3eKXdJhZeS1H4wEqxuHuts+G6corqy9SWXNZq2s cvDD2Cx84ZVyFn8MeJZVk87sOc+RcltlF8773nhk6DurxQjJYhC6QhXZmbu+L7amzkX5 J1tLGQnvzGKhv5t0AbmCQvia0QFOEXBYmK6G6jK+XAkzwL1F5wS6zfkyq9XNafcjGo9j 3Djp/Yk3Wrha64DZ6XAgNjczTRHEctx+o7M9KD95l+IGYUECYcLBrsQafJiNTLxmHBKU HIkD8Z0/KyWj8GMnfcU7cyFXvp+Yf9WcHaKDPcv5OvA9mXS3DSFKGC0RPtOeBZbvntoo tPhw== X-Gm-Message-State: AOAM531PSPeucZBwpeNUl3YgvgoxfkG33mKOV1qi0aTvXiY1liE+1td7 yTSbUu1qxx1cT2hNnrUKEomlU7UJqVsTxUf5G1Q= X-Google-Smtp-Source: ABdhPJzaLrSFz6pv6gc0K0G+alPfA/OTJDXMfpeSqPcwSHcLft0lFH8jlK6OgETv0HLu16e2XWXDZur1/torSSoFIXc= X-Received: by 2002:a17:902:e8c9:b0:141:6eaa:2137 with SMTP id v9-20020a170902e8c900b001416eaa2137mr65294587plg.22.1636313511811; Sun, 07 Nov 2021 11:31:51 -0800 (PST) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 7 Nov 2021 11:31:50 -0800 In-Reply-To: Received-SPF: pass client-ip=209.85.216.41; envelope-from=stefankangas@gmail.com; helo=mail-pj1-f41.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:278977 Archived-At: Stefan Kangas writes: > I hacked something quick together and pushed it to > features/user-directory, mostly so that we can decide on the basic API. > It needs more work, but the interface should hopefully be clear. > > The one I propose is: > > (user-directory 'cache) > => "/home/skangas/.cache" > > (user-file 'cache "foo") > => "/home/skangas/.cache/foo" > > There's also a defcustom `user-directory-alist' for overrides: > > (let ((user-directory-alist '((downloads "/foo")))) > (user-directory 'downloads)) > => "/foo" OK, I think this is ready for merging to master so that we can start experimenting with it, obviously based on the assumption that this is tentative and open for change. I guess someone will want to look at adding MS-Windows support to this, for example. 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 is a feature. If users prefer not to have a clean "~/.emacs.d/" they can say: (setq user-directory-alist '((cache . user-emacs-directory) (config . user-emacs-directory) (data . user-emacs-directory) (runtime . user-emacs-directory) (state . user-emacs-directory))) I also think we should consider adding some heuristics to `user-file' to be able to find the old name if it exists. I considered some alternatives, but I thought I'd see what people think first. Currently, application code would say: (user-file 'cache "image-dired" (locate-user-emacs-file "image-dired")) Which could, if we want to be smart, be simplified to: (user-file 'cache "image-dired" "image-dired") Or even: (user-file 'cache "image-dired") Unfortunately, in this case I think it's harder to be smart: (user-file 'data "bookmarks" (locate-user-emacs-file "bookmarks" ".emacs.bmk")) But perhaps we can think of something even for that.