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: Fri, 14 Nov 2014 14:58:51 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (windows-nt)


Hello Nicolas,

Nicolas Goaziou wrote:
> Sebastien Vauban writes:
>
>> After heavy testing (on all my Org files, I mean) of the above function,
>> it works perfectly except for the following corner-case [...].
>
> 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"))))))))))))

Nope, this one really breaks my Org file. For example:

--8<---------------cut here---------------start------------->8---
#+TITLE: Xxxxx Xxxxxx
#+AUTHOR: Xxxxxxx Xxxxxxx
#+EMAIL: address@hidden
#+LANGUAGE: xx

#+FILETAGS: :xxxx:xxxxx:

* Xxxxxx

** Xxxx xxxx "Xxxxxxxxxxx xxx xxxxxxx xxxxxxx - Xxxxxx xx xxxxxxxxxx xxx 
xxxxxxxx"
   <2014-10-09 Thu 10:00>

Xxxxxxx: Xxxxxxxx xx Xxxxxx (Xxxxxx XX).

* Xxxxx

** CANX Xxxx xxxxxxxx xxxxxxxxxxx xx xxxxxxxxxxx (xxxx Xxxxxx Xxxxxx Xxxxxxx)
   DEADLINE: <2014-10-08 Wed>
   :LOGBOOK:
   - Xxxxx "XXXX"        ->  "XXXX"       [2014-10-09 Thu 18:18]
   :END:
   [2014-09-30 Tue 11:18]

#+BEGIN_VERSE
Xxxxxx xxxxx xx xxxx xxxxx xxx xxxxxxxxxx. Xxxx xxxx x xxxxxxx:

- Xxxx x xxxx xxxx xx xxxxxxxx xxxxxxxxxx
- Xx x xxxxxxx
- Xxxxx xxxxx xxx xxxx

Xx xx xxxxxxxx, xx xxxx:

x Xxxxxxxxxx xxxxxxxxxxx xx xxxxxxxxxxx (xxx xx xxxx xxxx)
x Xxxxxxxx xxxxxxxxxxx xx xxxxxxxxxxx (xxx xxxxxxxxx xx xxxxx? xxxxxxxx?…)
x Xxxx xxx xx xxxx xxxx xxxx'x xxxx xxxx xx xx xxxxxxxxxxx?
x Xxxxxxxxxx "xxxxxxxxx xxxx" xx xxx

Xxxxx xxx xxxx xxxx xx (x) xxx (x)?
#+END_VERSE

Xxxx [[http://orgmode.org][Xxxxx xxxx Xxxxxx Xxxxxx Xxxxxxx: {xxx} Xxx: Xxxx x 
xxxx xxxxxxx]]
--8<---------------cut here---------------end--------------->8---

becomes:

--8<---------------cut here---------------start------------->8---
#+TITLE: Xxxxx Xxxxxx
#+AUTHOR: Xxxxxxx Xxxxxxx
#+EMAIL: address@hidden
#+LANGUAGE: xx

#+FILETAGS: :xxxx:xxxxx:

* Xxxxxx

** Xxxx xxxx "Xxxxxxxxxxx xxx xxxxxxx xxxxxxx - Xxxxxx xx xxxxxxxxxx xxx 
xxxxxxxx"
   <2014-10-09 Thu 10:00>

Xxxxxxx: Xxxxxxxx xx Xxxxxx (Xxxxxx XX).

* Xxxxx

ANX Xxxx xxxxxxxx xxxxxxxxxxx xx xxxxxxxxxxx (xxxx Xxxxxx Xxxxxx Xxxxxxx)
   DEADLINE: <2014-10-08 Wed>



** C
   :LOGBOOK:
   - Xxxxx "XXXX"        ->  "XXXX"       [2014-10-09 Thu 18:18]
   :END:
   [2014-09-30 Tue 11:18]

#+BEGIN_VERSE
Xxxxxx xxxxx xx xxxx xxxxx xxx xxxxxxxxxx. Xxxx xxxx x xxxxxxx:

- Xxxx x xxxx xxxx xx xxxxxxxx xxxxxxxxxx
- Xx x xxxxxxx
- Xxxxx xxxxx xxx xxxx

Xx xx xxxxxxxx, xx xxxx:

x Xxxxxxxxxx xxxxxxxxxxx xx xxxxxxxxxxx (xxx xx xxxx xxxx)
x Xxxxxxxx xxxxxxxxxxx xx xxxxxxxxxxx (xxx xxxxxxxxx xx xxxxx? xxxxxxxx?…)
x Xxxx xxx xx xxxx xxxx xxxx'x xxxx xxxx xx xx xxxxxxxxxxx?
x Xxxxxxxxxx "xxxxxxxxx xxxx" xx xxx

Xxxxx xxx xxxx xxxx xx (x) xxx (x)?
#+END_VERSE

Xxxx [[http://orgmode.org][Xxxxx xxxx Xxxxxx Xxxxxx Xxxxxxx: {xxx} Xxx: Xxxx x 
xxxx xxxxxxx]]
--8<---------------cut here---------------end--------------->8---

Observe that:
- many blank lines are added,
- the TODO keyword (CANX) is broken, and
- a new task is created.

>> 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?

It really was just editing the given example. So, this file:

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

caused me trouble with the initial `org-repair-property-drawers' added
to the `org-mode-hook'!?

Best regards,
  Seb

-- 
Sebastien Vauban




reply via email to

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