annotate runtime/autoload/dist/man.vim @ 35172:c98f002b1fe4 default tip

runtime(doc): fix typo in usr_52.txt Commit: https://github.com/vim/vim/commit/b7258738f80f26be302a84a99f968b3bdc2f29bb Author: Christian Brabandt <cb@256bit.org> Date: Sun May 12 19:04:47 2024 +0200 runtime(doc): fix typo in usr_52.txt fixes: https://github.com/vim/vim/issues/14758 Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sun, 12 May 2024 19:15:08 +0200
parents 86031416a201
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Vim filetype plugin autoload file
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 " Language: man
32929
4ae88f9389b4 runtime(man): remove backslashes in man pages using Vim script (#12557)
Christian Brabandt <cb@256bit.org>
parents: 32837
diff changeset
3 " Maintainer: Jason Franklin <jason@oneway.dev>
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 " Maintainer: SungHyun Nam <goweol@gmail.com>
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 " Autoload Split: Bram Moolenaar
34164
86031416a201 runtime(man): man on AIX does not understand -l
Christian Brabandt <cb@256bit.org>
parents: 33270
diff changeset
6 " Last Change: 2024 Jan 17 (make it work on AIX, see #13847)
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 let s:cpo_save = &cpo
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 set cpo-=C
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 let s:man_tag_depth = 0
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 let s:man_sect_arg = ""
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 let s:man_find_arg = "-w"
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 try
34164
86031416a201 runtime(man): man on AIX does not understand -l
Christian Brabandt <cb@256bit.org>
parents: 33270
diff changeset
16 if !has("win32") && $OSTYPE !~ 'cygwin\|linux'
86031416a201 runtime(man): man on AIX does not understand -l
Christian Brabandt <cb@256bit.org>
parents: 33270
diff changeset
17 " cache the value
86031416a201 runtime(man): man on AIX does not understand -l
Christian Brabandt <cb@256bit.org>
parents: 33270
diff changeset
18 let uname_s = system('uname -s')
86031416a201 runtime(man): man on AIX does not understand -l
Christian Brabandt <cb@256bit.org>
parents: 33270
diff changeset
19
86031416a201 runtime(man): man on AIX does not understand -l
Christian Brabandt <cb@256bit.org>
parents: 33270
diff changeset
20 if uname_s =~ "SunOS" && system('uname -r') =~ "^5"
86031416a201 runtime(man): man on AIX does not understand -l
Christian Brabandt <cb@256bit.org>
parents: 33270
diff changeset
21 " Special Case for Man on SunOS
86031416a201 runtime(man): man on AIX does not understand -l
Christian Brabandt <cb@256bit.org>
parents: 33270
diff changeset
22 let s:man_sect_arg = "-s"
86031416a201 runtime(man): man on AIX does not understand -l
Christian Brabandt <cb@256bit.org>
parents: 33270
diff changeset
23 let s:man_find_arg = "-l"
86031416a201 runtime(man): man on AIX does not understand -l
Christian Brabandt <cb@256bit.org>
parents: 33270
diff changeset
24 elseif uname_s =~? 'AIX'
86031416a201 runtime(man): man on AIX does not understand -l
Christian Brabandt <cb@256bit.org>
parents: 33270
diff changeset
25 " Special Case for Man on AIX
86031416a201 runtime(man): man on AIX does not understand -l
Christian Brabandt <cb@256bit.org>
parents: 33270
diff changeset
26 let s:man_sect_arg = ""
86031416a201 runtime(man): man on AIX does not understand -l
Christian Brabandt <cb@256bit.org>
parents: 33270
diff changeset
27 let s:man_find_arg = ""
86031416a201 runtime(man): man on AIX does not understand -l
Christian Brabandt <cb@256bit.org>
parents: 33270
diff changeset
28 endif
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 catch /E145:/
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 " Ignore the error in restricted mode
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 endtry
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33
34164
86031416a201 runtime(man): man on AIX does not understand -l
Christian Brabandt <cb@256bit.org>
parents: 33270
diff changeset
34 unlet! uname_s
86031416a201 runtime(man): man on AIX does not understand -l
Christian Brabandt <cb@256bit.org>
parents: 33270
diff changeset
35
32837
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
36 func s:ParseIntoPageAndSection()
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
37 " Accommodate a reference that terminates in a hyphen.
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
38 "
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
39 " See init_charset_table() at
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
40 " https://git.savannah.gnu.org/cgit/groff.git/tree/src/roff/troff/input.cpp?h=1.22.4#n6794
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
41 "
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
42 " See can_break_after() at
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
43 " https://git.savannah.gnu.org/cgit/groff.git/tree/src/roff/troff/charinfo.h?h=1.22.4#n140
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
44 "
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
45 " Assumptions and limitations:
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
46 " 1) Manual-page references (in consequence of command-related filenames)
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
47 " do not contain non-ASCII HYPHENs (0x2010), any terminating HYPHEN
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
48 " must have been introduced to mark division of a word at the end of
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
49 " a line and can be discarded; whereas similar references may contain
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
50 " ASCII HYPHEN-MINUSes (0x002d) and any terminating HYPHEN-MINUS forms
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
51 " a compound word in addition to marking word division.
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
52 " 2) Well-formed manual-page references always have a section suffix, e.g.
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
53 " "git-commit(1)", therefore suspended hyphenated compounds are not
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
54 " determined, e.g. [V] (With cursor at _git-merge-_ below...)
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
55 " ".................... git-merge- and git-merge-base. (See git-cherry-
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
56 " pick(1) and git-cherry(1).)" (... look up "git-merge-pick(1)".)
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
57 "
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
58 " Note that EM DASH (0x2014), a third stooge from init_charset_table(),
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
59 " neither connects nor divides parts of a word.
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
60 let str = expand("<cWORD>")
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
61
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
62 if str =~ '\%u2010$' " HYPHEN (-1).
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
63 let str = strpart(str, 0, strridx(str, "\u2010"))
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
64
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
65 " Append the leftmost WORD (or an empty string) from the line below.
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
66 let str .= get(split(get(getbufline(bufnr('%'), line('.') + 1), 0, '')), 0, '')
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
67 elseif str =~ '-$' " HYPHEN-MINUS.
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
68 " Append the leftmost WORD (or an empty string) from the line below.
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
69 let str .= get(split(get(getbufline(bufnr('%'), line('.') + 1), 0, '')), 0, '')
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
70 endif
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
71
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
72 " According to man(1), section name formats vary (MANSECT):
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
73 " 1 n l 8 3 2 3posix 3pm 3perl 3am 5 4 9 6 7
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
74 let parts = matchlist(str, '\(\k\+\)(\(\k\+\))')
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
75 return (len(parts) > 2)
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
76 \ ? {'page': parts[1], 'section': parts[2]}
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
77 \ : {'page': matchstr(str, '\k\+'), 'section': ''}
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
78 endfunc
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
79
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 func dist#man#PreGetPage(cnt)
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 if a:cnt == 0
32837
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
82 let what = s:ParseIntoPageAndSection()
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
83 let sect = what.section
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
84 let page = what.page
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 else
32837
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
86 let what = s:ParseIntoPageAndSection()
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 let sect = a:cnt
32837
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
88 let page = what.page
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 endif
32837
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
90
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 call dist#man#GetPage('', sect, page)
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 endfunc
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 func s:GetCmdArg(sect, page)
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 if empty(a:sect)
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 return shellescape(a:page)
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 return s:man_sect_arg . ' ' . shellescape(a:sect) . ' ' . shellescape(a:page)
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 endfunc
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 func s:FindPage(sect, page)
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 let l:cmd = printf('man %s %s', s:man_find_arg, s:GetCmdArg(a:sect, a:page))
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 call system(l:cmd)
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 if v:shell_error
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 return 0
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 return 1
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 endfunc
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 func dist#man#GetPage(cmdmods, ...)
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 if a:0 >= 2
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 let sect = a:1
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 let page = a:2
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 elseif a:0 >= 1
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 let sect = ""
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 let page = a:1
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 else
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 return
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123
32837
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
124 " To support: nmap K :Man <cWORD><CR>
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
125 if page ==? '<cword>'
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
126 let what = s:ParseIntoPageAndSection()
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
127 let sect = what.section
050794aa4ef2 man.vim: Recognise hyphenated-at-eol cross-references (#12609)
Christian Brabandt <cb@256bit.org>
parents: 32836
diff changeset
128 let page = what.page
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 if !exists('g:ft_man_no_sect_fallback') || (g:ft_man_no_sect_fallback == 0)
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 if sect != "" && s:FindPage(sect, page) == 0
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 let sect = ""
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 if s:FindPage(sect, page) == 0
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 let msg = 'man.vim: no manual entry for "' . page . '"'
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 if !empty(sect)
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 let msg .= ' in section ' . sect
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 echomsg msg
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 return
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 exec "let s:man_tag_buf_".s:man_tag_depth." = ".bufnr("%")
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 exec "let s:man_tag_lin_".s:man_tag_depth." = ".line(".")
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 exec "let s:man_tag_col_".s:man_tag_depth." = ".col(".")
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 let s:man_tag_depth = s:man_tag_depth + 1
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 let open_cmd = 'edit'
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 " Use an existing "man" window if it exists, otherwise open a new one.
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 if &filetype != "man"
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 let thiswin = winnr()
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 exe "norm! \<C-W>b"
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 if winnr() > 1
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 exe "norm! " . thiswin . "\<C-W>w"
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 while 1
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 if &filetype == "man"
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 break
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 exe "norm! \<C-W>w"
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 if thiswin == winnr()
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 break
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 endwhile
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 if &filetype != "man"
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 if exists("g:ft_man_open_mode")
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 if g:ft_man_open_mode == 'vert'
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 let open_cmd = 'vsplit'
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 elseif g:ft_man_open_mode == 'tab'
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172 let open_cmd = 'tabedit'
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 else
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 let open_cmd = 'split'
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 else
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 let open_cmd = a:cmdmods . ' split'
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 silent execute open_cmd . " $HOME/" . page . '.' . sect . '~'
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184 " Avoid warning for editing the dummy file twice
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 setl buftype=nofile noswapfile
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 setl fdc=0 ma nofen nonu nornu
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 %delete _
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 let unsetwidth = 0
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 if empty($MANWIDTH)
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 let $MANWIDTH = winwidth(0)
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 let unsetwidth = 1
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195 " Ensure Vim is not recursively invoked (man-db does this) when doing ctrl-[
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 " on a man page reference by unsetting MANPAGER.
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 " Some versions of env(1) do not support the '-u' option, and in such case
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198 " we set MANPAGER=cat.
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199 if !exists('s:env_has_u')
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 call system('env -u x true')
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 let s:env_has_u = (v:shell_error == 0)
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 let env_cmd = s:env_has_u ? 'env -u MANPAGER' : 'env MANPAGER=cat'
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 let env_cmd .= ' GROFF_NO_SGR=1'
32929
4ae88f9389b4 runtime(man): remove backslashes in man pages using Vim script (#12557)
Christian Brabandt <cb@256bit.org>
parents: 32837
diff changeset
205 let man_cmd = env_cmd . ' man ' . s:GetCmdArg(sect, page)
4ae88f9389b4 runtime(man): remove backslashes in man pages using Vim script (#12557)
Christian Brabandt <cb@256bit.org>
parents: 32837
diff changeset
206
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 silent exec "r !" . man_cmd
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208
32929
4ae88f9389b4 runtime(man): remove backslashes in man pages using Vim script (#12557)
Christian Brabandt <cb@256bit.org>
parents: 32837
diff changeset
209 " Emulate piping the buffer through the "col -b" command.
4ae88f9389b4 runtime(man): remove backslashes in man pages using Vim script (#12557)
Christian Brabandt <cb@256bit.org>
parents: 32837
diff changeset
210 " Ref: https://github.com/vim/vim/issues/12301
33270
058fa5df3376 runtime(man): Man plugin does not respect 'gdefault'
Christian Brabandt <cb@256bit.org>
parents: 32949
diff changeset
211 exe 'silent! keepjumps keeppatterns %s/\v(.)\b\ze\1?//e' .. (&gdefault ? '' : 'g')
32929
4ae88f9389b4 runtime(man): remove backslashes in man pages using Vim script (#12557)
Christian Brabandt <cb@256bit.org>
parents: 32837
diff changeset
212
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 if unsetwidth
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 let $MANWIDTH = ''
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 " Remove blank lines from top and bottom.
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 while line('$') > 1 && getline(1) =~ '^\s*$'
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 1delete _
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 endwhile
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 while line('$') > 1 && getline('$') =~ '^\s*$'
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221 $delete _
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 endwhile
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 1
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 setl ft=man nomod
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 setl bufhidden=hide
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226 setl nobuflisted
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 setl noma
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 endfunc
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 func dist#man#PopPage()
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 if s:man_tag_depth > 0
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232 let s:man_tag_depth = s:man_tag_depth - 1
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233 exec "let s:man_tag_buf=s:man_tag_buf_".s:man_tag_depth
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 exec "let s:man_tag_lin=s:man_tag_lin_".s:man_tag_depth
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 exec "let s:man_tag_col=s:man_tag_col_".s:man_tag_depth
32836
f0854888250f man.vim: Uniformly place cursor at the same column with `Ctrl-t` (#12608)
Christian Brabandt <cb@256bit.org>
parents: 29236
diff changeset
236
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 exec s:man_tag_buf."b"
32836
f0854888250f man.vim: Uniformly place cursor at the same column with `Ctrl-t` (#12608)
Christian Brabandt <cb@256bit.org>
parents: 29236
diff changeset
238 call cursor(s:man_tag_lin, s:man_tag_col)
f0854888250f man.vim: Uniformly place cursor at the same column with `Ctrl-t` (#12608)
Christian Brabandt <cb@256bit.org>
parents: 29236
diff changeset
239
29236
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 exec "unlet s:man_tag_buf_".s:man_tag_depth
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241 exec "unlet s:man_tag_lin_".s:man_tag_depth
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242 exec "unlet s:man_tag_col_".s:man_tag_depth
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 unlet s:man_tag_buf s:man_tag_lin s:man_tag_col
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244 endif
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 endfunc
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247 let &cpo = s:cpo_save
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 unlet s:cpo_save
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249
0eef32b4ebbc Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 " vim: set sw=2 ts=8 noet: