annotate runtime/plugin/manpager.vim @ 33515:f41bdc22abcd v9.0.2006

patch 9.0.2006: Vim9: need more tests Commit: https://github.com/vim/vim/commit/f4ee1cb74ba86383190ffcda84147892f7740f21 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Mon Oct 9 17:57:27 2023 +0200 patch 9.0.2006: Vim9: need more tests Problem: Vim9: need more tests Solution: add additional disassembly tests closes: #13305 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
author Christian Brabandt <cb@256bit.org>
date Mon, 09 Oct 2023 18:00:10 +0200
parents a57db996dbe3
children eb26acdda828
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9037
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Vim plugin for using Vim as manpager.
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 " Maintainer: Enno Nagel <ennonagel+vim@gmail.com>
30967
eb2638f278bf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30634
diff changeset
3 " Last Change: 2022 Oct 17
eb2638f278bf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30634
diff changeset
4
eb2638f278bf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30634
diff changeset
5 if exists('g:loaded_manpager_plugin')
eb2638f278bf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30634
diff changeset
6 finish
eb2638f278bf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30634
diff changeset
7 endif
eb2638f278bf Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 30634
diff changeset
8 let g:loaded_manpager_plugin = 1
9037
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9
29193
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29087
diff changeset
10 " Set up the current buffer (likely read from stdin) as a manpage
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29087
diff changeset
11 command MANPAGER call s:ManPager()
9037
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12
29087
f3ec3c57e070 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 25619
diff changeset
13 function s:ManPager()
f3ec3c57e070 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 25619
diff changeset
14 " global options, keep these to a minimum to avoid side effects
f3ec3c57e070 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 25619
diff changeset
15 if &compatible
f3ec3c57e070 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 25619
diff changeset
16 set nocompatible
f3ec3c57e070 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 25619
diff changeset
17 endif
13231
167a030448fa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
18 if exists('+viminfofile')
167a030448fa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
19 set viminfofile=NONE
167a030448fa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
20 endif
29193
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29087
diff changeset
21 syntax on
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29087
diff changeset
22
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29087
diff changeset
23 " Make this an unlisted, readonly scratch buffer
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29087
diff changeset
24 setlocal buftype=nofile noswapfile bufhidden=hide nobuflisted readonly
9037
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25
29193
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29087
diff changeset
26 " Ensure text width matches window width
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29087
diff changeset
27 setlocal foldcolumn& nofoldenable nonumber norelativenumber
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29087
diff changeset
28
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29087
diff changeset
29 " In case Vim was invoked with -M
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29087
diff changeset
30 setlocal modifiable
13231
167a030448fa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
31
167a030448fa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
32 " Emulate 'col -b'
32710
a57db996dbe3 Manpager: apply g flag conditionally to s command (#12679)
Christian Brabandt <cb@256bit.org>
parents: 30967
diff changeset
33 exe 'silent! keepj keepp %s/\v(.)\b\ze\1?//e' .. (&gdefault ? '' : 'g')
25619
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13231
diff changeset
34
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 13231
diff changeset
35 " Remove ansi sequences
32710
a57db996dbe3 Manpager: apply g flag conditionally to s command (#12679)
Christian Brabandt <cb@256bit.org>
parents: 30967
diff changeset
36 exe 'silent! keepj keepp %s/\v\e\[%(%(\d;)?\d{1,2})?[mK]//e' .. (&gdefault ? '' : 'g')
9037
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37
13231
167a030448fa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
38 " Remove empty lines above the header
167a030448fa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
39 call cursor(1, 1)
167a030448fa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
40 let n = search(".*(.*)", "c")
167a030448fa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
41 if n > 1
167a030448fa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
42 exe "1," . n-1 . "d"
167a030448fa Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 12826
diff changeset
43 endif
29193
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29087
diff changeset
44
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29087
diff changeset
45 " Finished preprocessing the buffer, prevent any further modifications
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29087
diff changeset
46 setlocal nomodified nomodifiable
9037
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47
29193
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29087
diff changeset
48 " Set filetype to man even if ftplugin is disabled
30634
f68f43043842 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29193
diff changeset
49 setlocal filetype=man
29193
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 29087
diff changeset
50 runtime ftplugin/man.vim
9037
d07035f84f0d commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 endfunction