The story

The creativity that you apply and capture to assemble your system… this is where
all of the fun stuff is. Let me elaborate, everything in your artifacts are
valuable because they tell the story. Actually, they tell the story about a
story, a story that has yet to occur and also a story that has previously
occurred. It is here, where the actions lives, that all of those things are
learned, practiced, suffered accordingly from, and reveled in! In other words,
it is yet another story, a fun one.

If you haven’t noticed by now, either by hearing rumors, reading accounts, or
learning of it yourself: human beings are story-oriented. Your ability to
successfully function in and contribute to society will be directly proportional
to your ability to listen to stories, tell others’ stories, live your life such
that you have new stories to tell, and capture them in some form of persistent
storage. Stories grant us the power to learn from others wisdom that was
painfully acquired thousands of years ago, and it gives you a chance to
contribute the results of your hard work, for the future of humanity, too. A
belief system about the value of story-telling is essential, critical, and
mandatory to successfully achieve your goals with literate programming.

As I change, the story will change, and the action will change. The cycle will
never end.

Nevertheless, I will attempt to do my best here with the good part of me being
a flawless, rational, and logical human being to:

  • Deliver a supportable system
  • Deliver an adaptable system
  • Deliver an expandable system

A tiny org-mode literate programming Makefile

Basic build for a document:

INIT=.emacs.el
$(INIT): TC3F.org
	caffeinate -s time emacs --batch --no-init-file --load .org-mode.emacs.el --find-file TC3F.org --funcall org-babel-tangle --kill
TC3F.txt: $(INIT)
	caffeinate -s time emacs --batch --no-init-file --load .org-mode.emacs.el --find-file TC3F.org --funcall org-ascii-export-to-ascii --kill
TC3F.html: $(INIT)
	caffeinate -s time emacs --batch --no-init-file --load .org-mode.emacs.el --find-file TC3F.org --funcall org-html-export-to-html --kill
TC3F.pdf: $(INIT)
	caffeinate -s time emacs --batch --no-init-file --load .org-mode.emacs.el --find-file TC3F.org --funcall org-latex-export-to-pdf --kill
all: TC3F.txt TC3F.html TC3F.pdf
clean:
	rm $(INIT)
	rm TC3F.txt
	rm TC3F.html
	rm TC3F.pdf

Addendum: 14-06-13
Added caffeinate command.

Easily setting system header arguments in org mode

A little helper function:

(defun gcr/set-org-system-header-arg (property value)
  "Easily set system header arguments in org mode.
PROPERTY is the system-wide value that you would like to modify.
VALUE is the new value you wish to store.
Attribution: URL http://orgmode.org/manual/System_002dwide-header-arguments.html#System_002dwide-header-arguments
"
  (setq org-babel-default-header-args
        (cons (cons property value)
              (assq-delete-all property org-babel-default-header-args))))

Set your expectations for your org-mode system

This weekend I set up a Makefile for tangling and weaving one of my org documents. Wanting to automate it for the obvious reasons, I also wanted to have a “fresh” environment for the run. Actually, I was hoping that it would be faster, not just fresher.
Playing with the command line arguments for Emacs, I was stunned to get the tangling down to 30s. Could. Not. Believe. It. Down from 8 minutes! Then, I see the warning:

Insufficient requirements. Expected 8.2.6. Found 7.9.3

(From my memory, didn’t copy and paste it)
Uh oh. I screwed something up. Oops.
Glad I added a check!
All org users should have something like this in their code!

(when (not (version= (org-version) "8.2.6"))
  (display-warning
   'org-mode
   (concat
    "Insufficient requirements. Expected 8.2.6. Found " (org-version))
   :emergency))

There may be more
AddendunM 14-06-09
Thank you SHK and Alexander Baier for pointing out that I should be using version= instead of string-equal.

Lower casing your source block templates

org-mode has nice template expansion for its frequently used blocks via Easy Templates. I wanted them to be lower cased because my document won’t tangle with upper case block statements. Thorsten pointed out which variable needs to be configured. This approach is preferable because it it is temporary:

(mapc (lambda (asc)
        (let ((org-sce-dc (downcase (nth 1 asc))))
          (setf (nth 1 asc) org-sce-dc)))
      org-structure-template-alist)

