emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [RFC] Change property drawer syntax


From: Sebastien Vauban
Subject: Re: [O] [RFC] Change property drawer syntax
Date: Wed, 12 Nov 2014 12:01:06 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (windows-nt)

Hello Nicolas,

Nicolas Goaziou wrote:
> As discussed previously, I would like to modify property drawers
> syntax. [...]
>
> 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"))))))))))))

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

--8<---------------cut here---------------start------------->8---
* Reference

Example of Custom ID:

#+begin_verse
,* Some title
  :PROPERTIES:
  :CUSTOM_ID: SomeTitle
  :END:

Lorem ipsum
#+end_verse
--8<---------------cut here---------------end--------------->8---

will be converted to:

--8<---------------cut here---------------start------------->8---
* Reference
  :PROPERTIES:
  :CUSTOM_ID: SomeTitle
  :END:

Example of Custom ID:

#+begin_verse
,* Some title

Lorem ipsum
#+end_verse
--8<---------------cut here---------------end--------------->8---

upon execution of `org-repair-property-drawers'.

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?). I've restarted Emacs 5 or 6 times before
    being able to write this ECM...

Best regards,
  Seb

-- 
Sebastien Vauban




reply via email to

[Prev in Thread] Current Thread [Next in Thread]