lang/org: add more org links & abbrevs
New org, doom, doom-module and doom-docs links, with completion and non-existing file highlights.
This commit is contained in:
parent
7e21d66bf7
commit
169cd809bc
1 changed files with 29 additions and 8 deletions
|
@ -171,14 +171,35 @@ unfold to point on startup."
|
||||||
:background nil t)))
|
:background nil t)))
|
||||||
|
|
||||||
;; Custom links
|
;; Custom links
|
||||||
(org-link-set-parameters
|
(setq org-link-abbrev-alist
|
||||||
"org"
|
'(("github" . "https://github.com/%s")
|
||||||
:complete (lambda () (+org-link-read-file "org" +org-dir))
|
("youtube" . "https://youtube.com/watch?v=%s")
|
||||||
:follow (lambda (link) (find-file (expand-file-name link +org-dir)))
|
("google" . "https://google.com/search?q=")
|
||||||
|
("gimages" . "https://google.com/images?q=%s")
|
||||||
|
("gmap" . "https://maps.google.com/maps?q=%s")
|
||||||
|
("duckduckgo" . "https://duckduckgo.com/?q=%s")
|
||||||
|
("wolfram" . "https://wolframalpha.com/input/?i=%s")
|
||||||
|
("doom-repo" . "https://github.com/hlissner/doom-emacs/%s")))
|
||||||
|
|
||||||
|
(defun +org--relpath (path root)
|
||||||
|
(if (and buffer-file-name (file-in-directory-p buffer-file-name root))
|
||||||
|
(file-relative-name path)
|
||||||
|
path))
|
||||||
|
|
||||||
|
(defmacro def-org-file-link! (key dir)
|
||||||
|
`(org-link-set-parameters
|
||||||
|
,key
|
||||||
|
:complete (lambda () (+org--relpath (+org-link-read-file ,key ,dir) ,dir))
|
||||||
|
:follow (lambda (link) (find-file (expand-file-name link ,dir)))
|
||||||
:face (lambda (link)
|
:face (lambda (link)
|
||||||
(if (file-exists-p (expand-file-name link +org-dir))
|
(if (file-exists-p (expand-file-name link ,dir))
|
||||||
'org-link
|
'org-link
|
||||||
'error)))
|
'(:inherit (error underline))))))
|
||||||
|
|
||||||
|
(def-org-file-link! "org" +org-dir)
|
||||||
|
(def-org-file-link! "doom" doom-emacs-dir)
|
||||||
|
(def-org-file-link! "doom-module" doom-modules-dir)
|
||||||
|
(def-org-file-link! "doom-docs" doom-docs-dir)
|
||||||
|
|
||||||
;; Update UI when theme is changed
|
;; Update UI when theme is changed
|
||||||
(add-hook 'doom-init-theme-hook #'+org|setup-ui))
|
(add-hook 'doom-init-theme-hook #'+org|setup-ui))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue