From 329b215494ed1d3a294a134ecc39dda3e5256e82 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 29 Jul 2022 20:26:43 +0200 Subject: [PATCH 1/2] rc man: hide helper command "man-search" This undocumented command is only used to share logic between the various man-link-* commands. Let's hide it to avoid confusion. --- rc/tools/man.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/tools/man.kak b/rc/tools/man.kak index facfaedf..ed85ce2a 100644 --- a/rc/tools/man.kak +++ b/rc/tools/man.kak @@ -107,7 +107,7 @@ declare-option -hidden regex man_link2 \ # Define a useful command sequence for searching a given regex # and a given sequence of search keys. -define-command man-search -params 2 %{ +define-command -hidden man-search -params 2 %{ set-register / %arg[1] try %{ execute-keys %arg[2] From 45aad1ed2cf9986942dc0ccc8aaf3729063ebf79 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 29 Jul 2022 20:42:59 +0200 Subject: [PATCH 2/2] 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 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 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. --- rc/tools/man.kak | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/rc/tools/man.kak b/rc/tools/man.kak index ed85ce2a..f017fa8c 100644 --- a/rc/tools/man.kak +++ b/rc/tools/man.kak @@ -122,19 +122,9 @@ man-link-next %{ man-search %opt[man_link2] n } define-command -docstring 'Go to previous man page link' \ man-link-prev %{ man-search %opt[man_link2] } -# 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] '\b\w?\)' -}} -hidden - -# Search current selection for a man page link -define-command man-link %{ evaluate-commands -save-regs / %{ - man-search %opt[man_link1] s -}} -hidden - define-command -docstring 'Try to jump to a man page' \ man-jump %{ - try %{ man-link } catch %{ man-link-here } catch %{ fail 'Not a valid man page link' } + try %{ execute-keys s %opt[man_link1] } catch %{ fail 'Not a valid man page link' } try %{ man } catch %{ fail 'No man page link to follow' } }