-;; Time-stamp: <2015-03-05 21:07:40 kmodi>
+;; Time-stamp: <2015-03-09 11:07:45 kmodi>
 
 ;; Org Mode
 

            ;; (remove-hook 'org-tree-slide-play-hook #'my/org-tree-slide-start)
            (add-hook 'org-tree-slide-stop-hook #'my/org-tree-slide-stop)
            ;; (remove-hook 'org-tree-slide-stop-hook #'my/org-tree-slide-stop)
            ))

      (use-package ox
          :commands (org-export-dispatch) ; bound to `C-c C-e' in org-mode

      ;; the edit.
      (with-eval-after-load 'org-src
        (bind-key "C-x C-s" #'org-edit-src-exit org-src-mode-map))

      ;; http://orgmode.org/manual/Easy-Templates.html
      ;; http://oremacs.com/2015/03/07/hydra-org-templates
      ;; https://github.com/abo-abo/hydra/wiki/Org-mode-block-templates
      (defhydra hydra-org-template (:color blue :hint nil)
        "
_c_enter  _q_uote     _E_macs-lisp    _L_aTeX:
_l_atex   _e_xample   _v_erilog       _i_ndex:
_a_scii   _v_erse     _S_hell         _I_NCLUDE:
_s_rc     ^ ^         _t_ext          _H_TML:
_h_tml    ^ ^         ^ ^             _A_SCII:
"
        ("s" (hot-expand "<s")) ; #+BEGIN_SRC ... #+END_SRC
        ("E" (progn
               (hot-expand "<s")
               (insert "emacs-lisp")
               (forward-line)))
        ("v" (progn
               (hot-expand "<s")
               (insert "systemverilog")
               (forward-line)))
        ("S" (progn
               (hot-expand "<s")
               (insert "sh")
               (forward-line)))
        ("t" (progn
               (hot-expand "<s")
               (insert "text")
               (forward-line)))
        ("e" (hot-expand "<e")) ; #+BEGIN_EXAMPLE ... #+END_EXAMPLE
        ("q" (hot-expand "<q")) ; #+BEGIN_QUOTE ... #+END_QUOTE
        ("V" (hot-expand "<v")) ; #+BEGIN_VERSE ... #+END_VERSE
        ("c" (hot-expand "<c")) ; #+BEGIN_CENTER ... #+END_CENTER
        ("l" (hot-expand "<l")) ; #+BEGIN_LaTeX ... #+END_LaTeX
        ("L" (hot-expand "<L")) ; #+LaTeX:
        ("h" (hot-expand "<h")) ; #+BEGIN_HTML ... #+END_HTML
        ("H" (hot-expand "<H")) ; #+HTML:
        ("a" (hot-expand "<a")) ; #+BEGIN_ASCII ... #+END_ASCII
        ("A" (hot-expand "<A")) ; #+ASCII:
        ("i" (hot-expand "<i")) ; #+INDEX: line
        ("I" (hot-expand "<I")) ; #+INCLUDE: line
        ("<" self-insert-command "<")
        ("o" nil         "quit"))

      (defun hot-expand (str)
        "Expand org template."
        (insert str)
        (org-try-structure-completion))

      (define-key org-mode-map "<" (λ (if (looking-back "^")
                                          (hydra-org-template/body)
                                        (self-insert-command 1))))
      ))


