在org-mode中定义自己的标签

Rea*_*onk 6 emacs org-mode

在组织模式中#+AUTHOR#+LATEX组织中有标签- 它们被称为标签吗?我想定义我自己的标签,它调用一个函数来预处理数据,然后输出它 - 如果导出目标是LaTeX.

Rea*_*onk 5

我的解决方案是qtreeSRC块定义一种自己的语言.

#+BEGIN_SRC qtree
[.CP [.TP [.NP [] [.N' [.N Syntax] []]] [.VP [] [.V' [.V sucks] []]]]]
#+END_SRC
Run Code Online (Sandbox Code Playgroud)

并相应地处理它.我甚至添加了一个qtree模式paredit.landscape如果树长大,还有一个参数.https://github.com/Tass/emacs-starter-kit/blob/master/vendor/assorted/org-babel-qtree.el

(require 'org)

(defun org-babel-execute:qtree (body params)
  "Reformat a block of lisp-edited tree to one tikz-qtree likes."
  (let (( tree
          (concat "\\begin{tikzpicture}
\\tikzset{every tree node/.style={align=center, anchor=north}}
\\Tree "
                  (replace-regexp-in-string
                   " \\_<\\w+\\_>" (lambda (x) (concat "\\\\\\\\" (substring x 1))) 
                   (replace-regexp-in-string
                    (regexp-quote "]") " ]" ; qtree needs a space
                                        ; before every closing
                                        ; bracket.
                    (replace-regexp-in-string
                     (regexp-quote "[]") "[.{}]" body)) ; empty leaf
                                        ; nodes, see
                                        ; http://tex.stackexchange.com/questions/75915
                   )                    ; For
                                        ; http://tex.stackexchange.com/questions/75217
                  "\n\\end{tikzpicture}"
                  )))
    (if (assoc :landscape params)
        (concat "\\begin{landscape}\n" tree "\n\\end{landscape}")
      tree)))

(setq org-babel-default-header-args:qtree '((:results . "latex") (:exports . "results")))
(add-to-list 'org-src-lang-modes '("qtree" . qtree))
(define-generic-mode 
    'qtree-mode                  ;; name of the mode to create
  '("%")                         ;; comments start with '%'
  '()                            ;; no keywords
  '(("[." . 'font-lock-operator) ;; some operators
    ("]" . 'font-lock-operator))
  '()                      ;; files for which to activate this mode 
  '(paredit-mode)          ;; other functions to call
  "A mode for qtree edits" ;; doc string for this mode
  )
Run Code Online (Sandbox Code Playgroud)