[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [RFC] Change property drawer syntax
From: |
Nicolas Goaziou |
Subject: |
Re: [O] [RFC] Change property drawer syntax |
Date: |
Fri, 14 Nov 2014 09:36:16 +0100 |
Hello,
Sebastien Vauban <sva-news-D0wtAvR13HarG/address@hidden>
writes:
> After heavy testing (on all my Org files, I mean) of the above function,
> it works perfectly except for the following corner-case (when there are
> Org properties in "quote" blocks):
>
> * Reference
>
> Example of Custom ID:
>
> #+begin_verse
> ,* Some title
> :PROPERTIES:
> :CUSTOM_ID: SomeTitle
> :END:
>
> Lorem ipsum
> #+end_verse
>
> will be converted to:
>
> * Reference
> :PROPERTIES:
> :CUSTOM_ID: SomeTitle
> :END:
>
> Example of Custom ID:
>
> #+begin_verse
> ,* Some title
>
> Lorem ipsum
> #+end_verse
>
> upon execution of `org-repair-property-drawers'.
Thanks for your feedback. Would the following updated function solve the
problem?
(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)
(eq (org-element-type
(save-match-data (org-element-at-point)))
'drawer)))
(insert (delete-and-extract-region
(match-beginning 0)
(min (1+ (match-end 0)) end)))
(unless (bolp) (insert "\n"))))))))))))
> PS- I did not retest (yet) the same thing in #+begin/end_src
> blocks... as playing with that example files makes my Emacs eat 100%
> of the CPU (infloop?).
Could you provide an ECM for that?
Regards,
--
Nicolas Goaziou
- Re: [O] [RFC] Change property drawer syntax, (continued)
Re: [O] [RFC] Change property drawer syntax, Sebastien Vauban, 2014/11/12
Re: [O] [RFC] Change property drawer syntax,
Nicolas Goaziou <=