On Thu, 7 Aug 2025 14:11:08 -0500 Dirk Eddelbuettel <edd at debian.org> wrote:> One suggestion is to use '*.sw[g-p]' to spare .swf files for FlashOn Unix-like systems (and, empirically, on Windows, despite ':help swap-file' says the dots are replaced), Vim prepends a dot to the name of the swap file. So how about only matching files that start with a dot and end with .sw[certain letters]? grepl( '(^|/)[.][^/]+[.]sw[a-p]$', c('.swap.file.swp', 'subdir/.swapfile.swn', 'not-a-swapfile.swc'), perl = TRUE ) # [1] TRUE TRUE FALSE -- Best regards, Ivan
On 7 August 2025 at 23:07, Ivan Krylov wrote: | On Thu, 7 Aug 2025 14:11:08 -0500 | Dirk Eddelbuettel <edd at debian.org> wrote: | | > One suggestion is to use '*.sw[g-p]' to spare .swf files for Flash | | On Unix-like systems (and, empirically, on Windows, despite ':help | swap-file' says the dots are replaced), Vim prepends a dot to the name | of the swap file. So how about only matching files that start with a | dot and end with .sw[certain letters]? | | grepl( | '(^|/)[.][^/]+[.]sw[a-p]$', | c('.swap.file.swp', 'subdir/.swapfile.swn', 'not-a-swapfile.swc'), | perl = TRUE | ) | # [1] TRUE TRUE FALSE Nice. This regexp '(^|/)[.][^/]+[.]sw[a-p]$' is a clear improvement over the (much) simpler one "\\.sw.$" from my PR (which was mostly about adding "^(GPATH|GRTAGS|GTAGS)$" for the GNU Global source tagger) as it covers both top-level and subdirectories and hence avoids hitting *.swf or *.swc files. I trust you checked that 'perl = TRUE' applies also to these entries from tools:::get_exclude_patterns() ? Dirk -- dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org