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

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

Re: replace-regexp


From: Emanuel Berg
Subject: Re: replace-regexp
Date: Sat, 08 May 2021 02:16:19 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>>>> 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}") )))
>>>
>>> I think you didn't call your command interactively but
>>> through code like (md-latex 170 82) where the BEG was
>>> larger than END. When being called interactively the "r"
>>> spec makes sure that BEG is always the smaller one, no
>>> matter if point is before mark or the other way round.
>>
>> Nope, I called it with M-x. Tried again now, still the same
>> error. It works but I get the error.
>>
>> Maybe it has something to do with the replacement being
>> longer than the original string?
>
> That's it, I think, as this doesn't give me the error:
>
> (defun md-latex-reduce (beg end)
>   (interactive "r")
>   (save-excursion
>     (goto-char beg)
>     (while (re-search-forward "_\\(.*\\)_" end t)
>       (replace-match "\\1") )))
>
> (Now the function doesn't make any sense, so this is just to
> try my theory...)

I thought it might be a configuration issue but I've now tried
with 'emacs -Q' and I get the samme error. So either that's
not the correct way to put it or it is a bug.

GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.5, cairo version 1.16.0) of 2020-10-23

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




reply via email to

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