In context, I'm some of the newcomers to emacs. I have not used it for very long, but used it more and more (I really like it). I am also comfortable with lisp, but not super familiar with elisp.
What I need to do is bind the regular expression to the key combination, because I often use this particular regular expression.
What I did:
MCs ^.*Table\(\(.*\n\)*?GO\)
Note. I used the new line above, but I found that for isearch-forward-regexp you really need to replace the \n in the regular expression with the result of Cq Qj . This inserts a literal new line (without completing the command), allowing me to put a new line in an expression and match strings.
How can I bind this to a key combination?
I vaguely understand that I need to create an elisp function that executes the isearch-forward-regexp expression with the expression, but I'm not clear on the details. I searched google and found most of the documentation a bit confusing.
How to associate a regex with a keyboard shortcut in emacs?
Mike Stone had the best answer - not exactly what I was looking for, but it worked for what I needed
Edit - this worked, but after saving the macro, when I returned to use it later, I could not use it with Cx e . (i.e. if I restart emacs and then type Mx macro-name and then Cx e , I get a message in the minibuffer like "no last kbd macro" or something like that)
@ Mike Stone - Thanks for the info. I tried to create a macro as follows:
Cx( MCs ^.*Table\(\(.*Cq CJ\)*?GO\) Cx)
This created my macro, but when I executed my macro, I did not get the same selection that I usually get when I use isearch-forward-regexp . Instead, he simply bounced to the end of the next match of expression. So it really does not work for what I need. Any ideas?
Edit: it looks like I can use macros to do what I want, I just need to think outside the isearch-forward-regexp box. I will try what you suggested.