Browse Source

Started org-brain configuration.

Mostly a port from my spacemacs messy configuration
Eiyeron Fulmincendii 6 years ago
parent
commit
a6183e791f
2 changed files with 63 additions and 0 deletions
  1. 61 0
      config.org
  2. 2 0
      packages.el

+ 61 - 0
config.org

@@ -130,6 +130,67 @@ time I close an item might be the best thing as I'd get tired of the prompt
 really quickly. I'll reserve this to manual additions.
 really quickly. I'll reserve this to manual additions.
 #+BEGIN_SRC emacs-lisp
 #+BEGIN_SRC emacs-lisp
 (setq org-log-done 'time)
 (setq org-log-done 'time)
+** TODO Org Brain
+Here will be located a routine to determine which folder we want to write the
+default brain(s) down.
+#+BEGIN_SRC emacs-lisp
+;; TODO proper folder
+(add-hook! org-brain
+  (setq org-brain-path "c:/Notes/Work/Brain"))
+#+END_SRC
+
+A small fix to avoid org-brain's key bindings be overwritten by evil.
+#+BEGIN_SRC emacs-lisp
+(add-hook! org-brain
+  (evil-set-initial-state 'org-brain-visualize-mode 'emacs))
+#+END_SRC
+
+Working icon display with ~all-the-icons~ to have a small icon before various
+kind of resource links.
+#+BEGIN_SRC emacs-lisp
+(add-hook! org-brain
+  (defun org-brain-insert-resource-icon (link)
+    "Insert an icon, based on content of org-mode LINK."
+    (let ((starts_with_http (string-prefix-p "http" link)))
+      (insert (format "%s "
+                      (cond
+                       ;; File extensions
+                       ((string-suffix-p ".pdf" link)
+                        (all-the-icons-octicon "file-pdf"))
+                       ((string-match "\\.cpp" link)
+                        (all-the-icons-alltheicon "cplusplus"))
+                       ;; [TODO] This will break http file links to header files.
+                       ;; Use instead a more clever regex match
+                       ((and (string-match "\\.h" link)
+                             (not starts_with_http))
+                        (all-the-icons-alltheicon "cplusplus-line"))
+                       ((string-match "\\.hpp" link)
+                        (all-the-icons-alltheicon "cplusplus-line"))
+                       ;; URL
+                       (starts_with_http (cond
+                                          ((string-match "wikipedia\\.org" link)
+                                           (all-the-icons-faicon "wikipedia-w"))
+                                          ((string-match "app\\.nuclino\\.com" link)
+                                           (all-the-icons-fileicon "brain"))
+                                          ((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 "twitter\\.com" link)
+                                           (all-the-icons-faicon "twitter"))
+                                          ((string-match "reddit\\.com" link)
+                                           (all-the-icons-faicon "reddit"))
+                                          (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))
 #+END_SRC
 #+END_SRC
 * Blog writing
 * Blog writing
 I have a [[https://retroactive.me][blog]]. I want to use emacs as my platform to type bits and bobs on it.
 I have a [[https://retroactive.me][blog]]. I want to use emacs as my platform to type bits and bobs on it.

+ 2 - 0
packages.el

@@ -12,3 +12,5 @@
 
 
 ;; Graphviz, I love graphes!
 ;; Graphviz, I love graphes!
 (package! graphviz-dot-mode)
 (package! graphviz-dot-mode)
+;; Org-brain, my friend!
+(package! org-brain)