drym-org / symex.el

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

enhancement: Use keybinding signals? #65

Open devcarbon-com opened 1 year ago

devcarbon-com commented 1 year ago

@countvajhula I decided to go ahead and add this as a draft issue, since that way it can be discussed as we go along instead of waiting till I have the time to formulate something more cohesive. I included a bit here from our previous discussion.

I really like corkey's idea of signals, which decouple conceptual operations (e.g. "eval current form") from concrete and mode-specific implementations.

There is a lightweight (57 sloc) package around this idea here: https://github.com/lilactown/kitten/blob/main/lisp/reflex.el

that let's you write code like this:

binding keys to signals: https://github.com/lilactown/kitten/blob/main/user/keybinds.el#L91-L112

providing functionality to the signals for a given mode: https://github.com/lilactown/kitten/blob/main/modules/kitten-clojure.el#L40-L57

With regard to signals, I feel like the biggest application would be in your "mode-mode" (I forget what that was called at the moment).

When it comes to Symex, it could be utilized here as well I reckon, although I will need to spend some more time looking at what and how.

Off the top of my head, though, it would probably simplify the dispatch for things like symex-eval. Also, it would allow for symex to have all the triggers/signals ready for other package features, but let that decision live in the end-users config, instead of being a hard requirement.

For undo tree, for example, let's pretend you wanted to add a key in your hydra for undo-tree-visualize, you could bind to the signal. Then the end user could have in their config:

(reflex/provide-signals
  global-map
  (:editor/visualize-undo-tree undo-tree-visualize)

But then say there are users that prefer vundo. All they need to do is swap out the signal binding in their own config:

(reflex/provide-signals
  global-map
  (:editor/visualize-undo-tree vundo)