saikyun / freja

Self-modifiable editor for coding graphical things
66 stars 2 forks source link

Evaluate expression #50

Closed sogaiu closed 2 years ago

sogaiu commented 2 years ago

The following is an edited transcript of a discussion about an "evaluate expression" feature.


sogaiu:

When trying to implement editor-related functionality, I'd like to be able to invoke functions when the caret is in specific places in the text editor. ATM what I do is to use global-set-key to bind a key sequence to the function I want to test.

Do you have a nicer way to do this sort of thing?

Having to rebind the key repeatedly to be a bit problematic because somehow it doesn't always seem to work, having to keep editing the (dh/global-set-key... form repeatedly gets old pretty quickly, but possibly most important is that one is limited to testing functions that can be bound to keys (those that take a single gap buffer as an argument?).

saikyun:

That should be pretty easy. I think it may be doable if one copies the way it's done for "search" but instead of searching you eval.

Probably need to add some more things, but I think almost everything needed is in that file. You also need to set your own hotkey table / struct.

Here you see how it is initalized with the bindings coming from a different file -- one could try just putting a table there instead since it uses the global keys as prototype.