5.9 KiB
Org
Organize your plain-life in plain-text. The hallmark feature of Emacs, org-mode
1 is the king of markup languages. It has rich feature support for project management, scheduling, development, and writing. It's hard to convey everything within its capabilities.
Setup
Define a custom hook when org-mode
1 is enabled to customize the experience:
-
Enable
org-indent-mode
to indent and align text with the parent heading -
Enable
visual-line-mode
to allow text to overflow and wrap to the next visual line -
Enable
variable-pitch-mode
to support multiple font-pitches and monospaced fonts
(defun dotfiles/org-mode-hook () (org-indent-mode) ;; Indent and align text. (visual-line-mode 1) ;; Allow text to overflow line. (variable-pitch-mode 1)) ;; Enable monospaced fonts.
Config
Force straight
to ignore the local version of org-mode
1, instead downloading the most recent version available.
(straight-use-package '(org :local-repo nil))
Setup the default babel languages and structure templates, and apply customizations:
-
Setup
org-mode-hook
with our custom hook -
Setup
org-ellipsis
to show headlines with hidden contents -
Setup
org-log-*
for event logging -
Setup
org-src-*
for source blocks -
Setup
org-todo-keyword
sequence
(use-package org :hook (org-mode . dotfiles/org-mode-hook) :custom (org-ellipsis " ▾") (org-log-done 'time) (org-log-into-drawer t) (org-return-follows-link t) (org-image-actual-width nil) (org-directory dotfiles/home) (org-src-fontify-natively t) (org-src-tab-acts-natively t) (org-src-preserve-indentation t) (org-confirm-babel-evaluate nil) (org-todo-keywords '((sequence "TODO" "START" "WAIT" "DONE"))) :config (require 'org-tempo) ;; Required for structure templates. (add-to-list 'org-structure-template-alist '("s" . "src")) (add-to-list 'org-structure-template-alist '("q" . "quote")) (add-to-list 'org-structure-template-alist '("e" . "example")) (add-to-list 'org-structure-template-alist '("sh" . "src shell")) (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) (org-babel-do-load-languages 'org-babel-load-languages '((shell . t) (emacs-lisp . t))))
Pomodoro
Adds support for the Pomodoro workflow in Emacs through the org-pomodoro
2 package. Some workflows benefit from thje option to work a few minutes of overtime to finish a task before taking a break. With this workflow, a break notification is sent at the end of the pomodoro timer, but the break starts when calling M-x org-pomodoro
.
(use-package org-pomodoro :after org :custom (org-pomodoro-manual-break t) ;; Enable the 'overtime' workflow. (org-pomodoro-keep-killed-time t)) ;; Track abandoned timers.
Flashcards
Create study flashcards using org-drill
3, an extension for org-mode
. It uses a spaced repititon algorithm to conduct interactive drill sesslions using org-mode
buffers as sources of facts to be memorized. Each drill can be restricted to topics in the current buffer, one of several, all agenda files, or a single topic across all buffers.
(use-package org-drill :after org)
Headline stars
Make the headline stars a bit more super with org-superstar-mode
4. Only enable this inside of a window system, as the effect can be distracting on the TTY.
(use-package org-superstar :when (window-system) :after org :hook (org-mode . org-superstar-mode))
Methods
Define some custom methods for use in the rest of the configuration.
Tangle directory
Build all of the org
files within a given directory, recursively. This is used in CI.
(defun dotfiles/tangle (dir) "Recursively tangle the Org files within a directory." (interactive) (let ((org-files (directory-files-recursively dir "org"))) (dolist (f org-files) (org-babel-tangle-file f))))
Force symbolic links
Function that takes in a system and configuration file path, checks to see if the system file doesn't exist, or doesn't point to the configuration file, deleting it for the latter, then creating a symbolic link to the configuration file in place.
(defun dotfiles/symlink (src tgt) "Forces a symlink from `src' to `tgt'." (interactive) (let ((sys-file (expand-file-name tgt)) (dot-file (expand-file-name src))) (when (or (not (file-exists-p sys-file)) (not (equal (file-symlink-p sys-file) dot-file))) (delete-file sys-file) (make-symbolic-link dot-file sys-file))))
Shortcuts
Place org-mode
1 extension bindings behind SPC o
.
-
Drill with
d
-
Drill with
d
-
Resume with
r
-
-
Pomodoro with
p
(dotfiles/leader "o" '(:ignore t :which-key "Org") "od" '(:ignore t :which-key "Drill") "odd" '(org-drill :which-key "Drill") "odc" '(org-drill-cram :which-key "Cram") "odr" '(org-drill-resume :which-key "Resume") "op" '(org-pomodoro :which-key "Pomodoro"))