Mercurial > vim
comparison src/tag.c @ 26268:3aa48d4e3dc8 v8.2.3665
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Commit: https://github.com/vim/vim/commit/19916a8c8920b6a1fd737ffa6d4e363fc7a96319
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Wed Nov 24 16:32:55 2021 +0000
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Problem: Cannot use a lambda for 'tagfunc'.
Solution: Use 'tagfunc' like 'opfunc'. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/9204)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 24 Nov 2021 17:45:03 +0100 |
parents | 336e2d9924e6 |
children | 8aba638e91eb |
comparison
equal
deleted
inserted
replaced
26267:069672443852 | 26268:3aa48d4e3dc8 |
---|---|
101 static taggy_T ptag_entry = {NULL, {{0, 0, 0}, 0}, 0, 0, NULL}; | 101 static taggy_T ptag_entry = {NULL, {{0, 0, 0}, 0}, 0, 0, NULL}; |
102 #endif | 102 #endif |
103 | 103 |
104 #ifdef FEAT_EVAL | 104 #ifdef FEAT_EVAL |
105 static int tfu_in_use = FALSE; // disallow recursive call of tagfunc | 105 static int tfu_in_use = FALSE; // disallow recursive call of tagfunc |
106 static callback_T tfu_cb; // 'tagfunc' callback function | |
106 #endif | 107 #endif |
107 | 108 |
108 // Used instead of NUL to separate tag fields in the growarrays. | 109 // Used instead of NUL to separate tag fields in the growarrays. |
109 #define TAG_SEP 0x02 | 110 #define TAG_SEP 0x02 |
111 | |
112 /* | |
113 * Reads the 'tagfunc' option value and convert that to a callback value. | |
114 * Invoked when the 'tagfunc' option is set. The option value can be a name of | |
115 * a function (string), or function(<name>) or funcref(<name>) or a lambda. | |
116 */ | |
117 int | |
118 set_tagfunc_option() | |
119 { | |
120 #ifdef FEAT_EVAL | |
121 free_callback(&tfu_cb); | |
122 free_callback(&curbuf->b_tfu_cb); | |
123 | |
124 if (*curbuf->b_p_tfu == NUL) | |
125 return OK; | |
126 | |
127 if (option_set_callback_func(curbuf->b_p_tfu, &tfu_cb) == FAIL) | |
128 return FAIL; | |
129 | |
130 copy_callback(&curbuf->b_tfu_cb, &tfu_cb); | |
131 #endif | |
132 | |
133 return OK; | |
134 } | |
135 | |
136 # if defined(EXITFREE) || defined(PROTO) | |
137 void | |
138 free_tagfunc_option(void) | |
139 { | |
140 # ifdef FEAT_EVAL | |
141 free_callback(&tfu_cb); | |
142 # endif | |
143 } | |
144 # endif | |
145 | |
146 /* | |
147 * Copy the global 'tagfunc' callback function to the buffer-local 'tagfunc' | |
148 * callback for 'buf'. | |
149 */ | |
150 void | |
151 buf_set_tfu_callback(buf_T *buf UNUSED) | |
152 { | |
153 #ifdef FEAT_EVAL | |
154 free_callback(&buf->b_tfu_cb); | |
155 if (tfu_cb.cb_name != NULL && *tfu_cb.cb_name != NUL) | |
156 copy_callback(&buf->b_tfu_cb, &tfu_cb); | |
157 #endif | |
158 } | |
110 | 159 |
111 /* | 160 /* |
112 * Jump to tag; handling of tag commands and tag stack | 161 * Jump to tag; handling of tag commands and tag stack |
113 * | 162 * |
114 * *tag != NUL: ":tag {tag}", jump to new tag, add to tag stack | 163 * *tag != NUL: ":tag {tag}", jump to new tag, add to tag stack |
1339 g_tag_at_cursor ? "c": "", | 1388 g_tag_at_cursor ? "c": "", |
1340 flags & TAG_INS_COMP ? "i": "", | 1389 flags & TAG_INS_COMP ? "i": "", |
1341 flags & TAG_REGEXP ? "r": ""); | 1390 flags & TAG_REGEXP ? "r": ""); |
1342 | 1391 |
1343 save_pos = curwin->w_cursor; | 1392 save_pos = curwin->w_cursor; |
1344 result = call_vim_function(curbuf->b_p_tfu, 3, args, &rettv); | 1393 result = call_callback(&curbuf->b_tfu_cb, 0, &rettv, 3, args); |
1345 curwin->w_cursor = save_pos; // restore the cursor position | 1394 curwin->w_cursor = save_pos; // restore the cursor position |
1346 --d->dv_refcount; | 1395 --d->dv_refcount; |
1347 | 1396 |
1348 if (result == FAIL) | 1397 if (result == FAIL) |
1349 return FAIL; | 1398 return FAIL; |