George Moutsopoulos <[email protected]> writes:

> On closer inspection, there is a larger error that (point) in the code
> is the point in the org-mode buffer whereas mid, end and body-start
> were calculated as positions inside the code block in the tangled
> buffer. E.g. in my case the tangled buffer is stripped of titles,
> headings, results etc.
>
> The following works in my MWE but not sure if it will throw for
> whatever reason. I send you a patch with
>
> (let* ((el (org-element-at-point))
>      (org-block-size (length (org-element-property :value el)))
>              (offset (min org-block-size (- mid body-start)))
>              )
> (forward-char offset))

That's indeed better.
The only problem is  that length of :value is not necessarily the same
as actual code in Org buffer. The :value is unescaped by
org-unescape-code-in-string and may have a different length.

A more reliable way is

(org-with-point-at (org-element-end element)
  (skip-chars-backward " \t\n\r")
  (forward-line 0)
  (point))

> Subject: [PATCH] fixes offset in org-babel-tangle-jump-to-org

While you are on it, could you also format the commit message as
described in
https://orgmode.org/worg/org-contribute.html#commit-messages and add a
TINYCHANGE cookie since you do not seem to have the copyright assignment?


-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to