Skip to content

Conversation

@silversquirl
Copy link
Contributor

Useful to allow bindings that work for any plugin that uses a jump buffer :)

try %{
evaluate-commands -client %opt{toolsclient} %{
buffer %arg{@}
buffer %opt{jump_current_buffer}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as written, this breaks users who override jump in buffer scope,
for example the kakoune-lsp plugin

creates some scratch buffers with
alias buffer jump "%val{hook_param_capture_1}-jump"

where the rhs can be one of

lsp-goto-jump
lsp-document-symbol-jump
lsp-diagnostics-jump

which are not aware of %opt{jump_current_buffer}

So it seems if we want this, we should set jump_current_buffer outside jump because that's intended to be overridden (as are jump-select-next and jump-select-previous).

Overall I'm not sure if this PR is worth it. It introduces extra implicit state.
Consider that other commands like :buffer have no memory either; but we do have generic command history which should cover some of your need.
I'm not against DWIM but it can be a lot of work to get right.

Does the jump-next -matching ... approach not work for the same use case?
We should definitely document that better.

@mawww
Copy link
Owner

mawww commented Dec 25, 2025

This use case is already catered for but I realize this is not really documented:

jump-next passes its arguments through to the buffer command, which means the -matching switch can be used. This means you can do jump-next -matching \*(grep|make)(-.*)\* and this will jump using the first buffer in the buffer list that matches the regex, with new buffers being added at the start. This means you can use the buffer list ordering (using arrange-buffers command) to control which buffer should be used for your jump command.

In other words, with the suggested previous command, the latest buffer that matches the regex will be used for jumping, so if you do a :grep then the new grep result buffer will be used, then if you do a :make it will jump using the make result buffer, then if you close the make result buffer the command will use the grep buffer again. And if you need to manually control which buffer should be used, the arrange-buffer command makes it possible to move existing buffer to the front of the buffer list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants