我参照了 懒猫大神 popweb,基于Web技术的弹窗框架 extension 中插件的写法,完成了 使用 popweb 弹出预览 Org-Roam ID link 和 footnote link 的功能。 仓库地址如下:GitHub - czqhurricnae/popweb: Show popup web window for Emacs ,因为还不知道有没有致命的 bug,所以没有提交 pull request。
配置
配置,我用的是 Spacemacs,还需要另外安装 org-transclusion 这个包:
(defconst hurricane-org-packages
`(
(org-transclusion :location (recipe
:fetcher github
:repo "nobiot/org-transclusion"))
(popweb :location (recipe
:fetcher github
:repo "czqhurricnae/popweb"
:files ("*.*" "extension")))
)
)
(defun hurricane-org/init-org-transclusion ()
(use-package org-transclusion
:config
(setq org-transclusion-include-first-section t)
(setq org-transclusion-exclude-elements '(property-drawer keyword))))
;; /usr/bin/env python3 -m pip install PyQt5 PyQtWebEngine epc
(defun hurricane-org/init-popweb ()
(use-package popweb
:ensure t
:load-path ("elpa/27.2/develop/popweb-20220125.2025" "elpa/27.2/develop/popweb-20220125.2025/extension/latex" "elpa/27.2/develop/popweb-20220125.2025/extension/dict" "elpa/27.2/develop/popweb-20220125.2025/extension/org-roam")
:init
(add-hook 'latex-mode-hook #'popweb-latex-mode)
:config
(require 'popweb-latex)
(require 'popweb-dict-youdao)
(require 'popweb-dict-bing)
(require 'popweb-org-roam-link)))
安装依赖,在终端运行命令,我用的是 Mac:
/usr/bin/env python3 -m pip install PyQt5 PyQtWebEngine epc
或者参考 懒猫大神 的文档进行配置。
预览调用的命令是:popweb-org-roam-link-show
。
效果
效果如下:
-
弹出预览 Org-Roam ID link,只支持 ID 类型,不支持 file 类型。
-
弹出预览 footnote link。
不足
- 没有办法光标移动到支持的链接上时自动弹出预览。
- 预览内容中的图片如果过大不好查看,不知道如何调节预览窗口大小?(在 popweb 的代码中没有找到可以配置的地方)或者使用 org-export-string-as 时对导出图片大小进行调整?自己没有仔细研究,希望有人可以提下意见。