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: user-directory: New library to find user {conf,data,state,...} files Date: Fri, 5 Nov 2021 18:38:40 -0700 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="25705"; 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 Sat Nov 06 02:39:49 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 1mjAgP-0006Pr-3U for ged-emacs-devel@m.gmane-mx.org; Sat, 06 Nov 2021 02:39:49 +0100 Original-Received: from localhost ([::1]:52566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mjAgN-0002zc-W5 for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Nov 2021 21:39:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mjAfS-0002JQ-CV for emacs-devel@gnu.org; Fri, 05 Nov 2021 21:38:50 -0400 Original-Received: from mail-pg1-f169.google.com ([209.85.215.169]:39472) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mjAfQ-0001hV-88; Fri, 05 Nov 2021 21:38:50 -0400 Original-Received: by mail-pg1-f169.google.com with SMTP id g184so9732072pgc.6; Fri, 05 Nov 2021 18:38:42 -0700 (PDT) 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=Rk6hxxjfPMa5yFI4z6jrWdf24or+Df+Ea3faiMQ0hCk=; b=qgSCFaQpCC9pqTdg1jP6cLm5mzgh+7up7w9y1qkJECiBQeZlnuXfKdzTls2Um5mVrE kgdQGRgVF1SUGkwO5+ud3gcJSH8T3oclo3tJsMp6PN6YmKP7CH+++rwJWOKBXpjeX6nM JtD8FGkxFr0VGS7nnrOWzwP54tdBpEITuPkhC7ZmyZFLTaovA24bp+J19oh5wliAQuy6 mGgJ4rDJ9pmqg3Yvnh/HSt5xzDFCqjemLp5UllmVQPjngihO8YfkC74Uz5yiokBAHTUb 5R7/2t9X/t4MpkKLwnvYB8efkkXoahexEQX7F8aPv9jiLx16Y4rybcoPJdIW0X7ngAjB xseQ== X-Gm-Message-State: AOAM53030809HK4gnOqZFYeAyUaxXawbaibv9vZPAygMlH6+boOeKenJ +msb5/GjF2EupzjhwJz/W9gRrou8HI8WHEG8TXs= X-Google-Smtp-Source: ABdhPJzsLVY9XPFIHbXo2Z4kIwasv1XNhWqzrbh+wshXgrxGCaRyERXOxMbv0+0sD0tRA7G23nmYo4jKOoByFbcVTJ8= X-Received: by 2002:a05:6a00:244d:b0:44d:c279:5155 with SMTP id d13-20020a056a00244d00b0044dc2795155mr63053967pfj.0.1636162721132; Fri, 05 Nov 2021 18:38:41 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Fri, 5 Nov 2021 18:38:40 -0700 In-Reply-To: Received-SPF: pass client-ip=209.85.215.169; envelope-from=stefankangas@gmail.com; helo=mail-pg1-f169.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:278828 Archived-At: Stefan Monnier writes: >> The only decision we need to make is whether we want a single function >> that accepts an argument telling it the purpose of the standard >> directory (in this case, I'd use 'PICTURES, a symbol), or maybe a >> separate function for each kind of directory, like user-pictures-dir. > > I'd vote for a single defgeneric function. 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" I thought about having defuns like `user-directory-cache', which gives us autocompletion, but I feel like the symbol approach is more straightforward and means we can avoid code like this: (intern (concat "user-directory-" (symbol-name sym))) This is implemented with a defgeneric, as suggested by Stefan Monnier (thanks!), but we could easily convert it to regular defuns if we need to preload it.