#+TITLE: my-org-config
#+AUTHOR: screwlisp
#+PROPERTY: header-args:elisp :tangle ~/.emacs.d/my-org-config.el

To go in ~/.emacs.d/config.org .

The idea is it will ==M-x org-babel-tangle <RET>== into an elisp file
==my-org-config.el== that will be hooked into the
==~/.emacs.d/init.el== file which customises emacs on startup.

Well, this one is just intended for extending a config but it seems
pretty cool.

By the way, shift-tab on a heading (line starting ==*==) rotates
between
|-----------------------------|
| fold just toplevel headings |
| fold just all headings      |
| Open everything             |
|-----------------------------|
* Elisp config blocks
** Explanation
Org-babel has elisp blocks enabled by default.

Elisp is the language that implements emacs.

We can create and name source blocks to do our
session configuration.

** Block-adder
Implemented from a kbd-macro.

Which is to say I just C-x ( ... C-x ) where ... was me doing it by hand, once.
Followed by name- and insert- kbd macro.

This is just to be CALLed to append a template block to the end of this file.
(Below)
*** src
#+name: define-and-screwtape-block
#+begin_src elisp :results none :tangle no :eval yes
  (defalias 'screwtape-block
   (kmacro "M-> M-RET Y o u r SPC b l o c k SPC n a m e RET # + n a m e : SPC y o u r - c a l l - n a m e C-c C-v d e l i s p RET M-> RET RET Your text"))
  (screwtape-block)
#+end_src

Obvious improvements:
- Use org-mode elisp rather than a kbd-macro (do-like-me) especially heading navigation.
  - A Kbd-macro is just a simple list of key presses
- Interactively recieve a name rather than stubbing it
- Interactively choose language (currently we just know about elisp)
*** Call that.                                     :call_this_for_new_blocks:
Bug: Unfold headings before running! (shift-tab until no more ...)
Put the cursor on the next line and ==C-c C-c==
Appends a template heading and elisp src block to the end of the file
Which will get tangled and loaded on emacs' initialization.
#+CALL: define-and-screwtape-block()

** Calling blocks
*** Explanation
Let's just call blocks over here.
*** scratch
#+call: first-block()

#+RESULTS:
: first block!

** Blocks

*** First block
The block can be opened by putting the cursor somewhere on the block and pressing C-'
#+name: first-block
#+begin_src elisp
  (print "first block!")
#+end_src

Textual commentary.

*** Your block name
#+name: foo-to-bar
#+begin_src elisp
(setq foo 'bar)
#+end_src


Yourtext

*** foo value printer
#+name: foo-printer
#+begin_src elisp
(format "foo is %s" foo)
#+end_src

Yourtext

*** enable org blocks                                           :informative:
#+name: enable-org-blocks
#+begin_src elisp :results none
  (org-babel-do-load-languages
   'org-babel-load-languages
   '((org . t)))
#+end_src

A better / more permanent way to do this is:
==M-x customize-variable==
==org-babel-load-languages==
then INS and use the values menu to find org
(default is to enable)
Accept-and-save (rather than just accept) adds this to your config.

*** Enable calc blocks
#+name: enable-calc-blocks
#+begin_src elisp :Results none
  (org-babel-do-load-languages
   'org-babel-load-languages
   '((calc . t)))
#+end_src


Calc = org's spreadsheets. see [[enable org blocks]] for a better way.
It would be cool to do some calc, but I guess this is just an config file.