emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Expose value-begin and value-end instead of just value in org-el


From: John Kitchin
Subject: Re: [O] Expose value-begin and value-end instead of just value in org-element API
Date: Tue, 20 Feb 2018 11:59:31 -0800

+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

On Mon, Feb 19, 2018 at 3:29 PM, Somelauw . <address@hidden> 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]