unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Ricardo Wurmus <rekado@elephly.net>
Cc: 36772@debbugs.gnu.org, Robert Vollmert <rob@vllmrt.net>
Subject: bug#36772: feature request: checked variant of "substitute*"
Date: Thu, 25 Jul 2019 19:40:48 +0200	[thread overview]
Message-ID: <875znqrp0f.fsf@gnu.org> (raw)
In-Reply-To: <87zhl4c1rc.fsf@elephly.net> (Ricardo Wurmus's message of "Tue, 23 Jul 2019 15:35:19 +0200")

Hi,

Ricardo Wurmus <rekado@elephly.net> skribis:

>> I think it would be great to have the following variant of substitute*:
>>
>> (substitute*-once filename (pattern vars) body)
>>
>> which acts like the usual substitute-*, except it also asserts that the
>> substitution applies to exactly one line in the file, causing a build
>> failure otherwise.
>
> I agree that the effect of substitute* should be checked.  I think
> substitute* should fail when one of its clauses failed to match
> anything.
>
> Each clause could also accept an optional argument to make them only
> match one location.  We wouldn’t have to duplicate the macro for that
> and it’s a simple extension to failing on zero matches.
>
> What do you think?

That’d be a useful extension.

Ludo’.

      parent reply	other threads:[~2019-07-25 17:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-23 12:49 bug#36772: feature request: checked variant of "substitute*" Robert Vollmert
2019-07-23 13:35 ` Ricardo Wurmus
2019-07-23 13:41   ` Robert Vollmert
2019-07-25 17:40   ` Ludovic Courtès [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://guix.gnu.org/

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

  git send-email \
    --in-reply-to=875znqrp0f.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=36772@debbugs.gnu.org \
    --cc=rekado@elephly.net \
    --cc=rob@vllmrt.net \
    /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/guix.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).