[emacs-berlin] How to search and select some text?

jman emacs-berlin at city17.xyz
Thu Jan 19 13:59:50 UTC 2023


Hello,

I'm writing an eLisp function to automate a list of actions in a region.

I've tried scripting a macro but the eLisp code in output is ... a bit
opaque, so for maintainability purposes I'd like to invoke a list of
functions one after the other.

My eLisp function should:
1. `regexp-replace` some text
2. find a specific string, select the first match
3. run `mc/mark-all-like-this`

I was able to do step 1. I was also able to find a good suggestion to start
for step 2, see this link[0] but that only works interactively: when I
invoke `my-search-function` from a function the matching text is not
selected.

I think I am missing some basic understanding of something (buffers?).
Can anyone explain me why the function suggested on stackexchange
selects the text when invoked with `M-x my-search-function` but not when
called from another function? I think I am naively expecting that any
function invoked as a command should work also when invoked as an "api",
since Emacs is basically a macro processor.

Thanks!

[0]: https://emacs.stackexchange.com/a/14313


More information about the emacs-berlin mailing list