Andrew Hyatt <ahy...@gmail.com> writes: > That's odd, I get "No org-babel-execute function for sh!". I think I > just hadn't require'd ob-sh, and when I did this fixed the problem. > Thanks! >
For security reasons evaluation is not turned on by default. The relevant chapter of the manual is a very good resource [1]. > > My point about removing the boilerplate still stands, however. If I > have some free time in the next month, I may try to see if I can get > it removed as I proposed above. > You can insert code-block templates by typing <s TAB, and there exists other methods of expressing code blocks (e.g., inline code blocks). If you do want to experiment with different syntax, it should be fairly easy to write a function which parses some sparse code syntax near the point and then calls existing org-babel-execute functions to run the code. For example the following function will check to see if the current line starts with a "$", and if so, it will run the line in your shell and insert the result immediately following the line. ;; -*- emacs-lisp -*- (defun sparse-execute () (interactive) (save-excursion (goto-char (point-at-bol)) (if (string= (thing-at-point 'char) "$") (let ((result (org-babel-execute:sh (substring (thing-at-point 'line) 1) '()))) (goto-char (point-at-eol)) (open-line 1) (forward-char 1) (let ((beg (point))) (insert (format "%s" result)) (org-babel-examplize-region beg (point)))) (error "this line doesn't look executable")))) Cheers, Footnotes: [1] http://orgmode.org/manual/Working-With-Source-Code.html -- Eric Schulte http://cs.unm.edu/~eschulte