comparison src/ex_cmds.c @ 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 c72eb8499a9d
children 3421b24e419c
comparison
equal deleted inserted replaced
6364:436a29956f6d 6365:387e63680524
32 static int 32 static int
33 #ifdef __BORLANDC__ 33 #ifdef __BORLANDC__
34 _RTLENTRYF 34 _RTLENTRYF
35 #endif 35 #endif
36 help_compare __ARGS((const void *s1, const void *s2)); 36 help_compare __ARGS((const void *s1, const void *s2));
37 static void prepare_help_buffer __ARGS((void));
37 38
38 /* 39 /*
39 * ":ascii" and "ga". 40 * ":ascii" and "ga".
40 */ 41 */
41 void 42 void
3529 check_fname() == FAIL) 3530 check_fname() == FAIL)
3530 goto theend; 3531 goto theend;
3531 oldbuf = (flags & ECMD_OLDBUF); 3532 oldbuf = (flags & ECMD_OLDBUF);
3532 } 3533 }
3533 3534
3535 #ifdef FEAT_AUTOCMD
3536 buf = curbuf;
3537 #endif
3534 if ((flags & ECMD_SET_HELP) || keep_help_flag) 3538 if ((flags & ECMD_SET_HELP) || keep_help_flag)
3535 { 3539 {
3536 char_u *p; 3540 prepare_help_buffer();
3537
3538 curbuf->b_help = TRUE;
3539 #ifdef FEAT_QUICKFIX
3540 set_string_option_direct((char_u *)"buftype", -1,
3541 (char_u *)"help", OPT_FREE|OPT_LOCAL, 0);
3542 #endif
3543
3544 /*
3545 * Always set these options after jumping to a help tag, because the
3546 * user may have an autocommand that gets in the way.
3547 * Accept all ASCII chars for keywords, except ' ', '*', '"', '|', and
3548 * latin1 word characters (for translated help files).
3549 * Only set it when needed, buf_init_chartab() is some work.
3550 */
3551 p =
3552 #ifdef EBCDIC
3553 (char_u *)"65-255,^*,^|,^\"";
3554 #else
3555 (char_u *)"!-~,^*,^|,^\",192-255";
3556 #endif
3557 if (STRCMP(curbuf->b_p_isk, p) != 0)
3558 {
3559 set_string_option_direct((char_u *)"isk", -1, p,
3560 OPT_FREE|OPT_LOCAL, 0);
3561 check_buf_options(curbuf);
3562 (void)buf_init_chartab(curbuf, FALSE);
3563 }
3564
3565 curbuf->b_p_ts = 8; /* 'tabstop' is 8 */
3566 curwin->w_p_list = FALSE; /* no list mode */
3567
3568 curbuf->b_p_ma = FALSE; /* not modifiable */
3569 curbuf->b_p_bin = FALSE; /* reset 'bin' before reading file */
3570 curwin->w_p_nu = 0; /* no line numbers */
3571 curwin->w_p_rnu = 0; /* no relative line numbers */
3572 RESET_BINDING(curwin); /* no scroll or cursor binding */
3573 #ifdef FEAT_ARABIC
3574 curwin->w_p_arab = FALSE; /* no arabic mode */
3575 #endif
3576 #ifdef FEAT_RIGHTLEFT
3577 curwin->w_p_rl = FALSE; /* help window is left-to-right */
3578 #endif
3579 #ifdef FEAT_FOLDING
3580 curwin->w_p_fen = FALSE; /* No folding in the help window */
3581 #endif
3582 #ifdef FEAT_DIFF
3583 curwin->w_p_diff = FALSE; /* No 'diff' */
3584 #endif
3585 #ifdef FEAT_SPELL
3586 curwin->w_p_spell = FALSE; /* No spell checking */
3587 #endif
3588
3589 #ifdef FEAT_AUTOCMD
3590 buf = curbuf;
3591 #endif
3592 set_buflisted(FALSE);
3593 } 3541 }
3594 else 3542 else
3595 { 3543 {
3596 #ifdef FEAT_AUTOCMD
3597 buf = curbuf;
3598 #endif
3599 /* Don't make a buffer listed if it's a help buffer. Useful when 3544 /* Don't make a buffer listed if it's a help buffer. Useful when
3600 * using CTRL-O to go back to a help file. */ 3545 * using CTRL-O to go back to a help file. */
3601 if (!curbuf->b_help) 3546 if (!curbuf->b_help)
3602 set_buflisted(TRUE); 3547 set_buflisted(TRUE);
3603 } 3548 }
6220 } 6165 }
6221 return OK; 6166 return OK;
6222 } 6167 }
6223 6168
6224 /* 6169 /*
6170 * Called when starting to edit a buffer for a help file.
6171 */
6172 static void
6173 prepare_help_buffer()
6174 {
6175 char_u *p;
6176
6177 curbuf->b_help = TRUE;
6178 #ifdef FEAT_QUICKFIX
6179 set_string_option_direct((char_u *)"buftype", -1,
6180 (char_u *)"help", OPT_FREE|OPT_LOCAL, 0);
6181 #endif
6182
6183 /*
6184 * Always set these options after jumping to a help tag, because the
6185 * user may have an autocommand that gets in the way.
6186 * Accept all ASCII chars for keywords, except ' ', '*', '"', '|', and
6187 * latin1 word characters (for translated help files).
6188 * Only set it when needed, buf_init_chartab() is some work.
6189 */
6190 p =
6191 #ifdef EBCDIC
6192 (char_u *)"65-255,^*,^|,^\"";
6193 #else
6194 (char_u *)"!-~,^*,^|,^\",192-255";
6195 #endif
6196 if (STRCMP(curbuf->b_p_isk, p) != 0)
6197 {
6198 set_string_option_direct((char_u *)"isk", -1, p, OPT_FREE|OPT_LOCAL, 0);
6199 check_buf_options(curbuf);
6200 (void)buf_init_chartab(curbuf, FALSE);
6201 }
6202
6203 /* Don't use the global foldmethod.*/
6204 set_string_option_direct((char_u *)"fdm", -1, (char_u *)"manual",
6205 OPT_FREE|OPT_LOCAL, 0);
6206
6207 curbuf->b_p_ts = 8; /* 'tabstop' is 8 */
6208 curwin->w_p_list = FALSE; /* no list mode */
6209
6210 curbuf->b_p_ma = FALSE; /* not modifiable */
6211 curbuf->b_p_bin = FALSE; /* reset 'bin' before reading file */
6212 curwin->w_p_nu = 0; /* no line numbers */
6213 curwin->w_p_rnu = 0; /* no relative line numbers */
6214 RESET_BINDING(curwin); /* no scroll or cursor binding */
6215 #ifdef FEAT_ARABIC
6216 curwin->w_p_arab = FALSE; /* no arabic mode */
6217 #endif
6218 #ifdef FEAT_RIGHTLEFT
6219 curwin->w_p_rl = FALSE; /* help window is left-to-right */
6220 #endif
6221 #ifdef FEAT_FOLDING
6222 curwin->w_p_fen = FALSE; /* No folding in the help window */
6223 #endif
6224 #ifdef FEAT_DIFF
6225 curwin->w_p_diff = FALSE; /* No 'diff' */
6226 #endif
6227 #ifdef FEAT_SPELL
6228 curwin->w_p_spell = FALSE; /* No spell checking */
6229 #endif
6230
6231 set_buflisted(FALSE);
6232 }
6233
6234 /*
6225 * After reading a help file: May cleanup a help buffer when syntax 6235 * After reading a help file: May cleanup a help buffer when syntax
6226 * highlighting is not used. 6236 * highlighting is not used.
6227 */ 6237 */
6228 void 6238 void
6229 fix_help_buffer() 6239 fix_help_buffer()