Patch 7.4.1945
Problem:    The Man plugin doesn't work that well.
Solution:   Use "g:ft_man_open_mode" to be able open man pages in vert split
            or separate tab. Set nomodifiable for buffer with man content. Add
            a test. (Andrey Starodubtsev, closes #873)
Files:      runtime/ftplugin/man.vim, src/testdir/test_man.vim,
            src/testdir/Make_all.mak


*** ../vim-7.4.1944/runtime/ftplugin/man.vim    2013-07-17 15:56:19.000000000 
+0200
--- runtime/ftplugin/man.vim    2016-06-20 11:05:33.874778431 +0200
***************
*** 1,7 ****
  " Vim filetype plugin file
  " Language:   man
  " Maintainer: SungHyun Nam <[email protected]>
! " Last Change:        2013 Jul 17
  
  " To make the ":Man" command available before editing a manual page, source
  " this script from your startup vimrc file.
--- 1,7 ----
  " Vim filetype plugin file
  " Language:   man
  " Maintainer: SungHyun Nam <[email protected]>
! " Last Change:        2016 Jun 20
  
  " To make the ":Man" command available before editing a manual page, source
  " this script from your startup vimrc file.
***************
*** 33,38 ****
--- 33,43 ----
  
      nnoremap <buffer> <c-]> :call <SID>PreGetPage(v:count)<CR>
      nnoremap <buffer> <c-t> :call <SID>PopPage()<CR>
+     nnoremap <buffer> <silent> q :q<CR>
+   endif
+ 
+   if exists('g:ft_man_folding_enable') && (g:ft_man_folding_enable == 1)
+     setlocal foldmethod=indent foldnestmax=1 foldenable
    endif
  
    let b:undo_ftplugin = "setlocal iskeyword<"
***************
*** 63,69 ****
  func <SID>PreGetPage(cnt)
    if a:cnt == 0
      let old_isk = &iskeyword
!     setl iskeyword+=(,)
      let str = expand("<cword>")
      let &l:iskeyword = old_isk
      let page = substitute(str, '(*\(\k\+\).*', '\1', '')
--- 68,76 ----
  func <SID>PreGetPage(cnt)
    if a:cnt == 0
      let old_isk = &iskeyword
!     if &ft == 'man'
!       setl iskeyword+=(,)
!     endif
      let str = expand("<cword>")
      let &l:iskeyword = old_isk
      let page = substitute(str, '(*\(\k\+\).*', '\1', '')
***************
*** 143,149 ****
        endwhile
      endif
      if &filetype != "man"
!       new
        setl nonu fdc=0
      endif
    endif
--- 150,166 ----
        endwhile
      endif
      if &filetype != "man"
!       if exists("g:ft_man_open_mode")
!         if g:ft_man_open_mode == "vert"
!           vnew
!         elseif g:ft_man_open_mode == "tab"
!           tabnew
!         else
!           new
!         endif
!       else
!         new
!       endif
        setl nonu fdc=0
      endif
    endif
***************
*** 153,171 ****
  
    setl ma nonu nornu nofen
    silent exec "norm 1GdG"
!   let $MANWIDTH = winwidth(0)
    silent exec "r!/usr/bin/man ".s:GetCmdArg(sect, page)." | col -b"
    " Remove blank lines from top and bottom.
    while getline(1) =~ '^\s*$'
!     silent norm ggdd
    endwhile
    while getline('$') =~ '^\s*$'
!     silent norm Gdd
    endwhile
    1
    setl ft=man nomod
    setl bufhidden=hide
    setl nobuflisted
  endfunc
  
  func <SID>PopPage()
--- 170,196 ----
  
    setl ma nonu nornu nofen
    silent exec "norm 1GdG"
!   let unsetwidth = 0
!   if empty($MANWIDTH)
!     let $MANWIDTH = winwidth(0)
!     let unsetwidth = 1
!   endif
    silent exec "r!/usr/bin/man ".s:GetCmdArg(sect, page)." | col -b"
