浏览代码

Org-Brain support

Eiyeron Fulmincendii 6 年之前
父节点
当前提交
18a7ad2efc
共有 2 个文件被更改,包括 41 次插入1 次删除
  1. 1 1
      layers.el
  2. 40 0
      packages.el

+ 1 - 1
layers.el

@@ -1 +1 @@
-(configuration-layer/declare-layer '(org org-bullets org-agenda org-babel))
+(configuration-layer/declare-layer '(org org-bullets org-agenda org-babel org-brain))

+ 40 - 0
packages.el

@@ -34,6 +34,8 @@
     org
     org-agenda
     org-bullets
+    org-brain
+    all-the-icons
     )
   "The list of Lisp packages required by the chicken-dotfiles layer.
 
@@ -63,6 +65,44 @@ installed using the Emacs package manager.
 recipe.  See: https://github.com/milkypostman/melpa#recipe-format"
   )
 
+(defun chicken-dotfiles/init-org-brain()
+  (use-package org-brain
+    :defer t
+    :init
+    (setq org-brain-path "D:/Notes/Brain")
+    :config
+    (setq org-id-locations-file "~/.emacs.d/.org-id-locations")
+    (evil-set-initial-state 'org-brain-visualize-mode 'emacs)
+
+    ;; See https://github.com/Kungsgeten/org-brain#all-the-icons
+    (defun org-brain-insert-resource-icon (link)
+      "Insert an icon, based on content of org-mode LINK."
+      (insert (format "%s "
+                      (cond ((string-prefix-p "http" link)
+                             (cond ((string-match "wikipedia\\.org" link)
+                                    (all-the-icons-faicon "wikipedia-w"))
+                                   ((string-match "github\\.com" link)
+                                    (all-the-icons-octicon "mark-github"))
+                                   ((string-match "vimeo\\.com" link)
+                                    (all-the-icons-faicon "vimeo"))
+                                   ((string-match "youtube\\.com" link)
+                                    (all-the-icons-faicon "youtube"))
+                                   ((string-match "bitbucket\\.org" link)
+                                    (all-the-icons-faicon "bitbucket"))
+                                   ((string-match "stackoverflow\\.com" link)
+                                    (all-the-icons-faicon "stack-overflow"))
+                                   ((string-match "\\.pdf$" link)
+                                    (all-the-icons-octicon "file-pdf"))
+                                   (t
+                                    (all-the-icons-faicon "globe"))))
+                            ((string-prefix-p "brain:" link)
+                             (all-the-icons-fileicon "brain"))
+                            (t
+                             (all-the-icons-icon-for-file link))))))
+
+    (add-hook 'org-brain-after-resource-button-functions #'org-brain-insert-resource-icon)
+    ))
+
 (defun chicken-dotfiles/post-init-org-bullets()
   (use-package org-bullets
     :defer t