drym-org / symex.el

An intuitive way to edit Lisp symbolic expressions ("symexes") structurally in Emacs
Other
271 stars 22 forks source link

When exiting evil's visual state after a yank or delete, bindings don't work anymore #60

Open bigodel opened 1 year ago

bigodel commented 1 year ago

This happens with a minimal config of

(symex-initialize)
(symex-mode)
(symex-mode-interface)

Steps to reproduce

  1. Evaluate that in a buffer;
  2. Go into Evil's visual state using either v or V;
  3. Yank with y or delete with d or x;
  4. It goes back to SYMEX state but none of the commands work anymore, it works just like NORMAL.

In order to make it go back I need to move into another state such as INSERT or EMACS and get back to SYMEX with symex-mode-interface.

countvajhula commented 1 year ago

Thanks for reporting the issue! Yes, visual mode isn't well-supported at the moment and there are plans to add support for it in the future, which is tracked in #53 . I'm going to close this issue as a duplicate, but I'm keen to hear your thoughts if you feel that the other issue doesn't cover your use case, and if that's the case, feel free to either post a comment there, or reopen this issue.

bigodel commented 1 year ago

Thanks for reporting the issue! Yes, visual mode isn't well-supported at the moment and there are plans to add support for it in the future, which is tracked in #53 . I'm going to close this issue as a duplicate, but I'm keen to hear your thoughts if you feel that the other issue doesn't cover your use case, and if that's the case, feel free to either post a comment there, or reopen this issue.

thank you for responding! i'm aware of #53, but even though it covers my issue, since it deals with visual state as a whole, i think this could be solved beforehand, since it is basically stopping me from trying to use Symex as my goto tool for structural lisp editing. that's because even though regions/visual state isn't entirely supported as it is in e.g. Lispy, my issue is that i cannot ever go into VISUAL state because it breaks Symex's bindings, and i'd need to go into INSERT and back to have Symex working correctly again. i'm not really sure what's causing it, and i tried poking around a little bit but with no success.

countvajhula commented 1 year ago

That's a fair point, and it could be reasonable to try falling back to Normal visual state instead of Symex visual state until we have that. For the moment, the workaround I use is to first escape to Normal state before entering visual state, so that you don't enter visual state directly from Symex state.

We could try mapping v, V and C-v in the symex evil keymap to functions that first enter Normal state and then enter the appropriate visual state (i.e. evil-visual-char, evil-visual-line, evil-visual-block), i.e. programmatically implementing the above workaround. But a first attempt at this didn't work, so it may not be this simple. Even if this did work, it would presumably not restore Symex state after the yank/delete but Normal state instead. I'm not sure if there would be a clean way to restore Symex state after the yank/delete here -- might require some hacks like manually setting evil-previous-state or something like that. Though, I'd hesitate to spend too much time on this if it ends up looking too hacky since we do have a proper solution planned in #53 .

Any other ideas?

bigodel commented 1 year ago

That's a fair point, and it could be reasonable to try falling back to Normal visual state instead of Symex visual state until we have that. For the moment, the workaround I use is to first escape to Normal state before entering visual state, so that you don't enter visual state directly from Symex state.

can you share that snippet?

We could try mapping v, V and C-v in the symex evil keymap to functions that first enter Normal state and then enter the appropriate visual state (i.e. evil-visual-char, evil-visual-line, evil-visual-block), i.e. programmatically implementing the above workaround. But a first attempt at this didn't work, so it may not be this simple. Even if this did work, it would presumably not restore Symex state after the yank/delete but Normal state instead. I'm not sure if there would be a clean way to restore Symex state after the yank/delete here -- might require some hacks like manually setting evil-previous-state or something like that. Though, I'd hesitate to spend too much time on this if it ends up looking too hacky since we do have a proper solution planned in #53 .

well, since that's the case i'm happy to wait for the overall region design to be complete.

countvajhula commented 1 year ago

can you share that snippet?

I meant that I don't enter visual state (e.g. via v or V) while in symex state - instead, I go to normal state first (e.g. via Esc if you're using the default bindings), and then hit v/V.

Could you explain a bit more your use case for using visual state?

bigodel commented 1 year ago

I meant that I don't enter visual state (e.g. via v or V) while in symex state - instead, I go to normal state first (e.g. via Esc if you're using the default bindings), and then hit v/V.

ah, got it.

Could you explain a bit more your use case for using visual state?

yeah, sure! i use it to copy some things most of the time, but also delete a whole bunch of lines as well, the usual. the most common usage i have is to go to a delimiter of a symex, hit v and % to encompass all of the symex in a region and copy it to paste in another buffer (or, alternatively, use the m special key for Lispy). of course, none of what i use visual state for couldn't be done without it, but i have it too much engraved into my muscle memory to just hit v/V and start selecting things.

countvajhula commented 1 year ago

yeah, sure! i use it to copy some things most of the time, but also delete a whole bunch of lines as well, the usual. the most common usage i have is to go to a delimiter of a symex, hit v and % to encompass all of the symex in a region and copy it to paste in another buffer (or, alternatively, use the m special key for Lispy). of course, none of what i use visual state for couldn't be done without it, but i have it too much engraved into my muscle memory to just hit v/V and start selecting things.

Yeah all that makes sense, thanks for sharing 🙂