Breaking change "revert"

Single point of damage to my workflow was caused by X removal. Did anyone had success replicating old X with new behaviour?

1 Like
define-command select-or-extend-lines %{
  try %{
    # At least one selection is not full, so select whole lines.
    execute-keys -draft '<a-K>\A^.+\n\z<ret>'
    execute-keys 'x'
  } catch %{
    execute-keys 'J'
  }
}

map global normal 'X' ': select-or-extend-lines<ret>'
3 Likes

perfect, thanks

I was hoping -itersel could raise to simplify the condition.

execute-keys -draft -itersel '<a-x>'
1 Like

On latest release this doesn’t seem to work if you start X on an empty line. I didn’t try on previous ones.

wish i understood what the hell does that do, because not being able to X like before really ruins the flow.

help, anyone?

define-command select-or-extend-lines %{
  execute-keys '<a-:>'
  try %{
    # At least one selection is not full, so select whole lines.
    execute-keys -draft '<a-K>\A^.*\n\z<ret>'
    execute-keys 'x'
  } catch %{
    execute-keys 'Jx'
  }
}

map global normal x ': select-or-extend-lines<ret>'
map global normal X 'x<a-:><a-;>'
1 Like

This works worse then the previous version.

I think I now see that kakoune might have no introduced a proper hidden state making being on an empty line and having an empty line selected, so making x advance consistency might be impossible to fix.

The X extending selection is something I miss more.

Well … maybe I should just rebase my fork kakoune-dpc/README.md at master · dpc/kakoune-dpc · GitHub and that’s that.

try %{
    exec -draft '<a-S>s^<ret>'
    exec -draft '<a-S>s\n<ret>'
    exec Jk
} catch %{
    exec x
}

Seems a close match for old X. I kinda like the new X now that I’m used to it tho. Old X might have left the “tail” of the current selection in place tho, I don’t recall exactly how it worked.

alternative (almost, you probs want an echo '' after) one liner that keeps the tail intact

exec -save-regs caret 'Z;?\n<ret>x<a-z>u'

Has an edge case of selecting the newline but not the rest of the line actually, although you can test for that using the previous method.

This isn’t a solution to reverting X, but the change didn’t affect me because I had already switched to using something else:

map global insert J Jx
map global insert K Kx

This makes J and K always select whole lines. To get the previous X behavior, you just press J. It’s absolutely wonderful. I almost never want to select a partial line downwards, and if I do, I use word motions instead of line motions.

I hope this helps!