Unable to filter and keep selection

@Screwtapello that issue with the newlines and spaces is one problem I can see

a linebreak, space, or anything that resembles it stops Alt-k altogether

Granted that you were to select with C or a-C then W accordingly,

If the line below is the same length or longer, this is fine and sensible. However, if the line below is shorter , it might not be long enough to have a copy of the selection.

Now we’re talking !

okay

 esto]
 es]
 una]
 prueba]
 ]

in that case, started with Alt+C and J added a space which is more than enough for Alt k not to pick anything

the whole purpose is to have Alt k and select a whole line, so s is not practical

but you’re referring to Kakoune now as a third-person object. Kakoune doesn’t know any better.

I mean, the Kakoune documentation and source-code use the word “selection” quite consistently that way. In the context of Kakoune and understanding how it works, “selection” has a very specific, technical meaning: a span of adjacent characters.

as a matter of fact, even C or a-C don’t do anything when there are newlines or whitespaces either.

C creates a new selection one line below each existing selection, covering the same columns. If the line below is the same length or longer, this is fine and sensible. However, if the line below is shorter, it might not be long enough to have a copy of the selection. Previously, Kakoune would do nothing if you pressed C and the following line was too short, but these days it skips over too-short lines and adds the selection to the next line that’s long enough.

I still don’t really understand what you’re trying to do. Perhaps you could try describing it in the tradition bug-report format? You know:

  • What I tried:
    • started Kakoune with kak -n
    • typed these keys…
  • What I expected:
  • What actually happened:

For clarity, it’s probably best to follow @andreyorst’s example and use [] to show which parts of the text are selected in your examples, or just post screenshots.

@Screwtapello I still see the problem with whatever space J adds, and not whether there’s a newline really.

@Screwtapello thank you for the clarification about the jedi/clang/etc scripts.

Does this following snippet work for you? On my kak it only prints NL.

hook window InsertIdle .* %{
    try %{
        execute-keys -draft <space>b_
        echo %val{selection}
    }
}

Ah, yeah. By the time echo runs, execute-keys -draft has already created, modified, and destroyed the draft context. How about something like:

hook window InsertIdle .* %{
    try %{
        evaluate-commands -draft %{
            execute-keys <space>b_
            echo -debug %val{selection}
        }
    }
}

Now the execute-keys and echo are both in the same draft context. Also, note that I’ve used echo -debug rather than echo - as well as having its own set of selections, the draft context has its own status line, so the result of a bare echo will be thrown away with the rest of the draft context once the block ends. echo -debug sends the text to the *debug* buffer, which is independent of any context, so you can come back and check it later.

1 Like