#+TITLE: config #+AUTHOR: screwlisp #+PROPERTY: header-args:elisp :tangle no :eval no To go in ~/.emacs.d/config.org . The idea is it will ==M-x org-babel-tangle == 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. Later this file can be lob-ingest'ed at startup by emacs. I will provide a kbd-macro derived function for adding a new block ** Block-adder 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 (end-of-buffer) (insert "..") (org-insert-heading "") (insert "my-heading\n") (insert "#+name: my-name") (org-babel-demarcate-block) (end-of-buffer) (insert ".\n") #+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 *** 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 org file. .. *** my-heading #+name: my-nameelisp #+begin_src lisp #+end_src .