Issue #4339 raises a subtle question. What characters should be valid in Leo's @path directives?
The existing code defines the valid characters with this regex:
r"^@path\s+([\w_:/\\]+)"
In other words, the valid characters are:
-- Unicode word characters.
-- Underscores.
-- The three common path separators: colon, slash, and backslash.
But many more characters are typically valid in directory names, including blanks!
The most general scheme would be to allow all printable characters in an @path directive except trailing blanks.
What do you all think?
Edward
Issue #4339 raises a subtle question. What characters should be valid in Leo's @path directives?
The existing code defines the valid characters with this regex:
r"^@path\s+([\w_:/\\]+)"
I have vaguely wondered "what does Leo allow in path directives" myself.Isn't the list of 'what characters are allowed in directory names' OS-dependent??
Since we expect the @path directive to be able to point to an actual existing directory, I think it has to allow spaces.
With spaces, I suppose that the paths would have to be quoted so that they are delimited.
I do not think that wild card path characters need to be (or should be) supported; if included, then Leo would not know how to create a non-existing path, and they would never occur in already-existing paths.
Actually, there are several characters that Windows doesn't allow in paths. According to ChatGPT they are <>:"/\\|?*
I don't like the idea of allowing other non-printing characters even if the OS would allow them because a user would have no way of knowing what the right character is supposed to be. I don't suppose they occur very often in the wild for just this reason.
The revised PR allows all characters except for trailing whitespace. It's up to the user to create a valid path. If a character doesn't make sense in a directory name, the OS will say so, so I think there is little practical danger in the PR's changes.
On Thursday, April 24, 2025 at 3:26:20 PM UTC-4 Edward K. Ream wrote:The revised PR allows all characters except for trailing whitespace. It's up to the user to create a valid path. If a character doesn't make sense in a directory name, the OS will say so, so I think there is little practical danger in the PR's changes.What I don't understand is how to know if a given space is a trailing space. It used to be, didn't it, that a headline could have text after the path of an @path directive. I never used it like that but I have been under the impression that it did.
If so, text following a space that was intended to have been a trailing space would get included into the path. The obvious cure is not to allow any text after the path. Is this going to be a new restriction, or has it always been like that?
On Fri, Apr 25, 2025 at 12:00 PM jkn <jkn...@nicorp.f9.co.uk> wrote:> You seem to be saying (if I am not mistaken) that you plan to allow trailing characters in an @path directive ... and that these will be reflected in the created directory name. Is that correct?No. I meant the reverse: the PR strips trailing blanks.> I am probably fairly agnostic about these sort of changes - since I would strongly try to avoid creating directories like this if at all possible.Leo never creates directories without your explicit permission.
> 'However' I do have a vague "It would be nice if" IWBNI you could have a trailing comment in in an @path headline. This of course implies some way of delimiting the comment ... and this probably clashes with what you are trying to achieve with the directory characters.This "feature" was never intended and the PR (just merged) eliminates it. The benefits of the former Easter Egg are miniscule compared with the problems.
Edward
...I would strongly resist creating/using directories with trailing spaces. Heck, I still resist spaces within file and directory names!