1 --- a/src/ex_cmds.c 2016-09-21 15:16:13.032570431 -0700
2 +++ b/src/ex_cmds.c 2016-09-21 15:16:13.055466074 -0700
5 int old_KeyTyped = KeyTyped;
7 + int nohelp = FALSE, nominhelp = FALSE;
12 @@ -6327,6 +6329,23 @@
13 n = find_help_tags(arg, &num_matches, &matches,
14 eap != NULL && eap->forceit);
17 + * If we didn't find the help topic, check to see whether 'helpfile'
18 + * (typically $VIMRUNTIME/doc/help.txt) exists. If not, then we'll send the
19 + * user to the minimized help file delivered with the core vim package which
20 + * explains why there's no help and how to get it.
22 + if (num_matches == 0 && mch_access((char *)p_hf, F_OK) < 0) {
24 + mhf = alloc(MAXPATHL);
25 + STRNCPY(mhf, p_hf, MAXPATHL - 1);
26 + mhf[STRLEN(mhf) - 8] = '\0';
27 + STRNCAT(mhf, "help_minimized.txt", MAXPATHL - STRLEN(mhf) - 1);
29 + if (mch_access((char *)mhf, F_OK) < 0)
34 #ifdef FEAT_MULTI_LANG
35 if (n != FAIL && lang != NULL)
40 - if (i >= num_matches || n == FAIL)
41 + if (!nohelp && i >= num_matches || n == FAIL)
43 #ifdef FEAT_MULTI_LANG
45 @@ -6352,9 +6371,11 @@
49 - /* The first match (in the requested language) is the best match. */
50 - tag = vim_strsave(matches[i]);
51 - FreeWild(num_matches, matches);
53 + /* The first match (in the requested language) is the best match. */
54 + tag = vim_strsave(matches[i]);
55 + FreeWild(num_matches, matches);
59 need_mouse_correct = TRUE;
60 @@ -6386,12 +6407,14 @@
61 * There is no help window yet.
62 * Try to open the file specified by the "helpfile" option.
64 - if ((helpfd = mch_fopen((char *)p_hf, READBIN)) == NULL)
66 - smsg((char_u *)_("Sorry, help file \"%s\" not found"), p_hf);
68 + if (!nohelp || nominhelp) {
69 + if ((helpfd = mch_fopen((char *)p_hf, READBIN)) == NULL)
71 + smsg((char_u *)_("Sorry, help file \"%s\" not found"), p_hf);
79 /* Split off help window; put it at far top if no position
81 * Set the alternate file to the previously edited file.
83 alt_fnum = curbuf->b_fnum;
84 - (void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL,
85 + (void)do_ecmd(0, mhf, NULL, NULL, ECMD_LASTL,
86 ECMD_HIDE + ECMD_SET_HELP,
88 NULL /* buffer is still open, don't store info */
90 KeyTyped = old_KeyTyped;
94 + if (!nohelp && tag != NULL)
95 do_tag(tag, DT_HELP, 1, FALSE, TRUE);
97 /* Delete the empty buffer if we're not using it. Careful: autocommands
99 curwin->w_alt_fnum = alt_fnum;