* [PATCH] Recognize property blocks even after text
@ 2015-02-12 1:39 Sacha Chua
2015-02-12 10:12 ` Rasmus
0 siblings, 1 reply; 4+ messages in thread
From: Sacha Chua @ 2015-02-12 1:39 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Recognize property blocks even after text
2015-02-12 1:39 [PATCH] Recognize property blocks even after text Sacha Chua
@ 2015-02-12 10:12 ` Rasmus
2015-02-13 17:49 ` Sacha Chua
0 siblings, 1 reply; 4+ messages in thread
From: Rasmus @ 2015-02-12 10:12 UTC (permalink / raw)
To: emacs-orgmode
Sacha Chua <sacha@sachachua.com> writes:
> 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!
Did you see this discussion? I think it's a feature.
http://permalink.gmane.org/gmane.emacs.orgmode/91752
—Rasmus
--
And I faced endless streams of vendor-approved Ikea furniture. . .
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Recognize property blocks even after text
2015-02-12 10:12 ` Rasmus
@ 2015-02-13 17:49 ` Sacha Chua
2015-02-17 20:59 ` Rasmus
0 siblings, 1 reply; 4+ messages in thread
From: Sacha Chua @ 2015-02-13 17:49 UTC (permalink / raw)
To: emacs-orgmode
Rasmus <rasmus@gmx.us> writes:
>> 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
> Did you see this discussion? I think it's a feature.
> http://permalink.gmane.org/gmane.emacs.orgmode/91752
Ah, that makes perfect sense. I'll try to train myself out of adding
stuff everywhere, then. Thank you!
Sacha
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Recognize property blocks even after text
2015-02-13 17:49 ` Sacha Chua
@ 2015-02-17 20:59 ` Rasmus
0 siblings, 0 replies; 4+ messages in thread
From: Rasmus @ 2015-02-17 20:59 UTC (permalink / raw)
To: emacs-orgmode
Sacha Chua <sacha@sachachua.com> writes:
> Ah, that makes perfect sense. I'll try to train myself out of adding
> stuff everywhere, then. Thank you!
If you the keybind it will do the right thing.
In ORG-NEWS there's a script to fix old files. Worst case use it as a
save-hook...
–Rasmus
--
And I faced endless streams of vendor-approved Ikea furniture. . .
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-02-17 20:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-12 1:39 [PATCH] Recognize property blocks even after text Sacha Chua
2015-02-12 10:12 ` Rasmus
2015-02-13 17:49 ` Sacha Chua
2015-02-17 20:59 ` Rasmus
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).