emacs-devel
[Top][All Lists]
Advanced

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

Re: master fb4f2aa038: * lisp/textmodes/paragraphs.el (repunctuate-sente


From: Juri Linkov
Subject: Re: master fb4f2aa038: * lisp/textmodes/paragraphs.el (repunctuate-sentences-filter): New function.
Date: Wed, 05 Jan 2022 20:47:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu)

>>    (not (length= (match-string 4) 2)))
>
> Note that the default function (whose body is visible above) depends on
> the match data set by the caller, so `add-function` risks messing it up
> if it clobbers the match data with code that runs before this default.
>
> At the very least, we need a docstring that makes it very clear what
> match-data is expected to be set when the function is called and that
> explains how/when it should be preserved.
>
> Tho maybe a better approach is to change the calling convention so we
> don't need to depend this way on the match data set by the caller.

Another reason not to use the match data is not to depend on
group numbering in the regexp such as (match-string 4).
So I replaced it with:

  (/= 2 (- (point) (save-excursion (skip-chars-backward " ") (point))))

Then there is no need to add a warning to the docstring because
query-replace-regexp is permissive in regard to interfering user regexps.



reply via email to

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