diff --git a/doc/pages/execeval.asciidoc b/doc/pages/execeval.asciidoc index 2826004d..8d7edb95 100644 --- a/doc/pages/execeval.asciidoc +++ b/doc/pages/execeval.asciidoc @@ -54,6 +54,3 @@ when the commands have been executed: */*, *"*, *|*, *^*, *@*. *-save-regs* :: regs is a string of registers to be restored after execution (overwrites the list of registers saved by default, c.f. description) - -*-collapse-jumps*:: - collapse all jumps into a single one from initial selection diff --git a/rc/base/ctags.kak b/rc/base/ctags.kak index 1e68fc30..4eb1ecce 100644 --- a/rc/base/ctags.kak +++ b/rc/base/ctags.kak @@ -37,9 +37,9 @@ If no symbol is passed then the current selection is used as symbol name} \ re=$0; sub(".*\t/\\^", "", re); sub("\\$?/$", "", re); gsub("(\\{|\\}|\\\\E).*$", "", re); keys=re; gsub(/", keys); gsub(/\t/, "", keys); - out = out " %{" $2 " {MenuInfo}" re "} %{evaluate-commands -collapse-jumps %{ try %{ edit %{" tagroot $2 "}; execute-keys %{/\\Q" keys "vc} } catch %{ echo %{unable to find tag} } } }" + out = out " %{" $2 " {MenuInfo}" re "} %{evaluate-commands %{ try %{ edit %{" tagroot $2 "}; execute-keys %{/\\Q" keys "vc} } catch %{ echo %{unable to find tag} } } }" } - /[^\t]+\t[^\t]+\t[0-9]+/ { out = out " %{" $2 ":" $3 "} %{evaluate-commands -collapse-jumps %{ edit %{" tagroot $2 "} %{" $3 "}}}" } + /[^\t]+\t[^\t]+\t[0-9]+/ { out = out " %{" $2 ":" $3 "} %{evaluate-commands %{ edit %{" tagroot $2 "} %{" $3 "}}}" } END { print ( length(out) == 0 ? "echo -markup %{{Error}no such tag " ENVIRON["tagname"] "}" : "menu -markup -auto-single " out ) }' }} diff --git a/rc/core/grep.kak b/rc/core/grep.kak index 4048c93c..e0697d70 100644 --- a/rc/core/grep.kak +++ b/rc/core/grep.kak @@ -47,7 +47,7 @@ declare-option -docstring "name of the client in which all source code jumps wil str jumpclient define-command -hidden grep-jump %{ - evaluate-commands -collapse-jumps %{ + evaluate-commands %{ # use evaluate-commands to ensure jumps are collapsed try %{ execute-keys 's^((?:\w:)?[^:]+):(\d+):(\d+)?' set-option buffer grep_current_line %val{cursor_line} @@ -58,7 +58,7 @@ define-command -hidden grep-jump %{ } define-command grep-next-match -docstring 'Jump to the next grep match' %{ - evaluate-commands -collapse-jumps -try-client %opt{jumpclient} %{ + evaluate-commands -try-client %opt{jumpclient} %{ buffer '*grep*' # First jump to enf of buffer so that if grep_current_line == 0 # 0g will be a no-op and we'll jump to the first result. @@ -70,7 +70,7 @@ define-command grep-next-match -docstring 'Jump to the next grep match' %{ } define-command grep-previous-match -docstring 'Jump to the previous grep match' %{ - evaluate-commands -collapse-jumps -try-client %opt{jumpclient} %{ + evaluate-commands -try-client %opt{jumpclient} %{ buffer '*grep*' # See comment in grep-next-match execute-keys "ge %opt{grep_current_line}g ^[^:]+:\d+:" diff --git a/rc/core/make.kak b/rc/core/make.kak index 490adb63..3bb66c16 100644 --- a/rc/core/make.kak +++ b/rc/core/make.kak @@ -55,7 +55,7 @@ define-command -hidden make-open-error -params 4 %{ } define-command -hidden make-jump %{ - evaluate-commands -collapse-jumps %{ + evaluate-commands %{ try %{ execute-keys gl "Entering directory" # Try to parse the error into capture groups, failing on absolute paths @@ -71,7 +71,7 @@ define-command -hidden make-jump %{ } define-command make-next-error -docstring 'Jump to the next make error' %{ - evaluate-commands -collapse-jumps -try-client %opt{jumpclient} %{ + evaluate-commands -try-client %opt{jumpclient} %{ buffer '*make*' execute-keys "%opt{make_current_error_line}ggl" "/^(?:\w:)?[^:\n]+:\d+:(?:\d+:)?%opt{make_error_pattern}" make-jump @@ -80,7 +80,7 @@ define-command make-next-error -docstring 'Jump to the next make error' %{ } define-command make-previous-error -docstring 'Jump to the previous make error' %{ - evaluate-commands -collapse-jumps -try-client %opt{jumpclient} %{ + evaluate-commands -try-client %opt{jumpclient} %{ buffer '*make*' execute-keys "%opt{make_current_error_line}g" "^(?:\w:)?[^:\n]+:\d+:(?:\d+:)?%opt{make_error_pattern}" make-jump diff --git a/rc/core/man.kak b/rc/core/man.kak index 7deba1f1..9925098e 100644 --- a/rc/core/man.kak +++ b/rc/core/man.kak @@ -69,5 +69,5 @@ The page can be a word, or a word directly followed by a section number between ;; esac - printf %s\\n "evaluate-commands -collapse-jumps -try-client %opt{docsclient} man-impl *man* $pagenum $subject" + printf %s\\n "evaluate-commands -try-client %opt{docsclient} man-impl *man* $pagenum $subject" } } diff --git a/src/commands.cc b/src/commands.cc index 66696202..a0b75ef2 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1522,8 +1522,7 @@ const ParameterDesc context_wrap_params = { { "no-hooks", { false, "disable hooks" } }, { "with-maps", { false, "use user defined key mapping when executing keys" } }, { "itersel", { false, "run once for each selection with that selection as the only one" } }, - { "save-regs", { true, "restore all given registers after execution (defaults to '/\"|^@')" } }, - { "collapse-jumps", { false, "collapse all jumps into a single one from initial selection" } } }, + { "save-regs", { true, "restore all given registers after execution (defaults to '/\"|^@')" } } }, ParameterDesc::Flags::SwitchesOnlyAtStart, 1 }; @@ -1675,17 +1674,17 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func) } else { - Optional original_jump_list; - if (not draft and (bool)parser.get_switch("collapse-jumps")) - original_jump_list = c.jump_list(); + auto original_jump_list = draft ? Optional{} : c.jump_list(); + auto jump = draft ? Optional{} : c.selections(); - SelectionList jump = c.selections(); func(parser, c); - if (original_jump_list and c.jump_list() != *original_jump_list) + // If the jump list got mutated, collapse all jumps into a single one from original selections + if (not draft and c.jump_list() != *original_jump_list) { - c.jump_list() = std::move(*original_jump_list); - c.jump_list().push(std::move(jump)); + original_jump_list->push(std::move(*jump)); + if (c.jump_list() != *original_jump_list) + c.jump_list() = std::move(*original_jump_list); } } }