1
0
forked from aniani/vim

updated for version 7.0218

This commit is contained in:
Bram Moolenaar
2006-03-08 21:32:40 +00:00
parent 1f35bf9cab
commit a3227e2b15
39 changed files with 719 additions and 213 deletions

View File

@@ -251,7 +251,7 @@ open_buffer(read_stdin, eap)
/* Go to the buffer that was opened. */
aucmd_prepbuf(&aco, old_curbuf);
#endif
do_modelines(FALSE);
do_modelines(0);
curbuf->b_flags &= ~(BF_CHECK_RO | BF_NEVERLOADED);
#ifdef FEAT_AUTOCMD
@@ -747,7 +747,7 @@ handle_swap_exists(old_curbuf)
ml_recover();
MSG_PUTS("\n"); /* don't overwrite the last message */
cmdline_row = msg_row;
do_modelines(FALSE);
do_modelines(0);
# if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
/* Restore the error/interrupt/exception state if not discarded by a
@@ -4632,16 +4632,20 @@ ex_buffer_all(eap)
#endif /* FEAT_WINDOWS */
static int chk_modeline __ARGS((linenr_T, int));
/*
* do_modelines() - process mode lines for the current file
*
* "flags" can be:
* OPT_WINONLY only set options local to window
* OPT_NOWIN don't set options local to window
*
* Returns immediately if the "ml" option isn't set.
*/
static int chk_modeline __ARGS((linenr_T, int));
void
do_modelines(win_only)
int win_only; /* Only do window-local options. */
do_modelines(flags)
int flags;
{
linenr_T lnum;
int nmlines;
@@ -4658,12 +4662,12 @@ do_modelines(win_only)
++entered;
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count && lnum <= nmlines;
++lnum)
if (chk_modeline(lnum, win_only) == FAIL)
if (chk_modeline(lnum, flags) == FAIL)
nmlines = 0;
for (lnum = curbuf->b_ml.ml_line_count; lnum > 0 && lnum > nmlines
&& lnum > curbuf->b_ml.ml_line_count - nmlines; --lnum)
if (chk_modeline(lnum, win_only) == FAIL)
if (chk_modeline(lnum, flags) == FAIL)
nmlines = 0;
--entered;
}
@@ -4675,9 +4679,9 @@ do_modelines(win_only)
* Return FAIL if an error encountered.
*/
static int
chk_modeline(lnum, win_only)
chk_modeline(lnum, flags)
linenr_T lnum;
int win_only; /* Only do window-local options. */
int flags; /* Same as for do_modelines(). */
{
char_u *s;
char_u *e;
@@ -4774,8 +4778,7 @@ chk_modeline(lnum, win_only)
save_SID = current_SID;
current_SID = SID_MODELINE;
#endif
retval = do_set(s, OPT_MODELINE | OPT_LOCAL
| (win_only ? OPT_WINONLY : 0));
retval = do_set(s, OPT_MODELINE | OPT_LOCAL | flags);
#ifdef FEAT_EVAL
current_SID = save_SID;
#endif

View File

@@ -2586,7 +2586,7 @@ do_write(eap)
if (*curbuf->b_p_ft == NUL)
{
(void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE);
do_modelines(FALSE);
do_modelines(0);
}
#endif
}
@@ -3495,7 +3495,7 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags)
/* Read the modelines, but only to set window-local options. Any
* buffer-local options have already been set and may have been
* changed by the user. */
do_modelines(TRUE);
do_modelines(OPT_WINONLY);
apply_autocmds_retval(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf,
&retval);

View File

@@ -4743,7 +4743,7 @@ ex_doautocmd(eap)
exarg_T *eap;
{
(void)do_doautocmd(eap->arg, TRUE);
do_modelines(FALSE);
do_modelines(0);
}
#endif
@@ -10505,7 +10505,7 @@ ex_filetype(eap)
if (*arg == 'd')
{
(void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE);
do_modelines(FALSE);
do_modelines(0);
}
}
else if (STRCMP(arg, "off") == 0)

View File

@@ -4655,7 +4655,7 @@ set_rw_fname(fname, sfname)
{
if (au_find_group((char_u *)"filetypedetect") != AUGROUP_ERROR)
(void)do_doautocmd((char_u *)"filetypedetect BufRead", FALSE);
do_modelines(FALSE);
do_modelines(0);
}
#endif
@@ -8045,7 +8045,7 @@ ex_doautoall(eap)
/* execute the autocommands for this buffer */
retval = do_doautocmd(eap->arg, FALSE);
do_modelines(FALSE);
do_modelines(0);
/* restore the current window */
aucmd_restbuf(&aco);

View File

