Create a file with more than 10 backup suffix (~) chars. in the name.
$ echo hello > '~~~~~~~~~~~'
Open the file in vim.
$ vim ~~~~~~~~~~~ Error detected while processing BufRead Autocommands for "*~"..BufRead Autocommands for "*~"..BufRead Autocommands for "*~"..BufRead Autocommands for "*~"..BufRead Autocommands for "*~"..BufRead Autocommands for "*~"..BufRead Autocommands for "*~"..BufRead Autocommands for "*~"..BufRead Autocommands for "*~"..BufRead Autocommands for "*~": E218: Autocommand nesting too deep No matching autocommands: filetypedetect BufRead ~ $
I've come up with this patch (sorry if it's ugly; this is my first vimscript!):
--- filetype.vim.orig 2023-06-17 00:53:06.712264000 +0000 +++ filetype.vim 2023-06-17 07:49:29.335998000 +0000 @@ -21,8 +21,14 @@ \ exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r")) au BufNewFile,BufRead *~ \ let s:name = expand("<afile>") | - \ let s:short = substitute(s:name, '\~$', '', '') | - \ if s:name != s:short && s:short != "" | + \ while 1 | + \ let s:short = substitute(s:name, '\~$', '', '') | + \ if s:name == s:short || s:short == "" | + \ break | + \ endif | + \ let s:name = s:short | + \ endwhile | + \ if s:short != "" | \ exe "doau filetypedetect BufRead " . fnameescape(s:short) | \ endif | \ unlet! s:name s:short
vim should open the file without the error message.
9.0.1637
Operating system: FreeBSD-13.2
Terminal: xterm-379
$TERM: xterm
Shell: bash
No response
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
let s:short = substitute(s:name, '~$', '', '') |
why not:
let s:short = substitute(s:name, '\~\+$', '', '') |
so remove as many ~ at the end of the name as possible?
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
why not
let s:short = substitute(s:name, '\~\+$', '', '') |so remove as many
~at the end of the name as possible?
Duh. Obvious when it's pointed out, innit? :) That works just fine (and I'll preemptively close this PR).
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Closed #12553 as completed.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()