2

Can I insert a variable 'alpha' into @2$3 ? Does the function belong Emacs org?

** test elisp make a table
#+name: make-table
#+BEGIN_SRC emacs-lisp :results value
(setq tol 0.1)
(setq alpha 1.38)
(setq alpha_1 (- 90 alpha))
'(("angle" "symbol"   "value"  "max"         "min") hline 
  ("toe"   "\\alpha"   alpha  (+ alpha tol)  (- alpha tol))
  ("c"   "\\alpha_1"   alpha_1  (+ alpha_1 tol)  (- alpha_1 tol))
 )
#+END_SRC

1 Answer 1

5

You are almost there. You just have to apply backquotes instead of single-quote for quoting and comma-operators where you want to insert the variable values. That is not org-mode specific but standard-lisp stuff.

** test elisp make a table
#+name: make-table
#+BEGIN_SRC emacs-lisp :results value
(setq tol 0.1)
(setq alpha 1.38)
(setq alpha_1 (- 90 alpha))
`(("angle" "symbol"   "value"  "max"         "min") hline 
  ("toe"   "\\alpha"   ,alpha  ,(+ alpha tol)  ,(- alpha tol))
  ("c"   "\\alpha_1"   ,alpha_1  ,(+ alpha_1 tol)  ,(- alpha_1 tol))
  )
#+END_SRC

#+RESULTS: make-table
| angle | symbol   | value |   max |                min |
|-------+----------+-------+-------+--------------------|
| toe   | \alpha   |  1.38 |  1.48 | 1.2799999999999998 |
| c     | \alpha_1 | 88.62 | 88.72 |  88.52000000000001 |
3
  • Thanks,I can't find a sample in ORG guide so ask here.Thanks again.Emacs and Elisp is great.
    – andrew
    Dec 13, 2017 at 14:18
  • Would there be a way to not call the results #+RESULTS: make-table rather #+TBLNAME: make-table? In general, is it possible to tell a code block ahead of time to send the results to a declared variable?
    – 147pm
    Apr 16, 2019 at 20:02
  • @147pm I hope I understood your question right. It is of general value. So I posted it as separate question at emacs.stackexchange.com/q/48972/2370. You also find an answer there.
    – Tobias
    Apr 16, 2019 at 23:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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