From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Bastien <bzg@gnu.org>
Cc: Tod Middlebrook <todmiddlebrook@gmail.com>,
Aaron Ecay <aaronecay@gmail.com>,
emacs-orgmode@gnu.org
Subject: Re: Bug: property drawers within code blocks interfere [8.2.2 (8.2.2-elpa @ /home/tod/.emacs.d/.cask/24.3.50.1/elpa/org-20131108/)]
Date: Wed, 13 Nov 2013 09:41:29 +0100 [thread overview]
Message-ID: <87txfgels6.fsf@gmail.com> (raw)
In-Reply-To: <87vbzxqorb.fsf@bzg.ath.cx> (Bastien's message of "Tue, 12 Nov 2013 22:44:08 +0100")
Bastien <bzg@gnu.org> writes:
> Hi Aaron and Tod,
>
> Aaron Ecay <aaronecay@gmail.com> writes:
>
>> This seems like an excellent use case for the parser: basically a bunch
>> of uses of org-*-regexp and org-re-property need to be augmented with
>> a check like:
>> (not (memq (org-element-type (org-element-at-point)) '(src-block example-block ...)))
>>
>> A better alternative might be to use the parser to find the property
>> drawer in the first place (instead of a regex). Either way, it seems
>> like the best strategy might be to fix all uses of these problem
>> variables at once, which is a big undertaking.
>
> Also don't forget the cost in terms of speed. It's fine to fix the
> behavior of Org for such cases, but those cases are rare, and could
> be explicitely prevented. If the general fix does not slow down the
> parsing too much, then I'm all for it. Nicolas might have better
> insight here than me.
With newly introduced parser cache, the cost is amortized when using
`org-element-at-point' and `org-element-context'. With a little care,
the overhead is negligible. Therefore, these functions should be used
whenever possible.
I'm slowly working on introducing these functions in basic parts of Org
(e.g. fontification, indentation). Then I will target other functions
not using them yet. There's a lot to do. Help is welcome. IMO, at the
bare minimum, new or rewritten functions should use them.
For example, a way to correctly find the property drawer associated to
the current section is to use something like the following:
(save-excursion
(outline-previous-heading)
(unless (bobp)
(let ((limit (save-excursion (outline-next-heading) (point))))
(catch 'exit
(while (re-search-forward org-property-start-re limit t)
(let ((drawer (org-element-at-point)))
(when (eq (org-element-type drawer) 'property-drawer)
...
(throw 'exit ...))))))))
Regards,
--
Nicolas Goaziou
next prev parent reply other threads:[~2013-11-13 8:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-11 4:11 Bug: property drawers within code blocks interfere [8.2.2 (8.2.2-elpa @ /home/tod/.emacs.d/.cask/24.3.50.1/elpa/org-20131108/)] Tod Middlebrook
2013-11-11 16:59 ` Bastien
2013-11-11 22:22 ` Tod Middlebrook
2013-11-12 6:03 ` Bastien
2013-11-12 10:47 ` Tod Middlebrook
2013-11-12 10:59 ` Bastien
2013-11-12 21:28 ` Aaron Ecay
2013-11-12 21:44 ` Bastien
2013-11-13 8:41 ` Nicolas Goaziou [this message]
2013-11-13 8:54 ` Bastien
2013-11-13 8:34 ` Sebastien Vauban
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87txfgels6.fsf@gmail.com \
--to=n.goaziou@gmail.com \
--cc=aaronecay@gmail.com \
--cc=bzg@gnu.org \
--cc=emacs-orgmode@gnu.org \
--cc=todmiddlebrook@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.