rc man: fix man-jump when selection contains first character of man link

If I use "man dirname" and select "basename" 

	SEE ALSO
	       basename(1), readlink(1)
	       ^------^

then pressing <ret> to trigger man-jump selects everything from "ALSO"
until "basename(1)" Obviously that's not the name of a man page,
so it fails. When I select only "asename" it works.

The bad selection happens because we use a combination of <a-?> and ?
to extend the selection to a full link. This is more complicated than
it needs to be; let's just select the surrounding WORD.  This works
fine because man page links never start mid-word, and trailing
characters are ignored anyway.
This commit is contained in:
Johannes Altmanninger 2022-07-29 20:42:59 +02:00
parent 329b215494
commit 45aad1ed2c

View File

@ -122,19 +122,9 @@ man-link-next %{ man-search %opt[man_link2] n }
define-command -docstring 'Go to previous man page link' \ define-command -docstring 'Go to previous man page link' \
man-link-prev %{ man-search %opt[man_link2] <a-n> } man-link-prev %{ man-search %opt[man_link2] <a-n> }
# Expand backward and forward, and then try to search for a man page link
define-command man-link-here %{ evaluate-commands -save-regs / %{
man-search %opt[man_link2] '<a-?>\b\w<ret><a-;>?\)<ret>'
}} -hidden
# Search current selection for a man page link
define-command man-link %{ evaluate-commands -save-regs / %{
man-search %opt[man_link1] s<ret>
}} -hidden
define-command -docstring 'Try to jump to a man page' \ define-command -docstring 'Try to jump to a man page' \
man-jump %{ man-jump %{
try %{ man-link } catch %{ man-link-here } catch %{ fail 'Not a valid man page link' } try %{ execute-keys <a-a><a-w> s %opt[man_link1] <ret> } catch %{ fail 'Not a valid man page link' }
try %{ man } catch %{ fail 'No man page link to follow' } try %{ man } catch %{ fail 'No man page link to follow' }
} }