emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [OT] Xiki - could something like that be done with emacs+orgmode


From: Eric Schulte
Subject: Re: [O] [OT] Xiki - could something like that be done with emacs+orgmode?
Date: Wed, 19 Sep 2012 18:59:51 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)

Andrew Hyatt <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]