1

In my Org Mode document I have the following two blocks

#+NAME: fcn
#+BEGIN_SRC elisp :var pt=(point)
  (list pt (point))
#+END_SRC

#+RESULTS: fcn
| 56 | 56 |

#+NAME: second_block
#+BEGIN_SRC elisp :var a=(point) b=fcn(pt=(point))
  (list a b)
#+END_SRC

#+RESULTS: second_block
| 213 | (13 13) | 

I want to determine a position of the second_block and pass it to fcn. As a result of the second_block I am expecting to obtain something like this

| XYZ | (XYZ 13) | 

where XYZ is a position of the second_block (it can be any point that belongs to the second_block: ultimately XYZ should work with property API functions as a POM).

Moreover, I would like to have a solution that works independent of the current cursor position. For instance It should work properly also when the cursor position doesn't point to the second_block, for example after executing all code blocks in current buffer (with C-c C-v b). In this context the point function might be incorrectly applied here, which I am aware of.

Secondly, why is b variable equal to (13 13) after execution of the second_block?

  • Did you try org-babel-map-src-blocks? I think that when blocks are evaluated they are copied into a different buffer, so position will not be the same as in the original buffer. – wvxvw Jan 28 '17 at 7:05
  • @wvxvw Nothing changed after replacing (point) by (org-babel-map-src-blocks nil). If blocks are evaluated in another buffer this problem might be unsolvable. – premopie Jan 30 '17 at 9:50
  • Oh, that's not what I meant. org-babel-map-src-blocks is a function that calls your function with the argument being a struct that describes the src block. On top of other things stored in this struct, there's its position in the buffer. – wvxvw Jan 30 '17 at 9:51
  • @wvxvw I see. How should I define an argument describing the function to be evaluated for org-babel-map-src-blocks? Can I do this by reference? – premopie Jan 30 '17 at 10:04
  • stackoverflow.com/a/23726135/5691066 here's some example usage (solving a different problem, but you could copy some code from it). – wvxvw Jan 30 '17 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.