Expand description
~ expansion, shared so every consumer resolves a home the same way.
~ expansion, in one place.
§Why this exists rather than a local helper per consumer
There were four, and they disagreed in the way that matters. The agenda’s,
the completion generator’s, the dispatcher’s and the org guest’s were each a
private expand_tilde, and the first three resolved the home directory as
std::env::var_os("HOME") — which is POSIX-only. On Windows that returns
None, so ~/notes was left verbatim and every lookup silently found
nothing. org.agenda-files’ own documentation says “~ is expanded”, and
on Windows it did not.
Silent is the operative word. A path that fails to expand does not error; it becomes a path that does not exist, and every consumer here reports “no files” rather than “that is not a real directory”. The user is then told their corpus is empty.
[dirs::home_dir] answers on Windows too (%USERPROFILE%, then the
known-folder API), which is the whole reason to converge rather than to fix
four copies of the HOME lookup.
§What it deliberately is not
Not shell expansion. No $VAR, no ~other-user, no globbing. The one thing
a user types by hand that a PathBuf will not resolve is a leading tilde,
and every step past that is a parser with its own quoting rules — which a
config value is not asking for. A $HOME/notes that stayed verbatim would
be visible and fixable; guessing at it would not.
Functions§
- contract_
tilde expand_tilde’s inverse: put the~back for DISPLAY.- expand_
tilde - Expand a leading
~against the user’s home directory. - expand_
tilde_ path expand_tildefor aPath, returning aPathBuf.