alphapapa / alphapapa/transclusion-in-emacs
Transclusion as overlay using org-link
- 主要语言
- 没有语言数据
- 星标
- 96
- 派生
- 4
- PR 合并指标
- 30 天内没有已合并 PR
描述
I've experimented a bit with using `org-link` to create a sort of transclusion. The basic functionality is there, but it could probably be improved upon quite a lot. I haven't publilshed it anywhere else, but here it is if someone is interested. After the code has been added to Emacs you could use `org-insert-link` and choose `peek` and choose a file that you wish to transclude.
```
(defun org-peek-link-activate-func (start end path bracketp)
(remove-overlays start end)
(when (file-exists-p path)
(let ((overlay (make-overlay start end nil t)))
(overlay-put overlay 'display
(with-temp-buffer
(insert-file-contents path)
(buffer-string)))
(overlay-put overlay 'before-string (concat "PEEK: " path "\n"))
(overlay-put overlay 'face 'org-quote)
(overlay-put overlay 'evaporate t))))
(defun org-peek-link-complete (&optional arg)
"Create a peek link using completion.
Modified version of `org-file-complete-link'."
(let ((file (read-file-name "File: "))
(pwd (file-name-as-directory (expand-file-name ".")))
(pwd1 (file-name-as-directory (abbreviate-file-name
(expand-file-name ".")))))
(cond ((equal arg '(16))
(concat "peek:"
(abbreviate-file-name (expand-file-name file))))
((string-match
(concat "^" (regexp-quote pwd1) "\\(.+\\)") file)
(concat "peek:" (match-string 1 file)))
((string-match
(concat "^" (regexp-quote pwd) "\\(.+\\)")
(expand-file-name file))
(concat "peek:"
(match-string 1 (expand-file-name file))))
(t (concat "peek:" file)))))
(org-link-set-parameters "peek"
:activate-func 'org-peek-link-activate-func
:complete 'org-peek-link-complete)
```
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。