Mercurial > vim
comparison src/buffer.c @ 23:3f44e9abe4ec v7.0015
updated for version 7.0015
author | vimboss |
---|---|
date | Mon, 06 Sep 2004 17:44:46 +0000 |
parents | cc049b00ee70 |
children | 8ff7fd162d3c |
comparison
equal
deleted
inserted
replaced
22:cc049b00ee70 | 23:3f44e9abe4ec |
---|---|
250 aco_save_T aco; | 250 aco_save_T aco; |
251 | 251 |
252 /* Go to the buffer that was opened. */ | 252 /* Go to the buffer that was opened. */ |
253 aucmd_prepbuf(&aco, old_curbuf); | 253 aucmd_prepbuf(&aco, old_curbuf); |
254 #endif | 254 #endif |
255 do_modelines(); | 255 do_modelines(FALSE); |
256 curbuf->b_flags &= ~(BF_CHECK_RO | BF_NEVERLOADED); | 256 curbuf->b_flags &= ~(BF_CHECK_RO | BF_NEVERLOADED); |
257 | 257 |
258 #ifdef FEAT_AUTOCMD | 258 #ifdef FEAT_AUTOCMD |
259 # ifdef FEAT_EVAL | 259 # ifdef FEAT_EVAL |
260 apply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf, | 260 apply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf, |
722 /* User selected Recover at ATTENTION prompt. */ | 722 /* User selected Recover at ATTENTION prompt. */ |
723 msg_scroll = TRUE; | 723 msg_scroll = TRUE; |
724 ml_recover(); | 724 ml_recover(); |
725 MSG_PUTS("\n"); /* don't overwrite the last message */ | 725 MSG_PUTS("\n"); /* don't overwrite the last message */ |
726 cmdline_row = msg_row; | 726 cmdline_row = msg_row; |
727 do_modelines(); | 727 do_modelines(FALSE); |
728 } | 728 } |
729 swap_exists_action = SEA_NONE; | 729 swap_exists_action = SEA_NONE; |
730 got_int |= old_got_int; | 730 got_int |= old_got_int; |
731 } | 731 } |
732 #endif | 732 #endif |
4336 /* | 4336 /* |
4337 * do_modelines() - process mode lines for the current file | 4337 * do_modelines() - process mode lines for the current file |
4338 * | 4338 * |
4339 * Returns immediately if the "ml" option isn't set. | 4339 * Returns immediately if the "ml" option isn't set. |
4340 */ | 4340 */ |
4341 static int chk_modeline __ARGS((linenr_T)); | 4341 static int chk_modeline __ARGS((linenr_T, int)); |
4342 | 4342 |
4343 void | 4343 void |
4344 do_modelines() | 4344 do_modelines(win_only) |
4345 { | 4345 int win_only; /* Only do window-local options. */ |
4346 linenr_T lnum; | 4346 { |
4347 int nmlines; | 4347 linenr_T lnum; |
4348 static int entered = 0; | 4348 int nmlines; |
4349 static int entered = 0; | |
4349 | 4350 |
4350 if (!curbuf->b_p_ml || (nmlines = (int)p_mls) == 0) | 4351 if (!curbuf->b_p_ml || (nmlines = (int)p_mls) == 0) |
4351 return; | 4352 return; |
4352 | 4353 |
4353 /* Disallow recursive entry here. Can happen when executing a modeline | 4354 /* Disallow recursive entry here. Can happen when executing a modeline |
4356 return; | 4357 return; |
4357 | 4358 |
4358 ++entered; | 4359 ++entered; |
4359 for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count && lnum <= nmlines; | 4360 for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count && lnum <= nmlines; |
4360 ++lnum) | 4361 ++lnum) |
4361 if (chk_modeline(lnum) == FAIL) | 4362 if (chk_modeline(lnum, win_only) == FAIL) |
4362 nmlines = 0; | 4363 nmlines = 0; |
4363 | 4364 |
4364 for (lnum = curbuf->b_ml.ml_line_count; lnum > 0 && lnum > nmlines | 4365 for (lnum = curbuf->b_ml.ml_line_count; lnum > 0 && lnum > nmlines |
4365 && lnum > curbuf->b_ml.ml_line_count - nmlines; --lnum) | 4366 && lnum > curbuf->b_ml.ml_line_count - nmlines; --lnum) |
4366 if (chk_modeline(lnum) == FAIL) | 4367 if (chk_modeline(lnum, win_only) == FAIL) |
4367 nmlines = 0; | 4368 nmlines = 0; |
4368 --entered; | 4369 --entered; |
4369 } | 4370 } |
4370 | 4371 |
4371 #include "version.h" /* for version number */ | 4372 #include "version.h" /* for version number */ |
4373 /* | 4374 /* |
4374 * chk_modeline() - check a single line for a mode string | 4375 * chk_modeline() - check a single line for a mode string |
4375 * Return FAIL if an error encountered. | 4376 * Return FAIL if an error encountered. |
4376 */ | 4377 */ |
4377 static int | 4378 static int |
4378 chk_modeline(lnum) | 4379 chk_modeline(lnum, win_only) |
4379 linenr_T lnum; | 4380 linenr_T lnum; |
4381 int win_only; /* Only do window-local options. */ | |
4380 { | 4382 { |
4381 char_u *s; | 4383 char_u *s; |
4382 char_u *e; | 4384 char_u *e; |
4383 char_u *linecopy; /* local copy of any modeline found */ | 4385 char_u *linecopy; /* local copy of any modeline found */ |
4384 int prev; | 4386 int prev; |
4471 { | 4473 { |
4472 #ifdef FEAT_EVAL | 4474 #ifdef FEAT_EVAL |
4473 save_SID = current_SID; | 4475 save_SID = current_SID; |
4474 current_SID = SID_MODELINE; | 4476 current_SID = SID_MODELINE; |
4475 #endif | 4477 #endif |
4476 retval = do_set(s, OPT_MODELINE | OPT_LOCAL); | 4478 retval = do_set(s, OPT_MODELINE | OPT_LOCAL |
4479 | (win_only ? OPT_WINONLY : 0)); | |
4477 #ifdef FEAT_EVAL | 4480 #ifdef FEAT_EVAL |
4478 current_SID = save_SID; | 4481 current_SID = save_SID; |
4479 #endif | 4482 #endif |
4480 if (retval == FAIL) /* stop if error found */ | 4483 if (retval == FAIL) /* stop if error found */ |
4481 break; | 4484 break; |
4556 buf_T *buf; | 4559 buf_T *buf; |
4557 #ifdef FEAT_WINDOWS | 4560 #ifdef FEAT_WINDOWS |
4558 win_T *win; | 4561 win_T *win; |
4559 #endif | 4562 #endif |
4560 char_u *line; | 4563 char_u *line; |
4564 int max_buffers; | |
4561 | 4565 |
4562 if (find_viminfo_parameter('%') == NULL) | 4566 if (find_viminfo_parameter('%') == NULL) |
4563 return; | 4567 return; |
4568 | |
4569 /* Without a number -1 is returned: do all buffers. */ | |
4570 max_buffers = get_viminfo_parameter('%'); | |
4564 | 4571 |
4565 /* Allocate room for the file name, lnum and col. */ | 4572 /* Allocate room for the file name, lnum and col. */ |
4566 line = alloc(MAXPATHL + 30); | 4573 line = alloc(MAXPATHL + 30); |
4567 if (line == NULL) | 4574 if (line == NULL) |
4568 return; | 4575 return; |
4583 || bt_quickfix(buf) | 4590 || bt_quickfix(buf) |
4584 #endif | 4591 #endif |
4585 || removable(buf->b_ffname)) | 4592 || removable(buf->b_ffname)) |
4586 continue; | 4593 continue; |
4587 | 4594 |
4595 if (max_buffers-- == 0) | |
4596 break; | |
4588 putc('%', fp); | 4597 putc('%', fp); |
4589 home_replace(NULL, buf->b_ffname, line, MAXPATHL, TRUE); | 4598 home_replace(NULL, buf->b_ffname, line, MAXPATHL, TRUE); |
4590 sprintf((char *)line + STRLEN(line), "\t%ld\t%d", | 4599 sprintf((char *)line + STRLEN(line), "\t%ld\t%d", |
4591 (long)buf->b_last_cursor.lnum, | 4600 (long)buf->b_last_cursor.lnum, |
4592 buf->b_last_cursor.col); | 4601 buf->b_last_cursor.col); |