emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 4f1a5e4: Add `file-name-set-extension'


From: Colin Woodbury
Subject: Re: master 4f1a5e4: Add `file-name-set-extension'
Date: Sat, 26 Jun 2021 11:26:46 -0700
User-agent: mu4e 1.4.15; emacs 28.0.50

Hi gentlemen, Lars brought up some excellent points, so I did a survey
of other languages to see what they expect/permit:

| Language | Forgives dot? | Scrutinizes ext? | Handles directories? |
|----------+---------------+------------------+----------------------|
| Rust     | No            | No               | No                   |
| Python   | "Yes"         | "Yes"            | No                   |
| Haskell  | Yes           | No               | No                   |

Rust allows everything, including setting the extension of a directory,
the result of which then returns `false` for `is_dir()`.

Python throws an exception if the passed extension doesn't begin with a
dot, but otherwise allows anything else in the filename or extension.

Haskell allows the "dot or not" trick that I had adopted in my patches,
but otherwise doesn't scrutinize the contents of the filename or extension.

I also looked at Golang, but it was just raw string manipulation with no
extra helper functions.

And given that my FS seems to accept spaces in both filenames and their
extensions without issue, I've landed on the following logic:

- DO allow the passing of an optionally dotted extension, like Haskell.
- DO only strip a single dot.
- DO check if the filename is empty or shaped like a directory name.
- DON'T otherwise care about the contents of the filename or extension.

I've attached a revised patch that accounts for these. And for Michael,
I made sure to add the texinfo docs and NEWS entry.

Cheers!
Colin

Attachment: file-name-with-extension.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]