1

Sometimes in combinatoric programming it is helpful to explain the meaning of certain threshold values in code blocks. Example:

if x > 20 # combi(20,4) == 4845 is too large
then
    value_too_large()
else
    continue the computation

Is there a way to compute and expand this 4845 part in org-mode's code blocks?

0

I am not sure about doing it directly in the org file.

What can be done is using C-c ' which is M-x org-edit-special

from the doc:

(org-edit-special &optional ARG)

Call a special editor for the element at point.
When at a table, call the formula editor with ‘org-table-edit- 
formulas’.
When in a source code block, call ‘org-edit-src-code’.
When in a fixed-width region, call ‘org-edit-fixed-width-region’.
When in an export block, call ‘org-edit-export-block’.
When in a LaTeX environment, call ‘org-edit-latex-environment’.
When at an #+INCLUDE keyword, visit the included file.
When at a footnote reference, call ‘org-edit-footnote-reference’
On a link, call ‘ffap’ to visit the link at point.
Otherwise, return a user error.

in Clojure for example using cider you can evaluate any line or part or region into a comment using 'eval-last-sexp-and-insert' as well as other functions.

In elisp lisp-interaction-mode you can evaluate-and-print.

there's something similar in lpy for Python. So it basically depends on the editing-mode which can also be configured in .emacs, for example cider for Clojure will be:

(setq org-babel-clojure-backend 'cider)
| improve this answer | |
  • I see. So the steps are:1. C-c ' and enter into the narrowed buffer with the major mode, 2. do mode-specific expansion in the buffer. – mnish Jun 14 '18 at 16:43
  • and finish with C-c ' to go back to org mode and save there (.. or also C-c C-s in that editing buffer for save) – manandearth Jun 14 '18 at 20:00

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.