From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Somelauw ." Subject: Re: Expose value-begin and value-end instead of just value in org-element API Date: Wed, 21 Feb 2018 22:13:33 +0100 Message-ID: References: <87k1v6k2wt.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:51477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eobiX-0007GX-BZ for emacs-orgmode@gnu.org; Wed, 21 Feb 2018 16:15:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eobho-0007UY-BE for emacs-orgmode@gnu.org; Wed, 21 Feb 2018 16:14:21 -0500 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]:37851) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eobho-0007TK-1L for emacs-orgmode@gnu.org; Wed, 21 Feb 2018 16:13:36 -0500 Received: by mail-wr0-x233.google.com with SMTP id z12so8391894wrg.4 for ; Wed, 21 Feb 2018 13:13:35 -0800 (PST) In-Reply-To: <87k1v6k2wt.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.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: "emacs-orgmode@gnu.org" , John Kitchin Thank you for your response. 2018-02-21 12:17 GMT+01:00 Nicolas Goaziou : > You get the beginning of the code of a source block with > > (org-with-point-at (org-element-property :post-affiliated element) > (line-beginning-position 2)) > > and its end with > > (org-with-point-at (org-element-property :end element) > (line-beginning-position (- (org-element-property :post-blank element)))) This works well to find the :value of code blocks, but doesn't work for other org elements such as clock, babel-call and comment. What I'm looking for is a generic way to find the beginning and end of the :value of the element at point that works on all elements and is future-proof. >>> - More powerful. In my evil-org plugin I want to be able to mark the value >>> property of the org element at point (so the user can do stuff like easily >>> copy the code of the current code block), but to do so I need the beginning >>> and ending position in the buffer of "value". The org-element API does >>> currently not provide clean way to retrieve these positions. > > See above. It is quite simple to extract this information from the parse > tree. Something I would like to have is a command to mark the "useful inner part" of the element that the point is currently on. For recursive elements this is usually the part between :contents-begin and :contents-end and for non-recursive elements this is usually :value. The org-element-parser was probably not written for the specific goal I have in mind, but the :value of org-element gives me almost what I want, except that I need the buffer positions. Kind regards, Somelauw