I need to select text in Emacs with regexp. And it would be for the best if I had an option to match only if match is surrounding caret.
Example:
text.....
<start oftext I want to select> text.....
text....
text.... <caret> text....
text....
text.... <end of text I want to select>
some other text
Edit: I am sorry that I obviously didn’t state my question clearly, so here is a clarification:
- Caret was meant as the place where cursor is currently placed, not literal text to be matched
- Start and end of text to be selected is just all the text that is in the document without any empty line.
It’s not hard to find something around point in elisp. Just use two searches, forward and backward.
When you use primary selection to select something around, you can’t save the position of your current point(you named it caret). To save current position and have some selection, you can use secondary selection.