summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob L. Kreuze2019-01-26 19:31:29 -0500
committerJakob L. Kreuze2019-01-26 19:31:29 -0500
commit4c09a9783727163587899b89ecece541d454ad40 (patch)
tree84924ae486fadfd64bcda2ad1181dd98e1277919
parentb7ce859f032fd426a7f79f70eaad8141a3cb6503 (diff)
Add link type for personal wiki
-rw-r--r--jakob.org187
1 files changed, 127 insertions, 60 deletions
diff --git a/jakob.org b/jakob.org
index 64c1c3b..74cce86 100644
--- a/jakob.org
+++ b/jakob.org
@@ -1028,7 +1028,69 @@ declarations.
("C-c t" . (lambda () (interactive) (org-capture nil "t")))
:map org-mode-map
("C-c C-q" . counsel-org-tag)
- ("C-c s" . org-goto)))
+ ("C-c s" . org-goto))
+#+END_SRC
+
+** Personal Wiki
+
+I maintain somewhat of a "personal wiki" using Org and I like to link between
+pages. This is just a convenience link type, rooted at the base of my notes
+folder so that I can easily refer to other pages from subdirectories of
+=notes-directory=.
+
+#+BEGIN_SRC elisp
+ :config
+ (defvar notes-directory "~/Notes"
+ "Where all the pages of my 'personal wiki' are stored.")
+
+ (defun org-notes-follow (link)
+ "Visits LINK, or if LINK names a subdirectory of
+ `notes-directory', the 'Index.org' in LINK."
+ (let ((directory-p (file-directory-p (expand-file-name link notes-directory))))
+ (find-file (expand-file-name (if directory-p "Index.org" (concat link ".org"))
+ notes-directory))))
+
+ (org-link-set-parameters "note" :follow #'org-notes-follow)
+#+END_SRC
+
+Code for generating hierarchical category listings.
+
+#+BEGIN_SRC elisp
+ :config
+ (defvar notes-directory-ignore
+ '("." ".." ".git" ".gitignore" "Drill"
+ "Finance" "GTD" "Interviewing" "Mind Dumps")
+ "Files and directories in `notes-directory' to exclude from
+ wiki interactions.")
+
+ (defun insert-notes-hierarchy (&optional current indent)
+ "Inserts an unordered Org list filled with links representing
+ the hierarchy of `current'. Useful for generating index pages."
+ (interactive)
+ (let* ((current (or current "."))
+ (indent (or indent ""))
+ (path (expand-file-name current notes-directory))
+ (files (remove-if #'(lambda (file) (member file notes-directory-ignore))
+ (directory-files path))))
+ (dolist (file files)
+ (when (not (string= file "Index.org"))
+ (let* ((name (if (string= (subseq file (- (length file) 4)) ".org")
+ (subseq file 0 (- (length file) 4))
+ file))
+ (name (if (string= current ".")
+ name
+ (concat current "/" name)))
+ (path (expand-file-name name notes-directory)))
+ (if (file-directory-p path)
+ (let ((index-path (concat path "/Index.org")))
+ (insert (if (file-exists-p index-path)
+ (format "%s- [[note:%s/Index.org][%s]]" indent name name)
+ (format "%s- %s" indent name)))
+ (newline)
+ (insert-notes-hierarchy name (concat " " indent)))
+ (progn
+ (insert (format "%s- [[note:%s][%s]]" indent name name))
+ (newline))))))))
#+END_SRC
** Workflow
@@ -1038,19 +1100,20 @@ thoughts. They're dated and saved in a directory so I can =ag= them. This is the
closest thing I will ever have to an implementation of =ag= for my thoughts.
#+BEGIN_SRC elisp
-(defvar mind-dump-directory "~/Notes/Mind Dumps"
- "Where to store dated 'mind dump' files.")
+ :config
+ (defvar mind-dump-directory "~/Notes/Mind Dumps"
+ "Where to store dated 'mind dump' files.")
-(defun mind-dump-filename ()
- "Returns the path of today's 'mind dump' file."
- (concatenate 'string
- (file-name-as-directory mind-dump-directory)
- (format-time-string "%Y-%m-%d")
- ".org"))
+ (defun mind-dump-filename ()
+ "Returns the path of today's 'mind dump' file."
+ (concatenate 'string
+ (file-name-as-directory mind-dump-directory)
+ (format-time-string "%Y-%m-%d")
+ ".org"))
-(let* ((buffer (find-file-noselect (mind-dump-filename))))
- (set-buffer buffer)
- (rename-buffer "*Mind Dump*"))
+ (let* ((buffer (find-file-noselect (mind-dump-filename))))
+ (set-buffer buffer)
+ (rename-buffer "*Mind Dump*"))
#+END_SRC
** Capture
@@ -1058,11 +1121,12 @@ closest thing I will ever have to an implementation of =ag= for my thoughts.
Low-friction of adding things to the day's "mind dump" and my GTD inbox.
#+BEGIN_SRC elisp
-(setq org-capture-templates
- `(("c" "Thought" plain (file ,(mind-dump-filename))
- "%?\n")
- ("t" "TODO" entry (file "~/Notes/GTD/Inbox.org")
- "* TODO %?\n")))
+ :init
+ (setq org-capture-templates
+ `(("c" "Thought" plain (file ,(mind-dump-filename))
+ "%?\n")
+ ("t" "TODO" entry (file "~/Notes/GTD/Inbox.org")
+ "* TODO %?\n")))
#+END_SRC
** Agenda
@@ -1074,52 +1138,53 @@ Rather convoluted agenda setup to show me:
- A view of deadlines and scheduled items for the week ahead.
#+BEGIN_SRC elisp
-(setq org-agenda-files '("~/Notes/GTD/Habits.org"
- "~/Notes/GTD/Inbox.org"
- "~/Notes/GTD/Actionable.org"))
+ :init
+ (setq org-agenda-files '("~/Notes/GTD/Habits.org"
+ "~/Notes/GTD/Inbox.org"
+ "~/Notes/GTD/Actionable.org"))
-(let ((entry-done
- '(lambda () (org-agenda-skip-entry-if 'todo 'done)))
+ (let ((entry-done
+ '(lambda () (org-agenda-skip-entry-if 'todo 'done)))
- (subtree-is-habit
- '(lambda ()
- (let ((subtree-end (save-excursion (org-end-of-subtree t))))
- (if (string= (org-entry-get nil "STYLE") "habit")
- subtree-end
- nil))))
+ (subtree-is-habit
+ '(lambda ()
+ (let ((subtree-end (save-excursion (org-end-of-subtree t))))
+ (if (string= (org-entry-get nil "STYLE") "habit")
+ subtree-end
+ nil))))
- (subtree-is-not-habit
- '(lambda ()
- (let ((subtree-end (save-excursion (org-end-of-subtree t))))
- (if (not (string= (org-entry-get nil "STYLE") "habit"))
- subtree-end
- nil))))
+ (subtree-is-not-habit
+ '(lambda ()
+ (let ((subtree-end (save-excursion (org-end-of-subtree t))))
+ (if (not (string= (org-entry-get nil "STYLE") "habit"))
+ subtree-end
+ nil))))
- (subtree-is-not-inbox
- '(lambda ()
- (let ((subtree-end (save-excursion (org-end-of-subtree t))))
- (if (not (search "Inbox.org" (buffer-name)))
- subtree-end
- nil)))))
+ (subtree-is-not-inbox
+ '(lambda ()
+ (let ((subtree-end (save-excursion (org-end-of-subtree t))))
+ (if (not (search "Inbox.org" (buffer-name)))
+ subtree-end
+ nil)))))
- (setq org-agenda-custom-commands
- `(("d" "Daily"
- ((tags "PRIORITY=\"A\""
- ((org-agenda-skip-function ,entry-done)
- (org-agenda-overriding-header "Tasks for Today:")))
- (alltodo ""
- ((org-agenda-skip-function ,subtree-is-not-inbox)
- (org-agenda-overriding-header "Inbox:")))
- (agenda ""
- ((org-agenda-span 'day)
- (org-agenda-skip-function ,subtree-is-not-habit)
- (org-deadline-warning-days 0)
- (org-agenda-overriding-header "Habits:")))
- (agenda ""
- ((org-agenda-span 'week)
- (org-agenda-skip-function ,subtree-is-habit)
- (org-agenda-overriding-header "Week Ahead:"))))
- ((org-agenda-compact-blocks t))))))
+ (setq org-agenda-custom-commands
+ `(("d" "Daily"
+ ((tags "PRIORITY=\"A\""
+ ((org-agenda-skip-function ,entry-done)
+ (org-agenda-overriding-header "Tasks for Today:")))
+ (alltodo ""
+ ((org-agenda-skip-function ,subtree-is-not-inbox)
+ (org-agenda-overriding-header "Inbox:")))
+ (agenda ""
+ ((org-agenda-span 'day)
+ (org-agenda-skip-function ,subtree-is-not-habit)
+ (org-deadline-warning-days 0)
+ (org-agenda-overriding-header "Habits:")))
+ (agenda ""
+ ((org-agenda-span 'week)
+ (org-agenda-skip-function ,subtree-is-habit)
+ (org-agenda-overriding-header "Week Ahead:"))))
+ ((org-agenda-compact-blocks t))))))
#+END_SRC
** Drill
@@ -1130,14 +1195,16 @@ them when I run =org-drill=. Combining topic during review sessions is
recommended by Michael Nielsen in his article, [[http://augmentingcognition.com/ltm.html]["Augmenting Long-term Memory"]].
#+BEGIN_SRC elisp
-(setq org-drill-scope 'directory)
+ :init
+ (setq org-drill-scope 'directory)
#+END_SRC
Shut up the nagging "are you studying enough!?" message if I don't get enough
items right on the first try. It's unhelpful and really just annoying.
#+BEGIN_SRC elisp
-(setq org-drill-forgetting-index 100)
+ :init
+ (setq org-drill-forgetting-index 100))
#+END_SRC
* Yasnippet

© 2015 - 2026 Jakob L. Kreuze