我在 Emacs
中使用 org-mode
来记录我的开发事件。我必须不断地手工完成的任务之一是描述代码区域。 Emacs
有一个非常好的 Bookmark List : 使用CTRL-x r m 创建书签,使用CTRL 列出它们-x r l。这非常有用,但不是我所需要的。
org-mode有链接的概念,命令org-store-link
会在任意文件中记录一个指向当前位置的链接,可以粘贴到org-file中。这个问题有两个方面:
- 它被存储为一个组织链接,链接的位置不直接可见(只是描述)。
- 以
file/search
的格式存储,这不是我想要的。
我需要文本形式的书签,以便我可以将其复制粘贴到 org-mode 中,并在需要时结束编辑,使用如下简单格式:
absolute-file-path:line
而这个必须是从当前点位置获取的。工作流程将非常简单:
- 转到我要记录的位置
- 调用函数:
position-to-kill-ring
(我会将它绑定(bind)到键盘快捷键) - 转到
org-mode
缓冲区。 - 猛拉位置。
- 根据需要进行编辑(有时我需要通过相对路径更改绝对路径,因为我的代码位于不同机器的不同位置)
不幸的是我的 lisp
不存在,所以我不知道该怎么做。我的问题有简单的解决方案吗?
最佳答案
(defun position-to-kill-ring ()
"Copy to the kill ring a string in the format \"file-name:line-number\"
for the current buffer's file name, and the line number at point."
(interactive)
(kill-new
(format "%s:%d" (buffer-file-name) (save-restriction
(widen) (line-number-at-pos)))))
关于Emacs 组织模式 : textual reference to a file:line,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10681766/