emacs - 是否可以使用组织模式链接在源代码内部导航

标签 emacs elisp org-mode

给定:

  1. 带有源代码的 elisp 文件
  2. 包含文档的 org 文件

典型源文件的方案:

;header, describing <code snippet 1>
<code snippet 1>

;header, describing <code snippet 2>
<code snippet 2>
...
;header, describing <code snippet n>
<code snippet n>

组织文件的方案:

* <file_name.el>
1. [[./<file_name.el>::1][header, describing <code snippet 1>]]
2. [[./<file_name.el>::<line of header 2>][header, describing <code snippet 2>]]
...
n. [[./<file_name.el>::<line of header n>][header, describing <code snippet n>]]

org 文件目前由我手动创建。当我单击该链接时,我将被重定向到文件的相应行。但是当源文件被修改时,我被重定向到错误的行。

是否可以更改当我单击链接时调用的函数,以便它搜索正则表达式:"^;header, describing <code snippet n>"而不是将我重定向到固定线路号码?

也许,您可以建议我一种更好的方法来在 org 文件和另一个文本文件的适当位置之间创建映射?

最佳答案

您可以在源文件中定义 anchor (即不会出现在文件中其他任何位置的单词),并在组织文件中链接到它们:

; <<foo>>
(defun foo ())

; <<bar>>
(defun bar ())
- [[file:source.el::<<foo>>][foo]]
- [[file:source.el::<<bar>>][bar]]

此类“文字搜索”链接仅限officially documented对于组织文件,但我怀疑它适用于每个基于文本的文件。

关于emacs - 是否可以使用组织模式链接在源代码内部导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24910380/

相关文章:

bash - Emacs ido 风格的 shell

emacs - 在 Emacs 中,视觉行尾转到下一行的开头

php - 使用 Emacs 和 GEBEN 调试多文件 PHP 脚本

emacs - Elisp:如何在字节编译时避免 "functions are not known to be defined"?

emacs - "Wrong type argument: stringp, cons"在串联列表上调用 apply 函数时

emacs - 在 emacs 中禁用或重新映射紧急逃生?

Emacs 元编程,动态定义方法

list - orgmode,引用编号列表中的项目

org-mode - orgmode - 更改代码块背景颜色

emacs - 将链接的组织文件添加到组织议程文件