Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
29809:7847804c8a72 | 29810:761631155a90 |
---|---|
1931 { | 1931 { |
1932 return fgetline == getsourceline | 1932 return fgetline == getsourceline |
1933 ? ((source_cookie_T *)cookie)->sourcing_lnum | 1933 ? ((source_cookie_T *)cookie)->sourcing_lnum |
1934 : SOURCING_LNUM; | 1934 : SOURCING_LNUM; |
1935 } | 1935 } |
1936 | |
1937 void | |
1938 f_getscriptinfo(typval_T *argvars UNUSED, typval_T *rettv) | |
1939 { | |
1940 int i; | |
1941 list_T *l; | |
1942 | |
1943 if (rettv_list_alloc(rettv) == FAIL) | |
1944 return; | |
1945 | |
1946 l = rettv->vval.v_list; | |
1947 | |
1948 for (i = 1; i <= script_items.ga_len; ++i) | |
1949 { | |
1950 scriptitem_T *si = SCRIPT_ITEM(i); | |
1951 dict_T *d; | |
1952 | |
1953 if (si->sn_name == NULL) | |
1954 continue; | |
1955 | |
1956 if ((d = dict_alloc()) == NULL | |
1957 || list_append_dict(l, d) == FAIL | |
1958 || dict_add_string(d, "name", si->sn_name) == FAIL | |
1959 || dict_add_number(d, "sid", i) == FAIL | |
1960 || dict_add_bool(d, "autoload", | |
1961 si->sn_state == SN_STATE_NOT_LOADED) == FAIL) | |
1962 return; | |
1963 } | |
1964 } | |
1965 | |
1936 #endif | 1966 #endif |
1937 | 1967 |
1938 static char_u * | 1968 static char_u * |
1939 get_one_sourceline(source_cookie_T *sp) | 1969 get_one_sourceline(source_cookie_T *sp) |
1940 { | 1970 { |