Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripting the editor / Macros support #338

Open
Curculigo opened this issue Sep 26, 2024 · 3 comments
Open

Scripting the editor / Macros support #338

Curculigo opened this issue Sep 26, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request needs design Some design decisions needs to be taken before implementing the feature

Comments

@Curculigo
Copy link

  1. Replace \n with ).
  2. Replace - with (.
  3. Replace \([^()]*\) with .

The input:

foo-1.0
bar-2.0

The output:

foo bar

I want to automate this boring task.

@SpartanJ SpartanJ self-assigned this Sep 26, 2024
@SpartanJ SpartanJ added the enhancement New feature or request label Sep 26, 2024
@SpartanJ SpartanJ changed the title Scripting the editor Scripting the editor / Macros Sep 26, 2024
@SpartanJ SpartanJ changed the title Scripting the editor / Macros Scripting the editor / Macros support Sep 26, 2024
@SpartanJ
Copy link
Owner

I'll implement some Lua bindings for eepp at some point where you'll be able to implement Lua scripts using eepp resources, but that's not going to happen soon (huge task).
This feature can be implemented in several ways, it's also commonly called as "macros" in editors. Some editors like Sublime Text and Notepad++ let you record your actions and generate a macro file with the actions recorded and you can then re-run them at any time. I'm not very fond of that feature, I've never used it because it can be much more limiting than just editing a script and also much more prone to errors. I think that scriptable macros are much more powerful and I would go that way for ecode.

@SpartanJ SpartanJ added the needs design Some design decisions needs to be taken before implementing the feature label Sep 26, 2024
@Curculigo
Copy link
Author

Scripting the whole eepp is too much. I don't want to write eepp applications in Lua (or other scripting languages). I only want to script ecode, and to be clear, only the find and replace feature. I think my regex is flawed. One could do the same thing with only one find and replace step instead of three like me. What I'm thinking now is I will write a sed script and have the build and run feature to invoke it to change the current opening file's content on the fly. Maybe easier than scripting ecode. After having to do this task more than a couple of times a day, I started to think about automating it.

@SpartanJ
Copy link
Owner

Yeah, I wasn't saying that for this particular feature I want to bind all eepp, I want to bind it for other stuff, what you need is much simpler and probably does not require even a macro.

For your particular example you can use regex captures and replace with those captured parts of the regex (you'll need to update eepp to test it, there was a small bug there with regex captures):

foo-1.0
bar-2.0

Find (for example, I don't know your real case): (\w+)-[\d\.]+\n?
Replace: $1

$1 is the number of capture to use as replacement, this will capture the first word (\w+) and use it in the replacement, so result will be: foo bar

This is very powerful, something that is pending since forever is saving the find history per-project, that could help for some situations where some searches are commonly repeated.
Regarding macros I'll think about a good design, I don't particularly care much about it so I have no rush for this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs design Some design decisions needs to be taken before implementing the feature
Projects
None yet
Development

No branches or pull requests

2 participants