[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#60929: 30.0.50; [FR] `file-name-extension' and backup suffixes
From: |
Ihor Radchenko |
Subject: |
bug#60929: 30.0.50; [FR] `file-name-extension' and backup suffixes |
Date: |
Wed, 18 Jan 2023 10:50:08 +0000 |
Hi,
Would it be possible to make `file-name-sans-extension' strip extension
upon removing backup suffixes (optionally)?
Currently, Emacs' handling of backup extensions is a bit inconsistent:
auto-mode-alist recognizes
("\\.~?[0-9]+\\.[0-9][-.0-9]*~?\\'" nil t)
("\\.\\(?:orig\\|in\\|[bB][aA][kK]\\)\\'" nil t)
as backup extension and thus opens files like foo.org.bak with Org mode.
Further, `file-name-extension' returns:
The extension, in a file name, is the part that begins with the last .,
excluding version numbers and backup suffixes, except that a leading .
of the file name, if there is one, doesn't count.
But it only works for the native Emacs "~" style of backups (on Linux,
at least). If one tries (file-name-extension "foo.org.bak") ; => "bak",
we do not see backup extension stripped, which is correct wrt the
docstring, but problematic when we need to handle backup files on
Windows.
If one needs to strip backup extension/suffix for .bak and similar
files, there is a need to re-use
"\\.\\(?:orig\\|in\\|[bB][aA][kK]\\)\\'" regexp, which is not ideal
because auto-mode-alist may include other backup suffixes in future.
It would be useful if functions like `file-name-extension',
`file-name-sans-extension', and similar could optionally strip backup
suffixes that contain ".".
Context: https://orgmode.org/list/25543.50706.554658.6937@gargle.gargle.HOWL
In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, cairo version
1.17.6) of 2023-01-16 built on localhost
Repository revision: bb679244152dddd9949ca065aa6617457f7a7144
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101006
System Description: Gentoo Linux
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
- bug#60929: 30.0.50; [FR] `file-name-extension' and backup suffixes,
Ihor Radchenko <=
- bug#60929: 30.0.50; [FR] `file-name-extension' and backup suffixes, Ruijie Yu, 2023/01/18
- bug#60929: 30.0.50; [FR] `file-name-extension' and backup suffixes, Eli Zaretskii, 2023/01/18
- bug#60929: 30.0.50; [FR] `file-name-extension' and backup suffixes, Ihor Radchenko, 2023/01/18
- bug#60929: 30.0.50; [FR] `file-name-extension' and backup suffixes, Eli Zaretskii, 2023/01/18
- bug#60929: 30.0.50; [FR] `file-name-extension' and backup suffixes, Ihor Radchenko, 2023/01/23
- bug#60929: 30.0.50; [FR] `file-name-extension' and backup suffixes, Eli Zaretskii, 2023/01/23
- bug#60929: 30.0.50; [FR] `file-name-extension' and backup suffixes, Ihor Radchenko, 2023/01/24
- bug#60929: 30.0.50; [FR] `file-name-extension' and backup suffixes, Eli Zaretskii, 2023/01/24
- bug#60929: 30.0.50; [FR] `file-name-extension' and backup suffixes, Ihor Radchenko, 2023/01/25
- bug#60929: 30.0.50; [FR] `file-name-extension' and backup suffixes, Eli Zaretskii, 2023/01/25