@@ -111,7 +111,16 @@ static XFontSet current_fontset = NULL;
if (current_fontset != NULL) \
XwcDrawString(dpy, win, current_fontset, gc, x, y, (wchar_t *)str, n); \
else \
XDrawString16(dpy, win, gc, x, y, str, n); \
XDrawString16(dpy, win, gc, x, y, (XChar2b *)str, n); \
} while (0)
#define XDrawImageString16(dpy, win, gc, x, y, str, n) \
do \
{ \
if (current_fontset != NULL) \
XwcDrawImageString(dpy, win, current_fontset, gc, x, y, (wchar_t *)str, n); \
else \
XDrawImageString16(dpy, win, gc, x, y, (XChar2b *)str, n); \
} while (0)
static int check_fontset_sanity __ARGS((XFontSet fs));
@@ -2503,7 +2512,7 @@ gui_mch_draw_string(row, col, s, len, flags)
{
int cells = len;
#ifdef FEAT_MBYTE
static XChar2b *buf = NULL;
static void *buf = NULL;
static int buflen = 0;
char_u *p;
int wlen = 0;
@@ -2517,7 +2526,8 @@ gui_mch_draw_string(row, col, s, len, flags)
if (buflen < len)
{
XtFree((char *)buf);
buf = (XChar2b *)XtMalloc(len * sizeof(XChar2b));
buf = (void *)XtMalloc(len * (sizeof(XChar2b) < sizeof(wchar_t)
? sizeof(wchar_t) : sizeof(XChar2b)));
buflen = len;
}
p = s;
@@ -2525,10 +2535,21 @@ gui_mch_draw_string(row, col, s, len, flags)
while (p < s + len)
{
c = utf_ptr2char(p);
if (c >= 0x10000) /* show chars > 0xffff as ? */
c = 0xbf;
buf[wlen].byte1 = (unsigned)c >> 8;
buf[wlen].byte2 = c;
# ifdef FEAT_XFONTSET
if (current_fontset != NULL)
{
if (c >= 0x10000 && sizeof(wchar_t) <= 2)
c = 0xbf; /* show chars > 0xffff as ? */
((wchar_t *)buf)[wlen] = c;
}
else
# endif
{
if (c >= 0x10000)
c = 0xbf; /* show chars > 0xffff as ? */
((XChar2b *)buf)[wlen].byte1 = (unsigned)c >> 8;
((XChar2b *)buf)[wlen].byte2 = c;
}
++wlen;
cells += utf_char2cells(c);
p += utf_ptr2len(p);

View File

@@ -2302,7 +2302,7 @@ create_windows(parmp)
ml_recover();
if (curbuf->b_ml.ml_mfp == NULL) /* failed */
getout(1);
do_modelines(FALSE); /* do modelines */
do_modelines(0); /* do modelines */
}
else
{

View File

@@ -1489,10 +1489,10 @@ nb_do_cmd(
lbuf[0] = '\0';
nb_set_curbuf(buf->bufp);
old_b_changed = buf->bufp->b_changed;
old_b_changed = curbuf->b_changed;
pos = off2pos(buf->bufp, off);
if (pos)
pos = off2pos(curbuf, off);
if (pos != NULL)
{
if (pos->lnum == 0)
pos->lnum = 1;
@@ -1506,28 +1506,30 @@ nb_do_cmd(
#ifdef FEAT_VIRTUALEDIT
pos->coladd = 0;
#endif
pos->lnum = buf->bufp->b_ml.ml_line_count;
pos->lnum = curbuf->b_ml.ml_line_count;
}
lnum = pos->lnum;
old_w_cursor = curwin->w_cursor;
curwin->w_cursor = *pos;
if (buf->bufp->b_start_eol == FALSE && lnum > 0)
if (curbuf->b_start_eol == FALSE
&& lnum > 0
&& lnum <= curbuf->b_ml.ml_line_count)
{
/* Append to a partial line */
char_u *partial = ml_get(lnum);
if (partial != IObuff)
STRCPY(lbuf, partial);
lbuf_len = STRLEN(partial);
ml_delete(lnum, FALSE);
STRCPY(lbuf, partial);
lbuf_len = STRLEN(partial);
ml_delete(lnum, FALSE);
buf_was_empty = (curbuf->b_ml.ml_flags & ML_EMPTY);
}
doupdate = 1;
while (*args)
{
nl = (char_u *)strchr((char *)args, '\n');
if (nl)
if (nl != NULL)
{
STRNCAT(lbuf, args, nl - args);
lbuf[lbuf_len + nl - args] = '\0';
@@ -1554,13 +1556,13 @@ nb_do_cmd(
if (*(args - 1) == '\n')
{
buf->bufp->b_p_eol = TRUE;
buf->bufp->b_start_eol = TRUE;
curbuf->b_p_eol = TRUE;
curbuf->b_start_eol = TRUE;
}
else
{
buf->bufp->b_p_eol = FALSE;
buf->bufp->b_start_eol = FALSE;
curbuf->b_p_eol = FALSE;
curbuf->b_start_eol = FALSE;
}
appended_lines_mark(pos->lnum - 1, lnum - pos->lnum);
@@ -1573,8 +1575,11 @@ nb_do_cmd(
if (ff_detected == EOL_UNKNOWN)
ff_detected = EOL_DOS;
set_fileformat(ff_detected, OPT_LOCAL);
buf->bufp->b_start_ffc = *buf->bufp->b_p_ff;
ml_delete(curbuf->b_ml.ml_line_count, FALSE);
curbuf->b_start_ffc = *curbuf->b_p_ff;
/* Safety check: only delete empty line */
if (*ml_get(curbuf->b_ml.ml_line_count) == NUL)
ml_delete(curbuf->b_ml.ml_line_count, FALSE);
}
curwin->w_cursor = old_w_cursor;
@@ -1584,11 +1589,11 @@ nb_do_cmd(
* text the buffer has been updated but not written. Will
* netbeans guarantee to write it? Even if I do a :q! ?
*/
buf->bufp->b_changed = old_b_changed; /* logically unchanged */
curbuf->b_changed = old_b_changed; /* logically unchanged */
netbeansFireChanges = oldFire;
u_blockfree(buf->bufp);
u_clearall(buf->bufp);
u_blockfree(curbuf);
u_clearall(curbuf);
}
vim_free(to_free);
nb_reply_nil(cmdno); /* or !error */

View File

@@ -3774,9 +3774,11 @@ set_title_defaults()
* does not need to be expanded with option_expand().
* "opt_flags":
* 0 for ":set"
* OPT_GLOBAL for ":setglobal"
* OPT_LOCAL for ":setlocal" and a modeline
* OPT_GLOBAL for ":setglobal"
* OPT_LOCAL for ":setlocal" and a modeline
* OPT_MODELINE for a modeline
* OPT_WINONLY to only set window-local options
* OPT_NOWIN to skip setting window-local options
*
* returns FAIL if an error is detected, OK otherwise
*/
@@ -3977,6 +3979,11 @@ do_set(arg, opt_flags)
&& (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
goto skip;
/* Skip all options that are window-local (used for :vimgrep). */
if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
&& options[opt_idx].var == VAR_WIN)
goto skip;
/* Disallow changing some options from modelines */
if ((opt_flags & OPT_MODELINE) && (flags & P_SECURE))
{

View File

@@ -3039,12 +3039,12 @@ ex_vimgrep(eap)
}
else
{
/* Try for a match in all lines of the buffer.
* For ":1vimgrep" look for first match only. */
found_match = FALSE;
/* Try for a match in all lines of the buffer. */
for (lnum = 1; lnum <= buf->b_ml.ml_line_count && tomatch > 0;
++lnum)
{
/* For ":1vimgrep" look for multiple matches. */
col = 0;
while (vim_regexec_multi(&regmatch, curwin, buf, lnum,
col) > 0)
@@ -3093,12 +3093,17 @@ ex_vimgrep(eap)
wipe_dummy_buffer(buf);
buf = NULL;
}
else if (!buf_hide(buf))
else if (!cmdmod.hide
|| buf->b_p_bh[0] == 'u' /* "unload" */
|| buf->b_p_bh[0] == 'w' /* "wipe" */
|| buf->b_p_bh[0] == 'd') /* "delete" */
{
/* When not hiding the buffer and no match was found we
* don't need to remember the buffer, wipe it out. If
* there was a match and it wasn't the first one or we
* won't jump there: only unload the buffer. */
/* When no match was found we don't need to remember the
* buffer, wipe it out. If there was a match and it
* wasn't the first one or we won't jump there: only
* unload the buffer.
* Ignore 'hidden' here, because it may lead to having too
* many swap files. */
if (!found_match)
{
wipe_dummy_buffer(buf);
@@ -3115,7 +3120,8 @@ ex_vimgrep(eap)
{
/* The buffer is still loaded, the Filetype autocommands
* need to be done now, in that buffer. And the modelines
* need to be done (again). */
* need to be done (again). But not the window-local
* options! */
#if defined(FEAT_AUTOCMD)
aucmd_prepbuf(&aco, buf);
#else
@@ -3127,7 +3133,7 @@ ex_vimgrep(eap)
apply_autocmds(EVENT_FILETYPE, buf->b_p_ft,
buf->b_fname, TRUE, buf);
#endif
do_modelines(FALSE);
do_modelines(OPT_NOWIN);
#if defined(FEAT_AUTOCMD)
aucmd_restbuf(&aco);
#else

View File

@@ -36,5 +36,5 @@
#define VIM_VERSION_NODOT "vim70aa"
#define VIM_VERSION_SHORT "7.0aa"
#define VIM_VERSION_MEDIUM "7.0aa ALPHA"
#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2006 Mar 7)"
#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2006 Mar 7, compiled "
#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2006 Mar 8)"
#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2006 Mar 8, compiled "

View File

@@ -1021,6 +1021,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
#define OPT_LOCAL 4 /* use local value */
#define OPT_MODELINE 8 /* option in modeline */
#define OPT_WINONLY 16 /* only set window-local options */
#define OPT_NOWIN 32 /* don't set window-local options */
/* Magic chars used in confirm dialog strings */
#define DLG_BUTTON_SEP '\n'