Ver Fonte

babel: variable references which look like lisp forms are now evaluated

  for example, the following simple example
    #+begin_src emacs-lisp :var two=(+ 1 1)
      (sqrt two)
    #+end_src

    #+results:
    : 1.4142135623730951

  Or this more interesting usage, which pulls variable values from
  headline properties
    *** example headline w/property
        :PROPERTIES:
        :special:  89
        :last-name: schulte
        :END:

    #+begin_src emacs-lisp :var special=(string-to-number (org-entry-get nil "special" t))
      (+ special 1)
    #+end_src

    #+results:
    : 90

    #+begin_src emacs-lisp :var last-name=(org-entry-get nil "last-name" t))
      (message "hello %s" last-name)
    #+end_src

    #+results:
    : hello schulte
Eric Schulte há 15 anos atrás
pai
commit
32bbd3f3bb
1 ficheiros alterados com 1 adições e 1 exclusões
  1. 1 1
      contrib/babel/lisp/org-babel.el

+ 1 - 1
contrib/babel/lisp/org-babel.el

@@ -1057,7 +1057,7 @@ This is taken almost directly from `org-read-prop'."
       (or (org-babel-number-p cell)
           (if (or (equal "(" (substring cell 0 1))
                   (equal "'" (substring cell 0 1)))
-              (read cell)
+              (eval (read cell))
             (progn (set-text-properties 0 (length cell) nil cell) cell)))
     cell))