jmorag / kakoune.el

A very simple simulation of the kakoune editor inside of emacs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Saving & Restoring Selections

geier1993 opened this issue · comments

Is it possible to save and restore selections — the behaviour is implemented in kakoune using z and Z.
Moreover on inserting text, all selection reduce to the cursor while in kakoune the selections maintain. That means in kakoune I can have multiple selections, edit some text, do something else with the selections and so on....

I'm no experienced emacs user, that's why I am asking charily.

I'm not sure what you mean precisely about the behavior in emacs when inserting with multiple selections. Do they overlap?

About saving and restoring, it's almost certainly possible, but nontrivial to implement, at least with my elisp ability. I can try working on it over the weekend, but no promises. If you'd like to try your hand at it, I'd of course welcome the pull request. Looking over the existing functions in the multiple-cursors is a good start.

Re: collapsing/maintaining selections.

Expected Behaviour

In Kakoune, say I've selected "assets/images/hello.png", it will look like {assets/images/hello.png}, where '{' is the "mark" (in emacs terminology), '}' is where my cursor is, and the text between them is the selected region.

If I press 'i' for insert, then "assets/images/hello.png" will still remain selected. When I enter the text "![image with text 'hello'](" and then exit to normal mode, "assets/images/hello.png" will still be selected. The selection will look like so ![image with text 'hello']({assets/images/hello.png} ('{' is mark, '}' is cursor, and region is between them).

I can now press 'a' to append text after my selection -- i.e., after ...png} ( '}' is cursor) --, and enter ")" to close the markdown image markup. That will give me the result ![image with text 'hello']({assets/images/hello.png)}, where '{' is again the mark, and '}' is the cursor -- notice how the cursor is always after the inserted text, so when you append text, the selection expands to the last entered character.

Actual Behaviour

However, in kakoune.el, if I do the insert operation and start typing, the region is collapsed to just the cursor -- the selection looks like ![image with text 'hello']({a}ssets/images/hello.png (only a is selected).

Similarly, when I downcase or upcase some text, the region is collapsed to the cursor (the mark is again taken back to the cursor position). If I want to operate further on the text, then I have to select it again.

Comments and Thanks

Perhaps this should be a separate issue :p

I'd also like to say: as an intermediate Kakoune user, I really appreciate the work you've done! Getting this plugin working and moving around my buffer with Kakoune keys had me (weirdly) very delighted. In that vein, I'm more than alright with what's been implemented and I won't be trying to figure this out yet, since I'm just starting out, nor am I making a feature request of you. I simply wanted to clarify the remark. However, I'll hack at it when I feel comfortable with Emacs and Elisp and try to add it to kakoune.el.