在组织模式下列出指向标头的所有入站链接

Tru*_*ong 5 emacs org-mode

说我有一个带有标题的组织模式文件和指向标题的链接(链接在文件中)。有什么方法可以列出缓冲区中当前标头的所有入站链接,当我按Enter或单击一项时,它会跳到链接?

例:

* Header 1
  Contents of header 1.
* Header 2
  [[Header 1][Link 1]]
* Header 3
  [[Header 1][Link 2]]
Run Code Online (Sandbox Code Playgroud)

当我处于页眉1时,我想要文件中指向页眉1的所有链接(即“链接1”和“链接2”)的列表在缓冲区中显示;当我单击或在“链接2”行上按Enter时,它跳到标题2中的链接2。

ffe*_*tte 5

您可以使用occur通过在缓冲区中搜索[[Header Name][和显示匹配行来查找链接occur-mode。这是一个自动执行此操作的函数(org-heading-components用于获取当前标题名称):

(defun my/get-links-to-current-heading ()
  (interactive)
  (let ((title (nth 4 (org-heading-components))))
    (occur (concat "\\[\\[" title "\\]\\["))))
Run Code Online (Sandbox Code Playgroud)

使用org-occur而不是occur将匹配列表显示为当前组织缓冲区中的稀疏树。