Mercurial > vim
changeset 6365:387e63680524 v7.4.515
updated for version 7.4.515
Problem: In a help buffer the global 'foldmethod' is used. (Paul Marshall)
Solution: Reset 'foldmethod' when starting to edit a help file. Move the
code to a separate function.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 12 Nov 2014 19:28:16 +0100 |
parents | 436a29956f6d |
children | 6ed1fb756560 |
files | src/ex_cmds.c src/version.c |
diffstat | 2 files changed, 72 insertions(+), 60 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -34,6 +34,7 @@ static int _RTLENTRYF #endif help_compare __ARGS((const void *s1, const void *s2)); +static void prepare_help_buffer __ARGS((void)); /* * ":ascii" and "ga". @@ -3531,71 +3532,15 @@ do_ecmd(fnum, ffname, sfname, eap, newln oldbuf = (flags & ECMD_OLDBUF); } +#ifdef FEAT_AUTOCMD + buf = curbuf; +#endif if ((flags & ECMD_SET_HELP) || keep_help_flag) { - char_u *p; - - curbuf->b_help = TRUE; -#ifdef FEAT_QUICKFIX - set_string_option_direct((char_u *)"buftype", -1, - (char_u *)"help", OPT_FREE|OPT_LOCAL, 0); -#endif - - /* - * Always set these options after jumping to a help tag, because the - * user may have an autocommand that gets in the way. - * Accept all ASCII chars for keywords, except ' ', '*', '"', '|', and - * latin1 word characters (for translated help files). - * Only set it when needed, buf_init_chartab() is some work. - */ - p = -#ifdef EBCDIC - (char_u *)"65-255,^*,^|,^\""; -#else - (char_u *)"!-~,^*,^|,^\",192-255"; -#endif - if (STRCMP(curbuf->b_p_isk, p) != 0) - { - set_string_option_direct((char_u *)"isk", -1, p, - OPT_FREE|OPT_LOCAL, 0); - check_buf_options(curbuf); - (void)buf_init_chartab(curbuf, FALSE); - } - - curbuf->b_p_ts = 8; /* 'tabstop' is 8 */ - curwin->w_p_list = FALSE; /* no list mode */ - - curbuf->b_p_ma = FALSE; /* not modifiable */ - curbuf->b_p_bin = FALSE; /* reset 'bin' before reading file */ - curwin->w_p_nu = 0; /* no line numbers */ - curwin->w_p_rnu = 0; /* no relative line numbers */ - RESET_BINDING(curwin); /* no scroll or cursor binding */ -#ifdef FEAT_ARABIC - curwin->w_p_arab = FALSE; /* no arabic mode */ -#endif -#ifdef FEAT_RIGHTLEFT - curwin->w_p_rl = FALSE; /* help window is left-to-right */ -#endif -#ifdef FEAT_FOLDING - curwin->w_p_fen = FALSE; /* No folding in the help window */ -#endif -#ifdef FEAT_DIFF - curwin->w_p_diff = FALSE; /* No 'diff' */ -#endif -#ifdef FEAT_SPELL - curwin->w_p_spell = FALSE; /* No spell checking */ -#endif - -#ifdef FEAT_AUTOCMD - buf = curbuf; -#endif - set_buflisted(FALSE); + prepare_help_buffer(); } else { -#ifdef FEAT_AUTOCMD - buf = curbuf; -#endif /* Don't make a buffer listed if it's a help buffer. Useful when * using CTRL-O to go back to a help file. */ if (!curbuf->b_help) @@ -6222,6 +6167,71 @@ find_help_tags(arg, num_matches, matches } /* + * Called when starting to edit a buffer for a help file. + */ + static void +prepare_help_buffer() +{ + char_u *p; + + curbuf->b_help = TRUE; +#ifdef FEAT_QUICKFIX + set_string_option_direct((char_u *)"buftype", -1, + (char_u *)"help", OPT_FREE|OPT_LOCAL, 0); +#endif + + /* + * Always set these options after jumping to a help tag, because the + * user may have an autocommand that gets in the way. + * Accept all ASCII chars for keywords, except ' ', '*', '"', '|', and + * latin1 word characters (for translated help files). + * Only set it when needed, buf_init_chartab() is some work. + */ + p = +#ifdef EBCDIC + (char_u *)"65-255,^*,^|,^\""; +#else + (char_u *)"!-~,^*,^|,^\",192-255"; +#endif + if (STRCMP(curbuf->b_p_isk, p) != 0) + { + set_string_option_direct((char_u *)"isk", -1, p, OPT_FREE|OPT_LOCAL, 0); + check_buf_options(curbuf); + (void)buf_init_chartab(curbuf, FALSE); + } + + /* Don't use the global foldmethod.*/ + set_string_option_direct((char_u *)"fdm", -1, (char_u *)"manual", + OPT_FREE|OPT_LOCAL, 0); + + curbuf->b_p_ts = 8; /* 'tabstop' is 8 */ + curwin->w_p_list = FALSE; /* no list mode */ + + curbuf->b_p_ma = FALSE; /* not modifiable */ + curbuf->b_p_bin = FALSE; /* reset 'bin' before reading file */ + curwin->w_p_nu = 0; /* no line numbers */ + curwin->w_p_rnu = 0; /* no relative line numbers */ + RESET_BINDING(curwin); /* no scroll or cursor binding */ +#ifdef FEAT_ARABIC + curwin->w_p_arab = FALSE; /* no arabic mode */ +#endif +#ifdef FEAT_RIGHTLEFT + curwin->w_p_rl = FALSE; /* help window is left-to-right */ +#endif +#ifdef FEAT_FOLDING + curwin->w_p_fen = FALSE; /* No folding in the help window */ +#endif +#ifdef FEAT_DIFF + curwin->w_p_diff = FALSE; /* No 'diff' */ +#endif +#ifdef FEAT_SPELL + curwin->w_p_spell = FALSE; /* No spell checking */ +#endif + + set_buflisted(FALSE); +} + +/* * After reading a help file: May cleanup a help buffer when syntax * highlighting is not used. */