暗无天日

=============>DarkSun的个人博客

org-mode根据不同条件tangle不同代码块

原来org-mode中代码块的参数可以是一段elisp代码,这个特性可以让我们动态tangle不同代码块,像这样(代码摘自https://eschulte.github.io/org-scraps/scraps/2010-08-31-conditional-tangling.html):

* conditional tangling
  :PROPERTIES:
  :DATE:     2010-08-31
  :END:
  #+begin_src emacs-lisp :results silent
    (setq tangle-tag "right")
  #+end_src

** first subheading                                                    :left:
   :PROPERTIES:
   :DATE:     2010-08-31
   :END:
   #+begin_src R :tangle (and (equal (car (org-get-tags-at (point))) tangle-tag) "yes")
 "first"
   #+end_src

** second subheading                                                  :right:
   :PROPERTIES:
   :DATE:     2010-08-31
   :END:
   #+begin_src R :tangle (and (equal (car (org-get-tags-at (point))) tangle-tag) "yes")
 "second"
   #+end_src