From: Eric Schulte <eric.schulte@gmx.com>
To: Andrew Hyatt <ahyatt@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [OT] Xiki - could something like that be done with emacs+orgmode?
Date: Wed, 19 Sep 2012 18:59:51 -0600 [thread overview]
Message-ID: <87ipb95x0b.fsf@gmx.com> (raw)
In-Reply-To: <CAM6wYYK-mg5V5eBTs-JtueWcWnddHnpjZLsPstMhiZ29SMgt2A@mail.gmail.com> (Andrew Hyatt's message of "Wed, 19 Sep 2012 17:49:00 -0400")
Andrew Hyatt <ahyatt@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
next prev parent reply other threads:[~2012-09-20 1:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-18 1:17 [OT] Xiki - could something like that be done with emacs+orgmode? Marcelo de Moraes Serpa
2012-09-18 6:23 ` Bastien
2012-09-19 3:37 ` Andrew Hyatt
2012-09-19 6:27 ` Sean O'Halpin
2012-09-19 21:49 ` Andrew Hyatt
2012-09-20 0:32 ` Torsten Wagner
2012-09-20 0:59 ` Eric Schulte [this message]
2012-09-18 9:54 ` Eden Cardim
2012-09-18 15:06 ` Marcelo de Moraes Serpa
2012-09-18 15:49 ` Luis Anaya
2012-09-19 6:40 ` Bastien
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ipb95x0b.fsf@gmx.com \
--to=eric.schulte@gmx.com \
--cc=ahyatt@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).