drym-org / symex.el

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

Evil repeat #46

Closed j-shilling closed 2 years ago

j-shilling commented 2 years ago

Summary of Changes

Integrates symex-evil.el with evil-repeat.el by advising key evil-repeat related functions. Mainly, this sets up behavior to:

  1. Start and stop repeatition recording in pre- and post-command-hook2.
  2. Sets the :repeat property for a bunch of symex commands to t.
  3. Ensures that symex state is preserved after completing a repitition.

Public Domain Dedication

(Why: The freely released, copyright-free work in this repository represents an investment in a better way of doing things called attribution-based economics. Attribution-based economics is based on the simple idea that we gain more by giving more, not by holding on to things that, truly, we could only create because we, in our turn, received from others. As it turns out, an economic system based on attribution -- where those who give more are more empowered -- is significantly more efficient than capitalism while also being stable and fair (unlike capitalism, on both counts), giving it transformative power to elevate the human condition and address the problems that face us today along with a host of others that have been intractable since the beginning. You can help make this a reality by releasing your work in the same way -- freely into the public domain in the simple hope of providing value. Learn more about attribution-based economics at drym.org, tell your friends, do your part.)

countvajhula commented 2 years ago

This is huge @j-shilling , probably the #1 feature missing from Symex. Thank you for being a hero and taking this on! I will take a closer look at this soon 🤸 💃

countvajhula commented 2 years ago

Initial impressions: I tried swallow and shift-right and they both work! Exciting. However, it looks like motions (e.g. symex-go-forward, symex-go-backward) are also treated as repeatable commands, even though they aren't listed in symex--evil-repeatable-commands. As a result, in order to repeat them after moving, we need to do . followed by C-. until it pops the motion off the most recent and finds the swallow/shift command.

Are you seeing this as well?

j-shilling commented 2 years ago

Initial impressions: I tried swallow and shift-right and they both work! Exciting. However, it looks like motions (e.g. symex-go-forward, symex-go-backward) are also treated as repeatable commands, even though they aren't listed in symex--evil-repeatable-commands. As a result, in order to repeat them after moving, we need to do . followed by C-. until it pops the motion off the most recent and finds the swallow/shift command.

Are you seeing this as well?

Ah, yep, that was happening for me as well, but I've found the problem and it should have been resolved by 54ac804.

countvajhula commented 2 years ago

Nice work on those changes 👌

I noticed that if the command exits with an error, then it is left in Normal state instead of Symex state. E.g.:

|(a b c)
(a b c)

Hitting z (swallow) works the first time. Then hit . when the expression is |a b c and it will raise an error, and this leaves it in Normal state.

Wrapping this line with error handling would probably be sufficient here. Something like this:

(unwind-protect
    (apply orig-fun args)
  (when symex-state-p
    (evil-symex-state)))
countvajhula commented 2 years ago

@j-shilling This is looking great so far. I noticed that there are a few commands missing from symex--evil-repeatable-commands:

symex-change
symex-change-remaining
symex-change-delimiter
symex-open-line-after
symex-open-line-before
symex-collapse
symex-unfurl
symex-collapse-remaining
symex-unfurl-remaining
symex-tidy-remaining
symex-tidy-proper
symex-append-after
symex-insert-at-end
symex-insert-at-beginning
symex-insert-before
symex-wrap-and-append

I'll continue using it for a few more days to test it further.

j-shilling commented 2 years ago

@j-shilling This is looking great so far. I noticed that there are a few commands missing from symex--evil-repeatable-commands:

symex-change
symex-change-remaining
symex-change-delimiter
symex-open-line-after
symex-open-line-before
symex-collapse
symex-unfurl
symex-collapse-remaining
symex-unfurl-remaining
symex-tidy-remaining
symex-tidy-proper
symex-append-after
symex-insert-at-end
symex-insert-at-beginning
symex-insert-before
symex-wrap-and-append

I'll continue using it for a few more days to test it further.

This might actually take some more experimentation. I'm not super confident what will happen with commands that change states--but I'll fiddle around with it and see.

countvajhula commented 2 years ago

Thank you for your contribution @j-shilling . Much appreciated 🙏