lang/org: move custom links into new hook function
This commit is contained in:
parent
2ca2050c6d
commit
ecaa8fc7cd
1 changed files with 45 additions and 43 deletions
|
@ -73,7 +73,8 @@
|
|||
+org|setup-agenda
|
||||
+org|setup-keybinds
|
||||
+org|setup-hacks
|
||||
+org|setup-pretty-code))
|
||||
+org|setup-pretty-code
|
||||
+org|setup-custom-links))
|
||||
|
||||
(add-hook! 'org-mode-hook
|
||||
#'(doom|disable-line-numbers ; org doesn't really need em
|
||||
|
@ -174,6 +175,48 @@ unfold to point on startup."
|
|||
:src_block "#+BEGIN_SRC"
|
||||
:src_block_end "#+END_SRC"))
|
||||
|
||||
(defun +org|setup-custom-links ()
|
||||
"Set up custom org links."
|
||||
(setq org-link-abbrev-alist
|
||||
'(("github" . "https://github.com/%s")
|
||||
("youtube" . "https://youtube.com/watch?v=%s")
|
||||
("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))
|
||||
|
||||
;; highlight broken links
|
||||
(org-link-set-parameters
|
||||
"file"
|
||||
:face (lambda (path)
|
||||
(if (or (file-remote-p path)
|
||||
(file-exists-p path))
|
||||
'org-link
|
||||
'error)))
|
||||
|
||||
(eval-when-compile
|
||||
(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)
|
||||
(if (file-exists-p (expand-file-name link ,dir))
|
||||
'org-link
|
||||
'error)))))
|
||||
|
||||
(def-org-file-link! "org" org-directory)
|
||||
(def-org-file-link! "doom" doom-emacs-dir)
|
||||
(def-org-file-link! "doom-docs" doom-docs-dir)
|
||||
(def-org-file-link! "doom-modules" doom-modules-dir))
|
||||
|
||||
(defun +org|setup-ui ()
|
||||
"Configures the UI for `org-mode'."
|
||||
(setq-default
|
||||
|
@ -236,48 +279,7 @@ unfold to point on startup."
|
|||
(face-attribute (or (cadr (assq 'default face-remapping-alist))
|
||||
'default)
|
||||
:background nil t))))
|
||||
(add-hook 'doom-load-theme-hook #'+org|update-latex-preview-background-color)
|
||||
|
||||
;; Custom links
|
||||
(setq org-link-abbrev-alist
|
||||
'(("github" . "https://github.com/%s")
|
||||
("youtube" . "https://youtube.com/watch?v=%s")
|
||||
("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))
|
||||
|
||||
;; highlight broken links
|
||||
(org-link-set-parameters
|
||||
"file"
|
||||
:face (lambda (path)
|
||||
(if (or (file-remote-p path)
|
||||
(file-exists-p path))
|
||||
'org-link
|
||||
'error)))
|
||||
|
||||
(eval-when-compile
|
||||
(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)
|
||||
(if (file-exists-p (expand-file-name link ,dir))
|
||||
'org-link
|
||||
'error)))))
|
||||
|
||||
(def-org-file-link! "org" org-directory)
|
||||
(def-org-file-link! "doom" doom-emacs-dir)
|
||||
(def-org-file-link! "doom-docs" doom-docs-dir)
|
||||
(def-org-file-link! "doom-modules" doom-modules-dir))
|
||||
(add-hook 'doom-load-theme-hook #'+org|update-latex-preview-background-color))
|
||||
|
||||
(defun +org|setup-keybinds ()
|
||||
"Sets up org-mode and evil keybindings. Tries to fix the idiosyncrasies
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue