@@ -34,6 +34,7 @@ static int
3434 _RTLENTRYF
3535#endif
3636 help_compare __ARGS ( (const void * s1 , const void * s2 ));
37+ static void prepare_help_buffer __ARGS ((void ));
3738
3839/*
3940 * ":ascii" and "ga".
@@ -3531,71 +3532,15 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags, oldwin)
35313532 oldbuf = (flags & ECMD_OLDBUF );
35323533 }
35333534
3534- if ((flags & ECMD_SET_HELP ) || keep_help_flag )
3535- {
3536- char_u * p ;
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-
35893535#ifdef FEAT_AUTOCMD
3590- buf = curbuf ;
3536+ buf = curbuf ;
35913537#endif
3592- set_buflisted (FALSE);
3538+ if ((flags & ECMD_SET_HELP ) || keep_help_flag )
3539+ {
3540+ prepare_help_buffer ();
35933541 }
35943542 else
35953543 {
3596- #ifdef FEAT_AUTOCMD
3597- buf = curbuf ;
3598- #endif
35993544 /* Don't make a buffer listed if it's a help buffer. Useful when
36003545 * using CTRL-O to go back to a help file. */
36013546 if (!curbuf -> b_help )
@@ -6221,6 +6166,71 @@ find_help_tags(arg, num_matches, matches, keep_lang)
62216166 return OK ;
62226167}
62236168
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+
62246234/*
62256235 * After reading a help file: May cleanup a help buffer when syntax
62266236 * highlighting is not used.
0 commit comments