HOME

org-mode-init

Org

You're looking at it.

Org-Babel

Fontify code blocks in an Org file:

(setq org-src-fontify-natively t)
(require 'ob)

(add-to-list 'org-babel-tangle-lang-exts '("clojure" . "clj"))
(add-to-list 'org-babel-tangle-lang-exts '("haskell" . "hs"))

(defun toby/babel-hook ()
            (condition-case nil
                (org-display-inline-images)
              (error nil)))

(add-hook 'org-babel-after-execute-hook
          'toby/babel-hook
          'append)

(add-to-list 'org-structure-template-alist
             '("el"  "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC" "<src lang=\"?\">\n\n</src>"))
(add-to-list 'org-structure-template-alist
             '("hs"  "#+BEGIN_SRC haskell\n?\n#+END_SRC" "<src lang=\"?\">\n\n</src>"))

This adds syntax highlighting to org-babel html exports.

(require-package 'htmlize)
(setq org-export-htmlize-output-type 'css)

To regenerate syntax highlighting CSS (for the active theme):

(org-export-htmlize-generate-css)

Org Publish

Org Publish

(setq org-publish-project-alist
      `(("Github Site"
         :base-directory       ,(expand-file-name "~/Code/tobytripp.github.com/org")
         :base-extension       "org"
         :recursive            t
         :publishing-function  org-html-publish-to-html
         :html-preamble ,(concat "<p><a accesskey=\"H\" href=\"index.html\">HOME</a></p>")
         :publishing-directory ,(expand-file-name "~/Code/tobytripp.github.com/"))
        ("emacs-config"
         :base-directory       ,org-lib-dir
         :base-extension       "org"
         :recursive            t
         :publishing-function  org-html-publish-to-html
         :htmlized-source      t
         :html-preamble ,(concat "<p><a accesskey=\"H\" href=\"index.html\">HOME</a></p>")
         :publishing-directory ,(concat dotfiles-dir "html"))))

Literate Haskell

Automatically load and run Haskell code after it's been “tangeled” (had the source code parsed out into source files).

Tangle with: C-c C-v t (org-babel-tangle)

(defun toby/tangle-and-run ()
  (cond
   ((eq 'haskell-mode major-mode)
    (message "Loading tangled buffer in haskell mode!")
    (inferior-haskell-load-file)
    (switch-to-haskell))))

(add-hook 'org-babel-post-tangle-hook 'toby/tangle-and-run)
(define-key org-mode-map (kbd "<f6>") 'org-babel-tangle)

Org-Mode Presentations

Org-Reveal is an org-mode export extension for creating presentations with reveal.js.

(require 'ox-reveal)
(setq org-reveal-root
      (concat "file://" (expand-file-name dotfiles-dir)
              "html/js/reveal.js-3.0.0/js/reveal.js"))

(add-hook 'org-mode-hook
          (lambda ()
            ;; (load-library "ox-reveal")
            (local-set-key (kbd "s-r") 'org-babel-tangle)))

(defadvice org-html-src-block
  (after toby/wrap-org-html-src-in-code-tag activate)
  (setq ad-return-value (replace-regexp-in-string
                         "\\(<pre[^>]+src-\\([^\"]+\\)\">\\)\\([^<]+\\)</pre>"
                         "\\1<code class=\"\\2\">\\3</code></pre>"
                         ad-return-value)))

(setq reveal-highlight-theme "zenburn")

(defadvice org-reveal-stylesheets
  (after toby/add-highlight-styles (info) activate)
  "Add stylesheet declaration for highlight.js formatting"
  (let* ((root-path (plist-get info :reveal-root))
         (css-path (concat root-path "/plugin/highlight/styles")))
    (setq ad-return-value
          (concat ad-return-value
                  (format "<link rel=\"stylesheet\" href=\"%s\">\n"
                          (concat css-path "/" reveal-highlight-theme ".css"))))))

Author: Toby Tripp

Created: 2015-02-04 Wed 10:41

Emacs 24.3.1 (Org mode 8.2.10)

Validate