4

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

 2 years ago
source link: https://www.lujun9972.win/blog/2019/03/08/org-mode%E6%A0%B9%E6%8D%AE%E4%B8%8D%E5%90%8C%E6%9D%A1%E4%BB%B6tangle%E4%B8%8D%E5%90%8C%E4%BB%A3%E7%A0%81%E5%9D%97/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK