From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sacha Chua Subject: [PATCH] Recognize property blocks even after text Date: Wed, 11 Feb 2015 20:39:03 -0500 Message-ID: <86wq3nucw8.fsf@sachachua.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLikU-0005x5-LS for emacs-orgmode@gnu.org; Wed, 11 Feb 2015 20:39:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLikK-0001vP-3h for emacs-orgmode@gnu.org; Wed, 11 Feb 2015 20:39:22 -0500 Received: from plane.gmane.org ([80.91.229.3]:48004) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLikJ-0001ux-SV for emacs-orgmode@gnu.org; Wed, 11 Feb 2015 20:39:12 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YLikH-0008UK-Gi for emacs-orgmode@gnu.org; Thu, 12 Feb 2015 02:39:09 +0100 Received: from 192-171-49-245.cpe.pppoe.ca ([192.171.49.245]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 12 Feb 2015 02:39:09 +0100 Received: from sacha by 192-171-49-245.cpe.pppoe.ca with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 12 Feb 2015 02:39:09 +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: emacs-orgmode@gnu.org Hi! I noticed that the refactored org-get-property-block no longer allows for any text (aside from the SCHEDULED / DEADLINE / CLOSED) text between the heading and the property drawer, which gave me problems when I accidentally added text or timestamps or things like that. Also, it means org-gcal's default format (which puts the timestamp before the property drawer) doesn't work, so maybe a bunch of other things rely on the old behavior. If that part of the change was unintentional, would you consider the patch below? It seems to be okay with my Org files, but maybe that flexibility was removed for performance reasons. Hope this is useful! Subject: [PATCH] Recognize property blocks even after text * lisp/org.el (org-get-property-block): Search for the property drawer anywhere before the next heading or the end of the buffer. * testing/lisp/test-org.el (test-org/property-blocks-are-flexible): Check if property blocks can be defined after text. --- lisp/org.el | 25 +++++++++++++++---------- testing/lisp/test-org.el | 17 +++++++++++++++++ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 64b546f..dac7390 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -15422,16 +15422,21 @@ return nil." (t (org-with-limited-levels (org-back-to-heading t)))))) (forward-line) (when (org-looking-at-p org-planning-line-re) (forward-line)) - (cond ((looking-at org-property-drawer-re) - (forward-line) - (cons (point) (progn (goto-char (match-end 0)) - (line-beginning-position)))) - (force - (goto-char beg) - (org-insert-property-drawer) - (let ((pos (save-excursion (search-forward ":END:") - (line-beginning-position)))) - (cons pos pos)))))))) + (cond ((re-search-forward + org-property-drawer-re + (save-excursion (save-match-data (outline-next-heading)) + (point)) t) + (progn + (goto-char (match-beginning 0)) + (forward-line) + (cons (point) (progn (goto-char (match-end 0)) + (line-beginning-position))))) + (force + (goto-char beg) + (org-insert-property-drawer) + (let ((pos (save-excursion (search-forward ":END:") + (line-beginning-position)))) + (cons pos pos)))))))) (defun org-at-property-p () "Non-nil when point is inside a property drawer. diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index ce1d519..800cffc 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -2618,6 +2618,23 @@ Text. "* H\n:PROPERTIES:\n:COLUMNS: %25ITEM %A %20B\n:END:" (org-buffer-property-keys nil nil t))))) +(ert-deftest test-org/property-blocks-are-flexible () + "Test if properties can be specified with some information before them." + ;; Retrieve properties accross siblings. + (should + (equal '("A" "B") + (org-test-with-temp-text " +* H1 +Some text goes here. +:PROPERTIES: +:A: 1 +:END: +* H2 +:PROPERTIES: +:B: 1 +:END:" + (org-buffer-property-keys))))) + (ert-deftest test-org/property-values () "Test `org-property-values' specifications." ;; Regular test. -- 2.1.4