From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastien Vauban Subject: Re: [RFC] Change property drawer syntax Date: Fri, 14 Nov 2014 14:58:51 +0100 Message-ID: <86k32xdgtg.fsf@example.com> References: <87oatek909.fsf@nicolasgoaziou.fr> <86zjbwlm31.fsf@example.com> <87ppcqnpq7.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <87ppcqnpq7.fsf-Gpy5sJQTEQHwkn9pgDnJRVAUjnlXr6A1@public.gmane.org> (Nicolas Goaziou's message of "Fri, 14 Nov 2014 09:36:16 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: Nicolas Goaziou Cc: public-emacs-orgmode-mXXj517/zsQ-wOFGN7rlS/M9smdsby/KFg@public.gmane.org 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-r= e)) > (save-excursion > (re-search-forward org-property-drawer-re = end t) > (eq (org-element-type > (save-match-data (org-element-at-poin= t))) > '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: xxx-XsV/KxTKYItexX8rFMpgi3AlXr9lQLeu@public.gmane.org #+LANGUAGE: xx #+FILETAGS: :xxxx:xxxxx: * Xxxxxx ** Xxxx xxxx "Xxxxxxxxxxx xxx xxxxxxx xxxxxxx - Xxxxxx xx xxxxxxxxxx xxx xx= xxxxxx" <2014-10-09 Thu 10:00> Xxxxxxx: Xxxxxxxx xx Xxxxxx (Xxxxxx XX). * Xxxxx ** CANX Xxxx xxxxxxxx xxxxxxxxxxx xx xxxxxxxxxxx (xxxx Xxxxxx Xxxxxx Xxxxxx= x) 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?=E2= =80=A6) 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: Xxx= x x xxxx xxxxxxx]] --8<---------------cut here---------------end--------------->8--- becomes: --8<---------------cut here---------------start------------->8--- #+TITLE: Xxxxx Xxxxxx #+AUTHOR: Xxxxxxx Xxxxxxx #+EMAIL: xxx-XsV/KxTKYItexX8rFMpgi3AlXr9lQLeu@public.gmane.org #+LANGUAGE: xx #+FILETAGS: :xxxx:xxxxx: * Xxxxxx ** Xxxx xxxx "Xxxxxxxxxxx xxx xxxxxxx xxxxxxx - Xxxxxx xx xxxxxxxxxx xxx xx= xxxxxx" <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?=E2= =80=A6) 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: Xxx= x 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 --=20 Sebastien Vauban