From 54fb43813443554c685306b92166218c53cdb18f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 12 Nov 2014 19:28:16 +0100 Subject: 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. --- src/ex_cmds.c | 130 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 70 insertions(+), 60 deletions(-) (limited to 'src/ex_cmds.c') diff --git a/src/ex_cmds.c b/src/ex_cmds.c index b8076fc37b..1114f85345 100644 --- 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, newlnum, flags, oldwin) oldbuf = (flags & ECMD_OLDBUF); } - 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; + buf = curbuf; #endif - set_buflisted(FALSE); + if ((flags & ECMD_SET_HELP) || keep_help_flag) + { + 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) @@ -6221,6 +6166,71 @@ find_help_tags(arg, num_matches, matches, keep_lang) return OK; } +/* + * 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. -- cgit v1.2.3