From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Bug: property drawer created within other drawers Date: Mon, 06 Jan 2014 17:48:14 +0100 Message-ID: <87fvp1cb01.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34204) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W0DLQ-00030H-U5 for emacs-orgmode@gnu.org; Mon, 06 Jan 2014 11:48:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W0DLI-0006ib-G5 for emacs-orgmode@gnu.org; Mon, 06 Jan 2014 11:48:04 -0500 Received: from mail-wi0-x22c.google.com ([2a00:1450:400c:c05::22c]:45098) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W0DLI-0006iT-5k for emacs-orgmode@gnu.org; Mon, 06 Jan 2014 11:47:56 -0500 Received: by mail-wi0-f172.google.com with SMTP id en1so3045105wid.11 for ; Mon, 06 Jan 2014 08:47:55 -0800 (PST) In-Reply-To: (Derek Feichtinger's message of "Mon, 6 Jan 2014 14:56:12 +0100") 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: Derek Feichtinger Cc: emacs-orgmode@gnu.org Hello, Derek Feichtinger writes: > Dear developers > > Property drawers for certain items end up getting created within an > already existing LOGBOOK drawer. > > The problem is that the first while loop in org-insert-property-drawer > is also matching CLOCK lines within the drawer, so it reads into the > drawer instead of stopping before it. I discovered a matching report > that was already submitted by Sebastien Vauban > (http://article.gmane.org/gmane.emacs.orgmode/78881). > > Problematic code in org.el: > (defun org-insert-property-drawer () > ;... > (let ((indent (if org-adapt-indentation > (- (match-end 0) (match-beginning 0)) > 0)) > (beg (point)) > (re (concat "^[ \t]*" org-keyword-time-regexp)) > end hiddenp) > (outline-next-heading) > (setq end (point)) > (goto-char beg) > (while (re-search-forward re end t)) ; <=== problem > > I did a quick fix using the following construct: > > (let ((indent (if org-adapt-indentation > (- (match-end 0) (match-beginning 0)) > 0)) > (beg (point)) > (re (concat "^[ \t]*" org-keyword-time-regexp)) > end hiddenp) > (outline-next-heading) > (setq end (point)) > (goto-char beg) > (next-line) > (while (looking-at re) (next-line)) > (setq hiddenp (outline-invisible-p)) > ; comment-out: (end-of-line 1) > ; comment-out: (and (equal (char-after) ?\n) (forward-char 1)) > > Here's a typical task, where the original code will fail and place the > property drawer just before the end of the LOGBOOK drawer. > > *** DONE some task > CLOSED: [2013-07-10 Wed 14:11] DEADLINE: <2013-06-03 Mon> SCHEDULED: > <2013-07-08 Mon> > :LOGBOOK: > - State "DONE" from "WAIT" [2013-07-10 Wed 14:11] > CLOCK: [2013-05-17 Fri 17:07]--[2013-05-17 Fri 17:16] => 0:09 > CLOCK: [2013-05-08 Wed 14:30]--[2013-05-08 Wed 15:30] => 1:00 > CLOCK: [2013-05-06 Mon 14:55]--[2013-05-06 Mon 15:30] => 0:35 > - State "WAIT" from "TODO" [2013-04-03 Wed 14:31] \\ > sent mail > - State "TODO" from "DONE" [2013-03-20 Wed 11:25] > - State "DONE" from "TODO" [2012-11-22 Thu 15:05] > CLOCK: [2012-11-22 Thu 14:40]--[2012-11-22 Thu 15:04] => 0:24 > - State "TODO" from "" [2012-11-20 Tue 16:14] > :END: > - bla > - some more bla Thanks for the report. It seems odd to skip so many lines in order to insert a property drawer. Couldn't we insert it right after the planning information (i.e. before LOGBOOK in the example)? Regards, -- Nicolas Goaziou