From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Expose value-begin and value-end instead of just value in org-element API Date: Tue, 20 Feb 2018 11:59:31 -0800 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="089e08238778c401830565aa3fb7" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoE4d-0001NG-88 for emacs-orgmode@gnu.org; Tue, 20 Feb 2018 14:59:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoE4c-0006rr-0t for emacs-orgmode@gnu.org; Tue, 20 Feb 2018 14:59:35 -0500 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]:43891) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eoE4b-0006rO-NG for emacs-orgmode@gnu.org; Tue, 20 Feb 2018 14:59:33 -0500 Received: by mail-wr0-x233.google.com with SMTP id u49so13177776wrc.10 for ; Tue, 20 Feb 2018 11:59:33 -0800 (PST) In-Reply-To: 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: "Somelauw ." Cc: "emacs-orgmode@gnu.org" --089e08238778c401830565aa3fb7 Content-Type: text/plain; charset="UTF-8" +1 on this. I also have some janky code to do things like go to the beginning/end of the value in a src block. Here is my solution to mark the code in a src block. (defun ob-ipython-mark-code () "Mark the code in the block." (interactive) (org-edit-special) (let ((p0 (point-min)) (p1 (point-max))) (goto-char p0) (org-edit-src-exit) (set-mark (point)) (goto-char (+ (point) (- p1 2))))) John ----------------------------------- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Mon, Feb 19, 2018 at 3:29 PM, Somelauw . wrote: > Some org-mode elements expose "contents-begin" and "contents-end" > properties as buffer positions, whereas other elements such as verbatim and > org-src-block expose a "value" property in the form of a string. > > I think it would be preferable to also expose the value by beginning and > ending buffer positions for the following reasons: > - Consistency with elements that expose contents-begin and contents-end. > - 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. > - It's usually more efficient to return the beginning and ending positions > than to retrieve the substring that contains the value, which may require a > large buffer partition to be copied. > > Kind regards, > Somelauw --089e08238778c401830565aa3fb7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
+1 on this.

I also have some janky code= to do things like go to the beginning/end of the value in a src block. Her= e is my solution to mark the code in a src block.

=
(defun ob-ipython-mark-code ()
=C2=A0 "Mark the code in= the block."
=C2=A0 (interactive)
=C2=A0 (org-edit= -special)
=C2=A0 (let ((p0 (point-min))
(p1 (point-max)))
=C2=A0 =C2=A0 (goto-ch= ar p0)
=C2=A0 =C2=A0 (org-edit-src-exit)
=C2=A0 =C2=A0 = (set-mark (point))
=C2=A0 =C2=A0 (goto-char (+ (point) (- p1 2)))= ))

John

-----------------------------------Professor John Kitchin=C2=A0
Doherty Hall A207F
Department of Chemic= al Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412= -268-7803

On Mon, Feb 19, 2018 at 3:29 PM, Somelauw . = <somelauw@gmail.com> wrote:
Some org-mode elements expose "contents-begin" and "conte= nts-end" properties as buffer positions, whereas other elements such a= s verbatim and org-src-block expose a "value" property in the for= m of a string.

I think it would be preferable to also expose the val= ue by beginning and ending buffer positions for the following reasons:
-= Consistency with elements that expose contents-begin and contents-end.
= - 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 AP= I does currently not provide clean way to retrieve these positions.
- It= 's usually more efficient to return the beginning and ending positions = than to retrieve the substring that contains the value, which may require a= large buffer partition to be copied.

Kind regards,
Somelauw

--089e08238778c401830565aa3fb7--