comparison src/ex_cmds.c @ 819:23f82b5d2814 v7.0c10

updated for version 7.0c10
author vimboss
date Wed, 05 Apr 2006 20:41:53 +0000
parents 4a79d6d376f0
children a2b128f7d705
comparison
equal deleted inserted replaced
818:1f929f3ca806 819:23f82b5d2814
2599 } 2599 }
2600 2600
2601 /* If 'filetype' was empty try detecting it now. */ 2601 /* If 'filetype' was empty try detecting it now. */
2602 if (*curbuf->b_p_ft == NUL) 2602 if (*curbuf->b_p_ft == NUL)
2603 { 2603 {
2604 (void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE); 2604 if (au_has_group((char_u *)"filetypedetect"))
2605 (void)do_doautocmd((char_u *)"filetypedetect BufRead",
2606 TRUE);
2605 do_modelines(0); 2607 do_modelines(0);
2606 } 2608 }
2607 #endif 2609 #endif
2608 } 2610 }
2609 2611
2610 retval = buf_write(curbuf, ffname, fname, eap->line1, eap->line2, 2612 retval = buf_write(curbuf, ffname, fname, eap->line1, eap->line2,
2611 eap, eap->append, eap->forceit, TRUE, FALSE); 2613 eap, eap->append, eap->forceit, TRUE, FALSE);
2612 2614
2615 /* After ":saveas fname" reset 'readonly'. */
2616 if (eap->cmdidx == CMD_saveas && retval == OK)
2617 curbuf->b_p_ro = FALSE;
2613 } 2618 }
2614 2619
2615 theend: 2620 theend:
2616 #ifdef FEAT_BROWSE 2621 #ifdef FEAT_BROWSE
2617 vim_free(browse_file); 2622 vim_free(browse_file);
2696 p = p_dir; 2701 p = p_dir;
2697 copy_option_part(&p, dir, MAXPATHL, ","); 2702 copy_option_part(&p, dir, MAXPATHL, ",");
2698 } 2703 }
2699 swapname = makeswapname(fname, ffname, curbuf, dir); 2704 swapname = makeswapname(fname, ffname, curbuf, dir);
2700 r = vim_fexists(swapname); 2705 r = vim_fexists(swapname);
2701 vim_free(swapname);
2702 if (r) 2706 if (r)
2703 { 2707 {
2704 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) 2708 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
2705 if (p_confirm || cmdmod.confirm) 2709 if (p_confirm || cmdmod.confirm)
2706 { 2710 {
2709 dialog_msg(buff, 2713 dialog_msg(buff,
2710 _("Swap file \"%s\" exists, overwrite anyway?"), 2714 _("Swap file \"%s\" exists, overwrite anyway?"),
2711 swapname); 2715 swapname);
2712 if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) 2716 if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2)
2713 != VIM_YES) 2717 != VIM_YES)
2718 {
2719 vim_free(swapname);
2714 return FAIL; 2720 return FAIL;
2721 }
2715 eap->forceit = TRUE; 2722 eap->forceit = TRUE;
2716 } 2723 }
2717 else 2724 else
2718 #endif 2725 #endif
2719 { 2726 {
2720 EMSG2(_("E768: Swap file exists: %s (:silent! overrides)"), 2727 EMSG2(_("E768: Swap file exists: %s (:silent! overrides)"),
2721 swapname); 2728 swapname);
2729 vim_free(swapname);
2722 return FAIL; 2730 return FAIL;
2723 } 2731 }
2724 } 2732 }
2733 vim_free(swapname);
2725 } 2734 }
2726 } 2735 }
2727 return OK; 2736 return OK;
2728 } 2737 }
2729 2738
2883 int retval; 2892 int retval;
2884 char_u *free_me = NULL; 2893 char_u *free_me = NULL;
2885 2894
2886 if (text_locked()) 2895 if (text_locked())
2887 return 1; 2896 return 1;
2897 #ifdef FEAT_AUTOCMD
2898 if (curbuf_locked())
2899 return 1;
2900 #endif
2888 2901
2889 if (fnum == 0) 2902 if (fnum == 0)
2890 { 2903 {
2891 /* make ffname full path, set sfname */ 2904 /* make ffname full path, set sfname */
2892 fname_expand(curbuf, &ffname, &sfname); 2905 fname_expand(curbuf, &ffname, &sfname);
4607 /* get length of substitution part */ 4620 /* get length of substitution part */
4608 sublen = vim_regsub_multi(&regmatch, sub_firstlnum, 4621 sublen = vim_regsub_multi(&regmatch, sub_firstlnum,
4609 sub, sub_firstline, FALSE, p_magic, TRUE); 4622 sub, sub_firstline, FALSE, p_magic, TRUE);
4610 4623
4611 /* When the match included the "$" of the last line it may 4624 /* When the match included the "$" of the last line it may
4612 * include one line too much. */ 4625 * go beyond the last line of the buffer. */
4613 if (nmatch > curbuf->b_ml.ml_line_count - sub_firstlnum + 1) 4626 if (nmatch > curbuf->b_ml.ml_line_count - sub_firstlnum + 1)
4614 { 4627 {
4615 nmatch = curbuf->b_ml.ml_line_count - sub_firstlnum + 1; 4628 nmatch = curbuf->b_ml.ml_line_count - sub_firstlnum + 1;
4616 skip_match = TRUE; 4629 skip_match = TRUE;
4617 } 4630 }
4699 } 4712 }
4700 4713
4701 /* Remember next character to be copied. */ 4714 /* Remember next character to be copied. */
4702 copycol = regmatch.endpos[0].col; 4715 copycol = regmatch.endpos[0].col;
4703 4716
4717 if (skip_match)
4718 {
4719 /* Already hit end of the buffer, sub_firstlnum is one
4720 * less than what it ought to be. */
4721 vim_free(sub_firstline);
4722 sub_firstline = vim_strsave((char_u *)"");
4723 copycol = 0;
4724 }
4725
4704 /* 4726 /*
4705 * Now the trick is to replace CTRL-M chars with a real line 4727 * Now the trick is to replace CTRL-M chars with a real line
4706 * break. This would make it impossible to insert a CTRL-M in 4728 * break. This would make it impossible to insert a CTRL-M in
4707 * the text. The line break can be avoided by preceding the 4729 * the text. The line break can be avoided by preceding the
4708 * CTRL-M with a backslash. To be able to insert a backslash, 4730 * CTRL-M with a backslash. To be able to insert a backslash,
5416 restart_edit = 0; /* don't want insert mode in help file */ 5438 restart_edit = 0; /* don't want insert mode in help file */
5417 5439
5418 if (tag != NULL) 5440 if (tag != NULL)
5419 do_tag(tag, DT_HELP, 1, FALSE, TRUE); 5441 do_tag(tag, DT_HELP, 1, FALSE, TRUE);
5420 5442
5421 /* Delete the empty buffer if we're not using it. */ 5443 /* Delete the empty buffer if we're not using it. Careful: autocommands
5444 * may have jumped to another window, check that the buffer is not in a
5445 * window. */
5422 if (empty_fnum != 0 && curbuf->b_fnum != empty_fnum) 5446 if (empty_fnum != 0 && curbuf->b_fnum != empty_fnum)
5423 { 5447 {
5424 buf = buflist_findnr(empty_fnum); 5448 buf = buflist_findnr(empty_fnum);
5425 if (buf != NULL) 5449 if (buf != NULL && buf->b_nwindows == 0)
5426 wipe_buffer(buf, TRUE); 5450 wipe_buffer(buf, TRUE);
5427 } 5451 }
5428 5452
5429 /* keep the previous alternate file */ 5453 /* keep the previous alternate file */
5430 if (alt_fnum != 0 && curwin->w_alt_fnum == empty_fnum && !cmdmod.keepalt) 5454 if (alt_fnum != 0 && curwin->w_alt_fnum == empty_fnum && !cmdmod.keepalt)