Mercurial > vim
diff src/scriptfile.c @ 29810:761631155a90 v9.0.0244
patch 9.0.0244: cannot easily get the list of sourced scripts
Commit: https://github.com/vim/vim/commit/f768c3d19c518822d89dec4cc3947ddeea249316
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Mon Aug 22 13:15:13 2022 +0100
patch 9.0.0244: cannot easily get the list of sourced scripts
Problem: Cannot easily get the list of sourced scripts.
Solution: Add the getscriptinfo() function. (Yegappan Lakshmanan,
closes #10957)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 22 Aug 2022 14:30:04 +0200 |
parents | bc6cf208b1b4 |
children | 8ebfea14d9bb |
line wrap: on
line diff
--- a/src/scriptfile.c +++ b/src/scriptfile.c @@ -1933,6 +1933,36 @@ get_sourced_lnum( ? ((source_cookie_T *)cookie)->sourcing_lnum : SOURCING_LNUM; } + + void +f_getscriptinfo(typval_T *argvars UNUSED, typval_T *rettv) +{ + int i; + list_T *l; + + if (rettv_list_alloc(rettv) == FAIL) + return; + + l = rettv->vval.v_list; + + for (i = 1; i <= script_items.ga_len; ++i) + { + scriptitem_T *si = SCRIPT_ITEM(i); + dict_T *d; + + if (si->sn_name == NULL) + continue; + + if ((d = dict_alloc()) == NULL + || list_append_dict(l, d) == FAIL + || dict_add_string(d, "name", si->sn_name) == FAIL + || dict_add_number(d, "sid", i) == FAIL + || dict_add_bool(d, "autoload", + si->sn_state == SN_STATE_NOT_LOADED) == FAIL) + return; + } +} + #endif static char_u *