Skip to content

Latest commit

 

History

History
336 lines (283 loc) · 12.7 KB

paolog-org.org

File metadata and controls

336 lines (283 loc) · 12.7 KB

Org-Mode configuration

Here, we configure and set up all kind of extensions and hacks for Org-mode. It is mostly derived from http://doc.norang.ca/org-mode.html ways and ideas.

I don’t use customize for Org because it gets too complicated.

Init

  • Text files should be in org-mode, as well as –obviously– org files.
(require 'org-install)
(add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . org-mode))

Bindings

Unbind keys

Unset C-[ and C-] in org-mode: it would alter our org-agenda-files, but we want to handle those programmatically.

(add-hook 'org-mode-hook #'(lambda ()
                            (local-unset-key (kbd "C-]"))
                            (local-unset-key (kbd "C-["))))

Custom key bindings

  • Global basic org keybindings. Note <F8> loops through the Agenda files.
    FunctionalityBindingMnemonic
    Capture a taskC-c c‘c’apture
    Agenda submenuC-c a‘a’genda
    Store linkC-c l‘link’
    Switch to Org bufferC-c b‘b’uffer
    Loop Org agenda files<F8>N/A
(global-set-key (kbd "C-c c") 'org-capture)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c l") 'org-store-link)
(global-set-key (kbd "C-c b") 'org-iswitchb)
(global-set-key (kbd "<f8>") 'org-cycle-agenda-files)

Code in Org

I use source code blocks now and then, especially for my init files. Make them easier to use by fontifying the code and making tab (almost) work.

(setq org-src-fontify-natively t)
(setq org-src-tab-acts-natively t)

Better visuals

  • Use UTF-8 bullets
    (i-require 'org-bullets)
    (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
        

Basic preferences

  • Can’t say a task is done unless all subtasks are already done.
(setq org-enforce-todo-dependencies t)
  • Create new headings after the current line, instead of after the current subtree
(setq org-insert-heading-respect-content nil)
  • Show context when revealing a location
(setq org-show-following-heading t)
(setq org-show-hierarchy-above t)
(setq org-show-siblings t)
  • Adapt commands to better behave in org
    (setq org-special-ctrl-a/e t)
    (setq org-special-ctrl-k t)
    (setq org-yank-adjusted-subtrees t)
        

Todo lists

Define the possible stages and transitions, and how they should appear in our buffers.

Here’s how I use the various stages:

StageShortcutMeaning
TODOtThis task is in my backlog
WEEKn (‘next’ in GTD)This is planned and will be done in the week
TODAYyI’m not doing this right now, but I think I will soon
DONEdNo more action is required. Think about archiving
SOMEDAYsI’m not planning to do this any time soon
WAITINGwSomeone or something must get back to me
DELEGATEDgSomeone or something is expected to do this, not me
CANCELEDcI thought I had to do this, but not anymore
MEETINGmI’m meeting someone. This is about it.
(setq org-use-fast-todo-selection t)
(setq org-todo-keywords
      (quote ((sequence "TODO(t)" "WEEK(n)" "TODAY(n)" "|" "DONE(d)" "SOMEDAY(s)")
              (sequence "WAITING(w@/!)" "DELEGATED(g@/!)" "|" "CANCELED(c@/!)" "MEETING(m)"))))

(setq org-todo-keyword-faces
      (quote (("TODO" :foreground "yellow" :weight bold)
              ("WEEK" :foreground "orange" :weight bold)
              ("TODAY" :foreground "red" :weight bold)
              ("DONE" :foreground "forest green" :weight bold)
              ("SOMEDAY" :foreground "navy blue" :weight bold)
              ("WAITING" :foreground "orange" :weight bold)
              ("DELEGATED" :foreground "magenta" :weight bold)
              ("CANCELED" :foreground "forest green" :weight bold)
              ("MEETING" :foreground "forest green" :weight bold))))

Agenda

  • We keep agenda Org files in ~/org/
    (setq org-agenda-files (directory-files-recursively "~/org/" "\\.org$" nil))
    (setq org-default-notes-file "~/org/notes.org")
        
  • Use the diary in the agenda
    (setq org-agenda-include-diary t)
    (setq org-agenda-diary-file "~/org/diary.org")
        
  • Deadlines are set for a month. They will show up in the agenda 30 days before they’re through.
    (setq org-deadline-warning-days 30)
        
  • What we want displayed in the log mode for the agenda
    (setq org-agenda-log-mode-items (quote (closed state)))
        
  • If a task is scheduled or has a timestamp, don’t display it in the TODO list part of the agenda
    (setq org-agenda-todo-ignore-scheduled t)
    (setq org-agenda-todo-ignore-timestamp t)
        
  • We use some personalized commands for the agenda:
    • Daily agenda and all Todos (n)
    • Week appts. + Daily agenda + Work (p)
    (setq org-agenda-custom-commands
          '(("n" "Agenda and all TODO's"
                           ((agenda "")
                            (alltodo "")))
    
            ("o" "Office daily agenda"
             ((agenda "" ((org-agenda-ndays 3)))
              (tags-todo "+PRIORITY=\"A\"")
              (tags-todo "@office")
              (tags "INBOX")
              (todo "WAITING"))
             ((org-agenda-compact-blocks t)))
    
            ("x" "Column view of todo" alltodo ""
             ((org-agenda-overriding-columns-format "%3PRIORITY %30ITEM(Task) %TIMESTAMP %DEADLINE %SCHEDULED")
              (org-agenda-view-columns-initially t)))
            ))
        
    • When showing the agenda, it should always go “fullscreen” (by that I mean use the whole frame). When quitting, go back to any previously existing window configuration.
      (defadvice org-agenda-list (around org-agenda-fullscreen activate)
        "Start agenda in fullscreen.
      
      After agenda loads, delete other windows.
      `org-agenda-restore-windows-after-quit' should non-nil to restore
      the previous window configuration. If `org-agenda-sticky' is
      non-nil, configurations with more than one window do not seem to
      be restored properly."
        ad-do-it
        (delete-other-windows))
      
      (setq org-agenda-restore-windows-after-quit t)
      
      (setq org-agenda-sticky nil)            ; this is required not to break this feature.
              

Capturing and refiling

  • The default directory for org files (where we should capture to) is ~/org/
    (setq org-directory "~/org")
        
  • Define what we can capture, and what template to use for each
    TemplateShortcutMeaning
    todotadd a todo action to the todo list
    notencapture a note (no action)
    meetingmcapture a meeting’s note
    phone callpcapture a phone call’s note
    (setq org-capture-templates
          (quote (("t" "todo" entry (file "~/org/todo.org")
                   "* TODO %?\n%U\n%a\n")
                  ("n" "note" entry (file "~/org/notes.org")
                   "* %? :NOTE:\n%U\n%a\n")
                  ("m" "Meeting" entry (file "~/org/notes.org")
                   "* MEETING wrt %? :MEETING:\n%U")
                  ("p" "Phone call" entry (file "~/org/notes.org")
                   "* PHONE %? :PHONE:\n%U"))))
        
  • Targets include this file and any file contributing to the agenda - up to 9 levels deep
    (setq org-refile-targets (quote ((nil :maxlevel . 9)
                                     (org-agenda-files :maxlevel . 9))))
        
  • We file directly with IDO. We need some settings to make it smooth.
    (setq org-refile-use-outline-path t)
    (setq org-outline-path-complete-in-steps nil)
    (setq org-refile-allow-creating-parent-nodes (quote confirm))
    (setq org-completion-use-ido t)
        
  • Use the current window for indirect buffer display
    (setq org-indirect-buffer-display 'current-window)
        

Footnotes

  • check org-footnote

Tagging

  • Define global fast tags.
    (setq org-tag-persistent-alist (quote ((:startgroup)
                                           ("@offline" . ?o)
                                           ("@office" . ?a)
                                           ("@home" . ?h)
                                           (:endgroup)
                                           ("PHONE" . ?T)
                                           ("PROJECT" . ?P)
                                           ("crypt" . ?k))))
        
  • Allow setting single tags without the menu
    (setq org-fast-tag-selection-single-key (quote expert))
        

Archiving

  • Archive in ~/Documents/archived.org under a file-based subtree, with status: ARCHIVED
(require 'org-archive)
(setq org-archive-mark-done "ARCHIVED")
(setq org-archive-location "~/Documents/archived.org::* Archive: %s")

Checklists

  • Enable the checklist magic
    • Need to better document this.
    ;       (i-require 'org-checklist)
        

Deft

Deft is an Emacs mode for quickly browsing, filtering, and editing directories of plain text notes, inspired by Notational Velocity.

(install-packages-if-needed 'deft)
(setq deft-extension "org")
(setq deft-directory org-directory)
(setq deft-text-mode 'org-mode)
(setq deft-use-filename-as-title t)
(global-set-key [f5] 'deft)

Encryption

  • Encrypt with a symmetric key all subtrees tagged as :crypt: on save.
    ;       (i-require 'org-crypt)
           ;; (org-crypt-use-before-save-magic)
           ;; (setq org-tags-exclude-from-inheritance (quote ("crypt")))
           ;; ;; GPG key to use for encryption
           ;; ;; Either the Key ID or set to nil to use symmetric encryption.
           ;; (setq org-crypt-key nil)
        
    • Decrypt entr(y|ies)
      (defun org-decrypt-dwim (arg)
        "Decrypt entry, but decrypt entries if ARG is passed."
        (interactive "P")
        (if arg
            (org-decrypt-entries)
          (org-decrypt-entry)))
      
      (add-hook 'org-mode-hook
                (lambda ()
                  (define-key
                    org-mode-map
                    (kbd "C-c s-c") 'org-decrypt-dwim)))
              

Extra links

  • On the Mac, get links from external apps (e.g. current selected mail in Outlook, current page in Chrome)
    ;; (i-require 'org-mac-link)
    ;; (add-hook 'org-mode-hook (lambda ()
    ;;                            (define-key org-mode-map (kbd "C-c C-g") 'org-mac-grab-link)))
    
        
    • Get magit links in org-mode
      (i-require 'orgit)
              

Journal

For journaling we use org-journal.

(i-require 'org-journal)
(setq org-journal-dir "~/Documents/Personal/journal/")