From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: emacs-orgmode@gnu.org
Subject: Re: [RFC] Change property drawer syntax
Date: Wed, 15 Oct 2014 00:18:02 +0800 [thread overview]
Message-ID: <87vbnmtykl.fsf@ericabrahamsen.net> (raw)
In-Reply-To: 87oatek909.fsf@nicolasgoaziou.fr
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> Hello,
>
> As discussed previously, I would like to modify property drawers syntax.
> The change is simple: they must be located right after a headline and
> its planning line, if any. Therefore the following cases are valid
>
> * Headline
> :PROPERTIES:
> :KEY: value
> :END:
>
> * Headline
> SCHEDULED: <2014-10-14 mar.>
> :PROPERTIES:
> :KEY: value
> :END:
>
> but, in the following case, the scheduled keyword will not be recognized
>
> * Headline
> :PROPERTIES:
> :KEY: value
> :END:
> SCHEDULED: <2014-10-14 mar.>
>
> When not empty, they also have to contain only node properties.
> Moreover, node properties' keys can only contain non-whitespace
> characters and cannot end with a plus sign (which is used for
> accumulation). Value can contain anything but a newline character.
>
> Thus, the following property drawer is invalid
>
> * Headline
> :PROPERTIES:
> :KEY: value
> Some text.
> :END:
>
> Any invalid property drawer becomes de facto a regular drawer, with
> "PROPERTIES" as its name.
>
> Besides defining exactly the syntax of property drawers, it should also
> make the property API faster in some cases. Indeed, there's no need to
> search through entire (possibly huge) sections in order to find
> properties attached to a headline.
>
> However, it will break some Org documents. In particular, TODO-states
> changes are usually logged before any drawer, including properties
> drawers. The following function repairs them.
>
> (defun org-repair-property-drawers ()
> "Fix properties drawers in current buffer.
> Ignore non Org buffers."
> (when (eq major-mode 'org-mode)
> (org-with-wide-buffer
> (goto-char (point-min))
> (let ((case-fold-search t)
> (inline-re (and (featurep 'org-inlinetask)
> (concat (org-inlinetask-outline-regexp)
> "END[ \t]*$"))))
> (org-map-entries
> (lambda ()
> (unless (and inline-re (org-looking-at-p inline-re))
> (save-excursion
> (let ((end (save-excursion (outline-next-heading) (point))))
> (forward-line)
> (when (org-looking-at-p org-planning-line-re) (forward-line))
> (when (and (< (point) end)
> (not (org-looking-at-p org-property-drawer-re))
> (save-excursion
> (re-search-forward org-property-drawer-re end t)))
> (insert (delete-and-extract-region
> (match-beginning 0)
> (min (1+ (match-end 0)) end)))
> (unless (bolp) (insert "\n"))))))))))))
>
> Internally, changes are somewhat invasive, as they include a rewrite of
> almost all the property API. They also alter clocking, tags, todo
> keywords, logging, initialization, hopefully in an invisible manner.
>
> I pushed a new branch, "top-properties" in the repository for code
> review and testing. It includes unit tests, documentation and an
> ORG-NEWS entry.
Sounds like fun! Here's maybe a bug. In this test case:
* Here's something
** Second level
:PROPERTIES:
:ID: 06b778b5-72a5-45b5-aea6-2d0fef0fd24b
:END:
Calling org-entry-put on the first heading will actually place the
property on its child. Reason being that, when org-entry-put calls
org-get-property-block, and that calls org-insert-property-drawer, point
has already been advanced to the beginning of the "** Second level"
line.
org-insert-property-drawer examines the child instead of the parent,
thinks it doesn't have to insert anything, and returns nil. Code later
in org-get-property-block locates the ":END:" belonging to the child,
assumes that's the end of the parent's block, and sticks the new
property there. (I found this because org-id-get-create placed new ID
values in the child's property drawer.)
That was a mouthful, but I'm not going to venture a patch at this point!
Eric
next prev parent reply other threads:[~2014-10-14 16:13 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-14 14:42 [RFC] Change property drawer syntax Nicolas Goaziou
2014-10-14 14:55 ` Andreas Leha
2014-10-14 15:55 ` Nicolas Goaziou
2014-10-14 16:18 ` Eric Abrahamsen [this message]
2014-10-14 19:26 ` Nicolas Goaziou
2014-10-14 16:25 ` Michael Brand
2014-10-14 19:38 ` Nicolas Goaziou
2014-10-15 17:25 ` Michael Brand
2014-10-15 20:52 ` Nicolas Goaziou
2014-10-15 2:58 ` Eric Abrahamsen
2014-10-15 10:11 ` Nicolas Goaziou
2014-10-15 11:22 ` Eric Abrahamsen
2014-10-15 7:38 ` Rainer M Krug
2014-10-15 10:14 ` Nicolas Goaziou
2014-10-15 11:27 ` Rainer M Krug
2014-10-20 22:35 ` Rasmus
2014-10-26 15:24 ` Nicolas Goaziou
2014-10-28 13:27 ` Nicolas Goaziou
2014-11-06 10:21 ` Sebastien Vauban
2014-11-08 13:46 ` Nicolas Goaziou
2014-11-10 10:19 ` Sebastien Vauban
2014-11-10 10:41 ` Nicolas Goaziou
2014-11-10 11:04 ` Sebastien Vauban
2014-11-10 11:51 ` Nicolas Goaziou
2014-11-10 12:55 ` Sebastien Vauban
2014-11-12 10:40 ` Sebastien Vauban
2014-11-13 19:58 ` Nicolas Goaziou
[not found] ` <87sihmq3dd.fsf-Gpy5sJQTEQHwkn9pgDnJRVAUjnlXr6A1@public.gmane.org>
2014-11-26 14:09 ` Sebastien Vauban
2014-10-31 13:10 ` Christian Egli
2014-10-31 16:10 ` John Hendy
2014-11-03 8:27 ` Christian Egli
2014-11-03 8:33 ` Nicolas Goaziou
2014-11-01 10:57 ` Nicolas Goaziou
2014-11-03 8:38 ` Christian Egli
2014-11-03 20:14 ` Nicolas Goaziou
2014-11-12 11:01 ` Sebastien Vauban
2014-11-12 11:11 ` Sebastien Vauban
2014-11-26 14:18 ` Sebastien Vauban
2014-11-26 23:37 ` Nicolas Goaziou
2014-11-27 9:24 ` Sebastien Vauban
2014-11-28 22:16 ` Nicolas Goaziou
2014-12-05 14:33 ` Puneeth Chaganti
2014-12-05 23:31 ` Nicolas Goaziou
2014-12-06 6:42 ` Puneeth Chaganti
2014-12-06 20:36 ` Nicolas Goaziou
2014-11-14 8:36 ` Nicolas Goaziou
[not found] ` <87ppcqnpq7.fsf-Gpy5sJQTEQHwkn9pgDnJRVAUjnlXr6A1@public.gmane.org>
2014-11-14 13:58 ` Sebastien Vauban
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vbnmtykl.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.