[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
user-directory: New library to find user {conf,data,state,...} files
From: |
Stefan Kangas |
Subject: |
user-directory: New library to find user {conf,data,state,...} files |
Date: |
Fri, 5 Nov 2021 18:38:40 -0700 |
Stefan Monnier <monnier@iro.umontreal.ca> 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.
- user-directory: New library to find user {conf,data,state,...} files,
Stefan Kangas <=
- Re: user-directory: New library to find user {conf,data,state,...} files, Lars Ingebrigtsen, 2021/11/05
- Re: user-directory: New library to find user {conf, data, state, ...} files, Stefan Kangas, 2021/11/05
- Re: user-directory: New library to find user {conf, data, state, ...} files, Stefan Kangas, 2021/11/07
- Re: user-directory: New library to find user {conf, data, state, ...} files, Eli Zaretskii, 2021/11/07
- Re: user-directory: New library to find user {conf, data, state, ...} files, Stefan Kangas, 2021/11/07
- Re: user-directory: New library to find user {conf, data, state, ...} files, Eric S Fraga, 2021/11/08
- Re: user-directory: New library to find user {conf, data, state, ...} files, Eli Zaretskii, 2021/11/08
- Re: user-directory: New library to find user {conf, data, state, ...} files, Stefan Kangas, 2021/11/08
- Re: user-directory: New library to find user {conf, data, state, ...} files, Eli Zaretskii, 2021/11/08