unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: jakanakaevangeli@chiru.no, emacs-devel@gnu.org
Subject: Re: master fb4f2aa038: * lisp/textmodes/paragraphs.el (repunctuate-sentences-filter): New function.
Date: Wed, 05 Jan 2022 20:47:51 +0200	[thread overview]
Message-ID: <86sfu2aujs.fsf@mail.linkov.net> (raw)
In-Reply-To: <jwvzgobb5dh.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Tue, 04 Jan 2022 15:44:23 -0500")

>>    (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	other threads:[~2022-01-05 18:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-04 17:21 master fb4f2aa038: * lisp/textmodes/paragraphs.el (repunctuate-sentences-filter): New function jakanakaevangeli
2022-01-04 18:03 ` Juri Linkov
2022-01-04 20:44   ` Stefan Monnier
2022-01-05 18:47     ` Juri Linkov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86sfu2aujs.fsf@mail.linkov.net \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    --cc=jakanakaevangeli@chiru.no \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).