[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#31727: 25.3; format-spec clobbers match data
From: |
Noam Postavsky |
Subject: |
bug#31727: 25.3; format-spec clobbers match data |
Date: |
Tue, 5 Jun 2018 13:39:34 -0400 |
On 5 June 2018 at 13:30, Ryan Thompson <rct@thompsonclan.org> wrote:
>
> The following code throws an error:
>
> (progn
> (string-match "h.*o" "hello")
> (format-spec "This sets the %s" (format-spec-make ?s "match data"))
> (match-string 0 "hello"))
>
> This is because the implementation of "format-spec" uses regular
> expressions internally, and does not save the match data and restore it
> afterward.
(elisp) Match Data:
Notice that all functions are allowed to overwrite the match data
unless they’re explicitly documented not to do so.