help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

replace-regexp


From: Emanuel Berg
Subject: replace-regexp
Date: Fri, 07 May 2021 01:06:22 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

I was using `replace-regexp' and it worked fine but then
I byte-compiled and it told me something that was in the help
as well, namely

  This function is for interactive use only; in Lisp code use
  `re-search-forward' and `replace-match' instead.

so I wrote this and it does the job but reports the error
"while: Invalid search bound (wrong side of point)"

(defun md-latex (beg end)
  (interactive "r")
  (save-excursion
    (goto-char beg)
    (while (re-search-forward "_\\(.*\\)_" end t)
      (replace-match  "\\\\textit{\\1}") )))

Also this "interactive use only", in general, what's the deal
with that?

If it is just a matter of re-writing it the way I did (only
without the error) I don't see why that cannot be dealt with
so the user can just call the/a function with a simple
interface, be it interactively or in Lisp...

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]