blob: ca57f696be08d7033a3c7235a3e9625215f947b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
(require 'org)
;; doc links
(defvar jao-org--sink-dir "./")
(org-add-link-type "doc" 'jao-org-follow-doc 'identity)
(defun jao-org-follow-doc (link)
(let ((dest-path (concat "./doc/"
(and (boundp 'docs-dir)
(concat (symbol-name docs-dir) "/"))
link)))
(when (not (file-exists-p dest-path))
(let* ((sink-file (expand-file-name link jao-org--sink-dir))
(real-file (if (file-exists-p sink-file) sink-file
(read-file-name "Import file: "
jao-org--sink-dir link link))))
(shell-command (format "mv %s %s" real-file dest-path))))
(browse-url (format "file://%s" (expand-file-name dest-path)))))
(defsubst jao-org--title->file (title)
(concat (mapconcat 'downcase (split-string title nil t) "-") ".pdf"))
(defun jao-org-insert-doc (title)
(interactive "sDocument title: ")
(insert (format "[[doc:%s][%s]]" (jao-org--title->file title) title)))
(defun jao-org-links-setup (sink-dir)
(setq jao-org--sink-dir (file-name-as-directory sink-dir)))
(provide 'jao-org-links)
|