Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
99 lines (85 sloc) 3.85 KB

Starter Kit Org

This is part of the Emacs Starter Kit.

Starter Kit Org

Configuration for the eminently useful Org Mode.

Org-mode is for keeping notes, maintaining ToDo lists, doing project planning, and authoring with a fast and effective plain-text system. Org Mode can be used as a very simple folding outliner or as a complex GTD system or tool for reproducible research and literate programming.

For more information on org-mode check out worg, a large Org-mode wiki which is also implemented using Org-mode and git.

Helpful Packages

(require 'org-install)
(setq org-support-shift-select t)
(setq org-completion-use-ido t)
;; (if window-system (require 'org-mouse))

;; Compatibility with WindMove
;; Make windmove work in org-mode:
(add-hook 'org-metaup-hook 'windmove-up)
(add-hook 'org-metaleft-hook 'windmove-left)
(add-hook 'org-metadown-hook 'windmove-down)
(add-hook 'org-metaright-hook 'windmove-right)
;; (add-hook 'org-shiftup-final-hook 'windmove-up)
;; (add-hook 'org-shiftleft-final-hook 'windmove-left)
;; (add-hook 'org-shiftdown-final-hook 'windmove-down)
;; (add-hook 'org-shiftright-final-hook 'windmove-right)

Org-Mode Hook

The latest version of yasnippets doesn’t play well with Org-mode, the following function allows these two to play nicely together

(defun yas/org-very-safe-expand ()
  (let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
(add-hook 'org-mode-hook
          (lambda ()
            (local-set-key "\M-\C-n" 'outline-next-visible-heading)
            (local-set-key "\M-\C-p" 'outline-previous-visible-heading)
            (local-set-key "\M-\C-u" 'outline-up-heading)
            ;; table
            (local-set-key "\M-\C-w" 'org-table-copy-region)
            (local-set-key "\M-\C-y" 'org-table-paste-rectangle)
            (local-set-key "\M-\C-l" 'org-table-sort-lines)
            ;; display images
            (local-set-key "\M-I" 'org-toggle-iimage-in-org)
            ;; yasnippet (using the new org-cycle hooks)
            (make-variable-buffer-local 'yas/trigger-key)
            (setq yas/trigger-key [tab])
            (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
            (define-key yas/keymap [tab] 'yas/next-field)
            ))

Support for viewing images

This allows for the viewing of images in-line in Org-mode documents.

(require 'iimage)
(setq iimage-mode-image-search-path (expand-file-name "~/"))
;; Match org file: links
(add-to-list 'iimage-mode-image-regex-alist
             (cons (concat "\\[\\[file:\\(~?" iimage-mode-image-filename-regex
                           "\\)\\]")  1))
(defun org-toggle-iimage-in-org ()
  (interactive)
  (let ((turning-on (not iimage-mode)))
    (set-face-underline-p 'org-link (not turning-on))
    (iimage-mode (or turning-on 0))))

Starter Kit Documentation

This code defines the starter-kit-project which is used to publish the documentation for the Starter Kit to html.

(unless (boundp 'org-publish-project-alist)
  (setq org-publish-project-alist nil))
(let ((this-dir (file-name-directory (or load-file-name buffer-file-name))))
  (add-to-list 'org-publish-project-alist
               `("starter-kit-documentation"
                 :base-directory ,this-dir
                 :base-extension "org"
                 :style "<link rel=\"stylesheet\" href=\"emacs.css\" type=\"text/css\"/>"
                 :publishing-directory ,(expand-file-name "doc" this-dir)
                 :index-filename "starter-kit.org"
                 :auto-postamble nil)))