Mercurial > vim
comparison src/ops.c @ 667:9090f866cd57 v7.0197
updated for version 7.0197
author | vimboss |
---|---|
date | Tue, 14 Feb 2006 22:29:30 +0000 |
parents | 53114ef7778f |
children | 9364d114ed8d |
comparison
equal
deleted
inserted
replaced
666:0137e7c3d31b | 667:9090f866cd57 |
---|---|
4310 } | 4310 } |
4311 } | 4311 } |
4312 #endif | 4312 #endif |
4313 } | 4313 } |
4314 | 4314 |
4315 #if defined(FEAT_EVAL) || defined(PROTO) | |
4316 /* | |
4317 * Implementation of the format operator 'gq' for when using 'formatexpr'. | |
4318 */ | |
4319 void | |
4320 op_formatexpr(oap) | |
4321 oparg_T *oap; | |
4322 { | |
4323 # ifdef FEAT_VISUAL | |
4324 if (oap->is_VIsual) | |
4325 /* When there is no change: need to remove the Visual selection */ | |
4326 redraw_curbuf_later(INVERTED); | |
4327 # endif | |
4328 | |
4329 (void)fex_format(oap->start.lnum, oap->line_count); | |
4330 } | |
4331 | |
4332 int | |
4333 fex_format(lnum, count) | |
4334 linenr_T lnum; | |
4335 long count; | |
4336 { | |
4337 int use_sandbox = was_set_insecurely((char_u *)"formatexpr"); | |
4338 int r; | |
4339 | |
4340 /* | |
4341 * Set v:lnum to the first line number and v:count to the number of lines. | |
4342 */ | |
4343 set_vim_var_nr(VV_LNUM, lnum); | |
4344 set_vim_var_nr(VV_COUNT, count); | |
4345 | |
4346 /* | |
4347 * Evaluate the function. | |
4348 */ | |
4349 if (use_sandbox) | |
4350 ++sandbox; | |
4351 r = eval_to_number(curbuf->b_p_fex); | |
4352 if (use_sandbox) | |
4353 --sandbox; | |
4354 return r; | |
4355 } | |
4356 #endif | |
4357 | |
4315 /* | 4358 /* |
4316 * Format "line_count" lines, starting at the cursor position. | 4359 * Format "line_count" lines, starting at the cursor position. |
4317 * When "line_count" is negative, format until the end of the paragraph. | 4360 * When "line_count" is negative, format until the end of the paragraph. |
4318 * Lines after the cursor line are saved for undo, caller must have saved the | 4361 * Lines after the cursor line are saved for undo, caller must have saved the |
4319 * first line. | 4362 * first line. |