I'm trying to do some debugging on some Prolog code, and I have several calls to a method.
Is it possible to do a global replace within emacs so that I could create a write statement that would displace the current line in the program?
Essentially, assuming a method call X and a write statement write(some string), could I replace all the instances of
X,
with
X, write(LINE-NUMBER)
where LINE-NUMBER was obtained through some emacs call?
Please let me know if I'm not being clear and thanks in advance.
This page has a similar example.
From it, I tried the following command
M-x replace-regexp
Replace regexp: \(word_to_replace\)
Replace regexp with: \1, write(\,(line-number-at-pos)
The replace-regexp
can be heavy handed, so you must be careful with
the regex you use for the pattern. M-x query-replace-regexp
may
be useful too, if there are not too many matches.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With