From 85c61d67160133ba53762bc1e5e7bbd7a0c582c0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 19 Apr 2023 10:06:34 +0800 Subject: vim-patch:9.0.1007: there is no way to get a list of swap file names Problem: There is no way to get a list of swap file names. Solution: Add the swapfilelist() function. Use it in the test script to clean up. Remove deleting individual swap files. https://github.com/vim/vim/commit/c216a7a21a25a701b84b79abc1ba6ab0baa3a311 vim-patch:9.0.1005: a failed test may leave a swap file behind Problem: A failed test may leave a swap file behind. Solution: Delete the swap file to avoid another test to fail. Use another file name. https://github.com/vim/vim/commit/d0f8d39d20f8d42f7451f781f7be0bcd20e06741 Cherry-pick test_window_cmd.vim changes from patch 8.2.1593. Remove FUNC_ATTR_UNUSED from eval functions as fptr is always unused. Co-authored-by: Bram Moolenaar --- runtime/doc/builtin.txt | 12 ++++++++++++ runtime/doc/usr_41.txt | 1 + 2 files changed, 13 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 15ccfd9b92..9a8ce4d2ad 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -506,6 +506,7 @@ submatch({nr} [, {list}]) String or List specific match in ":s" or substitute() substitute({expr}, {pat}, {sub}, {flags}) String all {pat} in {expr} replaced with {sub} +swapfilelist() List swap files found in 'directory' swapinfo({fname}) Dict information about swap file {fname} swapname({buf}) String swap file of buffer {buf} synID({lnum}, {col}, {trans}) Number syntax ID at {lnum} and {col} @@ -8417,6 +8418,17 @@ substitute({string}, {pat}, {sub}, {flags}) *substitute()* Can also be used as a |method|: > GetString()->substitute(pat, sub, flags) +swapfilelist() *swapfilelist()* + Returns a list of swap file names, like what "vim -r" shows. + See the |-r| command argument. The 'directory' option is used + for the directories to inspect. If you only want to get a + list of swap files in the current directory then temporarily + set 'directory' to a dot: > + let save_dir = &directory + let &directory = '.' + let swapfiles = swapfilelist() + let &directory = save_dir + swapinfo({fname}) *swapinfo()* The result is a dictionary, which holds information about the swapfile {fname}. The available fields are: diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index 17a34b1236..89111535ca 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -883,6 +883,7 @@ Buffers, windows and the argument list: getwininfo() get a list with window information getchangelist() get a list of change list entries getjumplist() get a list of jump list entries + swapfilelist() list of existing swap files in 'directory' swapinfo() information about a swap file swapname() get the swap file path of a buffer -- cgit