From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kosorukoff Subject: Re: [PATCH] Fix: Capture abort: (error: The mark is not set now, so there is no region) Date: Thu, 8 May 2014 20:55:50 -0700 Message-ID: References: <877g681jma.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b33d3c010ae7804f8ef94f5 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wibuw-0001FY-9P for emacs-orgmode@gnu.org; Thu, 08 May 2014 23:56:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wibuu-0003df-Si for emacs-orgmode@gnu.org; Thu, 08 May 2014 23:56:14 -0400 Received: from mail-oa0-x232.google.com ([2607:f8b0:4003:c02::232]:49624) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wibuu-0003dP-MC for emacs-orgmode@gnu.org; Thu, 08 May 2014 23:56:12 -0400 Received: by mail-oa0-f50.google.com with SMTP id i7so4211379oag.37 for ; Thu, 08 May 2014 20:56:11 -0700 (PDT) In-Reply-To: <877g681jma.fsf@bzg.ath.cx> 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --047d7b33d3c010ae7804f8ef94f5 Content-Type: text/plain; charset=UTF-8 After I replaced my patch and merged Bastien's fix, I started seeing the error though less frequently than before. It didn't occur in the template I posted, but I started seeing it again in another template. ("w" "org-protocol tag" entry (file "~/org/bookmarks.org") "* %:description %(org-set-tags)\n %i\n\n %:link\n%?" :prepend t :empty-lines-after 1 :clock-in t :clock-resume t) I switched back to my initial patch that was checking if the mark was set before trying to access the region. This worked: the errors disappeared. However, I couldn't understand why mark would be unset in the first place. It turns out that this is a result of the function org-capture-steal-local-variables that is copying mark-active variable from another buffer. This results in an inconsistent state where mark is not set and yet the variable mark-active is set. Emacs functions region-active-p and use-region-p expect the state to be consistent and fail with this error that they won't produce under normal circumstances. Here is the minimal patch that fixes the root cause of this problem: >From 3d84403964dec1ac55810883e4e8a812c3ff94fc Mon Sep 17 00:00:00 2001 From: Alex Kosorukoff Date: Thu, 8 May 2014 20:27:59 -0700 Subject: [PATCH] org-capture: better fix for error "The mark is not set now, ..." --- lisp/org-capture.el | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index d57b9e0..3c62b1d 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1590,6 +1590,7 @@ The template may still contain \"%?\" for cursor positioning." (goto-char (point-min)) (org-capture-steal-local-variables buffer) (setq buffer-file-name nil) + (setq mark-active nil) ;; %[] Insert contents of a file. (goto-char (point-min)) -- 1.7.0.4 On Tue, Apr 29, 2014 at 4:05 AM, Bastien wrote: > Hi Alex, > > Alex Kosorukoff writes: > > > I noticed a regression in the capture functionality after upgrading > > org. Capture fails with error in subj > > fixed, thanks, > > -- > Bastien > --047d7b33d3c010ae7804f8ef94f5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
After I replaced my patch and merged Bastien's fix, I = started seeing the error though less frequently than before. It didn't = occur in the template I posted, but I started seeing it again in another te= mplate.

("w" "org-protocol tag" entry (file= "~/org/bookmarks.org")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"* %:desc= ription %(org-set-tags)\n =C2=A0%i\n\n =C2=A0%:link\n%?"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:prepend t :emp= ty-lines-after 1 :clock-in t :clock-resume t)

I switched back to my initial patch that was checking if the mark w= as set before trying to access the region. This worked: the errors disappea= red. However, I couldn't understand why mark would be unset in the firs= t place. It turns out that this is a result of the function org-capture-ste= al-local-variables that is copying mark-active variable from another buffer= . This results in an inconsistent state where mark is not set and yet the v= ariable mark-active is set. Emacs functions region-active-p and use-region-= p expect the state to be consistent and fail with this error that they won&= #39;t produce under normal circumstances. Here is the minimal patch that fi= xes the root cause of this problem:

From 3d84403964dec1ac55810883e4e8a812c= 3ff94fc Mon Sep 17 00:00:00 2001
From: Alex Kosorukoff <alex@3form.com>
Date: Thu, 8 M= ay 2014 20:27:59 -0700
Subject: [PATCH] org-capture: better fix for error "The mark is n= ot set now, ..."

---
=C2=A0lisp/org= -capture.el | =C2=A0 =C2=A01 +
=C2=A01 files changed, 1 insertion= s(+), 0 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el<= /div>
index d57b9e0..3c62b1d 100644
--- a/lisp/org-capture.el=
+++ b/lisp/org-capture.el
@@ -1590,6 +1590,7 @@ The te= mplate may still contain \"%?\" for cursor positioning."
=C2=A0 =C2=A0 =C2=A0 =C2=A0(goto-char (point-min))
=C2=A0 = =C2=A0 =C2=A0 =C2=A0(org-capture-steal-local-variables buffer)
= =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq buffer-file-name nil)
+ =C2=A0 = =C2=A0 =C2=A0(setq mark-active nil)
=C2=A0
=C2=A0 =C2= =A0 =C2=A0 =C2=A0;; %[] Insert contents of a file.
=C2=A0 =C2=A0 =C2=A0 =C2=A0(goto-char (point-min))
--=C2=A0<= /div>
1.7.0.4





On Tue, Apr 29, 2014 at 4:05 AM, Bastien <bzg@gnu.org> wrote:=
Hi Alex,

Alex Kosorukoff <alex@3form.com>= ; writes:

> I noticed a regression in the capture functionality after upgrading > org. Capture fails with error in subj

fixed, thanks,

--
=C2=A0Bastien

--047d7b33d3c010ae7804f8ef94f5--