annotate src/help.c @ 26927:e3f3108a780a v8.2.3992

patch 8.2.3992: wrong local-additions in the help with language mix Commit: https://github.com/vim/vim/commit/0e2508d9e63e63414de2c06b3c8a446fdfe4470b Author: h-east <h.east.727@gmail.com> Date: Mon Jan 3 12:53:24 2022 +0000 patch 8.2.3992: wrong local-additions in the help with language mix Problem: Wrong local-additions in the help with language mix. Solution: Adjust how the local additions list is generated. (Hirohito Higashi, closes #9464)
author Bram Moolenaar <Bram@vim.org>
date Mon, 03 Jan 2022 14:00:04 +0100
parents 3631d2deb36c
children 61f686b38df9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 *
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 *
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 * help.c: functions for Vim help
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 #include "vim.h"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 * ":help": open a read-only window on a help file
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 ex_help(exarg_T *eap)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 char_u *arg;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 char_u *tag;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 FILE *helpfd; // file descriptor of help file
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 int n;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 int i;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 win_T *wp;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 int num_matches;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 char_u **matches;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 char_u *p;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 int empty_fnum = 0;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 int alt_fnum = 0;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 buf_T *buf;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 int len;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 char_u *lang;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 #ifdef FEAT_FOLDING
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 int old_KeyTyped = KeyTyped;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41
22518
81ae5fa92928 patch 8.2.1807: can use :help in a terminal popup window
Bram Moolenaar <Bram@vim.org>
parents: 21423
diff changeset
42 if (ERROR_IF_ANY_POPUP_WINDOW)
81ae5fa92928 patch 8.2.1807: can use :help in a terminal popup window
Bram Moolenaar <Bram@vim.org>
parents: 21423
diff changeset
43 return;
81ae5fa92928 patch 8.2.1807: can use :help in a terminal popup window
Bram Moolenaar <Bram@vim.org>
parents: 21423
diff changeset
44
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 if (eap != NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 // A ":help" command ends at the first LF, or at a '|' that is
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 // followed by some text. Set nextcmd to the following command.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 for (arg = eap->arg; *arg; ++arg)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 if (*arg == '\n' || *arg == '\r'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 || (*arg == '|' && arg[1] != NUL && arg[1] != '|'))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 *arg++ = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 eap->nextcmd = arg;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 arg = eap->arg;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 if (eap->forceit && *arg == NUL && !curbuf->b_help)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
63 emsg(_(e_dont_panic));
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 return;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 if (eap->skip) // not executing commands
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 return;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 arg = (char_u *)"";
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 // remove trailing blanks
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 p = arg + STRLEN(arg) - 1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 while (p > arg && VIM_ISWHITE(*p) && p[-1] != '\\')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 *p-- = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 // Check for a specified language
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 lang = check_help_lang(arg);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 // When no argument given go to the index.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 if (*arg == NUL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 arg = (char_u *)"help.txt";
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 // Check if there is a match for the argument.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 n = find_help_tags(arg, &num_matches, &matches,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 eap != NULL && eap->forceit);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 i = 0;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 if (n != FAIL && lang != NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 // Find first item with the requested language.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 for (i = 0; i < num_matches; ++i)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 len = (int)STRLEN(matches[i]);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 if (len > 3 && matches[i][len - 3] == '@'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 && STRICMP(matches[i] + len - 2, lang) == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 if (i >= num_matches || n == FAIL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 if (lang != NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 semsg(_("E661: Sorry, no '%s' help for %s"), lang, arg);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 #endif
26853
806f31579357 patch 8.2.3955: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26276
diff changeset
110 semsg(_(e_sorry_no_help_for_str), arg);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 if (n != FAIL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 FreeWild(num_matches, matches);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 return;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 // The first match (in the requested language) is the best match.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 tag = vim_strsave(matches[i]);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 FreeWild(num_matches, matches);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 #ifdef FEAT_GUI
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 need_mouse_correct = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 // Re-use an existing help window or open a new one.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 // Always open a new one for ":tab help".
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22574
diff changeset
126 if (!bt_help(curwin->w_buffer) || cmdmod.cmod_tab != 0)
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 {
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22574
diff changeset
128 if (cmdmod.cmod_tab != 0)
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 wp = NULL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 FOR_ALL_WINDOWS(wp)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 if (bt_help(wp->w_buffer))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 if (wp != NULL && wp->w_buffer->b_nwindows > 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 win_enter(wp, TRUE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 // There is no help window yet.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 // Try to open the file specified by the "helpfile" option.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 if ((helpfd = mch_fopen((char *)p_hf, READBIN)) == NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 smsg(_("Sorry, help file \"%s\" not found"), p_hf);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 goto erret;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 fclose(helpfd);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 // Split off help window; put it at far top if no position
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 // specified, the current window is vertically split and
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 // narrow.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 n = WSP_HELP;
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22574
diff changeset
151 if (cmdmod.cmod_split == 0 && curwin->w_width != Columns
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 && curwin->w_width < 80)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 n |= WSP_TOP;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 if (win_split(0, n) == FAIL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 goto erret;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 if (curwin->w_height < p_hh)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 win_setheight((int)p_hh);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 // Open help file (do_ecmd() will set b_help flag, readfile() will
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 // set b_p_ro flag).
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 // Set the alternate file to the previously edited file.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 alt_fnum = curbuf->b_fnum;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164 (void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 ECMD_HIDE + ECMD_SET_HELP,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 NULL); // buffer is still open, don't store info
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22574
diff changeset
167 if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0)
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 curwin->w_alt_fnum = alt_fnum;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 empty_fnum = curbuf->b_fnum;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 if (!p_im)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 restart_edit = 0; // don't want insert mode in help file
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 #ifdef FEAT_FOLDING
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 // Restore KeyTyped, setting 'filetype=help' may reset it.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 // It is needed for do_tag top open folds under the cursor.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 KeyTyped = old_KeyTyped;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 if (tag != NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183 do_tag(tag, DT_HELP, 1, FALSE, TRUE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 // Delete the empty buffer if we're not using it. Careful: autocommands
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 // may have jumped to another window, check that the buffer is not in a
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 // window.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 if (empty_fnum != 0 && curbuf->b_fnum != empty_fnum)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 buf = buflist_findnr(empty_fnum);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 if (buf != NULL && buf->b_nwindows == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 wipe_buffer(buf, TRUE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195 // keep the previous alternate file
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22574
diff changeset
196 if (alt_fnum != 0 && curwin->w_alt_fnum == empty_fnum
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22574
diff changeset
197 && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0)
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198 curwin->w_alt_fnum = alt_fnum;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 erret:
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 vim_free(tag);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 * ":helpclose": Close one help window
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208 ex_helpclose(exarg_T *eap UNUSED)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 win_T *win;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212 FOR_ALL_WINDOWS(win)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 if (bt_help(win->w_buffer))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 win_close(win, FALSE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 return;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 #if defined(FEAT_MULTI_LANG) || defined(PROTO)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 * In an argument search for a language specifiers in the form "@xx".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 * Changes the "@" to NUL if found, and returns a pointer to "xx".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226 * Returns NULL if not found.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 char_u *
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 check_help_lang(char_u *arg)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 int len = (int)STRLEN(arg);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233 if (len >= 3 && arg[len - 3] == '@' && ASCII_ISALPHA(arg[len - 2])
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 && ASCII_ISALPHA(arg[len - 1]))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 arg[len - 3] = NUL; // remove the '@'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 return arg + len - 2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 return NULL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244 * Return a heuristic indicating how well the given string matches. The
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 * smaller the number, the better the match. This is the order of priorities,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 * from best match to worst match:
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247 * - Match with least alphanumeric characters is better.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 * - Match with least total characters is better.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249 * - Match towards the start is better.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 * - Match starting with "+" is worse (feature instead of command)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 * Assumption is made that the matched_string passed has already been found to
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 * match some string for which help is requested. webb.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254 int
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 help_heuristic(
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 char_u *matched_string,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 int offset, // offset for match
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258 int wrong_case) // no matching case
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260 int num_letters;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 char_u *p;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 num_letters = 0;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 for (p = matched_string; *p; p++)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 if (ASCII_ISALNUM(*p))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 num_letters++;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 // Multiply the number of letters by 100 to give it a much bigger
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 // weighting than the number of characters.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270 // If there only is a match while ignoring case, add 5000.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 // If the match starts in the middle of a word, add 10000 to put it
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272 // somewhere in the last half.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 // If the match is more than 2 chars from the start, multiply by 200 to
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274 // put it after matches at the start.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 if (ASCII_ISALNUM(matched_string[offset]) && offset > 0
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276 && ASCII_ISALNUM(matched_string[offset - 1]))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277 offset += 10000;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278 else if (offset > 2)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 offset *= 200;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280 if (wrong_case)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 offset += 5000;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282 // Features are less interesting than the subjects themselves, but "+"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 // alone is not a feature.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 if (matched_string[0] == '+' && matched_string[1] != NUL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 offset += 100;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286 return (int)(100 * num_letters + STRLEN(matched_string) + offset);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
289 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 * Compare functions for qsort() below, that checks the help heuristics number
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291 * that has been put after the tagname by find_tags().
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 static int
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294 help_compare(const void *s1, const void *s2)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
296 char *p1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
297 char *p2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 int cmp;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
299
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300 p1 = *(char **)s1 + strlen(*(char **)s1) + 1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301 p2 = *(char **)s2 + strlen(*(char **)s2) + 1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
303 // Compare by help heuristic number first.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
304 cmp = strcmp(p1, p2);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305 if (cmp != 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306 return cmp;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 // Compare by strings as tie-breaker when same heuristic number.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 return strcmp(*(char **)s1, *(char **)s2);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313 * Find all help tags matching "arg", sort them and return in matches[], with
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314 * the number of matches in num_matches.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 * The matches will be sorted with a "best" match algorithm.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 * When "keep_lang" is TRUE try keeping the language of the current buffer.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318 int
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319 find_help_tags(
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320 char_u *arg,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321 int *num_matches,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322 char_u ***matches,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
323 int keep_lang)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325 char_u *s, *d;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326 int i;
22574
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
327 // Specific tags that either have a specific replacement or won't go
23229
b545334ae654 patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
328 // through the generic rules.
22574
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
329 static char *(except_tbl[][2]) = {
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
330 {"*", "star"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
331 {"g*", "gstar"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
332 {"[*", "[star"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
333 {"]*", "]star"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
334 {":*", ":star"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
335 {"/*", "/star"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
336 {"/\\*", "/\\\\star"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
337 {"\"*", "quotestar"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
338 {"**", "starstar"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
339 {"cpo-*", "cpo-star"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
340 {"/\\(\\)", "/\\\\(\\\\)"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
341 {"/\\%(\\)", "/\\\\%(\\\\)"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
342 {"?", "?"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
343 {"??", "??"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
344 {":?", ":?"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
345 {"?<CR>", "?<CR>"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
346 {"g?", "g?"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
347 {"g?g?", "g?g?"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
348 {"g??", "g??"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
349 {"-?", "-?"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
350 {"q?", "q?"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
351 {"v_g?", "v_g?"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
352 {"/\\?", "/\\\\?"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
353 {"/\\z(\\)", "/\\\\z(\\\\)"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
354 {"\\=", "\\\\="},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
355 {":s\\=", ":s\\\\="},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
356 {"[count]", "\\[count]"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
357 {"[quotex]", "\\[quotex]"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
358 {"[range]", "\\[range]"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
359 {":[range]", ":\\[range]"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
360 {"[pattern]", "\\[pattern]"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
361 {"\\|", "\\\\bar"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
362 {"\\%$", "/\\\\%\\$"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
363 {"s/\\~", "s/\\\\\\~"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
364 {"s/\\U", "s/\\\\U"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
365 {"s/\\L", "s/\\\\L"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
366 {"s/\\1", "s/\\\\1"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
367 {"s/\\2", "s/\\\\2"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
368 {"s/\\3", "s/\\\\3"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
369 {"s/\\9", "s/\\\\9"},
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
370 {NULL, NULL}
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
371 };
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372 static char *(expr_table[]) = {"!=?", "!~?", "<=?", "<?", "==?", "=~?",
22574
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
373 ">=?", ">?", "is?", "isnot?"};
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
374 int flags;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
376 d = IObuff; // assume IObuff is long enough!
22574
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
377 d[0] = NUL;
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
378
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
379 if (STRNICMP(arg, "expr-", 5) == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
380 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
381 // When the string starting with "expr-" and containing '?' and matches
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 // the table, it is taken literally (but ~ is escaped). Otherwise '?'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 // is recognized as a wildcard.
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
384 for (i = (int)ARRAY_LENGTH(expr_table); --i >= 0; )
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 if (STRCMP(arg + 5, expr_table[i]) == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 int si = 0, di = 0;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 for (;;)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 if (arg[si] == '~')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392 d[di++] = '\\';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 d[di++] = arg[si];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 if (arg[si] == NUL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396 ++si;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
402 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403 // Recognize a few exceptions to the rule. Some strings that contain
22574
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
404 // '*'are changed to "star", otherwise '*' is recognized as a wildcard.
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
405 for (i = 0; except_tbl[i][0] != NULL; ++i)
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
406 if (STRCMP(arg, except_tbl[i][0]) == 0)
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407 {
22574
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
408 STRCPY(d, except_tbl[i][1]);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412
22574
431367075f29 patch 8.2.1835: ":help ??" finds the "!!" tag
Bram Moolenaar <Bram@vim.org>
parents: 22518
diff changeset
413 if (d[0] == NUL) // no match in table
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 // Replace "\S" with "/\\S", etc. Otherwise every tag is matched.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 // Also replace "\%^" and "\%(", they match every tag too.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417 // Also "\zs", "\z1", etc.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418 // Also "\@<", "\@=", "\@<=", etc.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419 // And also "\_$" and "\_^".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 if (arg[0] == '\\'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 && ((arg[1] != NUL && arg[2] == NUL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422 || (vim_strchr((char_u *)"%_z@", arg[1]) != NULL
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 && arg[2] != NUL)))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 {
26276
35d000f3d591 patch 8.2.3669: buffer overflow with long help argument
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
425 vim_snprintf((char *)d, IOSIZE, "/\\\\%s", arg + 1);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 // Check for "/\\_$", should be "/\\_\$"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427 if (d[3] == '_' && d[4] == '$')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 STRCPY(d + 4, "\\$");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
431 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 // Replace:
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
433 // "[:...:]" with "\[:...:]"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
434 // "[++...]" with "\[++...]"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435 // "\{" with "\\{" -- matching "} \}"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436 if ((arg[0] == '[' && (arg[1] == ':'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 || (arg[1] == '+' && arg[2] == '+')))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
438 || (arg[0] == '\\' && arg[1] == '{'))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
439 *d++ = '\\';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
440
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
441 // If tag starts with "('", skip the "(". Fixes CTRL-] on ('option'.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442 if (*arg == '(' && arg[1] == '\'')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443 arg++;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444 for (s = arg; *s; ++s)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446 // Replace "|" with "bar" and '"' with "quote" to match the name of
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447 // the tags for these commands.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448 // Replace "*" with ".*" and "?" with "." to match command line
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
449 // completion.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
450 // Insert a backslash before '~', '$' and '.' to avoid their
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
451 // special meaning.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
452 if (d - IObuff > IOSIZE - 10) // getting too long!?
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454 switch (*s)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456 case '|': STRCPY(d, "bar");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457 d += 3;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
458 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459 case '"': STRCPY(d, "quote");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460 d += 5;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462 case '*': *d++ = '.';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 case '?': *d++ = '.';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466 case '$':
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 case '.':
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
468 case '~': *d++ = '\\';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 // Replace "^x" by "CTRL-X". Don't do this for "^_" to make
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
473 // ":help i_^_CTRL-D" work.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474 // Insert '-' before and after "CTRL-X" when applicable.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475 if (*s < ' ' || (*s == '^' && s[1] && (ASCII_ISALPHA(s[1])
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
476 || vim_strchr((char_u *)"?@[\\]^", s[1]) != NULL)))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 if (d > IObuff && d[-1] != '_' && d[-1] != '\\')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479 *d++ = '_'; // prepend a '_' to make x_CTRL-x
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480 STRCPY(d, "CTRL-");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481 d += 5;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482 if (*s < ' ')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
483 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
484 #ifdef EBCDIC
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
485 *d++ = CtrlChar(*s);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486 #else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487 *d++ = *s + '@';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 if (d[-1] == '\\')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 *d++ = '\\'; // double a backslash
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 *d++ = *++s;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494 if (s[1] != NUL && s[1] != '_')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
495 *d++ = '_'; // append a '_'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
498 else if (*s == '^') // "^" or "CTRL-^" or "^_"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 *d++ = '\\';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501 // Insert a backslash before a backslash after a slash, for search
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502 // pattern tags: "/\|" --> "/\\|".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
503 else if (s[0] == '\\' && s[1] != '\\'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
504 && *arg == '/' && s == arg + 1)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505 *d++ = '\\';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
507 // "CTRL-\_" -> "CTRL-\\_" to avoid the special meaning of "\_" in
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
508 // "CTRL-\_CTRL-N"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
509 if (STRNICMP(s, "CTRL-\\_", 7) == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
510 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511 STRCPY(d, "CTRL-\\\\");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
512 d += 7;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
513 s += 6;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
514 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
515
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 *d++ = *s;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518 // If tag contains "({" or "([", tag terminates at the "(".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519 // This is for help on functions, e.g.: abs({expr}).
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520 if (*s == '(' && (s[1] == '{' || s[1] =='['))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
521 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
522
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
523 // If tag starts with ', toss everything after a second '. Fixes
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
524 // CTRL-] on 'option'. (would include the trailing '.').
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
525 if (*s == '\'' && s > arg && *arg == '\'')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
526 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
527 // Also '{' and '}'.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
528 if (*s == '}' && s > arg && *arg == '{')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
529 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
530 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
531 *d = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
532
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
533 if (*IObuff == '`')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
534 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
535 if (d > IObuff + 2 && d[-1] == '`')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
536 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
537 // remove the backticks from `command`
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
538 mch_memmove(IObuff, IObuff + 1, STRLEN(IObuff));
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
539 d[-2] = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
540 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
541 else if (d > IObuff + 3 && d[-2] == '`' && d[-1] == ',')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
542 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543 // remove the backticks and comma from `command`,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
544 mch_memmove(IObuff, IObuff + 1, STRLEN(IObuff));
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
545 d[-3] = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
546 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
547 else if (d > IObuff + 4 && d[-3] == '`'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
548 && d[-2] == '\\' && d[-1] == '.')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
549 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
550 // remove the backticks and dot from `command`\.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
551 mch_memmove(IObuff, IObuff + 1, STRLEN(IObuff));
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
552 d[-4] = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
553 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
554 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
555 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
556 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
557
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
558 *matches = (char_u **)"";
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
559 *num_matches = 0;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
560 flags = TAG_HELP | TAG_REGEXP | TAG_NAMES | TAG_VERBOSE | TAG_NO_TAGFUNC;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
561 if (keep_lang)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
562 flags |= TAG_KEEP_LANG;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
563 if (find_tags(IObuff, num_matches, matches, flags, (int)MAXCOL, NULL) == OK
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
564 && *num_matches > 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
565 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
566 // Sort the matches found on the heuristic number that is after the
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
567 // tag name.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
568 qsort((void *)*matches, (size_t)*num_matches,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
569 sizeof(char_u *), help_compare);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
570 // Delete more than TAG_MANY to reduce the size of the listing.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571 while (*num_matches > TAG_MANY)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
572 vim_free((*matches)[--*num_matches]);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
573 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
574 return OK;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
575 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
576
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
577 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
578 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
579 * Cleanup matches for help tags:
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
580 * Remove "@ab" if the top of 'helplang' is "ab" and the language of the first
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
581 * tag matches it. Otherwise remove "@en" if "en" is the only language.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
582 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
583 void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
584 cleanup_help_tags(int num_file, char_u **file)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
585 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
586 int i, j;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
587 int len;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
588 char_u buf[4];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
589 char_u *p = buf;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
590
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
591 if (p_hlg[0] != NUL && (p_hlg[0] != 'e' || p_hlg[1] != 'n'))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
592 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
593 *p++ = '@';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
594 *p++ = p_hlg[0];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
595 *p++ = p_hlg[1];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
596 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
597 *p = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
598
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
599 for (i = 0; i < num_file; ++i)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
600 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
601 len = (int)STRLEN(file[i]) - 3;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
602 if (len <= 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
603 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
604 if (STRCMP(file[i] + len, "@en") == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
605 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
606 // Sorting on priority means the same item in another language may
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
607 // be anywhere. Search all items for a match up to the "@en".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
608 for (j = 0; j < num_file; ++j)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
609 if (j != i && (int)STRLEN(file[j]) == len + 3
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
610 && STRNCMP(file[i], file[j], len + 1) == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
611 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
612 if (j == num_file)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
613 // item only exists with @en, remove it
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
614 file[i][len] = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
615 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
616 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
617
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
618 if (*buf != NUL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
619 for (i = 0; i < num_file; ++i)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
620 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
621 len = (int)STRLEN(file[i]) - 3;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
622 if (len <= 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
623 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
624 if (STRCMP(file[i] + len, buf) == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
625 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
626 // remove the default language
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
627 file[i][len] = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
628 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
629 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
630 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
631 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
632
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
633 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
634 * Called when starting to edit a buffer for a help file.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
635 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
636 void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
637 prepare_help_buffer(void)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
638 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
639 char_u *p;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
640
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
641 curbuf->b_help = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
642 #ifdef FEAT_QUICKFIX
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
643 set_string_option_direct((char_u *)"buftype", -1,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
644 (char_u *)"help", OPT_FREE|OPT_LOCAL, 0);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
645 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
646
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
647 // Always set these options after jumping to a help tag, because the
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
648 // user may have an autocommand that gets in the way.
23229
b545334ae654 patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
649 // When adding an option here, also update the help file helphelp.txt.
b545334ae654 patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
650
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
651 // Accept all ASCII chars for keywords, except ' ', '*', '"', '|', and
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
652 // latin1 word characters (for translated help files).
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
653 // Only set it when needed, buf_init_chartab() is some work.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
654 p =
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
655 #ifdef EBCDIC
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
656 (char_u *)"65-255,^*,^|,^\"";
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
657 #else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
658 (char_u *)"!-~,^*,^|,^\",192-255";
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
659 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
660 if (STRCMP(curbuf->b_p_isk, p) != 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
661 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
662 set_string_option_direct((char_u *)"isk", -1, p, OPT_FREE|OPT_LOCAL, 0);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
663 check_buf_options(curbuf);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
664 (void)buf_init_chartab(curbuf, FALSE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
665 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
666
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
667 #ifdef FEAT_FOLDING
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
668 // Don't use the global foldmethod.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
669 set_string_option_direct((char_u *)"fdm", -1, (char_u *)"manual",
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
670 OPT_FREE|OPT_LOCAL, 0);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
671 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
672
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
673 curbuf->b_p_ts = 8; // 'tabstop' is 8
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
674 curwin->w_p_list = FALSE; // no list mode
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
675
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
676 curbuf->b_p_ma = FALSE; // not modifiable
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
677 curbuf->b_p_bin = FALSE; // reset 'bin' before reading file
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
678 curwin->w_p_nu = 0; // no line numbers
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
679 curwin->w_p_rnu = 0; // no relative line numbers
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
680 RESET_BINDING(curwin); // no scroll or cursor binding
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
681 #ifdef FEAT_ARABIC
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
682 curwin->w_p_arab = FALSE; // no arabic mode
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
683 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
684 #ifdef FEAT_RIGHTLEFT
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
685 curwin->w_p_rl = FALSE; // help window is left-to-right
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
686 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
687 #ifdef FEAT_FOLDING
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
688 curwin->w_p_fen = FALSE; // No folding in the help window
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
689 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
690 #ifdef FEAT_DIFF
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
691 curwin->w_p_diff = FALSE; // No 'diff'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
692 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
693 #ifdef FEAT_SPELL
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
694 curwin->w_p_spell = FALSE; // No spell checking
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
695 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
696
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
697 set_buflisted(FALSE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
698 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
699
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
700 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
701 * After reading a help file: May cleanup a help buffer when syntax
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
702 * highlighting is not used.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
703 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
704 void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
705 fix_help_buffer(void)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
706 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
707 linenr_T lnum;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
708 char_u *line;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
709 int in_example = FALSE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
710 int len;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
711 char_u *fname;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
712 char_u *p;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
713 char_u *rt;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
714 int mustfree;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
715
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
716 // Set filetype to "help" if still needed.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
717 if (STRCMP(curbuf->b_p_ft, "help") != 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
718 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
719 ++curbuf_lock;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
720 set_option_value((char_u *)"ft", 0L, (char_u *)"help", OPT_LOCAL);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
721 --curbuf_lock;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
722 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
723
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
724 #ifdef FEAT_SYN_HL
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
725 if (!syntax_present(curwin))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
726 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
727 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
728 for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
729 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
730 line = ml_get_buf(curbuf, lnum, FALSE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
731 len = (int)STRLEN(line);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
732 if (in_example && len > 0 && !VIM_ISWHITE(line[0]))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
733 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
734 // End of example: non-white or '<' in first column.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
735 if (line[0] == '<')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
736 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
737 // blank-out a '<' in the first column
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
738 line = ml_get_buf(curbuf, lnum, TRUE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
739 line[0] = ' ';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
740 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
741 in_example = FALSE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
742 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
743 if (!in_example && len > 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
744 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
745 if (line[len - 1] == '>' && (len == 1 || line[len - 2] == ' '))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
746 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
747 // blank-out a '>' in the last column (start of example)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
748 line = ml_get_buf(curbuf, lnum, TRUE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
749 line[len - 1] = ' ';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
750 in_example = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
751 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
752 else if (line[len - 1] == '~')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
753 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
754 // blank-out a '~' at the end of line (header marker)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
755 line = ml_get_buf(curbuf, lnum, TRUE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
756 line[len - 1] = ' ';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
757 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
758 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
759 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
760 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
761
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
762 // In the "help.txt" and "help.abx" file, add the locally added help
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
763 // files. This uses the very first line in the help file.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
764 fname = gettail(curbuf->b_fname);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
765 if (fnamecmp(fname, "help.txt") == 0
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
766 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
767 || (fnamencmp(fname, "help.", 5) == 0
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
768 && ASCII_ISALPHA(fname[5])
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
769 && ASCII_ISALPHA(fname[6])
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
770 && TOLOWER_ASC(fname[7]) == 'x'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
771 && fname[8] == NUL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
772 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
773 )
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
774 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
775 for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; ++lnum)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
776 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
777 line = ml_get_buf(curbuf, lnum, FALSE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
778 if (strstr((char *)line, "*local-additions*") == NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
779 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
780
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
781 // Go through all directories in 'runtimepath', skipping
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
782 // $VIMRUNTIME.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
783 p = p_rtp;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
784 while (*p != NUL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
785 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
786 copy_option_part(&p, NameBuff, MAXPATHL, ",");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
787 mustfree = FALSE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
788 rt = vim_getenv((char_u *)"VIMRUNTIME", &mustfree);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
789 if (rt != NULL &&
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
790 fullpathcmp(rt, NameBuff, FALSE, TRUE) != FPC_SAME)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
791 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
792 int fcount;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
793 char_u **fnames;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
794 FILE *fd;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
795 char_u *s;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
796 int fi;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
797 vimconv_T vc;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
798 char_u *cp;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
799
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
800 // Find all "doc/ *.txt" files in this directory.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
801 add_pathsep(NameBuff);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
802 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
803 STRCAT(NameBuff, "doc/*.??[tx]");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
804 #else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
805 STRCAT(NameBuff, "doc/*.txt");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
806 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
807 if (gen_expand_wildcards(1, &NameBuff, &fcount,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
808 &fnames, EW_FILE|EW_SILENT) == OK
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
809 && fcount > 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
810 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
811 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
812 int i1, i2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
813 char_u *f1, *f2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
814 char_u *t1, *t2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
815 char_u *e1, *e2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
816
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
817 // If foo.abx is found use it instead of foo.txt in
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
818 // the same directory.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
819 for (i1 = 0; i1 < fcount; ++i1)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
820 {
26927
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
821 f1 = fnames[i1];
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
822 t1 = gettail(f1);
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
823 e1 = vim_strrchr(t1, '.');
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
824 if (fnamecmp(e1, ".txt") != 0
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
825 && fnamecmp(e1, fname + 4) != 0)
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
826 {
26927
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
827 // Not .txt and not .abx, remove it.
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
828 VIM_CLEAR(fnames[i1]);
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
829 continue;
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
830 }
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
831
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
832 for (i2 = i1 + 1; i2 < fcount; ++i2)
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
833 {
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
834 f2 = fnames[i2];
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
835 if (f2 == NULL)
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
836 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
837 t2 = gettail(f2);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
838 e2 = vim_strrchr(t2, '.');
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
839 if (e1 == NULL || e2 == NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
840 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
841 if (e1 - f1 != e2 - f2
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
842 || fnamencmp(f1, f2, e1 - f1) != 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
843 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
844 if (fnamecmp(e1, ".txt") == 0
26927
e3f3108a780a patch 8.2.3992: wrong local-additions in the help with language mix
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
845 && fnamecmp(e2, fname + 4) == 0)
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
846 // use .abx instead of .txt
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
847 VIM_CLEAR(fnames[i1]);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
848 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
849 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
850 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
851 for (fi = 0; fi < fcount; ++fi)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
852 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
853 if (fnames[fi] == NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
854 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
855 fd = mch_fopen((char *)fnames[fi], "r");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
856 if (fd != NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
857 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
858 vim_fgets(IObuff, IOSIZE, fd);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
859 if (IObuff[0] == '*'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
860 && (s = vim_strchr(IObuff + 1, '*'))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
861 != NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
862 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
863 int this_utf = MAYBE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
864
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
865 // Change tag definition to a
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
866 // reference and remove <CR>/<NL>.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
867 IObuff[0] = '|';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
868 *s = '|';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
869 while (*s != NUL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
870 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
871 if (*s == '\r' || *s == '\n')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
872 *s = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
873 // The text is utf-8 when a byte
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
874 // above 127 is found and no
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
875 // illegal byte sequence is found.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
876 if (*s >= 0x80 && this_utf != FALSE)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
877 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
878 int l;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
879
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
880 this_utf = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
881 l = utf_ptr2len(s);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
882 if (l == 1)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
883 this_utf = FALSE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
884 s += l - 1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
885 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
886 ++s;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
887 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
888
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
889 // The help file is latin1 or utf-8;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
890 // conversion to the current
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
891 // 'encoding' may be required.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
892 vc.vc_type = CONV_NONE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
893 convert_setup(&vc, (char_u *)(
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
894 this_utf == TRUE ? "utf-8"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
895 : "latin1"), p_enc);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
896 if (vc.vc_type == CONV_NONE)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
897 // No conversion needed.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
898 cp = IObuff;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
899 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
900 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
901 // Do the conversion. If it fails
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
902 // use the unconverted text.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
903 cp = string_convert(&vc, IObuff,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
904 NULL);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
905 if (cp == NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
906 cp = IObuff;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
907 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
908 convert_setup(&vc, NULL, NULL);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
909
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
910 ml_append(lnum, cp, (colnr_T)0, FALSE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
911 if (cp != IObuff)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
912 vim_free(cp);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
913 ++lnum;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
914 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
915 fclose(fd);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
916 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
917 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
918 FreeWild(fcount, fnames);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
919 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
920 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
921 if (mustfree)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
922 vim_free(rt);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
923 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
924 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
925 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
926 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
927 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
928
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
929 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
930 * ":exusage"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
931 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
932 void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
933 ex_exusage(exarg_T *eap UNUSED)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
934 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
935 do_cmdline_cmd((char_u *)"help ex-cmd-index");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
936 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
937
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
938 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
939 * ":viusage"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
940 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
941 void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
942 ex_viusage(exarg_T *eap UNUSED)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
943 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
944 do_cmdline_cmd((char_u *)"help normal-index");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
945 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
946
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
947 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
948 * Generate tags in one help directory.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
949 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
950 static void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
951 helptags_one(
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
952 char_u *dir, // doc directory
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
953 char_u *ext, // suffix, ".txt", ".itx", ".frx", etc.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
954 char_u *tagfname, // "tags" for English, "tags-fr" for French.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
955 int add_help_tags, // add "help-tags" tag
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
956 int ignore_writeerr) // ignore write error
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
957 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
958 FILE *fd_tags;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
959 FILE *fd;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
960 garray_T ga;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
961 int filecount;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
962 char_u **files;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
963 char_u *p1, *p2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
964 int fi;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
965 char_u *s;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
966 int i;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
967 char_u *fname;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
968 int dirlen;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
969 int utf8 = MAYBE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
970 int this_utf8;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
971 int firstline;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
972 int mix = FALSE; // detected mixed encodings
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
973
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
974 // Find all *.txt files.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
975 dirlen = (int)STRLEN(dir);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
976 STRCPY(NameBuff, dir);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
977 STRCAT(NameBuff, "/**/*");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
978 STRCAT(NameBuff, ext);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
979 if (gen_expand_wildcards(1, &NameBuff, &filecount, &files,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
980 EW_FILE|EW_SILENT) == FAIL
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
981 || filecount == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
982 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
983 if (!got_int)
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26857
diff changeset
984 semsg(_(e_no_match_str_1), NameBuff);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
985 return;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
986 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
987
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
988 // Open the tags file for writing.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
989 // Do this before scanning through all the files.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
990 STRCPY(NameBuff, dir);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
991 add_pathsep(NameBuff);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
992 STRCAT(NameBuff, tagfname);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
993 fd_tags = mch_fopen((char *)NameBuff, "w");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
994 if (fd_tags == NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
995 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
996 if (!ignore_writeerr)
26857
2aeea8611342 patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26853
diff changeset
997 semsg(_(e_cannot_open_str_for_writing_1), NameBuff);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
998 FreeWild(filecount, files);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
999 return;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1000 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1001
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1002 // If using the "++t" argument or generating tags for "$VIMRUNTIME/doc"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1003 // add the "help-tags" tag.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1004 ga_init2(&ga, (int)sizeof(char_u *), 100);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1005 if (add_help_tags || fullpathcmp((char_u *)"$VIMRUNTIME/doc",
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1006 dir, FALSE, TRUE) == FPC_SAME)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1007 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1008 if (ga_grow(&ga, 1) == FAIL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1009 got_int = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1010 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1011 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1012 s = alloc(18 + (unsigned)STRLEN(tagfname));
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1013 if (s == NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1014 got_int = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1015 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1016 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1017 sprintf((char *)s, "help-tags\t%s\t1\n", tagfname);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1018 ((char_u **)ga.ga_data)[ga.ga_len] = s;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1019 ++ga.ga_len;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1020 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1021 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1022 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1023
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1024 // Go over all the files and extract the tags.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1025 for (fi = 0; fi < filecount && !got_int; ++fi)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1026 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1027 fd = mch_fopen((char *)files[fi], "r");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1028 if (fd == NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1029 {
26853
806f31579357 patch 8.2.3955: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26276
diff changeset
1030 semsg(_(e_unable_to_open_str_for_reading), files[fi]);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1031 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1032 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1033 fname = files[fi] + dirlen + 1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1034
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1035 firstline = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1036 while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1037 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1038 if (firstline)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1039 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1040 // Detect utf-8 file by a non-ASCII char in the first line.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1041 this_utf8 = MAYBE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1042 for (s = IObuff; *s != NUL; ++s)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1043 if (*s >= 0x80)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1044 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1045 int l;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1046
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1047 this_utf8 = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1048 l = utf_ptr2len(s);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1049 if (l == 1)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1050 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1051 // Illegal UTF-8 byte sequence.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1052 this_utf8 = FALSE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1053 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1054 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1055 s += l - 1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1056 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1057 if (this_utf8 == MAYBE) // only ASCII characters found
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1058 this_utf8 = FALSE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1059 if (utf8 == MAYBE) // first file
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1060 utf8 = this_utf8;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1061 else if (utf8 != this_utf8)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1062 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1063 semsg(_("E670: Mix of help file encodings within a language: %s"), files[fi]);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1064 mix = !got_int;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1065 got_int = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1066 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1067 firstline = FALSE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1068 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1069 p1 = vim_strchr(IObuff, '*'); // find first '*'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1070 while (p1 != NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1071 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1072 // Use vim_strbyte() instead of vim_strchr() so that when
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1073 // 'encoding' is dbcs it still works, don't find '*' in the
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1074 // second byte.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1075 p2 = vim_strbyte(p1 + 1, '*'); // find second '*'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1076 if (p2 != NULL && p2 > p1 + 1) // skip "*" and "**"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1077 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1078 for (s = p1 + 1; s < p2; ++s)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1079 if (*s == ' ' || *s == '\t' || *s == '|')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1080 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1081
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1082 // Only accept a *tag* when it consists of valid
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1083 // characters, there is white space before it and is
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1084 // followed by a white character or end-of-line.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1085 if (s == p2
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1086 && (p1 == IObuff || p1[-1] == ' ' || p1[-1] == '\t')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1087 && (vim_strchr((char_u *)" \t\n\r", s[1]) != NULL
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1088 || s[1] == '\0'))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1089 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1090 *p2 = '\0';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1091 ++p1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1092 if (ga_grow(&ga, 1) == FAIL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1093 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1094 got_int = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1095 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1096 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1097 s = alloc(p2 - p1 + STRLEN(fname) + 2);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1098 if (s == NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1099 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1100 got_int = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1101 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1102 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1103 ((char_u **)ga.ga_data)[ga.ga_len] = s;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1104 ++ga.ga_len;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1105 sprintf((char *)s, "%s\t%s", p1, fname);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1106
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1107 // find next '*'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1108 p2 = vim_strchr(p2 + 1, '*');
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1109 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1110 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1111 p1 = p2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1112 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1113 line_breakcheck();
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1114 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1115
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1116 fclose(fd);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1117 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1118
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1119 FreeWild(filecount, files);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1120
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1121 if (!got_int)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1122 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1123 // Sort the tags.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1124 if (ga.ga_data != NULL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1125 sort_strings((char_u **)ga.ga_data, ga.ga_len);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1126
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1127 // Check for duplicates.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1128 for (i = 1; i < ga.ga_len; ++i)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1129 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1130 p1 = ((char_u **)ga.ga_data)[i - 1];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1131 p2 = ((char_u **)ga.ga_data)[i];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1132 while (*p1 == *p2)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1133 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1134 if (*p2 == '\t')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1135 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1136 *p2 = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1137 vim_snprintf((char *)NameBuff, MAXPATHL,
26853
806f31579357 patch 8.2.3955: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26276
diff changeset
1138 _(e_duplicate_tag_str_in_file_str_str),
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1139 ((char_u **)ga.ga_data)[i], dir, p2 + 1);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1140 emsg((char *)NameBuff);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1141 *p2 = '\t';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1142 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1143 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1144 ++p1;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1145 ++p2;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1146 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1147 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1148
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1149 if (utf8 == TRUE)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1150 fprintf(fd_tags, "!_TAG_FILE_ENCODING\tutf-8\t//\n");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1151
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1152 // Write the tags into the file.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1153 for (i = 0; i < ga.ga_len; ++i)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1154 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1155 s = ((char_u **)ga.ga_data)[i];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1156 if (STRNCMP(s, "help-tags\t", 10) == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1157 // help-tags entry was added in formatted form
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1158 fputs((char *)s, fd_tags);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1159 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1160 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1161 fprintf(fd_tags, "%s\t/*", s);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1162 for (p1 = s; *p1 != '\t'; ++p1)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1163 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1164 // insert backslash before '\\' and '/'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1165 if (*p1 == '\\' || *p1 == '/')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1166 putc('\\', fd_tags);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1167 putc(*p1, fd_tags);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1168 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1169 fprintf(fd_tags, "*\n");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1170 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1171 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1172 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1173 if (mix)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1174 got_int = FALSE; // continue with other languages
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1175
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1176 for (i = 0; i < ga.ga_len; ++i)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1177 vim_free(((char_u **)ga.ga_data)[i]);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1178 ga_clear(&ga);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1179 fclose(fd_tags); // there is no check for an error...
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1180 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1181
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1182 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1183 * Generate tags in one help directory, taking care of translations.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1184 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1185 static void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1186 do_helptags(char_u *dirname, int add_help_tags, int ignore_writeerr)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1187 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1188 #ifdef FEAT_MULTI_LANG
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1189 int len;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1190 int i, j;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1191 garray_T ga;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1192 char_u lang[2];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1193 char_u ext[5];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1194 char_u fname[8];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1195 int filecount;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1196 char_u **files;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1197
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1198 // Get a list of all files in the help directory and in subdirectories.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1199 STRCPY(NameBuff, dirname);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1200 add_pathsep(NameBuff);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1201 STRCAT(NameBuff, "**");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1202 if (gen_expand_wildcards(1, &NameBuff, &filecount, &files,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1203 EW_FILE|EW_SILENT) == FAIL
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1204 || filecount == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1205 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1206 semsg(_("E151: No match: %s"), NameBuff);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1207 return;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1208 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1209
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1210 // Go over all files in the directory to find out what languages are
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1211 // present.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1212 ga_init2(&ga, 1, 10);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1213 for (i = 0; i < filecount; ++i)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1214 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1215 len = (int)STRLEN(files[i]);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1216 if (len > 4)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1217 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1218 if (STRICMP(files[i] + len - 4, ".txt") == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1219 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1220 // ".txt" -> language "en"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1221 lang[0] = 'e';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1222 lang[1] = 'n';
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1223 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1224 else if (files[i][len - 4] == '.'
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1225 && ASCII_ISALPHA(files[i][len - 3])
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1226 && ASCII_ISALPHA(files[i][len - 2])
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1227 && TOLOWER_ASC(files[i][len - 1]) == 'x')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1228 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1229 // ".abx" -> language "ab"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1230 lang[0] = TOLOWER_ASC(files[i][len - 3]);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1231 lang[1] = TOLOWER_ASC(files[i][len - 2]);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1232 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1233 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1234 continue;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1235
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1236 // Did we find this language already?
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1237 for (j = 0; j < ga.ga_len; j += 2)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1238 if (STRNCMP(lang, ((char_u *)ga.ga_data) + j, 2) == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1239 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1240 if (j == ga.ga_len)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1241 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1242 // New language, add it.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1243 if (ga_grow(&ga, 2) == FAIL)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1244 break;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1245 ((char_u *)ga.ga_data)[ga.ga_len++] = lang[0];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1246 ((char_u *)ga.ga_data)[ga.ga_len++] = lang[1];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1247 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1248 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1249 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1250
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1251 // Loop over the found languages to generate a tags file for each one.
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1252 for (j = 0; j < ga.ga_len; j += 2)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1253 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1254 STRCPY(fname, "tags-xx");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1255 fname[5] = ((char_u *)ga.ga_data)[j];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1256 fname[6] = ((char_u *)ga.ga_data)[j + 1];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1257 if (fname[5] == 'e' && fname[6] == 'n')
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1258 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1259 // English is an exception: use ".txt" and "tags".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1260 fname[4] = NUL;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1261 STRCPY(ext, ".txt");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1262 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1263 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1264 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1265 // Language "ab" uses ".abx" and "tags-ab".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1266 STRCPY(ext, ".xxx");
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1267 ext[1] = fname[5];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1268 ext[2] = fname[6];
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1269 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1270 helptags_one(dirname, ext, fname, add_help_tags, ignore_writeerr);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1271 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1272
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1273 ga_clear(&ga);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1274 FreeWild(filecount, files);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1275
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1276 #else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1277 // No language support, just use "*.txt" and "tags".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1278 helptags_one(dirname, (char_u *)".txt", (char_u *)"tags", add_help_tags,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1279 ignore_writeerr);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1280 #endif
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1281 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1282
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1283 static void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1284 helptags_cb(char_u *fname, void *cookie)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1285 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1286 do_helptags(fname, *(int *)cookie, TRUE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1287 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1288
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1289 /*
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1290 * ":helptags"
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1291 */
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1292 void
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1293 ex_helptags(exarg_T *eap)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1294 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1295 expand_T xpc;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1296 char_u *dirname;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1297 int add_help_tags = FALSE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1298
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1299 // Check for ":helptags ++t {dir}".
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1300 if (STRNCMP(eap->arg, "++t", 3) == 0 && VIM_ISWHITE(eap->arg[3]))
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1301 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1302 add_help_tags = TRUE;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1303 eap->arg = skipwhite(eap->arg + 3);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1304 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1305
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1306 if (STRCMP(eap->arg, "ALL") == 0)
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1307 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1308 do_in_path(p_rtp, (char_u *)"doc", DIP_ALL + DIP_DIR,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1309 helptags_cb, &add_help_tags);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1310 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1311 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1312 {
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1313 ExpandInit(&xpc);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1314 xpc.xp_context = EXPAND_DIRECTORIES;
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1315 dirname = ExpandOne(&xpc, eap->arg, NULL,
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1316 WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1317 if (dirname == NULL || !mch_isdir(dirname))
26853
806f31579357 patch 8.2.3955: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26276
diff changeset
1318 semsg(_(e_not_a_directory_str), eap->arg);
21423
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1319 else
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1320 do_helptags(dirname, add_help_tags, FALSE);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1321 vim_free(dirname);
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1322 }
5db63c2c6929 patch 8.2.1262: src/ex_cmds.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1323 }