From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou 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 Message-ID: <87txfgels6.fsf@gmail.com> References: <87txfjy3vg.fsf@gmail.com> <874n7iho2t.fsf@bzg.ath.cx> <87siv24lzg.fsf@gmail.com> <87mwladulx.fsf@bzg.ath.cx> <87y54t28y2.fsf@gmail.com> <87vbzx6g31.fsf@bzg.ath.cx> <8761rxb97r.fsf@gmail.com> <87vbzxqorb.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgW0j-0002IL-DN for emacs-orgmode@gnu.org; Wed, 13 Nov 2013 03:41:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VgW0e-0002IR-0w for emacs-orgmode@gnu.org; Wed, 13 Nov 2013 03:41:17 -0500 In-Reply-To: <87vbzxqorb.fsf@bzg.ath.cx> (Bastien's message of "Tue, 12 Nov 2013 22:44:08 +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@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Cc: Tod Middlebrook , Aaron Ecay , emacs-orgmode@gnu.org Bastien writes: > Hi Aaron and Tod, > > Aaron Ecay 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