+   if unsetwidth
+     let $MANWIDTH = ''
+   endif
    " Remove blank lines from top and bottom.
    while getline(1) =~ '^\s*$'
!     silent keepj norm ggdd
    endwhile
    while getline('$') =~ '^\s*$'
!     silent keepj norm Gdd
    endwhile
    1
    setl ft=man nomod
    setl bufhidden=hide
    setl nobuflisted
+   setl noma
  endfunc
  
  func <SID>PopPage()
***************
*** 186,189 ****
  
  endif
  
! " vim: set sw=2:
--- 211,214 ----
  
  endif
  
! " vim: set sw=2 ts=8 noet:
*** ../vim-7.4.1944/src/testdir/test_man.vim    2016-06-20 11:19:58.537570041 
+0200
--- src/testdir/test_man.vim    2016-06-20 11:10:04.115898378 +0200
***************
*** 0 ****
--- 1,59 ----
+ runtime ftplugin/man.vim
+ 
+ function Test_g_ft_man_open_mode()
+   let l:w = winwidth(1)
+   vnew
+   let l:h = winheight(1)
+   q
+ 
+   " split horizontally
+   let wincnt = winnr('$')
+   Man 'vim'
+   if wincnt == winnr('$')
+     " Vim manual page cannot be found.
+     return
+   endif
+   call assert_equal(l:w, winwidth(1))
+   call assert_true(l:h > winheight(1))
+   call assert_equal(1, tabpagenr('$'))
+   call assert_equal(1, tabpagenr())
+   q
+ 
+   " split horizontally
+   let g:ft_man_open_mode = "horz"
+   Man 'vim'
+   call assert_equal(l:w, winwidth(1))
+   call assert_true(l:h > winheight(1))
+   call assert_equal(1, tabpagenr('$'))
+   call assert_equal(1, tabpagenr())
+   q
+ 
+   " split vertically
+   let g:ft_man_open_mode = "vert"
+   Man 'vim'
+   call assert_true(l:w > winwidth(1))
+   call assert_equal(l:h, winheight(1))
+   call assert_equal(1, tabpagenr('$'))
+   call assert_equal(1, tabpagenr())
+   q
+ 
+   " separate tab
+   let g:ft_man_open_mode = "tab"
+   Man 'vim'
+   call assert_equal(l:w, winwidth(1))
+   call assert_equal(l:h, winheight(1))
+   call assert_equal(2, tabpagenr('$'))
+   call assert_equal(2, tabpagenr())
+   q
+ endfunction
+ 
+ function Test_nomodifiable()
+   let wincnt = winnr('$')
+   Man 'vim'
+   if wincnt == winnr('$')
+     " Vim manual page cannot be found.
+     return
+   endif
+   call assert_false(&l:modifiable)
+   q
+ endfunction
*** ../vim-7.4.1944/src/testdir/Make_all.mak    2016-06-11 23:22:22.895097595 
+0200
--- src/testdir/Make_all.mak    2016-06-20 11:06:00.570493795 +0200
***************
*** 175,180 ****
--- 175,181 ----
            test_increment.res \
            test_json.res \
            test_langmap.res \
+           test_man.res \
            test_matchadd_conceal.res \
            test_packadd.res \
            test_perl.res \
*** ../vim-7.4.1944/src/version.c       2016-06-18 21:58:07.334076734 +0200
--- src/version.c       2016-06-20 11:14:18.825187129 +0200
***************
*** 755,756 ****
--- 755,758 ----
  {   /* Add new patch number below this line */
+ /**/
+     1945,
  /**/

-- 
FIXME and XXX are two common keywords used to mark broken or incomplete code
not only since XXX as a sex reference would grab everybody's attention but
simply due to the fact that Vim would highlight these words.
                                        -- Hendrik Scholz

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui