From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alex =?utf-8?Q?Benn=C3=A9e?= Newsgroups: gmane.emacs.devel Subject: Re: org-capture: Capture template =?utf-8?B?4oCYZ+KAmTo=?= Match data clobbered by buffer modification hooks Date: Fri, 15 Jul 2016 20:12:21 +0100 Message-ID: <87bn1yyaui.fsf@linaro.org> References: <87vb066ejv.fsf@linaro.org> <8360s67qcp.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1468630530 31507 80.91.229.3 (16 Jul 2016 00:55:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 16 Jul 2016 00:55:30 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jul 16 02:55:26 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bODra-0007pf-E2 for ged-emacs-devel@m.gmane.org; Sat, 16 Jul 2016 02:53:50 +0200 Original-Received: from localhost ([::1]:34586 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bO8by-00031V-0u for ged-emacs-devel@m.gmane.org; Fri, 15 Jul 2016 15:17:22 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bO8XC-0005k1-4Y for emacs-devel@gnu.org; Fri, 15 Jul 2016 15:12:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bO8X6-0006fa-V7 for emacs-devel@gnu.org; Fri, 15 Jul 2016 15:12:25 -0400 Original-Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:35978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bO8X6-0006fQ-PF for emacs-devel@gnu.org; Fri, 15 Jul 2016 15:12:20 -0400 Original-Received: by mail-wm0-x234.google.com with SMTP id f126so36812068wma.1 for ; Fri, 15 Jul 2016 12:12:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version:content-transfer-encoding; bh=+1NscsJVSahPaSaUxdaqo03oLFpaS8RwkDMJ5EhRv0k=; b=KDGLxpgTtiAziU6JggakZlv/oP4IAxkPW+m9tL+eUFjDKC8Q6CO8AAgUEXM3sb2SVy d3VDPWqDWhc3f8qkxJxU+UEFXbUGnoFNHgeMHoy6bMxyhJJiNJm9JLylZem05zNPuG/8 ZnGeR8iupriOnYkZhV1IdEEvaxPHr5bX8EppE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version:content-transfer-encoding; bh=+1NscsJVSahPaSaUxdaqo03oLFpaS8RwkDMJ5EhRv0k=; b=bn5FeFYhIsazuUERIUWnpAg7nVHYZGImRDIGTBxUxkfjBgool7tyJcKnQejk7E0Ig2 juI+KL7n08Vg/3I1J8j9C1oobl2kdK1djNJUUOPCHk8MMj2RrEoqHJXccRFrwlgxdM0+ LdAQcLOFKAgGkeb9vPX0D4oh4EoxurVnbqqTdEZO8cNXOb1WVXuJKlwCHp2vcTMj0i0U ERHoJLyspJLkgBVrxR3Rw11JFxXsEUUr9kQ+g5RJqOiengC4ks2El/4sFVGVZuv60fmq JE/MV9fGcpSTiOhr4+LaTuGFQdRWwbhzGeEEAgh2W5hJ4p13FxEfVvyw/dYn3ARZudOM JWqg== X-Gm-Message-State: ALyK8tLZRWNQljcw5NZHTkjgTk59GlTGJDHklyQ5LVztSw8Cp7MmkZtfpepEOQ84JKaMDSOI X-Received: by 10.28.63.214 with SMTP id m205mr23221483wma.72.1468609939969; Fri, 15 Jul 2016 12:12:19 -0700 (PDT) Original-Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id kk3sm2128769wjc.6.2016.07.15.12.12.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jul 2016 12:12:18 -0700 (PDT) Original-Received: from zen (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTPS id C6A003E01B2; Fri, 15 Jul 2016 20:12:21 +0100 (BST) User-agent: mu4e 0.9.17; emacs 25.0.95.10 In-reply-to: <8360s67qcp.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::234 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:205744 Archived-At: Eli Zaretskii writes: >> From: Alex Bennée >> Cc: Eli Zaretskii >> Date: Fri, 15 Jul 2016 17:39:48 +0100 >> >> This seems to have been introduced by commit: >> >> 3a9d6296b35e5317c497674d5725eb52699bd3b8 >> Author: Eli Zaretskii >> >> Avoid crashes when buffer modification hooks clobber match data >> >> * src/search.c (Freplace_match): Error out if buffer modification >> hooks triggered by buffer changes in replace_range, upcase-region, >> and upcase-initials-region clobber the match data needed to be >> adjusted for the replacement. (Bug#23869) >> >> 1 file changed, 13 insertions(+) >> src/search.c | 13 +++++++++++++ >> >> I have a org-capture template set up that's triggered by a helper >> function: >> >> (defun my-capture-review-tags () >> "Return a list of DCO style tags for current buffer." >> (let ((tags)) >> (save-excursion >> (goto-char (point-min)) >> (while (re-search-forward my-dco-tag-re (point-max) t) >> (add-to-list 'tags (match-string-no-properties 0)))) >> tags)) >> >> (defun my-org-maybe-capture-review-tag () >> "Check buffer for DCO tags and if found queue a review comment." >> (interactive) >> (let ((tags (my-capture-review-tags))) >> (when tags >> (kill-new (mapconcat 'identity tags "\n")) >> (org-capture nil "g")))) >> >> And the following template: >> >> ("g" "Save reference to review tag" >> entry >> (file+headline "review.org" "Review Tags") >> "** %a\n%c" :immediate-finish t) >> >> But I'm not sure what's going on. > > You need to use save-match-data. Wrapping the org-capture with save-match-data or even just clearing it: (defun my-org-maybe-capture-review-tag () "Check buffer for DCO tags and if found queue a review comment." (interactive) (let ((tags (my-capture-review-tags))) (when tags (kill-new (mapconcat 'identity tags "\n")) (set-match-data nil) (org-capture nil "g")))) Had no effect. I'm guessing this must be something happening in org-mode then.... -- Alex Bennée