Emacs 在组织模式下定义您自己的标记
在组织模式下,有如Emacs 在组织模式下定义您自己的标记,emacs,org-mode,Emacs,Org Mode,在组织模式下,有如#+AUTHOR或#+LATEX中的标记-它们被称为标记吗?我想定义我自己的标记,它调用一个函数来预处理数据,然后输出数据-如果导出目标是LaTeX。它们似乎不再被称为关键字了。无论它们被称为什么,它们似乎都不是用户可定义的 您想做的事情与处理Xeletex或pdflatex的常用方式极为相关 相关部分将是: ;;最初取自布鲁诺酒馆:http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432 (解除我的自动特克斯指
#+AUTHOR
或#+LATEX
中的标记-它们被称为标记吗?我想定义我自己的标记,它调用一个函数来预处理数据,然后输出数据-如果导出目标是LaTeX。它们似乎不再被称为关键字了。无论它们被称为什么,它们似乎都不是用户可定义的
您想做的事情与处理Xeletex或pdflatex的常用方式极为相关
相关部分将是:
;;最初取自布鲁诺酒馆:http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
(解除我的自动特克斯指令()
(如果(字符串匹配“YOUR_TAG:value1”(缓冲字符串))
(做点什么)
(如果(字符串匹配“YOUR_TAG:value2”(缓冲字符串))
(做点别的事)
(在初始vars hook“my auto tex cmd”之后添加hook“org export latex”)
我的解决方案是为SRC
块定义自己的语言qtree
#+BEGIN_SRC qtree
[.CP [.TP [.NP [] [.N' [.N Syntax] []]] [.VP [] [.V' [.V sucks] []]]]]
#+END_SRC
我甚至用paredit
添加了一个qtree模式。
如果树长得很大,则使用景观
参数
(需要“组织”)
(defun-org-babel-execute:qtree(body-params)
“将lisp编辑的树块重新格式化为tikz qtree格式。”
让(树)
(concat“\\begin{tikzpicture}
\\tikzset{每个树节点/.style={align=center,anchor=north}
\\“树”
(替换字符串中的regexp)
“\\”(lambda(x)(concat“\\”(子串x1)))
(替换字符串中的regexp)
(regexp引号“]”“]”“qtree需要一个空格
;每次结账前
支架
(替换字符串中的regexp)
(regexp引号“[]”“[.{}]”体));空叶
;节点,请参见
; http://tex.stackexchange.com/questions/75915
);为了
; http://tex.stackexchange.com/questions/75217
“\n\\end{tikzpicture}”
)))
(如果(关联:景观参数)
(concat“\\begin{scape}\n”tree“\n\\end{scape}”)
(树)
(setq org babel默认标题参数:qtree'(:results.latex)(:exports.results)))
(添加到列表“组织src语言模式”(“qtree.qtree))
(定义通用模式)
'qtree mode;;要创建的模式的名称
“(“%”);注释以“%”开头
“();;没有关键字
“((“[.”字体锁定运算符);某些运算符
(“].”字体锁定运算符)
“();;要为其激活此模式的文件
“(paredit模式);;要调用的其他函数
“用于qtree编辑的模式”;此模式的文档字符串
)
我不认为它们被称为标签
,因为标签
被称为:东西:比如,在标题中,议程可以过滤。也许更确切。尸体是从哪里来的?@Tass:什么意思?你可能真的想看一下工作页面,恐怕我无法在elisp上帮你更多的忙。我想是的h字符串匹配
,您可以匹配自己的标记并从中提取主体。
(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
)