From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ihor Radchenko Subject: Re: Bug: org-element-at-point on headline does not contain :parent property [9.3 (release_9.3 @ /home/yantar92/.emacs.d/straight/build/org/)] Date: Wed, 05 Feb 2020 21:49:48 +0800 Message-ID: <87y2thrvnn.fsf@localhost> References: <874ky0o471.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> <87wo91bixl.fsf@gnu.org> <877e11tl3a.fsf@localhost> <87blqd2nxj.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:52714) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1izL6Z-0004Ws-FK for emacs-orgmode@gnu.org; Wed, 05 Feb 2020 08:52:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1izL6Y-0002d5-4q for emacs-orgmode@gnu.org; Wed, 05 Feb 2020 08:52:35 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:38416) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1izL6X-0002a4-Ub for emacs-orgmode@gnu.org; Wed, 05 Feb 2020 08:52:34 -0500 Received: by mail-pl1-x633.google.com with SMTP id t6so918946plj.5 for ; Wed, 05 Feb 2020 05:52:33 -0800 (PST) In-Reply-To: <87blqd2nxj.fsf@nicolasgoaziou.fr> 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-mx.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: emacs-orgmode@gnu.org > `org-element-at-point' returns only a partial parse tree. It never goes > higher than the current top-level element, i.e., from an element, you > cannot go up to the headline just following :parent. Thanks for the clarification. I was not sure if it is intended. I was mislead about this 2 times because of docstring, though it is clear from the source code. > Luckily, headlines are exactly where you do _not_ need Element library. > `org-back-to-heading' and `org-up-heading-safe' will always be faster, > and as accurate. I.e., the code operating on headlines is usually > distinct from the code handling other elements. Well. `org-back-to-heading` + `org-up-heading-safe` take more than 15% of my agenda generation time (I have really huge number of headings + multiple custom skip functions). I was hoping to use cache for speed up. > You can parse the full document and get all the :parent properties > filled. That's not the job for `org-element-at-point'. I once tried to do exactly this, but I did not manage to figure out how to obtain element at point from full parse tree (from inside an agenda skip function). Is it possible? > Note that `org-element-cache' was disabled a while ago because it could > introduce freezes. I think this is related to how this part handles > `before-change-functions' and `after-change-functions'. Anyway, YMMV. I see... I don't know how useful the cache is except my idea about using cache to speed up agenda. But I was stuck with the :parent property issue and did not play much further since that time. Best, Ihor Nicolas Goaziou writes: > Hello, > > Ihor Radchenko writes: > >>> Probably the docstring needs to be adapted - Nicolas knows this area >>> better than me. >> >> Do you mean that :parent property may not always be present? > > `org-element-at-point' returns only a partial parse tree. It never goes > higher than the current top-level element, i.e., from an element, you > cannot go up to the headline just following :parent. > > Luckily, headlines are exactly where you do _not_ need Element library. > `org-back-to-heading' and `org-up-heading-safe' will always be faster, > and as accurate. I.e., the code operating on headlines is usually > distinct from the code handling other elements. > >> If so, it is quite disappointing. It would be helpful to be able to find >> parent of any element at point (especially, in conjunction with >> org-element-cache). At least, optionally. > > You can parse the full document and get all the :parent properties > filled. That's not the job for `org-element-at-point'. > >> I was counting on this feature to try speeding up my agenda generation >> (using org-element-cache). > > Note that `org-element-cache' was disabled a while ago because it could > introduce freezes. I think this is related to how this part handles > `before-change-functions' and `after-change-functions'. Anyway, YMMV. > > Regards, > > -- > Nicolas Goaziou -- Ihor Radchenko, PhD, Center for Advancing Materials Performance from the Nanoscale (CAMP-nano) State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg