kjones@talos.uu.net (Kyle Jones) (02/01/90)
[ How this question ended up in gnu.emacs.gnus, I don't know. Followups are redirected to comp.emacs. ] Ronald Beekelaar writes: > I have written a functies that does a lot of (replace-string's ..). > But now I want to put my own message in the message area, instead of > "Mark set". So I will [k]now what it is doing. > > Is it possible to call (replace-string...) or something similar, so > that it won't put the message "Mark set" in the message area? replace-string is really not meant to be used in Lisp programs. It has too many side effects like pushing the mark, and generating messages. WHen you find yourself wanting to used replace-string inside another function, use the following equivalent calls to search-forward and replace-match, (while (search-forward "some string" nil t) (replace-match "replacement string" (not case-replace) t)) A similar idiom for replace-regexp is, (while (re-search-forward "some regexp" nil t) (replace-match "replacement pattern" (not case-replace) nil)) You will find it enlightening to read the documentation for the relevant functions (search-forward, re-search-forward) and variables (case-replace) used above. As for displaying status, jsut bracket the above code with calls to `message', like (message "Replacing \"some string\" with \"replacement string\"...") (while (search-forward "some string" nil t) (replace-match "replacement string" (not case-replace) t)) (message "Replacing \"some string\" with \"replacement string\"... done")