This is an alternative (which I find better) to https://github.com/geany/geany/pull/1191.
When cloning documents, a filename that's similar to the original - with a `.clone` extension appended to it, is given to the clone. The new filename is unique. It starts first with `filename.clone`. If the filename exists or is used by another document, a number is appended to it (e.g. `.clone1`), which increments until a unique filename is found.
You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/1197
-- Commit Summary --
* Give '.cloneX' filenames to cloned documents * Add documentation * Use locale-encoded string when testing if file exists
-- File Changes --
M doc/geany.txt (6) M src/document.c (46)
-- Patch Links --
https://github.com/geany/geany/pull/1197.patch https://github.com/geany/geany/pull/1197.diff
One problem I see with adding `.clone` to the end fo the filename is that after its closed Geany may not be able to determine its filetype again. Better to make the change inside the filename so the extension is unchanged.
Better to make the change inside the filename so the extension is unchanged.
I thought about that version, but it would make the code more complicated for just a simple feature. You'd have to do some splitting and use more temporary strings than just use `g_strdup_sprintf()`. It's also unclear how you'd get the no-extension part of the filename that has multiple dots in it, and it could mean more code as well.
I also don't think all people would want that version since appending an extension to a copy or backup is a common convention. A lot of people do `cp filename.ext{,.orig}` or `cp filename.ext{,.copy}`. I also find it more descriptive, even when done recursively like `filename.ext.clone.clone`, and is also consistent with the manner on how other file formats are named like `.tar.gz`. Besides, a clone is meant to be renamed anyway, when it's needed to be used to something other than just a copy.
Closing for lack of interest.
Closed #1197.
github-comments@lists.geany.org