[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:02:25 +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...)
--
underground experts united
https://dataswamp.org/~incal
- replace-regexp, Emanuel Berg, 2021/05/06
- Re: replace-regexp, Tassilo Horn, 2021/05/07
- Re: replace-regexp, Emanuel Berg, 2021/05/07
- Re: replace-regexp,
Emanuel Berg <=
- Re: replace-regexp, Emanuel Berg, 2021/05/07
- Re: replace-regexp, Yuri Khan, 2021/05/08
- Re: replace-regexp, Stefan Monnier, 2021/05/08
- Re: replace-regexp, Emanuel Berg, 2021/05/08
- Re: replace-regexp, Stefan Monnier, 2021/05/08
- Re: replace-regexp, Emanuel Berg, 2021/05/08
- Re: replace-regexp, Tassilo Horn, 2021/05/08
- Re: replace-regexp, Emanuel Berg, 2021/05/08
- RE: [External] : Re: replace-regexp, Drew Adams, 2021/05/08
- Re: replace-regexp, Emanuel Berg, 2021/05/08