reddit / emacs

Script to execute or translate evil search and replace commands?

vfclists 路 2022-08-02 19:08
Is there some script that can take the search and replace strings used by evil-search and replace and execute them? I want to get them from the `savehist` history and write some functions to execute them. Knowing the function that handles execution when `Enter` is pressed in the mini-buffer will help
JustinSilverman 路 2022-08-02 22:15
What do you mean execute? Do you mean repeat the search?
vfclists 路 2022-08-02 23:44
For instance this `馃挙 ` is a prepended by a Firefox addon to the URLs of browser tabs which it suspends. I can copy up to about 25 URLs of these sleeping tabs at a go and they all have this sequence that I need to delete. The evil style search and replace string for this is `<,>s/馃挙 //g` so what I want to do is take the string and pass it to a function which will run the search and replace. I know those strings are stored in some variable. Do you know what it us?
wasamasa 路 2022-08-04 07:42
I think it's called `sed`. It's a whole text editor that can do several editing operations in a row.
vfclists 路 2022-08-04 12:19
That involves running a shell or an external command. After pressing the "Enter" key there has to be a function that takes the string entered in the minibuffer and apply to the selected region or the file. It is that function I'm looking for
wasamasa 路 2022-08-04 15:00
evil is not designed to be used at the base for further scripting. It's a lot easier to write equivalent vanilla elisp code. Given the existence of `C-u M-|`, it's not unreasonable to use a shell command on a region.