From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Monnier Subject: =?UTF-8?B?YnVnIzIzOTE3OiBQbGVhc2UgY29uc2lkZXIgbWFraW5nIEJ1ZyAj?= =?UTF-8?B?MjM5MTcgYSBibG9ja2VyIGZvciAyNS4xICh3YXMgUmU6IG9yZy1jYXB0dXJl?= =?UTF-8?B?OiBDYXB0dXJlIHRlbXBsYXRlIOKAmGfigJk6IE1hdGNoIGRhdGEgY2xvYmJl?= =?UTF-8?B?cmVkIGJ5IGJ1ZmZlciBtb2RpZmljYXRpb24gaG9va3Mp?= Date: Tue, 19 Jul 2016 12:03:51 -0400 Message-ID: References: <87vb066ejv.fsf@linaro.org> <8360s67qcp.fsf@gnu.org> <87bn1yyaui.fsf@linaro.org> <87mvlhmv0x.fsf_-_@moondust.awandering> <837fcl5zs9.fsf@gnu.org> <87a8hgkwcb.fsf@linaro.org> <8360s42mcb.fsf@gnu.org> <87eg6rgmlg.fsf@gmail.com> <83lh0y24y6.fsf@gnu.org> <83eg6q1hbo.fsf@gnu.org> <83a8hd1vzi.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPXW6-00088P-8d for emacs-orgmode@gnu.org; Tue, 19 Jul 2016 12:05:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPXW2-0005Ip-Mc for emacs-orgmode@gnu.org; Tue, 19 Jul 2016 12:05:06 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <83a8hd1vzi.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 19 Jul 2016 18:35:45 +0300") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Eli Zaretskii Cc: 23917@debbugs.gnu.org, rpluim@gmail.com, jwiegley@gmail.com, alex.bennee@linaro.org, nljlistbox2@gmail.com > Before call to replace_range in replace-match: > > |---------------------------|---|------|----| > s1 e1 s2 e2 EOB > > (s1, e1, etc. are the start and end of the corresponding > sub-expressions.) > > After the call to replace_range in replace-match: > > |---------|---|------|----| > s1 e1 s2 e2 EOB Ah, right, now I see my confusion, thank you. So, the data is within bounds before replace_range but after bounds afterwards and the subsequent adjustments should fix it, but an intervening save-match-data will mess it up. Hmm... indeed, the adjustment isn't working correctly in this case. I don't think we can safely change the way save-match-data works, so I guess the next best thing is: - copy search_regs.start and search_regs.end before calling replace_range. - use that copy when adjusting the match data. Or equivalently, use save-match-data. IOW go back to your original patch. Duh! Stefan