[vim/vim] runtime(man): UX fixes (PR #15117)

24 views
Skip to first unread message

Ivan Shapovalov

unread,
Jun 27, 2024, 11:52:18 PM (5 days ago) Jun 27
to vim/vim, Subscribed

Two minor improvements to manpage support that seem to do the right thing for me.
Note that I'm fairly new to Vim{,script}, so please do not kick me too hard if any of these changes are bogus.

  • Honor placement (vert/hor/tab) cmd modifiers to :Man, if any are present, before g:ft_man_open_mode.
    This way, e.g. :vert Man does the expected thing even in presence of a contradicting g:ft_man_open_mode.

  • Actually add parentheses to iskeyword= so that K on a man page reference considers its section (if present).
    The comment suggests that the parentheses were added to the iskeyword set elsewhere, but I could not find it in the code (and, indeed, it did not work in practice).


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/15117

Commit Summary

  • f270573 runtime(man): honor cmd modifiers before `g:ft_man_open_mode`
  • c955ffc runtime(man): add parentheses to iskeyword=

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15117@github.com>

Ivan Shapovalov

unread,
Jun 28, 2024, 1:51:06 AM (5 days ago) Jun 28
to vim/vim, Push

@intelfx pushed 2 commits.

  • f394f04 runtime(man): honor cmd modifiers before `g:ft_man_open_mode`
  • af30dec runtime(man): add parentheses to iskeyword=


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15117/before/c955ffc1d683caa502c2ad0af0f9ac9fbe7044f2/after/af30deceea1ac7a17282dfeb7b0acd0901f6efd7@github.com>

Aliaksei Budavei

unread,
Jun 28, 2024, 5:33:02 PM (4 days ago) Jun 28
to vim/vim, Subscribed

What manual page issue are you currently having that can be
solved by including (,) in &iskeyword script-wide?

The reason for chucking out parentheses at 8cfe52 was that
having them included or not is immaterial for parsing str:

https://github.com/vim/vim/blob/88bbdb04c2776ba69b8e5da58051fd94f8842b03/runtime/autoload/dist/man.vim#L72-L77


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15117/c2197687829@github.com>

Ivan Shapovalov

unread,
Jun 28, 2024, 11:26:31 PM (4 days ago) Jun 28
to vim/vim, Subscribed

What manual page issue are you currently having that can be solved by including (,) in &iskeyword script-wide?

If you define keywordprg=:Man and then use plain K to navigate to a man page under cursor, the section is not considered.

I see that man.vim itself suggests a nmap K :Man <cWORD><CR> mapping (that is special-cased in GetPage), and also defines a <Leader> K mapping for the same, but it feels unnecessary if one can just use builtin K?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15117/c2197876959@github.com>

Aliaksei Budavei

unread,
Jun 29, 2024, 5:25:16 PM (3 days ago) Jun 29
to vim/vim, Subscribed

I can reproduce the faulty behaviour (v9.1.0516).

For example, initially read signal(2) and later fail to
read signal(7)with K (when &kp is set to :Man):

MANWIDTH=80 VIMRUNTIME=/path/to/fork/dir/runtime \
vim --clean --not-a-term \
  '+set vif=NONE' \
  '+sil! unmap K' \
  '+doautoall FileType setl ft=man kp=:Man nofen' \
  '+Man 2 signal' \
  '+/signal(7)' \
  '+norm f7BK'

However, finding a page should work whenever the sought page
is locally installed in only one section directory and its
name matches the referenced section number (e.g. full(4)).

It appears that parentheses had exclusively been used for
fetching <cword> ever since vim-6-0k (Oct. 2000) and until
recently, when at f269ea (see #11244) similar changes were
applied, but summarily dismissed at 71badf with a comment
referencing dist#man#PreGetPage().

And you don't get to see signal(7) anyway with the proposed
changes for the above Vim command, because any parenthesis
now belongs to \k, so K would try looking for signal(7))
(note the extra closing parenthesis). Also, with K you
can't follow a reference that terminates in a hyphen-minus
or a hyphen; that is, split between two lines.

Anyway, you need to run the changes by the maintainers:
@goweol, @lifecrisis.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15117/c2198341062@github.com>

Ivan Shapovalov

unread,
Jun 30, 2024, 5:52:50 AM (3 days ago) Jun 30
to vim/vim, Subscribed

And you don't get to see signal(7) anyway with the proposed
changes for the above Vim command, because any parenthesis
now belongs to \k, so K would try looking for signal(7))
(note the extra closing parenthesis). Also, with K you
can't follow a reference that terminates in a hyphen-minus
or a hyphen; that is, split between two lines.

Yes, that is true. The custom <Leader>K mapping man.vim defines is more powerful than the built-in K functionality, where the latter does have limitations as you describe. But I think there is perhaps still value to making it work OOTB-ish?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15117/c2198502015@github.com>

D. Ben Knoble

unread,
Jun 30, 2024, 9:30:35 AM (3 days ago) Jun 30
to vim/vim, Subscribed

I expect the modifiers support would be welcome, but the parentheses bit seems controversial.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15117/c2198564424@github.com>

Aliaksei Budavei

unread,
Jun 30, 2024, 6:33:57 PM (2 days ago) Jun 30
to vim/vim, Subscribed

Further observations.

The current execution of K (setl kp=:Man) is aligned with
the Man command invocation when the latter does not take any
section number, e.g. :Man signal, either would pick the same
page; and [count]K is aligned with :Man [section] [page],
e.g. 7K and :Man 7 signal.

Indefinitely adding (,) to &isk would break this symmetry
by rendering K more capable than :Man [page], and it would
also neither make K work nor \K nor C-] to boot on some
references that contain a \k character after the closing
parenthesis, e.g. signal(7)) , signal(7).). If accepted,
this line should also be adapted:

https://github.com/vim/vim/blob/88bbdb04c2776ba69b8e5da58051fd94f8842b03/runtime/autoload/dist/man.vim#L74


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15117/c2198785057@github.com>

Reply all
Reply to author
Forward
0 new messages