org 模式 - 可点击的文本跳转到 emacs 中的特定行
org mode - clickable text jump to specific line in emacs
我有一个文件列表,希望在单击文本时跳转到特定行。
#+BEGIN_SRC python :results output
for i in range(0,10):
print "[[./test%d.txt:100]]"%i
#+END_SRC
#+RESULTS:
#+begin_example
[[./test0.txt:100]]
[[./test1.txt:100]]
[[./test2.txt:100]]
[[./test3.txt:100]]
[[./test4.txt:100]]
[[./test5.txt:100]]
[[./test6.txt:100]]
[[./test7.txt:100]]
[[./test8.txt:100]]
[[./test9.txt:100]]
#+end_example
如果末尾没有行号,点击文本行将打开文件但不会跳转到特定行号。
我应该如何更改语法以跳转到行号?
在您的示例中,唯一的问题是 Org external links 的语法。是
[[./test%d.txt::100]] (and not [[./test%d.txt:100]])
这将在您的 Emacs Org 缓冲区中工作,但是如果您发布文件 (C-c C-e h o),link 将不会导出。
如果您还想 export/publish 您的 link,您可以使用:
#+OPTIONS: d:t \n:t
#+BEGIN_SRC python :results output drawer :exports both
for i in range(0,10):
print "[[./test%d.txt::100][test%d.txt::100]]" %(i,i)
#+END_SRC
d:t 选项指示导出抽屉,\n:t 选项指示保留换行符。
将您的 python 代码结果放入抽屉(:results 输出抽屉)允许组织模式将其解释为真正的组织模式代码。
我有一个文件列表,希望在单击文本时跳转到特定行。
#+BEGIN_SRC python :results output
for i in range(0,10):
print "[[./test%d.txt:100]]"%i
#+END_SRC
#+RESULTS:
#+begin_example
[[./test0.txt:100]]
[[./test1.txt:100]]
[[./test2.txt:100]]
[[./test3.txt:100]]
[[./test4.txt:100]]
[[./test5.txt:100]]
[[./test6.txt:100]]
[[./test7.txt:100]]
[[./test8.txt:100]]
[[./test9.txt:100]]
#+end_example
如果末尾没有行号,点击文本行将打开文件但不会跳转到特定行号。
我应该如何更改语法以跳转到行号?
在您的示例中,唯一的问题是 Org external links 的语法。是
[[./test%d.txt::100]] (and not [[./test%d.txt:100]])
这将在您的 Emacs Org 缓冲区中工作,但是如果您发布文件 (C-c C-e h o),link 将不会导出。
如果您还想 export/publish 您的 link,您可以使用:
#+OPTIONS: d:t \n:t
#+BEGIN_SRC python :results output drawer :exports both
for i in range(0,10):
print "[[./test%d.txt::100][test%d.txt::100]]" %(i,i)
#+END_SRC
d:t 选项指示导出抽屉,\n:t 选项指示保留换行符。
将您的 python 代码结果放入抽屉(:results 输出抽屉)允许组织模式将其解释为真正的组织模式代码。