Org-mode使用笔记
Table of Contents
1 Org.Myself
1.1 输入程序源码
我在写文档的时候。会引用一段elisp代码。org-mode中可以这样实现
- 一般般
(defun org-xor (a b) "Exclusive or." (if a (not b) b))
- 带行号的
源码:
'#+BEGIN_SRC c -r -n -l #include <stdio.h> int main(){ } '#+END_SRC
效果:
1: #include <stdio.h> 2: int main(){ 3: }
一个c++的例子
#include <iostream> using namespace std; int main() { }
python: 呵呵,顺带说一下,这个是我用来生成一些文件的.org索引的,用这些索引管理灰常方便。
#!/usr/bin/python3 import re,glob,sys,os from string import Template ApplicationIndex = {'pdf':'evince','PDF':'foxit','djvu':'evince','chm':'gnochm','CHM':'gnochm','rmvb':'smplayer', 'rm':'smplayer','mp3':'mplayer','wma':'mplayer'} taglist = {'陈寅恪':'陈寅恪','钱钟书':'钱锺书','Python':'Python','c\+\+':'CPP','钱锺书':'钱锺书'} tagrestr = 'java' haha= 'java' for x in taglist.keys(): tagrestr += '|' tagrestr += x taglist['java']='java' p = re.compile('.*/(.*)\.(.*$)') ree='.*('+tagrestr+').*' p2 = re.compile (ree) def generate(filepath,appindex=ApplicationIndex) : m =p.match(filepath) m2 = p2.match (filepath) if m2 : tagtag=':' + taglist[m2.group(1)] + ':' else : tagtag='\n 嘿嘿' tagtag1=m.group(2) string = '[[shell:$app $path &][$description]]$qi :$tag1:$tag' qiqi=' '*(70-len(m.group(1))) temp=Template(string) return temp.substitute(app = appindex[m.group(2)],path = m.group(0),description = m.group(1),qi=qiqi,tag1=tagtag1,tag=tagtag) def globwrap (string,path) : p=re.compile('(.*)/?$') m=p.match(path) return glob.glob(m.group(1)+'/*.'+string) def expt (path,tag) : f=lambda x: globwrap(x,path) print ('* '+tag) y=[] for x in ApplicationIndex.keys(): y+=f(x) #print ('-------------------------------------------------\n',y[1]) for s in map (generate,y): print ('** '+s) pass pass if __name__=='__main__': if len(sys.argv)>1 and len(sys.argv)<4: expt (sys.argv[1],sys.argv[-1]) if len(sys.argv)==1: expt (os.getcwd(),os.getcwd())
α → β
Footnotes:
1 FOOTNOTE DEFINITION NOT FOUND: 4
Date: 2009-03-27 03:24:15 GST
HTML generated by org-mode 6.24trans in emacs 23
1 条评论:
你的名字和电话泄露了,呵呵
发表评论