emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [RFC] [PATCH] org.el: fix ‘org-buffer-property-keys’
@ 2014-08-27  1:35 Aaron Ecay
  2014-08-28  9:48 ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: Aaron Ecay @ 2014-08-27  1:35 UTC (permalink / raw)
  To: emacs-orgmode

* lisp/org.el (org-buffer-property-keys): Only match real property
drawers.

This patch adds an org-element based check.  Otherwise the following
triggers a bogus prompt to fix a malformed drawer on
typing M-: (org-buffer-property-keys)

* foo
  (add-to-list 'org-capture-templates
               '("c" "Contact" entry (file "~/org/contacts.org")
                 "* %(org-contacts-template-name)%?
  :PROPERTIES:
  :EMAIL: %(org-contacts-template-email)
  :END:"))
---
 lisp/org.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/org.el b/lisp/org.el
index d529a31..2e3003a 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15825,6 +15825,8 @@ formats in the current buffer."
 	(goto-char (point-min))
 	(while (re-search-forward org-property-start-re nil t)
 	  (catch 'cont
+	    (unless (eq (org-element-type (org-element-at-point)) 'property-drawer)
+	      (throw 'cont nil))
 	    (setq range (or (org-get-property-block)
 			    (if (y-or-n-p
 				 (format "Malformed drawer at %d, repair?" (point)))
--
2.1.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC] [PATCH] org.el: fix ‘org-buffer-property-keys’
  2014-08-27  1:35 [RFC] [PATCH] org.el: fix ‘org-buffer-property-keys’ Aaron Ecay
@ 2014-08-28  9:48 ` Nicolas Goaziou
  2014-08-30 18:51   ` Aaron Ecay
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Goaziou @ 2014-08-28  9:48 UTC (permalink / raw)
  To: Aaron Ecay; +Cc: emacs-orgmode

Hello,

Aaron Ecay <aaronecay@gmail.com> writes:

> +	    (unless (eq (org-element-type (org-element-at-point)) 'property-drawer)
> +	      (throw 'cont nil))
>  	    (setq range (or (org-get-property-block)
>  			    (if (y-or-n-p
>  				 (format "Malformed drawer at %d, repair?" (point)))

This will not work as you short-circuit the following part of the test
(i.e., since you only get `property-drawer' type on a well-formed
drawer, you get no change to repair malformed ones).

Also, if you store `org-element-at-point', you don't need anymore to
call `org-get-propert-block'.

Nevertheless, I think we should take a radical different approach, as
discussed recently with Bastien, which is to enforce property drawers to
start on the line right after the headline and maybe the planning info,
if any. As a consequence, the code for this function will be different
anyway. IOW, I wouldn't bother too much.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC] [PATCH] org.el: fix ‘org-buffer-property-keys’
  2014-08-28  9:48 ` Nicolas Goaziou
@ 2014-08-30 18:51   ` Aaron Ecay
  0 siblings, 0 replies; 3+ messages in thread
From: Aaron Ecay @ 2014-08-30 18:51 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

Hi Nicolas,

2014ko abuztuak 28an, Nicolas Goaziou-ek idatzi zuen:

[...]

> 
> Nevertheless, I think we should take a radical different approach, as
> discussed recently with Bastien, which is to enforce property drawers to
> start on the line right after the headline and maybe the planning info,
> if any. As a consequence, the code for this function will be different
> anyway. IOW, I wouldn't bother too much.

I see.  Thanks for the explanation.

-- 
Aaron Ecay

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-08-30 18:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-27  1:35 [RFC] [PATCH] org.el: fix ‘org-buffer-property-keys’ Aaron Ecay
2014-08-28  9:48 ` Nicolas Goaziou
2014-08-30 18:51   ` Aaron Ecay

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).