org-scraps

Every org-mode literate programmer must at least become aware of org-scraps.
Studying and mastering each of them brings you further down the path of org-mode literate programming mastery.
Addendum:
Here is perhaps a better link.
These examples to reveal the evaluation model, which is helpful for understanding what exactly is possible with babel. For example, I like the use of a var binding to force evaluation before a computation is performed, unnamed source blocks may still tangle code, the noweb ref expansion without a newline clearly shows successfully integration between the noweb feature and the shell language, noweb variable index syntax, single line data blocks, examples of argument variable binding, obtaining values in code that are defined as properties by SHA1 id which is kind of radical when you stare at it, unnamed variables in a call, inline function call, and there I must stop. The file is 5960 lines long. It will take some time to work through it. Perhaps a better approach would be to a need first, though.

Emacs peer and consultant teaching

For the past week I’ve been day dreaming about a nice way where Emacs and org-mode users could collaborate in real time, share their configurations, learn from, and teach each other about their workflow. Sure the Internet is a great resource to pull from, it is also nice to interact with people, too!
Imaginations included weekly “Team Emacs” meetings where folks may present on interesting topics, live online. Code reviews may also be performed, even sharing how to implement a desired feature would be great. The real effort would be to organize “Team Emacs”, and do all of the logistical work. There is of course plenty of work to do for the presenters. What about the attendees? Surely, the work load may be distributed. That said, there is something in the collective consciousness right now. Sacha just posted on one step forward; Bastien!
Bastien is a delightful person online and an excellent leader. Starting an Emacs consultancy is a wonderful idea. The value of your time is priceless, so reflect that in your offering :).

A lightweight philosophy for an Emacs keymap

Any approach for your desired keymap in Emacs is possible. My current philosophy under development is to keep things as close to “stock” as possible. The idea is that I won’t run into many collisions, and bindings will be generally documented quite well, and that is less work for me. What is my plan?
First, it is really simple. The F keys are nice to use, but far away, and the first handful are bound anyway. Looking at 1…0 though, are those really critical? Well that depends. Unless you pass numeric to functions to functions a lot, then feel free to rebind them. That brings 10 keys to be bound that are quite comfortable to use being so easy to reach, that is a very easy fix.
Second, I overload bindings whenever possible. org-mode C-c C-c binding is really delightful. There are a bunch of situations where given the context, hitting C-c C-c, 80% of the time will do “the right thing” for that situation. It is really pleasant to use. My version is pretty basic actually. The thing is that I like the VC bindings in Emacs even if they only operate on one file at a time, I love the workflow.
As such, I’m calling vc-next-action and log-edit done a lot of times every day. In the spirit of “saving keystrokes” and “micro-optimizations” it kind of jumped out at me that I’m wasting some time constantly hitting C-x s to save the buffer (despite having real-auto-save running quite aggressively), C-x vv to initiate the commit, fill the log message, and C-c C-c to finalize the commit. Well, that doesn’t sound like much, but trust me it is!
My override was to first find the easiest number key for me to reach with my right hand, that is 9, and bind C-9 to vc-next action. Adding some advice to vc-next-action, save-buffer is called so that doesn’t require a keystroke. After filling out the buffer, log-edit is bound to to C-9 but only in log edit mode. In that case, defadvice and C-9 make it a little simpler and so much faster. My tentative goal is to make C-9 “just do the right thing” in most situations, we’ll see where that goes.
Those are my two beliefs right now… any more lightweight and it wouldn’t even exist.

Lightweight multiple modes for semi-literate programming

Sometimes you don’t want a 100% reproducible system (org-mode, noweb, polymode) and instead just want an easy way to work with multiple languages within the same document (MuMaMo). Sometimes you don’t even want to go that far though and just want a really easy way to hack on different languages that have somehow ended up in the same file.
Jon posted the link here to Zane’s solution. Very cool. Nice reminder that if we were to read the Emacs and Emacs Lisp user manual, we would all know how to do this. Another nice reminder, even if we don’t, kind people provide the information and solutions for us, the very definition of community. I wanted a slightly different approach with just a couple additional things: line numbers instead of the point, safety checks for use via code, and a little more documentation:
Continue reading “Lightweight multiple modes for semi-literate programming”