On 10 October 2017, Bram Moolenaar <b...@moolenaar.net> wrote:
> 
> lcd wrote:
> 
> >     Per title: if MANPAGER is set to "env MAN_PN=1 vim -M +MANPAGER -",
> > running "man Xorg" results in a message "Cannot find a 'xorg'.".
> > 
> >     The culprit is a "tolower()" in plugin/manpager.vim.  Man page names
> > are case-sensitive on most UNIX systems.  The patch below seems to fix
> > the problem.
> > 
> >     /lcd
> > 
> > 
> > diff --git a/runtime/plugin/manpager.vim b/runtime/plugin/manpager.vim
> > index be6e30b70..9d30fab2f 100644
> > --- a/runtime/plugin/manpager.vim
> > +++ b/runtime/plugin/manpager.vim
> > @@ -20,7 +20,7 @@ function! s:MANPAGER()
> >      let manpage = expand('$MAN_PN')
> >    endif
> >  
> > -  let page_sec = matchlist(tolower(manpage), '^' . pagesec_pattern  . '$')
> > +  let page_sec = matchlist(manpage, '^' . pagesec_pattern  . '$')
> >  
> >    bwipe!
> 
> Can you try this instead:
>   let page_sec = matchlist(tolower(manpage), '^' . tolower(pagesec_pattern)  
> . '$')

    It doesn't help, "Xorg" still gets converted to "xorg".

    As I understand it, what's going on is something like this: Vim
receives the formatted man page via MANPAGER, but this is not directly
usable, so Vim needs to run "man" again.  However at that point the
original "man" options are not available, so Vim tries to infer them
from the first line in the formatted man page.

    Now, some man pages preserve the case of the name of the utility
they document (such as "Xorg(1)"), others uppercase it (f.i. "LS(1)").
That's why Vim calls tolower().  This works for most man pages, because
the names are all lower-case, but fails for things like "Xorg" and
"Net::DNS".  Please note that the ":Man" command is not affected, it's
only the MANPAGER mechanism that has this problem.

    Trying to infer the real name from the title of a man page is a
losing battle, and running "man" again from MANPAGER is wasteful anyway.
I think a better approach would be to write a wrapper script around
"man", which would do some minimal option parsing, adjust options to
suit Vim, save the original options, run "man", and then pass the result
to Vim along with the options.  This would then bypass manpager.vim
completely, and since the options were adjusted there would be no need
to run "man" again, so a part of man.vim would also be bypassed.

    Basically most of the job of man.vim would be done by the script
(but man.vim would still be needed, for the ":Man" command).  The only
problem I see are that passing options to Vim from the script is not
easy, it would involve writing something like

        -c 'let man_opts = ["ls", "1"]'

and quoting everything properly could get interesting.  Also I'm not
sure how feasible this is on Windows.

    /lcd

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui