mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-22 12:10:44 +00:00
Merge branch 'master' of git://repo.or.cz/org-mode
This commit is contained in:
commit
7012bb7add
133
Makefile
133
Makefile
|
@ -28,8 +28,12 @@ infodir = $(prefix)/share/info
|
|||
|
||||
# Using emacs in batch mode.
|
||||
|
||||
BATCH=$(EMACS) -batch -q -no-site-file -eval \
|
||||
"(setq load-path (cons (expand-file-name \"./lisp/\") (cons \"$(lispdir)\" load-path)))"
|
||||
BATCH=$(EMACS) -batch -q -no-site-file -eval \
|
||||
"(setq load-path (cons (expand-file-name\
|
||||
\"langs\"\
|
||||
(expand-file-name \"babel\" (expand-file-name \"./lisp/\")))\
|
||||
(cons (expand-file-name \"babel\" (expand-file-name \"./lisp/\"))\
|
||||
(cons (expand-file-name \"./lisp/\") (cons \"$(lispdir)\" load-path)))))"
|
||||
|
||||
# Specify the byte-compiler for compiling org-mode files
|
||||
ELC= $(BATCH) -f batch-byte-compile
|
||||
|
@ -58,61 +62,72 @@ INSTALL_INFO=install-info
|
|||
##----------------------------------------------------------------------
|
||||
|
||||
# The following variables need to be defined by the maintainer
|
||||
LISPF = org.el \
|
||||
org-agenda.el \
|
||||
org-ascii.el \
|
||||
org-attach.el \
|
||||
org-archive.el \
|
||||
org-bbdb.el \
|
||||
org-beamer.el \
|
||||
org-bibtex.el \
|
||||
org-clock.el \
|
||||
org-colview.el \
|
||||
org-colview-xemacs.el \
|
||||
org-compat.el \
|
||||
org-crypt.el \
|
||||
org-ctags.el \
|
||||
org-datetree.el \
|
||||
org-docview.el \
|
||||
org-entities.el \
|
||||
org-exp.el \
|
||||
org-exp-blocks.el \
|
||||
org-docbook.el \
|
||||
org-faces.el \
|
||||
org-feed.el \
|
||||
org-footnote.el \
|
||||
org-freemind.el \
|
||||
org-gnus.el \
|
||||
org-habit.el \
|
||||
org-html.el \
|
||||
org-icalendar.el \
|
||||
org-id.el \
|
||||
org-indent.el \
|
||||
org-info.el \
|
||||
org-inlinetask.el \
|
||||
org-jsinfo.el \
|
||||
org-irc.el \
|
||||
org-latex.el \
|
||||
org-list.el \
|
||||
org-mac-message.el \
|
||||
org-macs.el \
|
||||
org-mew.el \
|
||||
org-mhe.el \
|
||||
org-mobile.el \
|
||||
org-mouse.el \
|
||||
org-publish.el \
|
||||
org-plot.el \
|
||||
org-protocol.el \
|
||||
org-remember.el \
|
||||
org-rmail.el \
|
||||
org-src.el \
|
||||
org-table.el \
|
||||
org-taskjuggler.el \
|
||||
org-timer.el \
|
||||
org-vm.el \
|
||||
org-w3m.el \
|
||||
org-wl.el \
|
||||
org-xoxo.el
|
||||
LISPF = org.el \
|
||||
org-agenda.el \
|
||||
org-ascii.el \
|
||||
org-attach.el \
|
||||
org-archive.el \
|
||||
org-bbdb.el \
|
||||
org-beamer.el \
|
||||
org-bibtex.el \
|
||||
org-capture.el \
|
||||
org-clock.el \
|
||||
org-colview.el \
|
||||
org-colview-xemacs.el \
|
||||
org-compat.el \
|
||||
org-crypt.el \
|
||||
org-ctags.el \
|
||||
org-datetree.el \
|
||||
org-docview.el \
|
||||
org-entities.el \
|
||||
org-exp.el \
|
||||
org-exp-blocks.el \
|
||||
org-docbook.el \
|
||||
org-faces.el \
|
||||
org-feed.el \
|
||||
org-footnote.el \
|
||||
org-freemind.el \
|
||||
org-gnus.el \
|
||||
org-habit.el \
|
||||
org-html.el \
|
||||
org-icalendar.el \
|
||||
org-id.el \
|
||||
org-indent.el \
|
||||
org-info.el \
|
||||
org-inlinetask.el \
|
||||
org-jsinfo.el \
|
||||
org-irc.el \
|
||||
org-latex.el \
|
||||
org-list.el \
|
||||
org-mac-message.el \
|
||||
org-macs.el \
|
||||
org-mew.el \
|
||||
org-mhe.el \
|
||||
org-mks.el \
|
||||
org-mobile.el \
|
||||
org-mouse.el \
|
||||
org-publish.el \
|
||||
org-plot.el \
|
||||
org-protocol.el \
|
||||
org-remember.el \
|
||||
org-rmail.el \
|
||||
org-src.el \
|
||||
org-table.el \
|
||||
org-taskjuggler.el \
|
||||
org-timer.el \
|
||||
org-vm.el \
|
||||
org-w3m.el \
|
||||
org-wl.el \
|
||||
org-xoxo.el \
|
||||
babel/ob.el \
|
||||
babel/ob-table.el \
|
||||
babel/ob-lob.el \
|
||||
babel/ob-ref.el \
|
||||
babel/ob-exp.el \
|
||||
babel/ob-tangle.el \
|
||||
babel/ob-comint.el \
|
||||
babel/ob-keys.el \
|
||||
babel/langs/ob-emacs-lisp.el
|
||||
|
||||
LISPFILES0 = $(LISPF:%=lisp/%)
|
||||
LISPFILES = $(LISPFILES0) lisp/org-install.el
|
||||
|
@ -181,6 +196,8 @@ lisp/org-install.el: $(LISPFILES0) Makefile
|
|||
--eval '(find-file "org-install.el")' \
|
||||
--eval '(erase-buffer)' \
|
||||
--eval '(mapc (lambda (x) (generate-file-autoloads (symbol-name x))) (quote ($(LISPFILES0))))' \
|
||||
--eval "(insert \"(add-to-list 'load-path (expand-file-name \\\"babel\\\" (file-name-directory (or (buffer-file-name) load-file-name))))\")" \
|
||||
--eval "(insert \"\n(add-to-list 'load-path (expand-file-name \\\"langs\\\" (expand-file-name \\\"babel\\\" (file-name-directory (or (buffer-file-name) load-file-name)))))\")\n" \
|
||||
--eval '(insert "\n(provide (quote org-install))\n")' \
|
||||
--eval '(save-buffer)'
|
||||
mv org-install.el lisp
|
||||
|
@ -348,6 +365,7 @@ lisp/org-archive.elc: lisp/org.el
|
|||
lisp/org-bbdb.elc: lisp/org.el
|
||||
lisp/org-beamer.elc: lisp/org.el
|
||||
lisp/org-bibtex.elc: lisp/org.el
|
||||
lisp/org-capture.elc: lisp/org.el lisp/org-mks.el
|
||||
lisp/org-clock.elc: lisp/org.el
|
||||
lisp/org-colview.elc: lisp/org.el
|
||||
lisp/org-colview-xemacs.elc: lisp/org.el
|
||||
|
@ -380,6 +398,7 @@ lisp/org-mac-message.elc: lisp/org.el
|
|||
lisp/org-macs.elc:
|
||||
lisp/org-mew.elc: lisp/org.el
|
||||
lisp/org-mhe.elc: lisp/org.el
|
||||
lisp/org-mks.elc:
|
||||
lisp/org-mobile.elc: lisp/org.el
|
||||
lisp/org-mouse.elc: lisp/org.el
|
||||
lisp/org-plot.elc: lisp/org.el lisp/org-exp.el lisp/org-table.el
|
||||
|
|
70
UTILITIES/git-changelog
Executable file
70
UTILITIES/git-changelog
Executable file
|
@ -0,0 +1,70 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# git-changelog
|
||||
#
|
||||
# version 2.0, by John Wiegley
|
||||
#
|
||||
# The purpose of this code is to turn "git log" output into a complete
|
||||
# ChangeLog, for projects who wish to begin using a ChangeLog, but haven't
|
||||
# been.
|
||||
#
|
||||
# This version of git-changelog depends on GitPython:
|
||||
# git://gitorious.org/git-python/mainline.git
|
||||
|
||||
import time
|
||||
import string
|
||||
import sys
|
||||
import re
|
||||
import os
|
||||
|
||||
from git import * # GitPython
|
||||
from subprocess import *
|
||||
|
||||
repo = Repo(os.getcwd())
|
||||
ref = 'origin/master..'
|
||||
path = ''
|
||||
|
||||
# Usage: git changelog [COMMITISH] [-- [PATH]]
|
||||
|
||||
saw_dashdash = False
|
||||
if len(sys.argv) > 1:
|
||||
for arg in sys.argv[1:]:
|
||||
if arg == "--":
|
||||
saw_dashdash = True
|
||||
elif saw_dashdash:
|
||||
path = arg
|
||||
else:
|
||||
ref = arg
|
||||
|
||||
for commit in repo.iter_commits(ref, paths=path):
|
||||
hash_id = commit.sha
|
||||
author = commit.author
|
||||
date = commit.committed_date
|
||||
log_text = commit.message.split('\n')[0]
|
||||
|
||||
log_text_remainder = commit.message.split('\n\n')[1:]
|
||||
while len(log_text_remainder) > 0 and not log_text_remainder[0]:
|
||||
log_text_remainder = log_text_remainder[1:]
|
||||
log_text_remainder = string.join(log_text_remainder, '\n\t')
|
||||
if log_text_remainder:
|
||||
log_text_remainder = '\n\t' + log_text_remainder
|
||||
|
||||
diff = commit.diff(commit.parents[0])
|
||||
files = []
|
||||
for f in diff:
|
||||
p = f.a_blob.path or f.b_blob.path
|
||||
p2 = re.sub('^' + path + '/', '', p)
|
||||
if p != p2:
|
||||
files.append(p2)
|
||||
|
||||
fp = Popen(["fmt", "-72"], shell = True, stdin = PIPE, stdout = PIPE)
|
||||
fp.stdin.write("\t* %s: %s" % (string.join(files, ",\n\t"), log_text))
|
||||
fp.stdin.close()
|
||||
log_text = fp.stdout.read()
|
||||
del fp
|
||||
|
||||
print "%s %s <%s>\n\n%s%s" % \
|
||||
(time.strftime("%Y-%m-%d", time.gmtime(date)),
|
||||
author.name, author.email, log_text, log_text_remainder)
|
||||
|
||||
# git-changelog ends here
|
527
UTILITIES/pw
Executable file
527
UTILITIES/pw
Executable file
|
@ -0,0 +1,527 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Patchwork command line client
|
||||
# Copyright (C) 2008 Nate Case <ncase@xes-inc.com>
|
||||
#
|
||||
# This file is part of the Patchwork package.
|
||||
#
|
||||
# Patchwork is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Patchwork is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Patchwork; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
import os
|
||||
import sys
|
||||
import xmlrpclib
|
||||
import getopt
|
||||
import string
|
||||
import tempfile
|
||||
import subprocess
|
||||
import base64
|
||||
import ConfigParser
|
||||
import datetime
|
||||
import re
|
||||
|
||||
# Default Patchwork remote XML-RPC server URL
|
||||
# This script will check the PW_XMLRPC_URL environment variable
|
||||
# for the URL to access. If that is unspecified, it will fallback to
|
||||
# the hardcoded default value specified here.
|
||||
DEFAULT_URL = "http://patchwork/xmlrpc/"
|
||||
CONFIG_FILES = [os.path.expanduser('~/.pwclientrc')]
|
||||
|
||||
class Filter:
|
||||
"""Filter for selecting patches."""
|
||||
def __init__(self):
|
||||
# These fields refer to specific objects, so they are special
|
||||
# because we have to resolve them to IDs before passing the
|
||||
# filter to the server
|
||||
self.state = ""
|
||||
self.project = ""
|
||||
|
||||
# The dictionary that gets passed to via XML-RPC
|
||||
self.d = {}
|
||||
|
||||
def add(self, field, value):
|
||||
if field == 'state':
|
||||
self.state = value
|
||||
elif field == 'project':
|
||||
self.project = value
|
||||
else:
|
||||
# OK to add directly
|
||||
self.d[field] = value
|
||||
|
||||
def resolve_ids(self, rpc):
|
||||
"""Resolve State, Project, and Person IDs based on filter strings."""
|
||||
if self.state != "":
|
||||
id = state_id_by_name(rpc, self.state)
|
||||
if id == 0:
|
||||
sys.stderr.write("Note: No State found matching %s*, " \
|
||||
"ignoring filter\n" % self.state)
|
||||
else:
|
||||
self.d['state_id'] = id
|
||||
|
||||
if self.project != "":
|
||||
id = project_id_by_name(rpc, self.project)
|
||||
if id == 0:
|
||||
sys.stderr.write("Note: No Project found matching %s, " \
|
||||
"ignoring filter\n" % self.project)
|
||||
else:
|
||||
self.d['project_id'] = id
|
||||
|
||||
def __str__(self):
|
||||
"""Return human-readable description of the filter."""
|
||||
return str(self.d)
|
||||
|
||||
class BasicHTTPAuthTransport(xmlrpclib.SafeTransport):
|
||||
|
||||
def __init__(self, username = None, password = None, use_https = False):
|
||||
self.username = username
|
||||
self.password = password
|
||||
self.use_https = use_https
|
||||
xmlrpclib.SafeTransport.__init__(self)
|
||||
|
||||
def authenticated(self):
|
||||
return self.username != None and self.password != None
|
||||
|
||||
def send_host(self, connection, host):
|
||||
xmlrpclib.Transport.send_host(self, connection, host)
|
||||
if not self.authenticated():
|
||||
return
|
||||
credentials = '%s:%s' % (self.username, self.password)
|
||||
auth = 'Basic ' + base64.encodestring(credentials).strip()
|
||||
connection.putheader('Authorization', auth)
|
||||
|
||||
def make_connection(self, host):
|
||||
if self.use_https:
|
||||
fn = xmlrpclib.SafeTransport.make_connection
|
||||
else:
|
||||
fn = xmlrpclib.Transport.make_connection
|
||||
return fn(self, host)
|
||||
|
||||
def usage():
|
||||
sys.stderr.write("Usage: %s <action> [options]\n\n" % \
|
||||
(os.path.basename(sys.argv[0])))
|
||||
sys.stderr.write("Where <action> is one of:\n")
|
||||
sys.stderr.write(
|
||||
""" apply <ID> : Apply a patch (in the current dir, using -p1)
|
||||
get <ID> : Download a patch and save it locally
|
||||
projects : List all projects
|
||||
states : Show list of potential patch states
|
||||
list [str] : List patches, using the optional filters specified
|
||||
below and an optional substring to search for patches
|
||||
by name
|
||||
search [str] : Same as 'list'
|
||||
view <ID> : View a patch
|
||||
update [-s state] [-c commit-ref] <ID>
|
||||
: Update patch\n""")
|
||||
sys.stderr.write("""\nFilter options for 'list' and 'search':
|
||||
-s <state> : Filter by patch state (e.g., 'New', 'Accepted', etc.)
|
||||
-p <project> : Filter by project name (see 'projects' for list)
|
||||
-w <who> : Filter by submitter (name, e-mail substring search)
|
||||
-d <who> : Filter by delegate (name, e-mail substring search)
|
||||
-n <max #> : Restrict number of results\n""")
|
||||
sys.stderr.write("""\nActions that take an ID argument can also be \
|
||||
invoked with:
|
||||
-h <hash> : Lookup by patch hash\n""")
|
||||
sys.exit(1)
|
||||
|
||||
def project_id_by_name(rpc, linkname):
|
||||
"""Given a project short name, look up the Project ID."""
|
||||
if len(linkname) == 0:
|
||||
return 0
|
||||
projects = rpc.project_list(linkname, 0)
|
||||
for project in projects:
|
||||
if project['linkname'] == linkname:
|
||||
return project['id']
|
||||
return 0
|
||||
|
||||
def state_id_by_name(rpc, name):
|
||||
"""Given a partial state name, look up the state ID."""
|
||||
if len(name) == 0:
|
||||
return 0
|
||||
states = rpc.state_list(name, 0)
|
||||
for state in states:
|
||||
if state['name'].lower().startswith(name.lower()):
|
||||
return state['id']
|
||||
return 0
|
||||
|
||||
def person_ids_by_name(rpc, name):
|
||||
"""Given a partial name or email address, return a list of the
|
||||
person IDs that match."""
|
||||
if len(name) == 0:
|
||||
return []
|
||||
people = rpc.person_list(name, 0)
|
||||
return map(lambda x: x['id'], people)
|
||||
|
||||
def list_patches(patches):
|
||||
"""Dump a list of patches to stdout."""
|
||||
print("%-5s %-12s %s" % ("ID", "State", "Name"))
|
||||
print("%-5s %-12s %s" % ("--", "-----", "----"))
|
||||
for patch in patches:
|
||||
print("%-5d %-12s %s" % (patch['id'], patch['state'], patch['name']))
|
||||
|
||||
def action_list(rpc, filter, submitter_str, delegate_str):
|
||||
filter.resolve_ids(rpc)
|
||||
|
||||
if submitter_str != "":
|
||||
ids = person_ids_by_name(rpc, submitter_str)
|
||||
if len(ids) == 0:
|
||||
sys.stderr.write("Note: Nobody found matching *%s*\n", \
|
||||
submitter_str)
|
||||
else:
|
||||
for id in ids:
|
||||
person = rpc.person_get(id)
|
||||
print "Patches submitted by %s <%s>:" % \
|
||||
(person['name'], person['email'])
|
||||
f = filter
|
||||
f.add("submitter_id", id)
|
||||
patches = rpc.patch_list(f.d)
|
||||
list_patches(patches)
|
||||
return
|
||||
|
||||
if delegate_str != "":
|
||||
ids = person_ids_by_name(rpc, delegate_str)
|
||||
if len(ids) == 0:
|
||||
sys.stderr.write("Note: Nobody found matching *%s*\n", \
|
||||
delegate_str)
|
||||
else:
|
||||
for id in ids:
|
||||
person = rpc.person_get(id)
|
||||
print "Patches delegated to %s <%s>:" % \
|
||||
(person['name'], person['email'])
|
||||
f = filter
|
||||
f.add("delegate_id", id)
|
||||
patches = rpc.patch_list(f.d)
|
||||
list_patches(patches)
|
||||
return
|
||||
|
||||
patches = rpc.patch_list(filter.d)
|
||||
list_patches(patches)
|
||||
|
||||
def action_projects(rpc):
|
||||
projects = rpc.project_list("", 0)
|
||||
print("%-5s %-24s %s" % ("ID", "Name", "Description"))
|
||||
print("%-5s %-24s %s" % ("--", "----", "-----------"))
|
||||
for project in projects:
|
||||
print("%-5d %-24s %s" % (project['id'], \
|
||||
project['linkname'], \
|
||||
project['name']))
|
||||
|
||||
def action_states(rpc):
|
||||
states = rpc.state_list("", 0)
|
||||
print("%-5s %s" % ("ID", "Name"))
|
||||
print("%-5s %s" % ("--", "----"))
|
||||
for state in states:
|
||||
print("%-5d %s" % (state['id'], state['name']))
|
||||
|
||||
def action_get(rpc, patch_id):
|
||||
patch = rpc.patch_get(patch_id)
|
||||
s = rpc.patch_get_mbox(patch_id)
|
||||
|
||||
if patch == {} or len(s) == 0:
|
||||
sys.stderr.write("Unable to get patch %d\n" % patch_id)
|
||||
sys.exit(1)
|
||||
|
||||
base_fname = fname = os.path.basename(patch['filename'])
|
||||
i = 0
|
||||
while os.path.exists(fname):
|
||||
fname = "%s.%d" % (base_fname, i)
|
||||
i += 1
|
||||
|
||||
try:
|
||||
f = open(fname, "w")
|
||||
except:
|
||||
sys.stderr.write("Unable to open %s for writing\n" % fname)
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
f.write(unicode(s).encode("utf-8"))
|
||||
f.close()
|
||||
print "Saved patch to %s" % fname
|
||||
except:
|
||||
sys.stderr.write("Failed to write to %s\n" % fname)
|
||||
sys.exit(1)
|
||||
|
||||
def action_apply(rpc, patch_id):
|
||||
patch = rpc.patch_get(patch_id)
|
||||
if patch == {}:
|
||||
sys.stderr.write("Error getting information on patch ID %d\n" % \
|
||||
patch_id)
|
||||
sys.exit(1)
|
||||
print "Applying patch #%d to current directory" % patch_id
|
||||
print "Description: %s" % patch['name']
|
||||
s = rpc.patch_get_mbox(patch_id)
|
||||
if len(s) > 0:
|
||||
proc = subprocess.Popen(['patch', '-p1'], stdin = subprocess.PIPE)
|
||||
proc.communicate(s)
|
||||
else:
|
||||
sys.stderr.write("Error: No patch content found\n")
|
||||
sys.exit(1)
|
||||
|
||||
def action_update_patch(rpc, patch_id, state = None, commit = None):
|
||||
patch = rpc.patch_get(patch_id)
|
||||
if patch == {}:
|
||||
sys.stderr.write("Error getting information on patch ID %d\n" % \
|
||||
patch_id)
|
||||
sys.exit(1)
|
||||
|
||||
params = {}
|
||||
|
||||
if state:
|
||||
state_id = state_id_by_name(rpc, state)
|
||||
if state_id == 0:
|
||||
sys.stderr.write("Error: No State found matching %s*\n" % state)
|
||||
sys.exit(1)
|
||||
params['state'] = state_id
|
||||
|
||||
if commit:
|
||||
params['commit_ref'] = commit
|
||||
|
||||
success = False
|
||||
try:
|
||||
success = rpc.patch_set(patch_id, params)
|
||||
except xmlrpclib.Fault, f:
|
||||
sys.stderr.write("Error updating patch: %s\n" % f.faultString)
|
||||
|
||||
if not success:
|
||||
sys.stderr.write("Patch not updated\n")
|
||||
|
||||
def patch_id_from_hash(rpc, project, hash):
|
||||
try:
|
||||
patch = rpc.patch_get_by_project_hash(project, hash)
|
||||
except xmlrpclib.Fault:
|
||||
# the server may not have the newer patch_get_by_project_hash function,
|
||||
# so fall back to hash-only.
|
||||
patch = rpc.patch_get_by_hash(hash)
|
||||
|
||||
if patch == {}:
|
||||
return None
|
||||
|
||||
return patch['id']
|
||||
|
||||
def branch_with(patch_id, rpc):
|
||||
s = rpc.patch_get_mbox(patch_id)
|
||||
if len(s) > 0:
|
||||
print unicode(s).encode("utf-8")
|
||||
|
||||
patch = rpc.patch_get(patch_id)
|
||||
|
||||
# Find the latest commit from the day before the patch
|
||||
proc = subprocess.Popen(['git', 'log', '--until=' + patch['date'],
|
||||
'-1', '--format=%H', 'master'],
|
||||
stdout = subprocess.PIPE)
|
||||
sha = proc.stdout.read()[:-1]
|
||||
|
||||
# Create a topic branch named after this commit
|
||||
proc = subprocess.Popen(['git', 'checkout', '-b', 't/patch%s' %
|
||||
patch_id, sha])
|
||||
sts = os.waitpid(proc.pid, 0)
|
||||
if sts[1] != 0:
|
||||
sys.stderr.write("Could not create branch for patch\n")
|
||||
return
|
||||
|
||||
# Apply the patch to the branch
|
||||
fname = '/tmp/patch'
|
||||
try:
|
||||
f = open(fname, "w")
|
||||
except:
|
||||
sys.stderr.write("Unable to open %s for writing\n" % fname)
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
f.write(unicode(s).encode("utf-8"))
|
||||
f.close()
|
||||
print "Saved patch to %s" % fname
|
||||
except:
|
||||
sys.stderr.write("Failed to write to %s\n" % fname)
|
||||
sys.exit(1)
|
||||
|
||||
proc = subprocess.Popen(['git', 'am', '/tmp/patch'])
|
||||
sts = os.waitpid(proc.pid, 0)
|
||||
if sts[1] != 0:
|
||||
sys.stderr.write("Failed to apply patch to branch\n")
|
||||
proc = subprocess.Popen(['git', 'checkout', 'master'])
|
||||
os.waitpid(proc.pid, 0)
|
||||
proc = subprocess.Popen(['git', 'branch', '-D', 't/patch%s' %
|
||||
patch_id, sha])
|
||||
os.waitpid(proc.pid, 0)
|
||||
return
|
||||
|
||||
proc = subprocess.Popen(['git', 'rebase', 'master'])
|
||||
sts = os.waitpid(proc.pid, 0)
|
||||
|
||||
print sha
|
||||
|
||||
auth_actions = ['update']
|
||||
|
||||
def main():
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[2:], 's:p:w:d:n:c:h:')
|
||||
except getopt.GetoptError, err:
|
||||
print str(err)
|
||||
usage()
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
usage()
|
||||
|
||||
action = sys.argv[1].lower()
|
||||
|
||||
# set defaults
|
||||
filt = Filter()
|
||||
submitter_str = ""
|
||||
delegate_str = ""
|
||||
project_str = ""
|
||||
commit_str = ""
|
||||
state_str = "New"
|
||||
hash_str = ""
|
||||
url = DEFAULT_URL
|
||||
|
||||
config = ConfigParser.ConfigParser()
|
||||
config.read(CONFIG_FILES)
|
||||
|
||||
# grab settings from config files
|
||||
if config.has_option('base', 'url'):
|
||||
url = config.get('base', 'url')
|
||||
|
||||
if config.has_option('base', 'project'):
|
||||
project_str = config.get('base', 'project')
|
||||
|
||||
for name, value in opts:
|
||||
if name == '-s':
|
||||
state_str = value
|
||||
elif name == '-p':
|
||||
project_str = value
|
||||
elif name == '-w':
|
||||
submitter_str = value
|
||||
elif name == '-d':
|
||||
delegate_str = value
|
||||
elif name == '-c':
|
||||
commit_str = value
|
||||
elif name == '-h':
|
||||
hash_str = value
|
||||
elif name == '-n':
|
||||
try:
|
||||
filt.add("max_count", int(value))
|
||||
except:
|
||||
sys.stderr.write("Invalid maximum count '%s'\n" % value)
|
||||
usage()
|
||||
else:
|
||||
sys.stderr.write("Unknown option '%s'\n" % name)
|
||||
usage()
|
||||
|
||||
if len(args) > 1:
|
||||
sys.stderr.write("Too many arguments specified\n")
|
||||
usage()
|
||||
|
||||
(username, password) = (None, None)
|
||||
transport = None
|
||||
if action in auth_actions:
|
||||
if config.has_option('auth', 'username') and \
|
||||
config.has_option('auth', 'password'):
|
||||
|
||||
use_https = url.startswith('https')
|
||||
|
||||
transport = BasicHTTPAuthTransport( \
|
||||
config.get('auth', 'username'),
|
||||
config.get('auth', 'password'),
|
||||
use_https)
|
||||
|
||||
else:
|
||||
sys.stderr.write(("The %s action requires authentication, "
|
||||
"but no username or password\nis configured\n") % action)
|
||||
sys.exit(1)
|
||||
|
||||
if project_str:
|
||||
filt.add("project", project_str)
|
||||
|
||||
if state_str:
|
||||
filt.add("state", state_str)
|
||||
|
||||
try:
|
||||
rpc = xmlrpclib.Server(url, transport = transport)
|
||||
except:
|
||||
sys.stderr.write("Unable to connect to %s\n" % url)
|
||||
sys.exit(1)
|
||||
|
||||
patch_id = None
|
||||
if hash_str:
|
||||
patch_id = patch_id_from_hash(rpc, project_str, hash_str)
|
||||
if patch_id is None:
|
||||
sys.stderr.write("No patch has the hash provided\n")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if action == 'list' or action == 'search':
|
||||
if len(args) > 0:
|
||||
filt.add("name__icontains", args[0])
|
||||
action_list(rpc, filt, submitter_str, delegate_str)
|
||||
|
||||
elif action.startswith('project'):
|
||||
action_projects(rpc)
|
||||
|
||||
elif action.startswith('state'):
|
||||
action_states(rpc)
|
||||
|
||||
elif action == 'branch':
|
||||
try:
|
||||
patch_id = patch_id or int(args[0])
|
||||
except:
|
||||
sys.stderr.write("Invalid patch ID given\n")
|
||||
sys.exit(1)
|
||||
|
||||
branch_with(patch_id, rpc)
|
||||
|
||||
elif action == 'view':
|
||||
try:
|
||||
patch_id = patch_id or int(args[0])
|
||||
except:
|
||||
sys.stderr.write("Invalid patch ID given\n")
|
||||
sys.exit(1)
|
||||
|
||||
s = rpc.patch_get_mbox(patch_id)
|
||||
if len(s) > 0:
|
||||
print unicode(s).encode("utf-8")
|
||||
|
||||
elif action == 'get' or action == 'save':
|
||||
try:
|
||||
patch_id = patch_id or int(args[0])
|
||||
except:
|
||||
sys.stderr.write("Invalid patch ID given\n")
|
||||
sys.exit(1)
|
||||
|
||||
action_get(rpc, patch_id)
|
||||
|
||||
elif action == 'apply':
|
||||
try:
|
||||
patch_id = patch_id or int(args[0])
|
||||
except:
|
||||
sys.stderr.write("Invalid patch ID given\n")
|
||||
sys.exit(1)
|
||||
|
||||
action_apply(rpc, patch_id)
|
||||
|
||||
elif action == 'update':
|
||||
try:
|
||||
patch_id = patch_id or int(args[0])
|
||||
except:
|
||||
sys.stderr.write("Invalid patch ID given\n")
|
||||
sys.exit(1)
|
||||
|
||||
action_update_patch(rpc, patch_id, state = state_str,
|
||||
commit = commit_str)
|
||||
|
||||
else:
|
||||
sys.stderr.write("Unknown action '%s'\n" % action)
|
||||
usage()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,4 +1,4 @@
|
|||
;;; org-babel-oz.el --- org-babel functions for Oz evaluation
|
||||
;;; ob-oz.el --- org-babel functions for Oz evaluation
|
||||
|
||||
;; Copyright (C) 2009 Torsten Anders and Eric Schulte
|
||||
|
||||
|
@ -88,18 +88,10 @@
|
|||
;;
|
||||
|
||||
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
;;; major mode for editing Oz programs
|
||||
(require 'mozart)
|
||||
|
||||
;; Add Oz to the list of supported languages. Org-babel will match
|
||||
;; the string below against the declared language of the source-code
|
||||
;; block.
|
||||
(org-babel-add-interpreter "oz")
|
||||
|
||||
;; specify the name and file extension for Oz
|
||||
(add-to-list 'org-babel-tangle-langs '("oz" "oz" nil nil))
|
||||
|
||||
;;
|
||||
;; Interface to communicate with Oz.
|
||||
;; (1) For statements without any results: oz-send-string
|
||||
|
@ -310,5 +302,5 @@ Emacs-lisp table, otherwise return the results as a string."
|
|||
(error "org-babel-oz-table-or-string unimplemented"))
|
||||
|
||||
|
||||
(provide 'org-babel-oz)
|
||||
(provide 'ob-oz)
|
||||
;;; org-babel-oz.el ends here
|
|
@ -1,22 +1,6 @@
|
|||
#+title: The Library of Babel
|
||||
#+SEQ_TODO: TODO PROPOSED | DONE DEFERRED REJECTED
|
||||
#+OPTIONS: H:3 num:nil toc:2 \n:nil @:t ::t |:t ^:t -:t f:t *:t TeX:t LaTeX:t skip:nil d:(HIDE) tags:not-in-toc
|
||||
#+author: Org-mode People
|
||||
#+STARTUP: odd hideblocks
|
||||
#+STYLE: <style type="text/css">#outline-container-1 { clear:both; }</style>
|
||||
|
||||
#+begin_html
|
||||
<div id="logo" style="float: left; text-align: center; max-width: 340px; font-size: 8pt; margin-left: 1em;">
|
||||
<p>
|
||||
<img src="../../images/babel/library-of-babel.png" alt="Library of Babel"/>
|
||||
<div id="attr">
|
||||
The Library of Babel, by Pierre Clayette
|
||||
<p>
|
||||
<a href="http://downlode.org/Etext/library_of_babel.html">Full text of the Borges short story</a>
|
||||
</p>
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
#+end_html
|
||||
|
||||
* Introduction
|
||||
The Library of Babel is an extensible collection of ready-made and
|
||||
|
@ -69,6 +53,25 @@ as a table in traditional Org-mode table syntax.
|
|||
nil
|
||||
#+end_src
|
||||
|
||||
** remote files
|
||||
|
||||
Read local or remote file in [[http://www.json.org/][json]] format into emacs-lisp objects.
|
||||
#+srcname: json
|
||||
#+begin_src emacs-lisp :var file='() :var url='()
|
||||
(require 'json)
|
||||
(cond
|
||||
(file
|
||||
(with-temp-filebuffer file
|
||||
(goto-char (point-min))
|
||||
(json-read)))
|
||||
(url
|
||||
(require 'w3m)
|
||||
(with-temp-buffer
|
||||
(w3m-retrieve url)
|
||||
(goto-char (point-min))
|
||||
(json-read))))
|
||||
#+end_src
|
||||
|
||||
* Plotting code
|
||||
|
||||
** R
|
||||
|
|
|
@ -1,127 +0,0 @@
|
|||
;;; org-babel-comint.el --- org-babel functions for interaction with comint buffers
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research, comint
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; These functions build on comint to ease the sending and receiving
|
||||
;; of commands and results from comint buffers.
|
||||
;;
|
||||
;; Note that the buffers in this file are analogous to sessions in
|
||||
;; org-babel at large.
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'comint)
|
||||
|
||||
(defun org-babel-comint-buffer-livep (buffer)
|
||||
(let ((buffer (if buffer (get-buffer buffer))))
|
||||
(and buffer (buffer-live-p buffer) (get-buffer-process buffer) buffer)))
|
||||
|
||||
(defmacro org-babel-comint-in-buffer (buffer &rest body)
|
||||
"Check BUFFER with `org-babel-comint-buffer-livep' then execute
|
||||
body inside the protection of `save-window-excursion' and
|
||||
`save-match-data'."
|
||||
(declare (indent 1))
|
||||
`(save-excursion
|
||||
(save-match-data
|
||||
(unless (org-babel-comint-buffer-livep ,buffer)
|
||||
(error (format "buffer %s doesn't exist or has no process" ,buffer)))
|
||||
(set-buffer ,buffer)
|
||||
,@body)))
|
||||
|
||||
(defmacro org-babel-comint-with-output
|
||||
(buffer eoe-indicator remove-echo &rest body)
|
||||
"Evaluate BODY in BUFFER, wait until EOE-INDICATOR appears in
|
||||
output, then return all process output. This ensures that the
|
||||
filter is removed in case of an error or user `keyboard-quit'
|
||||
during execution of body."
|
||||
(declare (indent 3))
|
||||
`(org-babel-comint-in-buffer ,buffer
|
||||
(let ((string-buffer "") dangling-text)
|
||||
(flet ((my-filt (text) (setq string-buffer (concat string-buffer text))))
|
||||
;; setup filter
|
||||
(add-hook 'comint-output-filter-functions 'my-filt)
|
||||
(unwind-protect
|
||||
(progn
|
||||
;; got located, and save dangling text
|
||||
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
||||
(let ((start (point))
|
||||
(end (point-max)))
|
||||
(setq dangling-text (buffer-substring start end))
|
||||
(delete-region start end))
|
||||
;; pass FULL-BODY to process
|
||||
,@body
|
||||
;; wait for end-of-evaluation indicator
|
||||
(while (progn
|
||||
(goto-char comint-last-input-end)
|
||||
(not (save-excursion
|
||||
(and (re-search-forward
|
||||
comint-prompt-regexp nil t)
|
||||
(re-search-forward
|
||||
(regexp-quote ,eoe-indicator) nil t)))))
|
||||
(accept-process-output (get-buffer-process (current-buffer)))
|
||||
;; thought the following this would allow async
|
||||
;; background running, but I was wrong...
|
||||
;; (run-with-timer .5 .5 'accept-process-output
|
||||
;; (get-buffer-process (current-buffer)))
|
||||
)
|
||||
;; replace cut dangling text
|
||||
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
||||
(insert dangling-text))
|
||||
;; remove filter
|
||||
(remove-hook 'comint-output-filter-functions 'my-filt)))
|
||||
;; remove echo'd FULL-BODY from input
|
||||
(if (and ,remove-echo
|
||||
(string-match
|
||||
(replace-regexp-in-string
|
||||
"\n" "[\r\n]+" (regexp-quote ,full-body))
|
||||
string-buffer))
|
||||
(setq raw (substring string-buffer (match-end 0))))
|
||||
(split-string string-buffer comint-prompt-regexp))))
|
||||
|
||||
(defun org-babel-comint-input-command (buffer cmd)
|
||||
"Pass CMD to BUFFER The input will not be echoed."
|
||||
(org-babel-comint-in-buffer buffer
|
||||
(goto-char (process-mark (get-buffer-process buffer)))
|
||||
(insert cmd)
|
||||
(comint-send-input)
|
||||
(org-babel-comint-wait-for-output buffer)))
|
||||
|
||||
(defun org-babel-comint-wait-for-output (buffer)
|
||||
"Wait until output arrives. Note: this is only safe when
|
||||
waiting for the result of a single statement (not large blocks of
|
||||
code)."
|
||||
(org-babel-comint-in-buffer buffer
|
||||
(while (progn
|
||||
(goto-char comint-last-input-end)
|
||||
(not (and (re-search-forward comint-prompt-regexp nil t)
|
||||
(goto-char (match-beginning 0))
|
||||
(string= (face-name (face-at-point))
|
||||
"comint-highlight-prompt"))))
|
||||
(accept-process-output (get-buffer-process buffer)))))
|
||||
|
||||
(provide 'org-babel-comint)
|
||||
;;; org-babel-comint.el ends here
|
|
@ -1,70 +0,0 @@
|
|||
;;; org-babel-init.el --- loads org-babel
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; for more information see the comments in org-babel.el
|
||||
|
||||
;;; Code:
|
||||
(let* ((babel-dir (expand-file-name
|
||||
"lisp"
|
||||
(expand-file-name
|
||||
"babel"
|
||||
(expand-file-name
|
||||
".." (file-name-directory (or load-file-name buffer-file-name))))))
|
||||
|
||||
(langs-dir (expand-file-name "langs" babel-dir)))
|
||||
|
||||
(add-to-list 'load-path babel-dir)
|
||||
(add-to-list 'load-path langs-dir)
|
||||
|
||||
;; org-babel core
|
||||
(require 'cl)
|
||||
(require 'org)
|
||||
(require 'org-table)
|
||||
(require 'org-exp-blocks)
|
||||
(require 'org-babel)
|
||||
(require 'org-babel-ref)
|
||||
(require 'org-babel-exp)
|
||||
(require 'org-babel-table)
|
||||
(require 'org-babel-comint)
|
||||
(require 'org-babel-lob)
|
||||
(require 'org-babel-tangle)
|
||||
(require 'org-babel-keys)
|
||||
|
||||
;; org-babel languages
|
||||
(require 'org-babel-emacs-lisp)
|
||||
(require 'org-babel-sh)
|
||||
|
||||
;; Library of babel
|
||||
(defvar org-babel-lob-dir
|
||||
(expand-file-name ".." babel-dir)
|
||||
"The directory holding the library-of-babel")
|
||||
(defun org-babel-load-library-of-babel ()
|
||||
(org-babel-lob-ingest (expand-file-name "library-of-babel.org" org-babel-lob-dir))))
|
||||
|
||||
(provide 'org-babel-init)
|
||||
;;; org-babel-init.el ends here
|
|
@ -64,13 +64,14 @@ seen. This is run after a few special cases are taken care of."
|
|||
(defun org-special-blocks-convert-latex-special-cookies ()
|
||||
"Converts the special cookies into LaTeX blocks."
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^ORG-\\(.*\\)-\\(START\\|END\\)$" nil t)
|
||||
(while (re-search-forward "^ORG-\\([^ \t\n]*\\)[ \t]*\\(.*\\)-\\(START\\|END\\)$" nil t)
|
||||
(replace-match
|
||||
(if (equal (match-string 2) "START")
|
||||
(concat "\\begin{" (match-string 1) "}")
|
||||
(if (equal (match-string 3) "START")
|
||||
(concat "\\begin{" (match-string 1) "}" (match-string 2))
|
||||
(concat "\\end{" (match-string 1) "}"))
|
||||
t t)))
|
||||
|
||||
|
||||
(add-hook 'org-export-latex-after-blockquotes-hook
|
||||
'org-special-blocks-convert-latex-special-cookies)
|
||||
|
||||
|
|
3059
doc/org.texi
3059
doc/org.texi
File diff suppressed because it is too large
Load diff
|
@ -169,15 +169,15 @@ Dates and Times
|
|||
|
||||
Capture - Refile - Archive
|
||||
|
||||
* Remember:: Capture new tasks/ideas with little interruption
|
||||
* Capture::
|
||||
* Refiling notes:: Moving a tree from one place to another
|
||||
* Archiving:: What to do with finished projects
|
||||
|
||||
Remember
|
||||
Capture
|
||||
|
||||
* Setting up Remember for Org:: Some code for .emacs to get things going
|
||||
* Remember templates:: Define the outline of different note types
|
||||
* Storing notes:: Directly get the note to where it belongs
|
||||
* Setting up a capture location:: Where notes will be stored
|
||||
* Using capture:: Commands to invoke and terminate capture
|
||||
* Capture templates:: Define the outline of different note types
|
||||
|
||||
Agenda Views
|
||||
|
||||
|
@ -1525,89 +1525,90 @@ Cave's Date and Time tutorial}@*
|
|||
|
||||
An important part of any organization system is the ability to quickly
|
||||
capture new ideas and tasks, and to associate reference material with them.
|
||||
Org uses the @file{remember.el} package to create tasks, and stores files
|
||||
related to a task (@i{attachments}) in a special directory. Once in the
|
||||
system, tasks and projects need to be moved around. Moving completed project
|
||||
trees to an archive file keeps the system compact and fast.
|
||||
Org defines a capture process to create tasks. It stores files related to a
|
||||
task (@i{attachments}) in a special directory. Once in the system, tasks and
|
||||
projects need to be moved around. Moving completed project trees to an
|
||||
archive file keeps the system compact and fast.
|
||||
|
||||
@menu
|
||||
* Remember:: Capture new tasks/ideas with little interruption
|
||||
* Capture::
|
||||
* Refiling notes:: Moving a tree from one place to another
|
||||
* Archiving:: What to do with finished projects
|
||||
@end menu
|
||||
|
||||
@node Remember, Refiling notes, Capture - Refile - Archive, Capture - Refile - Archive
|
||||
@section Remember
|
||||
@node Capture, Refiling notes, Capture - Refile - Archive, Capture - Refile - Archive
|
||||
@section Capture
|
||||
|
||||
The Remember package by John Wiegley lets you store quick notes with little
|
||||
interruption of your work flow. It is an excellent way to add new notes and
|
||||
tasks to Org files. The @code{remember.el} package is part of Emacs 23, not
|
||||
Emacs 22. See @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for
|
||||
more information.
|
||||
|
||||
Org significantly expands the possibilities of Remember: you may define
|
||||
templates for different note types, and associate target files and headlines
|
||||
with specific templates. It also allows you to select the location where a
|
||||
note should be stored interactively, on the fly.
|
||||
Org's method for capturing new items is heavily inspired by John Wiegley
|
||||
excellent remember package. It lets you store quick notes with little
|
||||
interruption of your work flow. Org lets you define templates for new
|
||||
entries and associate them with different targets for storing notes.
|
||||
|
||||
@menu
|
||||
* Setting up Remember for Org:: Some code for .emacs to get things going
|
||||
* Remember templates:: Define the outline of different note types
|
||||
* Storing notes:: Directly get the note to where it belongs
|
||||
* Setting up a capture location:: Where notes will be stored
|
||||
* Using capture:: Commands to invoke and terminate capture
|
||||
* Capture templates:: Define the outline of different note types
|
||||
@end menu
|
||||
|
||||
@node Setting up Remember for Org, Remember templates, Remember, Remember
|
||||
@unnumberedsubsec Setting up Remember for Org
|
||||
@node Setting up a capture location, Using capture, Capture, Capture
|
||||
@unnumberedsubsec Setting up a capture location
|
||||
|
||||
The following customization will tell Remember to use Org files as
|
||||
target, and to create annotations compatible with Org links.
|
||||
The following customization sets a default target@footnote{Using capture
|
||||
templates, you can define more fine-grained capture locations, see
|
||||
@ref{Capture templates}.} file for notes, and defines a global
|
||||
key@footnote{Please select your own key, @kbd{C-c c} is only a suggestion.}
|
||||
for capturing new stuff.
|
||||
|
||||
@smallexample
|
||||
(org-remember-insinuate)
|
||||
(setq org-directory "~/path/to/my/orgfiles/")
|
||||
@example
|
||||
(setq org-default-notes-file (concat org-directory "/notes.org"))
|
||||
(define-key global-map "\C-cr" 'org-remember)
|
||||
@end smallexample
|
||||
(define-key global-map "\C-cc" 'org-capture)
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
The last line binds the command @code{org-remember} to a global
|
||||
key@footnote{Please select your own key, @kbd{C-c r} is only a
|
||||
suggestion.}. @code{org-remember} basically just calls Remember,
|
||||
but it makes a few things easier: if there is an active region, it will
|
||||
automatically copy the region into the Remember buffer. It also allows
|
||||
to jump to the buffer and location where Remember notes are being
|
||||
stored: just call @code{org-remember} with a prefix argument. If you
|
||||
use two prefix arguments, Org jumps to the location where the last
|
||||
remember note was stored.
|
||||
@node Using capture, Capture templates, Setting up a capture location, Capture
|
||||
@unnumberedsubsec Using capture
|
||||
|
||||
@node Remember templates, Storing notes, Setting up Remember for Org, Remember
|
||||
@unnumberedsubsec Remember templates
|
||||
@table @kbd
|
||||
@item C-c c
|
||||
Start a capture process. You will be placed into a narrowed indirect buffer
|
||||
to edit the item.
|
||||
@item C-c C-c
|
||||
Once you are done entering information into the capture buffer,
|
||||
@kbd{C-c C-c} will return you to the window configuration before the capture
|
||||
process, so that you can resume your work without further distraction.
|
||||
@item C-c C-w
|
||||
Finalize by moving the entry to a refile location (@pxref{Refiling notes}).
|
||||
@item C-c C-k
|
||||
Abort the capture process and return to the previous state.
|
||||
@end table
|
||||
|
||||
In combination with Org, you can use templates to generate
|
||||
different types of Remember notes. For example, if you would like
|
||||
to use one template to create general TODO entries, another one for
|
||||
journal entries, and a third one for collecting random ideas, you could
|
||||
@node Capture templates, , Using capture, Capture
|
||||
@unnumberedsubsec Capture templates
|
||||
|
||||
You can use templates to generate different types of capture notes, and to
|
||||
store them in different places. For example, if you would like
|
||||
to store new tasks under a heading @samp{Tasks} in file @file{TODO.org}, and
|
||||
journal entries in a date tree in @file{journal.org} you could
|
||||
use:
|
||||
|
||||
@smallexample
|
||||
(setq org-remember-templates
|
||||
'(("Todo" ?t "* TODO %?\n %i\n %a" "~/org/TODO.org" "Tasks")
|
||||
("Journal" ?j "* %U %?\n\n %i\n %a" "~/org/JOURNAL.org")
|
||||
("Idea" ?i "* %^@{Title@}\n %i\n %a" "~/org/JOURNAL.org" "New Ideas")))
|
||||
(setq org-capture-templates
|
||||
'(("t" "Todo" entry (file+headline "~/org/gtd.org" "Tasks")
|
||||
"* TODO %?\n %i\n %a")
|
||||
("j" "Journal" entry (file+datetree "~/org/journal.org")
|
||||
"* %?\nEntered on %U\n %i\n %a")))
|
||||
@end smallexample
|
||||
|
||||
@noindent In these entries, the first string is just a name, and the
|
||||
character specifies how to select the template. It is useful if the
|
||||
character is also the first letter of the name. The next string specifies
|
||||
the template. Two more (optional) strings give the file in which, and the
|
||||
headline under which, the new note should be stored.
|
||||
@noindent In these entries, the first string is the key to reach the
|
||||
template, the second is a short description. Then follows the type of the
|
||||
entry and a definition of the target location for storing the note. Finally,
|
||||
the template itself, a string with %-escapes to fill in information based on
|
||||
time and context.
|
||||
|
||||
When you call @kbd{M-x org-remember} (or @kbd{M-x remember}) to remember
|
||||
something, Org will prompt for a key to select the template (if you have
|
||||
more than one template) and then prepare the buffer like
|
||||
When you call @kbd{M-x org-capture}, Org will prompt for a key to select the
|
||||
template (if you have more than one template) and then prepare the buffer like
|
||||
@smallexample
|
||||
* TODO
|
||||
[[file:@var{link to where you called remember}]]
|
||||
[[file:@var{link to where you were when initiating capture}]]
|
||||
@end smallexample
|
||||
|
||||
@noindent
|
||||
|
@ -1623,18 +1624,7 @@ possibilities, consult the manual for more.
|
|||
%u, %U @r{like the above, but inactive timestamps}
|
||||
@end smallexample
|
||||
|
||||
@node Storing notes, , Remember templates, Remember
|
||||
@unnumberedsubsec Storing notes
|
||||
|
||||
When you are finished preparing a note with Remember, you have to press
|
||||
@kbd{C-c C-c} to file the note away.
|
||||
|
||||
The handler will store the note in the file and under the headline
|
||||
specified in the template, or it will use the default file and headline. The
|
||||
window configuration will be restored, sending you back to the working
|
||||
context before the call to Remember.
|
||||
|
||||
@node Refiling notes, Archiving, Remember, Capture - Refile - Archive
|
||||
@node Refiling notes, Archiving, Capture, Capture - Refile - Archive
|
||||
@section Refiling notes
|
||||
|
||||
When reviewing the captured data, you may want to refile some of the entries
|
||||
|
@ -2432,10 +2422,8 @@ code.
|
|||
@section iCalendar export
|
||||
|
||||
@table @kbd
|
||||
@kindex C-c C-e i
|
||||
@item C-c C-e i
|
||||
Create iCalendar entries for the current file in a @file{.ics} file.
|
||||
@kindex C-c C-e c
|
||||
@item C-c C-e c
|
||||
Create a single large iCalendar file from all files in
|
||||
@code{org-agenda-files} and write it to the file given by
|
||||
|
|
|
@ -1,28 +1,26 @@
|
|||
;;; org-babel-C.el --- org-babel functions for C and similar languages
|
||||
;;; ob-C.el --- org-babel functions for C and similar languages
|
||||
|
||||
;; Copyright (C) 2010 Eric Schulte
|
||||
;; Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
|
@ -33,14 +31,15 @@
|
|||
;; - not much in the way of error feedback
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
(require 'org)
|
||||
(require 'cc-mode)
|
||||
|
||||
(org-babel-add-interpreter "C")
|
||||
(add-to-list 'org-babel-tangle-langs '("C" "c" nil))
|
||||
(declare-function org-entry-get "org" (&optional inherit))
|
||||
|
||||
(org-babel-add-interpreter "c++")
|
||||
(add-to-list 'org-babel-tangle-langs '("c++" "cpp" nil))
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("c++" . "cpp"))
|
||||
|
||||
(defvar org-babel-default-header-args:C '())
|
||||
|
||||
(defvar org-babel-C-compiler "gcc"
|
||||
"Command used to compile a C source code file into an
|
||||
|
@ -50,38 +49,44 @@
|
|||
"Command used to compile a c++ source code file into an
|
||||
executable.")
|
||||
|
||||
(defvar org-babel-c-variant nil
|
||||
"Internal variable used to hold which type of C (e.g. C or C++)
|
||||
is currently being evaluated.")
|
||||
|
||||
(defun org-babel-execute:cpp (body params)
|
||||
"Execute BODY according to PARAMS. This function calls
|
||||
`org-babel-execute:C'."
|
||||
(org-babel-execute:C body params))
|
||||
|
||||
(defun org-babel-execute:c++ (body params)
|
||||
"Execute a block of C++ code with org-babel. This function is
|
||||
called by `org-babel-execute-src-block'."
|
||||
(let ((c-variant 'cpp)) (org-babel-C-execute body params)))
|
||||
(let ((org-babel-c-variant 'cpp)) (org-babel-C-execute body params)))
|
||||
|
||||
(defun org-babel-expand-body:c++ (body params &optional processed-params)
|
||||
"Expand a block of C++ code with org-babel according to it's
|
||||
header arguments (calls `org-babel-C-expand')."
|
||||
(let ((c-variant 'cpp)) (org-babel-C-expand body params processed-params)))
|
||||
(let ((org-babel-c-variant 'cpp)) (org-babel-C-expand body params processed-params)))
|
||||
|
||||
(defun org-babel-execute:C (body params)
|
||||
"Execute a block of C code with org-babel. This function is
|
||||
called by `org-babel-execute-src-block'."
|
||||
(let ((c-variant 'c)) (org-babel-C-execute body params)))
|
||||
(let ((org-babel-c-variant 'c)) (org-babel-C-execute body params)))
|
||||
|
||||
(defun org-babel-expand-body:c (body params &optional processed-params)
|
||||
"Expand a block of C code with org-babel according to it's
|
||||
header arguments (calls `org-babel-C-expand')."
|
||||
(let ((c-variant 'c)) (org-babel-C-expand body params processed-params)))
|
||||
(let ((org-babel-c-variant 'c)) (org-babel-C-expand body params processed-params)))
|
||||
|
||||
(defun org-babel-C-execute (body params)
|
||||
"This should only be called by `org-babel-execute:C' or
|
||||
`org-babel-execute:c++'."
|
||||
"This function should only be called by `org-babel-execute:C'
|
||||
or `org-babel-execute:c++'."
|
||||
(message "executing C source code block")
|
||||
(let* ((processed-params (org-babel-process-params params))
|
||||
(tmp-src-file (make-temp-file "org-babel-C-src" nil
|
||||
(case c-variant
|
||||
('c ".c")
|
||||
('cpp ".cpp"))))
|
||||
(cond
|
||||
((equal org-babel-c-variant 'c) ".c")
|
||||
((equal org-babel-c-variant 'cpp) ".cpp"))))
|
||||
(tmp-bin-file (make-temp-file "org-babel-C-bin"))
|
||||
(tmp-out-file (make-temp-file "org-babel-C-out"))
|
||||
(cmdline (cdr (assoc :cmdline params)))
|
||||
|
@ -95,9 +100,9 @@ header arguments (calls `org-babel-C-expand')."
|
|||
(org-babel-shell-command-on-region
|
||||
(point-min) (point-max)
|
||||
(format "%s -o %s %s %s"
|
||||
(case c-variant
|
||||
('c org-babel-C-compiler)
|
||||
('cpp org-babel-c++-compiler))
|
||||
(cond
|
||||
((equal org-babel-c-variant 'c) org-babel-C-compiler)
|
||||
((equal org-babel-c-variant 'cpp) org-babel-c++-compiler))
|
||||
tmp-bin-file
|
||||
(mapconcat 'identity
|
||||
(if (listp flags) flags (list flags)) " ")
|
||||
|
@ -125,7 +130,7 @@ header arguments (calls `org-babel-C-expand')."
|
|||
(defun org-babel-C-expand (body params &optional processed-params)
|
||||
"Expand a block of C or C++ code with org-babel according to
|
||||
it's header arguments."
|
||||
(let ((vars (second (or processed-params
|
||||
(let ((vars (nth 1 (or processed-params
|
||||
(org-babel-process-params params))))
|
||||
(main-p (not (string= (cdr (assoc :main params)) "no")))
|
||||
(includes (or (cdr (assoc :includes params))
|
||||
|
@ -157,18 +162,21 @@ it's header arguments."
|
|||
(format "int main() {\n%s\n}\n" body)))
|
||||
|
||||
(defun org-babel-prep-session:C (session params)
|
||||
"C is a compiled languages -- no support for sessions"
|
||||
"This function does nothing as C is a compiled language with no
|
||||
support for sessions"
|
||||
(error "C is a compiled languages -- no support for sessions"))
|
||||
|
||||
(defun org-babel-load-session:C (session body params)
|
||||
"C is a compiled languages -- no support for sessions"
|
||||
"This function does nothing as C is a compiled language with no
|
||||
support for sessions"
|
||||
(error "C is a compiled languages -- no support for sessions"))
|
||||
|
||||
;; helper functions
|
||||
|
||||
(defun org-babel-C-var-to-C (pair)
|
||||
"Convert an elisp val into a string of C code specifying a var
|
||||
of the same value. TODO list support."
|
||||
of the same value."
|
||||
;; TODO list support
|
||||
(let ((var (car pair))
|
||||
(val (cdr pair)))
|
||||
(when (symbolp val)
|
||||
|
@ -189,5 +197,8 @@ of the same value. TODO list support."
|
|||
(format "u32 %S = %S;" var val)))))
|
||||
|
||||
|
||||
(provide 'org-babel-C)
|
||||
;;; org-babel-C.el ends here
|
||||
(provide 'ob-C)
|
||||
|
||||
;; arch-tag: 8f49e462-54e3-417b-9a8d-423864893b37
|
||||
|
||||
;;; ob-C.el ends here
|
|
@ -1,39 +1,33 @@
|
|||
;;; org-babel-R.el --- org-babel functions for R code evaluation
|
||||
;;; ob-R.el --- org-babel functions for R code evaluation
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Author: Eric Schulte, Dan Davison
|
||||
;; Keywords: literate programming, reproducible research, R, statistics
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating R code
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
|
||||
(org-babel-add-interpreter "R")
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("R" "R" "#!/usr/bin/env Rscript"))
|
||||
(require 'ob)
|
||||
|
||||
(defconst org-babel-header-arg-names:R
|
||||
'(width height bg units pointsize antialias quality compression
|
||||
|
@ -41,15 +35,18 @@
|
|||
pagecentre colormodel useDingbats horizontal)
|
||||
"R-specific header arguments.")
|
||||
|
||||
(defvar org-babel-default-header-args:R '())
|
||||
|
||||
(defun org-babel-expand-body:R (body params &optional processed-params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let* ((processed-params (or processed-params
|
||||
(org-babel-process-params params)))
|
||||
(vars (mapcar (lambda (i) (cons (car (nth i (second processed-params)))
|
||||
(vars (mapcar (lambda (i) (cons (car (nth i (nth 1 processed-params)))
|
||||
(org-babel-reassemble-table
|
||||
(cdr (nth i (second processed-params)))
|
||||
(cdr (nth i (fifth processed-params)))
|
||||
(cdr (nth i (sixth processed-params))))))
|
||||
(number-sequence 0 (1- (length (second processed-params))))))
|
||||
(cdr (nth i (nth 1 processed-params)))
|
||||
(cdr (nth i (nth 4 processed-params)))
|
||||
(cdr (nth i (nth 5 processed-params))))))
|
||||
(number-sequence 0 (1- (length (nth 1 processed-params))))))
|
||||
(out-file (cdr (assoc :file params))))
|
||||
(concat
|
||||
(if out-file (concat (org-babel-R-construct-graphics-device-call out-file params) "\n") "")
|
||||
|
@ -67,7 +64,7 @@ called by `org-babel-execute-src-block'."
|
|||
(message "executing R source code block...")
|
||||
(save-excursion
|
||||
(let* ((processed-params (org-babel-process-params params))
|
||||
(result-type (fourth processed-params))
|
||||
(result-type (nth 3 processed-params))
|
||||
(session (org-babel-R-initiate-session (first processed-params) params))
|
||||
(colnames-p (cdr (assoc :colnames params)))
|
||||
(rownames-p (cdr (assoc :rownames params)))
|
||||
|
@ -127,7 +124,7 @@ called by `org-babel-execute-src-block'."
|
|||
(insert "\n"))
|
||||
(format "%s <- read.table(\"%s\", header=%s, row.names=%s, sep=\"\\t\", as.is=TRUE)"
|
||||
name transition-file
|
||||
(if (or (eq (second value) 'hline) colnames-p) "TRUE" "FALSE")
|
||||
(if (or (eq (nth 1 value) 'hline) colnames-p) "TRUE" "FALSE")
|
||||
(if rownames-p "1" "NULL")))
|
||||
(format "%s <- %s" name (org-babel-R-quote-tsv-field value))))
|
||||
|
||||
|
@ -144,7 +141,7 @@ called by `org-babel-execute-src-block'."
|
|||
(if (stringp session) session (buffer-name)))) (current-buffer))))))
|
||||
|
||||
(defun org-babel-R-construct-graphics-device-call (out-file params)
|
||||
"Construct the call to the graphics device"
|
||||
"Construct the call to the graphics device."
|
||||
(let ((devices
|
||||
'((:bmp . "bmp")
|
||||
(:jpg . "jpeg")
|
||||
|
@ -211,8 +208,9 @@ last statement in BODY, as elisp."
|
|||
org-babel-R-eoe-indicator) "\n"))
|
||||
(output
|
||||
(mapconcat #'org-babel-chomp (list body org-babel-R-eoe-indicator) "\n"))))
|
||||
(raw (org-babel-comint-with-output session org-babel-R-eoe-output nil
|
||||
(insert full-body) (inferior-ess-send-input)))
|
||||
(raw
|
||||
(org-babel-comint-with-output (session org-babel-R-eoe-output)
|
||||
(insert full-body) (inferior-ess-send-input)))
|
||||
(comint-prompt-regexp
|
||||
(concat "^\\("
|
||||
inferior-ess-primary-prompt
|
||||
|
@ -242,13 +240,16 @@ last statement in BODY, as elisp."
|
|||
(delete nil (mapcar #'extractor (mapcar #'org-babel-chomp raw))) "\n"))))))))
|
||||
|
||||
(defun org-babel-R-process-value-result (result column-names-p)
|
||||
"R-specific processing of return value prior to return to org-babel.
|
||||
|
||||
Currently, insert hline if column names in output have been requested."
|
||||
"R-specific processing of return value prior to return to
|
||||
org-babel. Insert hline if column names in output have been
|
||||
requested."
|
||||
(if column-names-p
|
||||
(cons (car result) (cons 'hline (cdr result)))
|
||||
result))
|
||||
|
||||
|
||||
(provide 'org-babel-R)
|
||||
;;; org-babel-R.el ends here
|
||||
(provide 'ob-R)
|
||||
|
||||
;; arch-tag: cd4c7298-503b-450f-a3c2-f3e74b630237
|
||||
|
||||
;;; ob-R.el ends here
|
|
@ -1,28 +1,26 @@
|
|||
;;; org-babel-asymptote.el --- org-babel functions for asymptote evaluation
|
||||
;;; ob-asymptote.el --- org-babel functions for asymptote evaluation
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
|
@ -45,18 +43,18 @@
|
|||
;; - asy-mode :: Major mode for editing asymptote files
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(org-babel-add-interpreter "asymptote")
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("asymptote" "asymptote"))
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("asymptote" . "asy"))
|
||||
|
||||
(defvar org-babel-default-header-args:asymptote
|
||||
'((:results . "file") (:exports . "results"))
|
||||
"Default arguments to use when evaluating a asymptote source block.")
|
||||
|
||||
(defun org-babel-expand-body:asymptote (body params &optional processed-params)
|
||||
(let ((vars (second (or processed-params
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let ((vars (nth 1 (or processed-params
|
||||
(org-babel-process-params params)))))
|
||||
(concat (mapconcat 'org-babel-asymptote-var-to-asymptote vars "\n")
|
||||
"\n" body "\n")))
|
||||
|
@ -85,6 +83,7 @@ called by `org-babel-execute-src-block'."
|
|||
out-file))
|
||||
|
||||
(defun org-babel-prep-session:asymptote (session params)
|
||||
"Prepare a session named SESSION according to PARAMS."
|
||||
(error "Asymptote does not support sessions"))
|
||||
|
||||
(defun org-babel-asymptote-var-to-asymptote (pair)
|
||||
|
@ -133,10 +132,10 @@ Empty cells are ignored."
|
|||
(org-combine-plists '(:hline nil :sep "," :tstart "{" :tend "}") params))))
|
||||
|
||||
(defun org-babel-asymptote-define-type (data)
|
||||
"Determine type of DATA. DATA is a list.
|
||||
Type symbol is returned as 'symbol. The type is usually the type
|
||||
of the first atom encountered, except for arrays of int where
|
||||
every cell must be of int type."
|
||||
"Determine type of DATA. DATA is a list. Type symbol is
|
||||
returned as 'symbol. The type is usually the type of the first
|
||||
atom encountered, except for arrays of int where every cell must
|
||||
be of int type."
|
||||
(labels ((anything-but-int (el)
|
||||
(cond
|
||||
((null el) nil)
|
||||
|
@ -151,5 +150,8 @@ every cell must be of int type."
|
|||
(anything-but-int (cdr el)))))))
|
||||
(or (anything-but-int data) 'int)))
|
||||
|
||||
(provide 'org-babel-asymptote)
|
||||
;;; org-babel-asymptote.el ends here
|
||||
(provide 'ob-asymptote)
|
||||
|
||||
;; arch-tag: f2f5bd0d-78e8-412b-8e6c-6dadc94cc06b
|
||||
|
||||
;;; ob-asymptote.el ends here
|
|
@ -1,32 +1,30 @@
|
|||
;;; org-babel-clojure.el --- org-babel functions for clojure evaluation
|
||||
;;; ob-clojure.el --- org-babel functions for clojure evaluation
|
||||
|
||||
;; Copyright (C) 2009 Joel Boehland
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Joel Boehland
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Org-Babel support for evaluating clojure code
|
||||
;;; ob support for evaluating clojure code
|
||||
|
||||
;;; Requirements:
|
||||
|
||||
|
@ -40,15 +38,14 @@
|
|||
;;; web page: http://technomancy.us/126
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
(require 'cl)
|
||||
(require 'slime)
|
||||
(require 'swank-clojure)
|
||||
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("clojure" . "clj"))
|
||||
|
||||
(org-babel-add-interpreter "clojure")
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("clojure" "clj"))
|
||||
(defvar org-babel-default-header-args:clojure '())
|
||||
|
||||
(defvar org-babel-clojure-wrapper-method
|
||||
"
|
||||
|
@ -70,10 +67,12 @@
|
|||
|
||||
;;taken mostly from clojure-test-mode.el
|
||||
(defun org-babel-clojure-clojure-slime-eval (string &optional handler)
|
||||
"Evaluate a STRING of clojure code using `slime-eval-async'."
|
||||
(slime-eval-async `(swank:eval-and-grab-output ,string)
|
||||
(or handler #'identity)))
|
||||
|
||||
(defun org-babel-clojure-slime-eval-sync (string)
|
||||
"Evaluate a STRING of clojure code using `slime-eval'."
|
||||
(slime-eval `(swank:eval-and-grab-output ,string)))
|
||||
|
||||
;;taken from swank-clojure.el
|
||||
|
@ -102,7 +101,7 @@
|
|||
"clojure.main"))))))
|
||||
|
||||
(defun org-babel-clojure-table-or-string (results)
|
||||
"If the results look like a table, then convert them into an
|
||||
"If RESULTS looks like a table, then convert them into an
|
||||
Emacs-lisp table, otherwise return the results as a string."
|
||||
(org-babel-read
|
||||
(if (string-match "^\\[.+\\]$" results)
|
||||
|
@ -123,7 +122,7 @@ specifying a var of the same value."
|
|||
(format "%S" var)))
|
||||
|
||||
(defun org-babel-clojure-build-full-form (body vars)
|
||||
"Construct a clojure let form with vars as the let vars"
|
||||
"Construct a clojure let form with vars as the let vars."
|
||||
(let ((vars-forms (mapconcat ;; define any variables
|
||||
(lambda (pair)
|
||||
(format "%s %s" (car pair) (org-babel-clojure-var-to-clojure (cdr pair))))
|
||||
|
@ -155,11 +154,12 @@ specifying a var of the same value."
|
|||
(defvar org-babel-clojure-pending-sessions '())
|
||||
|
||||
(defun org-babel-clojure-session-buffer (session)
|
||||
"Return the buffer associated with SESSION."
|
||||
(cdr (assoc session org-babel-clojure-buffers)))
|
||||
|
||||
(defun org-babel-clojure-initiate-session-by-key (&optional session)
|
||||
"If there is not a current inferior-process-buffer in SESSION
|
||||
then create. Return the initialized session."
|
||||
then create one. Return the initialized session."
|
||||
(save-window-excursion
|
||||
(let* ((session (if session
|
||||
(if (stringp session) (intern session)
|
||||
|
@ -187,12 +187,12 @@ then create. Return the initialized session."
|
|||
|
||||
(defun org-babel-clojure-initiate-session (&optional session params)
|
||||
"Return the slime-clojure repl buffer bound to this session
|
||||
or nil if \"none\" is specified"
|
||||
or nil if \"none\" is specified."
|
||||
(unless (and (stringp session) (string= session "none"))
|
||||
(org-babel-clojure-session-buffer (org-babel-clojure-initiate-session-by-key session))))
|
||||
|
||||
(defun org-babel-clojure-session-connected-hook ()
|
||||
"Finish setting up the bindings of org-babel session to a slime-clojure repl"
|
||||
"Finish setting up the bindings of org-babel session to a slime-clojure repl."
|
||||
(let ((pending-session (pop org-babel-clojure-pending-sessions)))
|
||||
(when pending-session
|
||||
(save-excursion
|
||||
|
@ -203,16 +203,19 @@ or nil if \"none\" is specified"
|
|||
(add-hook 'slime-connected-hook 'org-babel-clojure-session-connected-hook)
|
||||
|
||||
(defun org-babel-clojure-bind-session-to-repl-buffer (session repl-buffer)
|
||||
"Associate SESSION with REPL-BUFFER."
|
||||
(when (stringp session) (setq session (intern session)))
|
||||
(setq org-babel-clojure-buffers
|
||||
(cons (cons session repl-buffer)
|
||||
(assq-delete-all session org-babel-clojure-buffers))))
|
||||
|
||||
(defun org-babel-clojure-repl-buffer-pred ()
|
||||
"Predicate used to test whether the passed in buffer is an active slime-clojure repl buffer"
|
||||
"Test whether the current buffer is an active slime-clojure
|
||||
repl buffer."
|
||||
(and (buffer-live-p (current-buffer)) (eq major-mode 'slime-repl-mode)))
|
||||
|
||||
(defun org-babel-clojure-bind-session-to-repl (session)
|
||||
"Bind SESSION to a clojure repl."
|
||||
(interactive "sEnter session name: ")
|
||||
(let ((repl-bufs (slime-filter-buffers 'org-babel-clojure-repl-buffer-pred)))
|
||||
(unless repl-bufs (error "No existing slime-clojure repl buffers exist"))
|
||||
|
@ -244,7 +247,7 @@ or nil if \"none\" is specified"
|
|||
(insert-file-contents (org-babel-maybe-remote-file tmp-file)) (buffer-string)))))))))
|
||||
|
||||
(defun org-babel-clojure-evaluate-session (buffer body &optional result-type)
|
||||
"Evaluate the body in the context of a clojure session"
|
||||
"Evaluate the body in the context of a clojure session."
|
||||
(let ((raw nil)
|
||||
(results nil))
|
||||
(save-window-excursion
|
||||
|
@ -265,8 +268,9 @@ last statement in BODY, as elisp."
|
|||
(org-babel-clojure-evaluate-external-process buffer body result-type)))
|
||||
|
||||
(defun org-babel-expand-body:clojure (body params &optional processed-params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(org-babel-clojure-build-full-form
|
||||
body (second (or processed-params (org-babel-process-params params)))))
|
||||
body (nth 1 (or processed-params (org-babel-process-params params)))))
|
||||
|
||||
(defun org-babel-execute:clojure (body params)
|
||||
"Execute a block of Clojure code with org-babel."
|
||||
|
@ -274,8 +278,12 @@ last statement in BODY, as elisp."
|
|||
(body (org-babel-expand-body:clojure body params processed-params))
|
||||
(session (org-babel-clojure-initiate-session (first processed-params))))
|
||||
(org-babel-reassemble-table
|
||||
(org-babel-clojure-evaluate session body (fourth processed-params))
|
||||
(org-babel-clojure-evaluate session body (nth 3 processed-params))
|
||||
(org-babel-pick-name (nth 4 processed-params) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name (nth 5 processed-params) (cdr (assoc :rownames params))))))
|
||||
|
||||
(provide 'org-babel-clojure)
|
||||
(provide 'ob-clojure)
|
||||
|
||||
;; arch-tag: a43b33f2-653e-46b1-ac56-2805cf05b7d1
|
||||
|
||||
;;; ob-clojure.el ends here
|
|
@ -1,28 +1,26 @@
|
|||
;;; org-babel-css.el --- org-babel functions for css evaluation
|
||||
;;; ob-css.el --- org-babel functions for css evaluation
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
|
@ -30,13 +28,12 @@
|
|||
;; CSS from org-mode files.
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
|
||||
(org-babel-add-interpreter "css")
|
||||
(defvar org-babel-default-header-args:css '())
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("css" "css" nil t))
|
||||
|
||||
(defun org-babel-expand-body:css (body params &optional processed-params) body)
|
||||
(defun org-babel-expand-body:css (body params &optional processed-params)
|
||||
"Expand BODY according to PARAMS, return the expanded body." body)
|
||||
|
||||
(defun org-babel-execute:css (body params)
|
||||
"Execute a block of CSS code with org-babel. This function is
|
||||
|
@ -48,5 +45,8 @@ called by `org-babel-execute-src-block'."
|
|||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
(error "CSS sessions are nonsensical"))
|
||||
|
||||
(provide 'org-babel-css)
|
||||
;;; org-babel-css.el ends here
|
||||
(provide 'ob-css)
|
||||
|
||||
;; arch-tag: f4447e8c-50ab-41f9-b322-b7b9574d9fbe
|
||||
|
||||
;;; ob-css.el ends here
|
|
@ -1,28 +1,26 @@
|
|||
;;; org-babel-ditaa.el --- org-babel functions for ditaa evaluation
|
||||
;;; ob-ditaa.el --- org-babel functions for ditaa evaluation
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
|
@ -39,17 +37,14 @@
|
|||
;; 4) there are no variables (at least for now)
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
|
||||
(org-babel-add-interpreter "ditaa")
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("ditaa" "ditaa"))
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-default-header-args:ditaa
|
||||
'((:results . "file") (:exports . "results"))
|
||||
"Default arguments to use when evaluating a ditaa source block.")
|
||||
|
||||
(defun org-babel-expand-body:ditaa (body params &optional processed-params) body)
|
||||
(defun org-babel-expand-body:ditaa (body params &optional processed-params)
|
||||
"Expand BODY according to PARAMS, return the expanded body." body)
|
||||
|
||||
(defun org-babel-execute:ditaa (body params)
|
||||
"Execute a block of Ditaa code with org-babel. This function is
|
||||
|
@ -67,7 +62,12 @@ called by `org-babel-execute-src-block'."
|
|||
out-file))
|
||||
|
||||
(defun org-babel-prep-session:ditaa (session params)
|
||||
"This function does nothing as ditaa does not support
|
||||
sessions."
|
||||
(error "Ditaa does not support sessions"))
|
||||
|
||||
(provide 'org-babel-ditaa)
|
||||
;;; org-babel-ditaa.el ends here
|
||||
(provide 'ob-ditaa)
|
||||
|
||||
;; arch-tag: 492cd006-07d9-4fac-bef6-5bb60b48842e
|
||||
|
||||
;;; ob-ditaa.el ends here
|
|
@ -1,28 +1,26 @@
|
|||
;;; org-babel-dot.el --- org-babel functions for dot evaluation
|
||||
;;; ob-dot.el --- org-babel functions for dot evaluation
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
|
@ -41,16 +39,13 @@
|
|||
;; 4) there are no variables (at least for now)
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
|
||||
(org-babel-add-interpreter "dot")
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("dot" "dot"))
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-default-header-args:dot '((:results . "file") (:exports . "results"))
|
||||
"Default arguments to use when evaluating a dot source block.")
|
||||
|
||||
(defun org-babel-expand-body:dot (body params &optional processed-params) body)
|
||||
(defun org-babel-expand-body:dot (body params &optional processed-params)
|
||||
"Expand BODY according to PARAMS, return the expanded body." body)
|
||||
|
||||
(defun org-babel-execute:dot (body params)
|
||||
"Execute a block of Dot code with org-babel. This function is
|
||||
|
@ -67,7 +62,11 @@ called by `org-babel-execute-src-block'."
|
|||
out-file))
|
||||
|
||||
(defun org-babel-prep-session:dot (session params)
|
||||
"Prepare SESSION according to the contents of PARAMS."
|
||||
(error "Dot does not support sessions"))
|
||||
|
||||
(provide 'org-babel-dot)
|
||||
;;; org-babel-dot.el ends here
|
||||
(provide 'ob-dot)
|
||||
|
||||
;; arch-tag: 817d0516-7b47-4f77-a8b2-2aadd8e4d0e2
|
||||
|
||||
;;; ob-dot.el ends here
|
|
@ -1,49 +1,49 @@
|
|||
;;; org-babel-emacs-lisp.el --- org-babel functions for emacs-lisp code evaluation
|
||||
;;; ob-emacs-lisp.el --- org-babel functions for emacs-lisp code evaluation
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating emacs-lisp code
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
|
||||
(org-babel-add-interpreter "emacs-lisp")
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("emacs-lisp" "el"))
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-default-header-args:emacs-lisp
|
||||
'((:hlines . "yes") (:colnames . "no"))
|
||||
"Default arguments to use when evaluating an emacs-lisp source block.")
|
||||
|
||||
(declare-function org-babel-comint-with-output "ob-comint" (&rest body))
|
||||
(declare-function org-babel-comint-buffer-livep "ob-comint" (buffer))
|
||||
(declare-function org-babel-comint-wait-for-output "ob-comint" (buffer))
|
||||
(declare-function org-babel-comint-in-buffer "ob-comint" (buffer &rest body))
|
||||
(declare-function orgtbl-to-generic "org-table" (table params))
|
||||
|
||||
(defun org-babel-expand-body:emacs-lisp (body params &optional processed-params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let* ((processed-params (or processed-params (org-babel-process-params params)))
|
||||
(vars (second processed-params))
|
||||
(processed-params (org-babel-process-params params))
|
||||
(result-params (third processed-params))
|
||||
(vars (nth 1 processed-params))
|
||||
(result-params (nth 2 processed-params))
|
||||
(print-level nil) (print-length nil)
|
||||
(body (if (> (length vars) 0)
|
||||
(concat "(let ("
|
||||
|
@ -63,9 +63,13 @@
|
|||
(let ((processed-params (org-babel-process-params params)))
|
||||
(org-babel-reassemble-table
|
||||
(eval (read (format "(progn %s)"
|
||||
(org-babel-expand-body:emacs-lisp body params))))
|
||||
(org-babel-expand-body:emacs-lisp
|
||||
body params processed-params))))
|
||||
(org-babel-pick-name (nth 4 processed-params) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name (nth 5 processed-params) (cdr (assoc :rownames params)))))))
|
||||
|
||||
(provide 'org-babel-emacs-lisp)
|
||||
;;; org-babel-emacs-lisp.el ends here
|
||||
(provide 'ob-emacs-lisp)
|
||||
|
||||
;; arch-tag: e9a3acca-dc84-472a-9f5a-23c35befbcd6
|
||||
|
||||
;;; ob-emacs-lisp.el ends here
|
|
@ -1,28 +1,26 @@
|
|||
;;; org-babel-gnuplot.el --- org-babel functions for gnuplot evaluation
|
||||
;;; ob-gnuplot.el --- org-babel functions for gnuplot evaluation
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
|
@ -41,13 +39,9 @@
|
|||
;; - gnuplot-mode :: http://cars9.uchicago.edu/~ravel/software/gnuplot-mode.html
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
(require 'gnuplot)
|
||||
|
||||
(org-babel-add-interpreter "gnuplot")
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("gnuplot" "gnuplot"))
|
||||
|
||||
(defvar org-babel-default-header-args:gnuplot
|
||||
'((:results . "file") (:exports . "results") (:session . nil))
|
||||
"Default arguments to use when evaluating a gnuplot source block.")
|
||||
|
@ -56,8 +50,9 @@
|
|||
|
||||
(defun org-babel-gnuplot-process-vars (params)
|
||||
"Extract variables from PARAMS and process the variables
|
||||
dumping all vectors into files returning an association list of
|
||||
variable names and the value to be used in the gnuplot code."
|
||||
dumping all vectors into files and returning an association list
|
||||
of variable names and the related value to be used in the gnuplot
|
||||
code."
|
||||
(mapcar
|
||||
(lambda (pair)
|
||||
(cons
|
||||
|
@ -69,6 +64,7 @@ variable names and the value to be used in the gnuplot code."
|
|||
(org-babel-ref-variables params)))
|
||||
|
||||
(defun org-babel-expand-body:gnuplot (body params &optional processed-params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(save-window-excursion
|
||||
(let* ((vars (org-babel-gnuplot-process-vars params))
|
||||
(out-file (cdr (assoc :file params)))
|
||||
|
@ -176,7 +172,7 @@ called by `org-babel-execute-src-block'."
|
|||
|
||||
(defun org-babel-gnuplot-initiate-session (&optional session params)
|
||||
"If there is not a current inferior-process-buffer in SESSION
|
||||
then create. Return the initialized session. The current
|
||||
then create one. Return the initialized session. The current
|
||||
`gnuplot-mode' doesn't provide support for multiple sessions."
|
||||
(unless (string= session "none")
|
||||
(save-window-excursion (gnuplot-send-string-to-gnuplot "" "line")
|
||||
|
@ -210,5 +206,8 @@ Pass PARAMS through to `orgtbl-to-generic' when exporting TABLE."
|
|||
params))))
|
||||
data-file)
|
||||
|
||||
(provide 'org-babel-gnuplot)
|
||||
;;; org-babel-gnuplot.el ends here
|
||||
(provide 'ob-gnuplot)
|
||||
|
||||
;; arch-tag: 50490ace-a9e1-4b29-a6e5-0db9f16c610b
|
||||
|
||||
;;; ob-gnuplot.el ends here
|
|
@ -1,28 +1,26 @@
|
|||
;;; org-babel-haskell.el --- org-babel functions for haskell evaluation
|
||||
;;; ob-haskell.el --- org-babel functions for haskell evaluation
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
|
@ -42,20 +40,21 @@
|
|||
;; - (optionally) lhs2tex :: http://people.cs.uu.nl/andres/lhs2tex/
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
(require 'haskell-mode)
|
||||
(require 'inf-haskell)
|
||||
|
||||
(org-babel-add-interpreter "haskell")
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("haskell" . "hs"))
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("haskell" "hs"))
|
||||
(defvar org-babel-default-header-args:haskell '())
|
||||
|
||||
(defvar org-babel-haskell-lhs2tex-command "lhs2tex")
|
||||
|
||||
(defvar org-babel-haskell-eoe "\"org-babel-haskell-eoe\"")
|
||||
|
||||
(defun org-babel-expand-body:haskell (body params &optional processed-params)
|
||||
(let (vars (second (or processed-params (org-babel-process-params params))))
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let (vars (nth 1 (or processed-params (org-babel-process-params params))))
|
||||
(concat
|
||||
(mapconcat
|
||||
(lambda (pair) (format "let %s = %s;" (car pair) (cdr pair)))
|
||||
|
@ -66,11 +65,12 @@
|
|||
(message "executing haskell source code block")
|
||||
(let* ((processed-params (org-babel-process-params params))
|
||||
(session (first processed-params))
|
||||
(vars (second processed-params))
|
||||
(result-type (fourth processed-params))
|
||||
(vars (nth 1 processed-params))
|
||||
(result-type (nth 3 processed-params))
|
||||
(full-body (org-babel-expand-body:haskell body params processed-params))
|
||||
(session (org-babel-prep-session:haskell session params))
|
||||
(raw (org-babel-comint-with-output session org-babel-haskell-eoe t
|
||||
(raw (org-babel-comint-with-output
|
||||
(session org-babel-haskell-eoe t full-body)
|
||||
(insert (org-babel-trim full-body))
|
||||
(comint-send-input nil t)
|
||||
(insert org-babel-haskell-eoe)
|
||||
|
@ -87,14 +87,14 @@
|
|||
(org-babel-pick-name (nth 5 processed-params) (cdr (assoc :rownames params))))))
|
||||
|
||||
(defun org-babel-haskell-read-string (string)
|
||||
"Strip \\\"s from around haskell string"
|
||||
"Strip \\\"s from around a haskell string."
|
||||
(if (string-match "^\"\\([^\000]+\\)\"$" string)
|
||||
(match-string 1 string)
|
||||
string))
|
||||
|
||||
(defun org-babel-haskell-initiate-session (&optional session params)
|
||||
"If there is not a current inferior-process-buffer in SESSION
|
||||
then create. Return the initialized session."
|
||||
then create one. Return the initialized session."
|
||||
;; TODO: make it possible to have multiple sessions
|
||||
(run-haskell) (current-buffer))
|
||||
|
||||
|
@ -141,7 +141,7 @@ Emacs-lisp table, otherwise return the results as a string."
|
|||
results)))
|
||||
|
||||
(defun org-babel-haskell-export-to-lhs (&optional arg)
|
||||
"Export to a .lhs with all haskell code blocks escaped
|
||||
"Export to a .lhs file with all haskell code blocks escaped
|
||||
appropriately. When called with a prefix argument the resulting
|
||||
.lhs file will be exported to a .tex file. This function will
|
||||
create two new files, base-name.lhs and base-name.tex where
|
||||
|
@ -201,5 +201,8 @@ constructs (header arguments, no-web syntax etc...) are ignored."
|
|||
;; process .lhs file with lhs2tex
|
||||
(message "running %s" command) (shell-command command) (find-file tex-file))))
|
||||
|
||||
(provide 'org-babel-haskell)
|
||||
;;; org-babel-haskell.el ends here
|
||||
(provide 'ob-haskell)
|
||||
|
||||
;; arch-tag: b53f75f3-ba1a-4b05-82d9-a2a0d4e70804
|
||||
|
||||
;;; ob-haskell.el ends here
|
|
@ -1,28 +1,26 @@
|
|||
;;; org-babel-latex.el --- org-babel functions for latex "evaluation"
|
||||
;;; ob-latex.el --- org-babel functions for latex "evaluation"
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
|
@ -33,24 +31,23 @@
|
|||
;; be created directly form the latex source code.
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
|
||||
(org-babel-add-interpreter "latex")
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("latex" "tex"))
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("latex" . "tex"))
|
||||
|
||||
(defvar org-babel-default-header-args:latex
|
||||
'((:results . "latex") (:exports . "results"))
|
||||
"Default arguments to use when evaluating a latex source block.")
|
||||
|
||||
(defun org-babel-expand-body:latex (body params &optional processed-params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(mapc (lambda (pair) ;; replace variables
|
||||
(setq body
|
||||
(replace-regexp-in-string
|
||||
(regexp-quote (format "%S" (car pair)))
|
||||
(if (stringp (cdr pair))
|
||||
(cdr pair) (format "%S" (cdr pair)))
|
||||
body))) (second (org-babel-process-params params)))
|
||||
body))) (nth 1 (org-babel-process-params params)))
|
||||
body)
|
||||
|
||||
(defun org-babel-execute:latex (body params)
|
||||
|
@ -83,7 +80,8 @@ called by `org-babel-execute-src-block'."
|
|||
body))
|
||||
|
||||
(defun org-babel-latex-body-to-tex-file (tex-file body &optional height width)
|
||||
"Extracted from `org-create-formula-image' in org.el."
|
||||
"Place the contents of BODY into TEX-FILE. Extracted from
|
||||
`org-create-formula-image' in org.el."
|
||||
(with-temp-file tex-file
|
||||
(insert (org-splice-latex-header
|
||||
org-format-latex-header
|
||||
|
@ -101,7 +99,8 @@ called by `org-babel-execute-src-block'."
|
|||
(org-export-latex-fix-inputenc)))
|
||||
|
||||
(defun org-babel-latex-tex-to-pdf (tex-file)
|
||||
"Extracted from `org-export-as-pdf' in org-latex.el."
|
||||
"Generate a pdf according to the contents TEX-FILE. Extracted
|
||||
from `org-export-as-pdf' in org-latex.el."
|
||||
(let* ((wconfig (current-window-configuration))
|
||||
(default-directory (file-name-directory tex-file))
|
||||
(base (file-name-sans-extension tex-file))
|
||||
|
@ -134,7 +133,11 @@ called by `org-babel-execute-src-block'."
|
|||
pdffile)))
|
||||
|
||||
(defun org-babel-prep-session:latex (session params)
|
||||
"Create a session named SESSION according to PARAMS."
|
||||
(error "Latex does not support sessions"))
|
||||
|
||||
(provide 'org-babel-latex)
|
||||
;;; org-babel-latex.el ends here
|
||||
(provide 'ob-latex)
|
||||
|
||||
;; arch-tag: 1f13f7e2-26de-4c24-9274-9f331d4c6ff3
|
||||
|
||||
;;; ob-latex.el ends here
|
|
@ -1,28 +1,26 @@
|
|||
;;; org-babel-matlab.el --- org-babel support for matlab evaluation
|
||||
;;; ob-matlab.el --- org-babel support for matlab evaluation
|
||||
|
||||
;; Copyright (C) Dan Davison
|
||||
;; Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Dan Davison
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
|
@ -39,16 +37,15 @@
|
|||
|
||||
;;; Code:
|
||||
(require 'matlab)
|
||||
(require 'org-babel-octave)
|
||||
|
||||
(org-babel-add-interpreter "matlab")
|
||||
(add-to-list 'org-babel-tangle-langs '("matlab" "m" "#!/usr/bin/env matlab"))
|
||||
(require 'ob-octave)
|
||||
|
||||
(defvar org-babel-default-header-args:matlab '())
|
||||
|
||||
(defvar org-babel-matlab-shell-command "matlab -nosplash"
|
||||
"Shell command to use to run matlab as an external process.")
|
||||
|
||||
(defun org-babel-expand-body:matlab (body params &optional processed-params) body)
|
||||
(defun org-babel-expand-body:matlab (body params &optional processed-params)
|
||||
"Expand BODY according to PARAMS, return the expanded body." body)
|
||||
|
||||
(defvar org-babel-matlab-with-emacs-link nil
|
||||
"If non-nil use matlab-shell-run-region for session
|
||||
|
@ -68,13 +65,17 @@ delete('%s')
|
|||
(org-babel-execute:octave body params 'matlab))
|
||||
|
||||
(defun org-babel-prep-session:matlab (session params)
|
||||
"Prepare SESSION according to PARAMS."
|
||||
(org-babel-prep-session:octave session params 'matlab))
|
||||
|
||||
(defun org-babel-matlab-initiate-session (&optional session params)
|
||||
"Create matlab inferior process buffer.
|
||||
If there is not a current inferior-process-buffer in SESSION
|
||||
then create. Return the initialized session."
|
||||
"Create a matlab inferior process buffer. If there is not a
|
||||
current inferior-process-buffer in SESSION then create. Return
|
||||
the initialized session."
|
||||
(org-babel-octave-initiate-session session params 'matlab))
|
||||
|
||||
(provide 'org-babel-matlab)
|
||||
;;; org-babel-matlab.el ends here
|
||||
(provide 'ob-matlab)
|
||||
|
||||
;; arch-tag: 6b234299-c1f7-4eb1-ace8-7b93344065ac
|
||||
|
||||
;;; ob-matlab.el ends here
|
|
@ -1,28 +1,26 @@
|
|||
;;; org-babel-ocaml.el --- org-babel functions for ocaml evaluation
|
||||
;;; ob-ocaml.el --- org-babel functions for ocaml evaluation
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
|
@ -38,18 +36,19 @@
|
|||
;; - tuareg-mode :: http://www-rocq.inria.fr/~acohen/tuareg/
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
(require 'tuareg)
|
||||
|
||||
(org-babel-add-interpreter "ocaml")
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("ocaml" . "ml"))
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("ocaml" "ml"))
|
||||
(defvar org-babel-default-header-args:ocaml '())
|
||||
|
||||
(defvar org-babel-ocaml-eoe-indicator "\"org-babel-ocaml-eoe\";;")
|
||||
(defvar org-babel-ocaml-eoe-output "org-babel-ocaml-eoe")
|
||||
|
||||
(defun org-babel-expand-body:ocaml (body params &optional processed-params)
|
||||
(let ((vars (second (or processed-params (org-babel-process-params params)))))
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let ((vars (nth 1 (or processed-params (org-babel-process-params params)))))
|
||||
(concat
|
||||
(mapconcat
|
||||
(lambda (pair) (format "let %s = %s;" (car pair) (cdr pair)))
|
||||
|
@ -59,10 +58,11 @@
|
|||
"Execute a block of Ocaml code with org-babel."
|
||||
(message "executing ocaml source code block")
|
||||
(let* ((processed-params (org-babel-process-params params))
|
||||
(vars (second processed-params))
|
||||
(vars (nth 1 processed-params))
|
||||
(full-body (org-babel-expand-body:ocaml body params processed-params))
|
||||
(session (org-babel-prep-session:ocaml session params))
|
||||
(raw (org-babel-comint-with-output session org-babel-ocaml-eoe-output t
|
||||
(raw (org-babel-comint-with-output
|
||||
(session org-babel-ocaml-eoe-output t full-body)
|
||||
(insert (concat (org-babel-chomp full-body) " ;;"))
|
||||
(comint-send-input nil t)
|
||||
(insert org-babel-ocaml-eoe-indicator)
|
||||
|
@ -83,6 +83,8 @@
|
|||
(get-buffer tuareg-interactive-buffer-name))))
|
||||
|
||||
(defun org-babel-ocaml-parse-output (output)
|
||||
"Parse OUTPUT where OUTPUT is string output from an ocaml
|
||||
process."
|
||||
(let ((regexp "%s = \\(.+\\)$"))
|
||||
(cond
|
||||
((string-match (format regexp "string") output)
|
||||
|
@ -122,5 +124,8 @@ Emacs-lisp table, otherwise return the results as a string."
|
|||
"'" "\"" results)))))
|
||||
results)))
|
||||
|
||||
(provide 'org-babel-ocaml)
|
||||
;;; org-babel-ocaml.el ends here
|
||||
(provide 'ob-ocaml)
|
||||
|
||||
;; arch-tag: 2e815f4d-365e-4d69-b1df-dd17fdd7b7b7
|
||||
|
||||
;;; ob-ocaml.el ends here
|
|
@ -1,28 +1,26 @@
|
|||
;;; org-babel-octave.el --- org-babel functions for octave and matlab evaluation
|
||||
;;; ob-octave.el --- org-babel functions for octave and matlab evaluation
|
||||
|
||||
;; Copyright (C) Dan Davison
|
||||
;; Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Dan Davison
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
|
@ -32,17 +30,17 @@
|
|||
;; octave-mode.el and octave-inf.el come with GNU emacs
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
(require 'octave-inf)
|
||||
|
||||
(org-babel-add-interpreter "octave")
|
||||
(add-to-list 'org-babel-tangle-langs '("octave" "m" "#!/usr/bin/env octave"))
|
||||
(defvar org-babel-default-header-args:octave '())
|
||||
|
||||
(defvar org-babel-octave-shell-command "octave -q"
|
||||
"Shell command to use to run octave as an external process.")
|
||||
|
||||
(defun org-babel-expand-body:octave (body params &optional processed-params)
|
||||
(let ((vars (second (or processed-params (org-babel-process-params params)))))
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let ((vars (nth 1 (or processed-params (org-babel-process-params params)))))
|
||||
(concat
|
||||
;; prepend code to define all arguments passed to the code block
|
||||
;; (may not be appropriate for all languages)
|
||||
|
@ -60,9 +58,9 @@
|
|||
;; set the session if the session variable is non-nil
|
||||
(session (funcall (intern (format "org-babel-%s-initiate-session" lang))
|
||||
(first processed-params) params))
|
||||
(vars (second processed-params))
|
||||
(result-params (third processed-params))
|
||||
(result-type (fourth processed-params))
|
||||
(vars (nth 1 processed-params))
|
||||
(result-params (nth 2 processed-params))
|
||||
(result-type (nth 3 processed-params))
|
||||
(out-file (cdr (assoc :file params)))
|
||||
(augmented-body (org-babel-expand-body:octave body params processed-params))
|
||||
(result (org-babel-octave-evaluate session augmented-body result-type matlabp)))
|
||||
|
@ -97,9 +95,9 @@ specifying a variable of the same value."
|
|||
session))
|
||||
|
||||
(defun org-babel-octave-initiate-session (&optional session params matlabp)
|
||||
"Create octave inferior process buffer.
|
||||
If there is not a current inferior-process-buffer in SESSION
|
||||
then create. Return the initialized session."
|
||||
"Create an octave inferior process buffer. If there is not a
|
||||
current inferior-process-buffer in SESSION then create. Return
|
||||
the initialized session."
|
||||
(unless (string= session "none")
|
||||
(let ((session (or session (if matlabp "*Inferior Matlab*" "*Inferior Octave*"))))
|
||||
(if (org-babel-comint-buffer-livep session) session
|
||||
|
@ -120,15 +118,16 @@ end")
|
|||
(defvar org-babel-octave-eoe-output "ans = org_babel_eoe")
|
||||
|
||||
(defun org-babel-octave-evaluate (session body result-type lang)
|
||||
"Pass BODY to the octave process.
|
||||
If RESULT-TYPE equals 'output then return the outputs of the
|
||||
statements in BODY, if RESULT-TYPE equals 'value then return the
|
||||
value of the last statement in BODY, as elisp."
|
||||
"Pass BODY to the octave process in SESSION. If RESULT-TYPE
|
||||
equals 'output then return the outputs of the statements in BODY,
|
||||
if RESULT-TYPE equals 'value then return the value of the last
|
||||
statement in BODY, as elisp."
|
||||
(if session
|
||||
(org-babel-octave-evaluate-session session body result-type matlabp)
|
||||
(org-babel-octave-evaluate-external-process body result-type matlabp)))
|
||||
|
||||
(defun org-babel-octave-evaluate-external-process (body result-type matlabp)
|
||||
"Evaluate BODY in an external octave process."
|
||||
(let ((cmd (if matlabp org-babel-matlab-shell-command org-babel-octave-shell-command)))
|
||||
(save-excursion
|
||||
(case result-type
|
||||
|
@ -149,6 +148,7 @@ value of the last statement in BODY, as elisp."
|
|||
(org-babel-octave-import-elisp-from-file (org-babel-maybe-remote-file tmp-file))))))))
|
||||
|
||||
(defun org-babel-octave-evaluate-session (session body result-type &optional matlabp)
|
||||
"Evaluate BODY in SESSION."
|
||||
(let* ((tmp-file (make-temp-file "org-babel-results-"))
|
||||
(wait-file (make-temp-file "org-babel-matlab-emacs-link-wait-signal-"))
|
||||
(full-body
|
||||
|
@ -178,8 +178,12 @@ value of the last statement in BODY, as elisp."
|
|||
;; make *matlab* buffer contents easily
|
||||
;; available, so :results output currently
|
||||
;; won't work
|
||||
(org-babel-comint-with-output session
|
||||
(if matlabp org-babel-octave-eoe-indicator org-babel-octave-eoe-output) t
|
||||
(org-babel-comint-with-output
|
||||
(session
|
||||
(if matlabp
|
||||
org-babel-octave-eoe-indicator
|
||||
org-babel-octave-eoe-output)
|
||||
t full-body)
|
||||
(insert full-body) (comint-send-input nil t)))) results)
|
||||
(case result-type
|
||||
(value
|
||||
|
@ -196,9 +200,8 @@ value of the last statement in BODY, as elisp."
|
|||
(mapconcat #'identity (reverse results) "\n"))))))
|
||||
|
||||
(defun org-babel-octave-import-elisp-from-file (file-name)
|
||||
"Import data written to file by octave.
|
||||
This removes initial blank and comment lines and then calls
|
||||
`org-babel-import-elisp-from-file'."
|
||||
"Import data from FILE-NAME. This removes initial blank and
|
||||
comment lines and then calls `org-babel-import-elisp-from-file'."
|
||||
(let ((temp-file (make-temp-file "org-babel-results-")) beg end)
|
||||
(with-temp-file temp-file
|
||||
(insert-file-contents file-name)
|
||||
|
@ -214,5 +217,8 @@ This removes initial blank and comment lines and then calls
|
|||
(match-string 1 string)
|
||||
string))
|
||||
|
||||
(provide 'org-babel-octave)
|
||||
;;; org-babel-octave.el ends here
|
||||
(provide 'ob-octave)
|
||||
|
||||
;; arch-tag: d8e5f68b-ba13-440a-a495-b653e989e704
|
||||
|
||||
;;; ob-octave.el ends here
|
|
@ -1,42 +1,41 @@
|
|||
;;; org-babel-perl.el --- org-babel functions for perl evaluation
|
||||
;;; ob-perl.el --- org-babel functions for perl evaluation
|
||||
|
||||
;; Copyright (C) 2009 Dan Davison, Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation
|
||||
|
||||
;; Author: Dan Davison, Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating perl source code.
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
|
||||
(org-babel-add-interpreter "perl")
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("perl" . "pl"))
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("perl" "pl" "#!/usr/bin/env perl"))
|
||||
(defvar org-babel-default-header-args:perl '())
|
||||
|
||||
(defun org-babel-expand-body:perl (body params &optional processed-params)
|
||||
(let ((vars (second (or processed-params (org-babel-process-params params)))))
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let ((vars (nth 1 (or processed-params (org-babel-process-params params)))))
|
||||
(concat
|
||||
(mapconcat ;; define any variables
|
||||
(lambda (pair)
|
||||
|
@ -51,9 +50,9 @@ called by `org-babel-execute-src-block'."
|
|||
(message "executing Perl source code block")
|
||||
(let* ((processed-params (org-babel-process-params params))
|
||||
(session (first processed-params))
|
||||
(vars (second processed-params))
|
||||
(result-params (third processed-params))
|
||||
(result-type (fourth processed-params))
|
||||
(vars (nth 1 processed-params))
|
||||
(result-params (nth 2 processed-params))
|
||||
(result-type (nth 3 processed-params))
|
||||
(full-body (org-babel-expand-body:perl
|
||||
body params processed-params)) ;; then the source block body
|
||||
(session (org-babel-perl-initiate-session session)))
|
||||
|
@ -126,5 +125,8 @@ last statement in BODY, as elisp."
|
|||
;; comint session evaluation
|
||||
(error "Sessions are not supported for Perl.")))
|
||||
|
||||
(provide 'org-babel-perl)
|
||||
;;; org-babel-perl.el ends here
|
||||
(provide 'ob-perl)
|
||||
|
||||
;; arch-tag: 88ef9396-d857-4dc3-8946-5a72bdfa2337
|
||||
|
||||
;;; ob-perl.el ends here
|
|
@ -1,51 +1,50 @@
|
|||
;;; org-babel-python.el --- org-babel functions for python evaluation
|
||||
;;; ob-python.el --- org-babel functions for python evaluation
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Author: Eric Schulte, Dan Davison
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating python source code.
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'org-babel-tangle)
|
||||
(require 'org-babel-comint)
|
||||
(require 'ob)
|
||||
(require 'ob-tangle)
|
||||
(require 'ob-comint)
|
||||
(require (if (featurep 'xemacs) 'python-mode 'python))
|
||||
|
||||
(org-babel-add-interpreter "python")
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("python" . "py"))
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("python" "py" "#!/usr/bin/env python"))
|
||||
(defvar org-babel-default-header-args:python '())
|
||||
|
||||
(defun org-babel-expand-body:python (body params &optional processed-params)
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(concat
|
||||
(mapconcat ;; define any variables
|
||||
(lambda (pair)
|
||||
(format "%s=%s"
|
||||
(car pair)
|
||||
(org-babel-python-var-to-python (cdr pair))))
|
||||
(second (or processed-params (org-babel-process-params params))) "\n")
|
||||
(nth 1 (or processed-params (org-babel-process-params params))) "\n")
|
||||
"\n" (org-babel-trim body) "\n"))
|
||||
|
||||
(defun org-babel-execute:python (body params)
|
||||
|
@ -54,8 +53,8 @@ called by `org-babel-execute-src-block'."
|
|||
(message "executing Python source code block")
|
||||
(let* ((processed-params (org-babel-process-params params))
|
||||
(session (org-babel-python-initiate-session (first processed-params)))
|
||||
(result-params (third processed-params))
|
||||
(result-type (fourth processed-params))
|
||||
(result-params (nth 2 processed-params))
|
||||
(result-type (nth 3 processed-params))
|
||||
(full-body (org-babel-expand-body:python
|
||||
body params processed-params)) ;; then the source block body
|
||||
(result (org-babel-python-evaluate session full-body result-type)))
|
||||
|
@ -97,7 +96,7 @@ called by `org-babel-execute-src-block'."
|
|||
specifying a var of the same value."
|
||||
(if (listp var)
|
||||
(concat "[" (mapconcat #'org-babel-python-var-to-python var ", ") "]")
|
||||
(format "%S" var)))
|
||||
(if (equal var 'hline) "None" (format "%S" var))))
|
||||
|
||||
(defun org-babel-python-table-or-string (results)
|
||||
"If the results look like a list or tuple, then convert them into an
|
||||
|
@ -111,12 +110,15 @@ Emacs-lisp table, otherwise return the results as a string."
|
|||
"\\[" "(" (replace-regexp-in-string
|
||||
"\\]" ")" (replace-regexp-in-string
|
||||
", " " " (replace-regexp-in-string
|
||||
"'" "\"" results))))))
|
||||
"'" "\""
|
||||
(replace-regexp-in-string
|
||||
"None" "hline" results t)))))))
|
||||
results)))
|
||||
|
||||
(defvar org-babel-python-buffers '(:default . nil))
|
||||
|
||||
(defun org-babel-python-session-buffer (session)
|
||||
"Return the buffer associated with SESSION."
|
||||
(cdr (assoc session org-babel-python-buffers)))
|
||||
|
||||
(defun org-babel-python-initiate-session-by-key (&optional session)
|
||||
|
@ -145,6 +147,7 @@ then create. Return the initialized session."
|
|||
session)))
|
||||
|
||||
(defun org-babel-python-initiate-session (&optional session params)
|
||||
"Create a session named SESSION according to PARAMS."
|
||||
(unless (string= session "none")
|
||||
(org-babel-python-session-buffer (org-babel-python-initiate-session-by-key session))))
|
||||
|
||||
|
@ -214,7 +217,8 @@ last statement in BODY, as elisp."
|
|||
(org-babel-python-table-or-string raw)))))))
|
||||
;; comint session evaluation
|
||||
(org-babel-comint-in-buffer buffer
|
||||
(let* ((raw (org-babel-comint-with-output buffer org-babel-python-eoe-indicator t
|
||||
(let* ((raw (org-babel-comint-with-output
|
||||
(buffer org-babel-python-eoe-indicator t full-body)
|
||||
;; for some reason python is fussy, and likes enters after every input
|
||||
(let ((comint-process-echoes nil))
|
||||
(mapc (lambda (statement) (insert statement) (comint-send-input))
|
||||
|
@ -249,5 +253,8 @@ last statement in BODY, as elisp."
|
|||
(match-string 1 string)
|
||||
string))
|
||||
|
||||
(provide 'org-babel-python)
|
||||
;;; org-babel-python.el ends here
|
||||
(provide 'ob-python)
|
||||
|
||||
;; arch-tag: f19b6c3d-dfcb-4a1a-9ce0-45ade1ebc212
|
||||
|
||||
;;; ob-python.el ends here
|
|
@ -1,28 +1,26 @@
|
|||
;;; org-babel-ruby.el --- org-babel functions for ruby evaluation
|
||||
;;; ob-ruby.el --- org-babel functions for ruby evaluation
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
|
@ -39,15 +37,16 @@
|
|||
;; http://github.com/eschulte/rinari/raw/master/util/inf-ruby.el
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
(require 'inf-ruby)
|
||||
|
||||
(org-babel-add-interpreter "ruby")
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("ruby" . "rb"))
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("ruby" "rb" "#!/usr/bin/env ruby"))
|
||||
(defvar org-babel-default-header-args:ruby '())
|
||||
|
||||
(defun org-babel-expand-body:ruby (body params &optional processed-params)
|
||||
(let ((vars (second (or processed-params (org-babel-process-params params)))))
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let ((vars (nth 1 (or processed-params (org-babel-process-params params)))))
|
||||
(concat
|
||||
(mapconcat ;; define any variables
|
||||
(lambda (pair)
|
||||
|
@ -62,8 +61,8 @@ called by `org-babel-execute-src-block'."
|
|||
(message "executing Ruby source code block")
|
||||
(let* ((processed-params (org-babel-process-params params))
|
||||
(session (org-babel-ruby-initiate-session (first processed-params)))
|
||||
(result-params (third processed-params))
|
||||
(result-type (fourth processed-params))
|
||||
(result-params (nth 2 processed-params))
|
||||
(result-type (nth 3 processed-params))
|
||||
(full-body (org-babel-expand-body:ruby
|
||||
body params processed-params))
|
||||
(result (org-babel-ruby-evaluate session full-body result-type)))
|
||||
|
@ -113,7 +112,7 @@ specifying a var of the same value."
|
|||
(format "%S" var)))
|
||||
|
||||
(defun org-babel-ruby-table-or-string (results)
|
||||
"If the results look like a table, then convert them into an
|
||||
"If RESULTS look like a table, then convert them into an
|
||||
Emacs-lisp table, otherwise return the results as a string."
|
||||
(message "converting %S" results)
|
||||
(org-babel-read
|
||||
|
@ -129,7 +128,7 @@ Emacs-lisp table, otherwise return the results as a string."
|
|||
|
||||
(defun org-babel-ruby-initiate-session (&optional session params)
|
||||
"If there is not a current inferior-process-buffer in SESSION
|
||||
then create. Return the initialized session."
|
||||
then create one. Return the initialized session."
|
||||
(unless (string= session "none")
|
||||
(let ((session-buffer (save-window-excursion
|
||||
(run-ruby nil session) (current-buffer))))
|
||||
|
@ -213,7 +212,7 @@ last statement in BODY, as elisp."
|
|||
org-babel-ruby-last-value-eval)
|
||||
org-babel-ruby-eoe-indicator) "\n"))
|
||||
(raw (org-babel-comint-with-output
|
||||
buffer org-babel-ruby-eoe-indicator t
|
||||
(buffer org-babel-ruby-eoe-indicator t full-body)
|
||||
(insert full-body) (comint-send-input nil t)))
|
||||
(results (cdr (member
|
||||
org-babel-ruby-eoe-indicator
|
||||
|
@ -227,10 +226,13 @@ last statement in BODY, as elisp."
|
|||
(org-babel-ruby-table-or-string (car results))))))))
|
||||
|
||||
(defun org-babel-ruby-read-string (string)
|
||||
"Strip \\\"s from around ruby string"
|
||||
"Strip \\\"s from around a ruby string."
|
||||
(if (string-match "^\"\\([^\000]+\\)\"$" string)
|
||||
(match-string 1 string)
|
||||
string))
|
||||
|
||||
(provide 'org-babel-ruby)
|
||||
;;; org-babel-ruby.el ends here
|
||||
(provide 'ob-ruby)
|
||||
|
||||
;; arch-tag: 3e9726db-4520-49e2-b263-e8f571ac88f5
|
||||
|
||||
;;; ob-ruby.el ends here
|
|
@ -1,28 +1,26 @@
|
|||
;;; org-babel-sass.el --- org-babel functions for the sass css generation language
|
||||
;;; ob-sass.el --- org-babel functions for the sass css generation language
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
|
@ -41,14 +39,13 @@
|
|||
;; - sass-mode :: http://github.com/nex3/haml/blob/master/extra/sass-mode.el
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
(require 'sass-mode)
|
||||
|
||||
(org-babel-add-interpreter "sass")
|
||||
(defvar org-babel-default-header-args:sass '())
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("sass" "sass"))
|
||||
|
||||
(defun org-babel-expand-body:sass (body params &optional processed-params) body)
|
||||
(defun org-babel-expand-body:sass (body params &optional processed-params)
|
||||
"Expand BODY according to PARAMS, return the expanded body." body)
|
||||
|
||||
(defun org-babel-execute:sass (body params)
|
||||
"Execute a block of Sass code with org-babel. This function is
|
||||
|
@ -65,7 +62,11 @@ called by `org-babel-execute-src-block'."
|
|||
(or file (with-temp-buffer (insert-file-contents out-file) (buffer-string)))))
|
||||
|
||||
(defun org-babel-prep-session:sass (session params)
|
||||
"This function does nothing as sass does not support sessions."
|
||||
(error "Sass does not support sessions"))
|
||||
|
||||
(provide 'org-babel-sass)
|
||||
;;; org-babel-sass.el ends here
|
||||
(provide 'ob-sass)
|
||||
|
||||
;; arch-tag: 2954b169-eef4-45ce-a8e5-3e619f0f07ac
|
||||
|
||||
;;; ob-sass.el ends here
|
|
@ -1,28 +1,26 @@
|
|||
;;; org-babel-screen.el --- org-babel support for interactive terminal
|
||||
;;; ob-screen.el --- org-babel support for interactive terminal
|
||||
|
||||
;; Copyright (C) 2009 Benjamin Andresen
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation
|
||||
|
||||
;; Author: Benjamin Andresen
|
||||
;; Keywords: literate programming, interactive shell
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
|
@ -36,11 +34,7 @@
|
|||
;; M-x org-babel-screen-test RET
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
|
||||
(org-babel-add-interpreter "screen")
|
||||
|
||||
(add-to-list 'org-src-lang-modes '("screen" . sh))
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-screen-location "screen"
|
||||
"The command location for screen.
|
||||
|
@ -50,7 +44,8 @@ In case you want to use a different screen than one selected by your $PATH")
|
|||
'((:results . "silent") (:session . "default") (:cmd . "sh") (:terminal . "xterm"))
|
||||
"Default arguments to use when running screen source blocks.")
|
||||
|
||||
(defun org-babel-expand-body:screen (body params &optional processed-params) body)
|
||||
(defun org-babel-expand-body:screen (body params &optional processed-params)
|
||||
"Expand BODY according to PARAMS, return the expanded body." body)
|
||||
|
||||
(defun org-babel-execute:screen (body params)
|
||||
"Send a block of code via screen to a terminal using org-babel.
|
||||
|
@ -68,7 +63,7 @@ In case you want to use a different screen than one selected by your $PATH")
|
|||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
(let* ((processed-params (org-babel-process-params params))
|
||||
(session (first processed-params))
|
||||
(vars (second processed-params))
|
||||
(vars (nth 1 processed-params))
|
||||
(socket (org-babel-screen-session-socketname session))
|
||||
(vars (org-babel-ref-variables params))
|
||||
(cmd (cdr (assoc :cmd params)))
|
||||
|
@ -121,8 +116,8 @@ In case you want to use a different screen than one selected by your $PATH")
|
|||
tmpfile))
|
||||
|
||||
(defun org-babel-screen-test ()
|
||||
"Command that tests if the default setup works.
|
||||
The terminal should shortly flicker."
|
||||
"Test if the default setup works. The terminal should shortly
|
||||
flicker."
|
||||
(interactive)
|
||||
(let* ((session "org-babel-testing")
|
||||
(random-string (format "%s" (random 99999)))
|
||||
|
@ -143,5 +138,8 @@ The terminal should shortly flicker."
|
|||
"WORKS."
|
||||
"DOESN'T work.")))))
|
||||
|
||||
(provide 'org-babel-screen)
|
||||
;;; org-babel-screen.el ends here
|
||||
(provide 'ob-screen)
|
||||
|
||||
;; arch-tag: 908e5afe-89a0-4f27-b982-23f1f2e3bac9
|
||||
|
||||
;;; ob-screen.el ends here
|
|
@ -1,47 +1,53 @@
|
|||
;;; org-babel-sh.el --- org-babel functions for shell evaluation
|
||||
;;; ob-sh.el --- org-babel functions for shell evaluation
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating shell source code.
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
(require 'shell)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(org-babel-add-interpreter "sh")
|
||||
(declare-function org-babel-ref-variables "ob-ref" (params))
|
||||
(declare-function org-babel-comint-in-buffer "ob-comint" (buffer &rest body))
|
||||
(declare-function org-babel-comint-wait-for-output "ob-comint" (buffer))
|
||||
(declare-function org-babel-comint-buffer-livep "ob-comint" (buffer))
|
||||
(declare-function org-babel-comint-with-output "ob-comint" (meta &rest body))
|
||||
(declare-function orgtbl-to-generic "org-table" (table params))
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("sh" "sh" "#!/usr/bin/env sh"))
|
||||
(defvar org-babel-default-header-args:sh '())
|
||||
|
||||
(defvar org-babel-sh-command "sh"
|
||||
"Command used to invoke a shell. This will be passed to
|
||||
`shell-command-on-region'")
|
||||
|
||||
(defun org-babel-expand-body:sh (body params &optional processed-params)
|
||||
(let ((vars (second (or processed-params (org-babel-process-params params))))
|
||||
"Expand BODY according to PARAMS, return the expanded body."
|
||||
(let ((vars (nth 1 (or processed-params (org-babel-process-params params))))
|
||||
(sep (cdr (assoc :separator params))))
|
||||
(concat
|
||||
(mapconcat ;; define any variables
|
||||
|
@ -56,8 +62,8 @@
|
|||
function is called by `org-babel-execute-src-block'."
|
||||
(message "executing Shell source code block")
|
||||
(let* ((processed-params (org-babel-process-params params))
|
||||
(session (org-babel-sh-initiate-session (first processed-params)))
|
||||
(result-params (third processed-params))
|
||||
(session (org-babel-sh-initiate-session (nth 0 processed-params)))
|
||||
(result-params (nth 2 processed-params))
|
||||
(full-body (org-babel-expand-body:sh
|
||||
body params processed-params))) ;; then the source block body
|
||||
(org-babel-reassemble-table
|
||||
|
@ -120,7 +126,8 @@ Emacs-lisp table, otherwise return the results as a string."
|
|||
results)))
|
||||
|
||||
(defun org-babel-sh-initiate-session (&optional session params)
|
||||
(unless (string= session "none")
|
||||
"Initiate a session named SESSION according to PARAMS."
|
||||
(when (and session (not (string= session "none")))
|
||||
(save-window-excursion
|
||||
(or (org-babel-comint-buffer-livep session)
|
||||
(progn (shell session) (get-buffer (current-buffer)))))))
|
||||
|
@ -164,7 +171,7 @@ last statement in BODY."
|
|||
(mapcar #'org-babel-sh-strip-weird-long-prompt
|
||||
(mapcar #'org-babel-trim
|
||||
(org-babel-comint-with-output
|
||||
session org-babel-sh-eoe-output t
|
||||
(session org-babel-sh-eoe-output t body)
|
||||
(mapc (lambda (line) (insert line) (comint-send-input))
|
||||
(strip-empty (split-string body "\n")))
|
||||
(insert org-babel-sh-eoe-indicator)
|
||||
|
@ -183,9 +190,13 @@ last statement in BODY."
|
|||
"")))))
|
||||
|
||||
(defun org-babel-sh-strip-weird-long-prompt (string)
|
||||
"Remove prompt cruft from a string of shell output."
|
||||
(while (string-match "^% +[\r\n$]+ *" string)
|
||||
(setq string (substring string (match-end 0))))
|
||||
string)
|
||||
|
||||
(provide 'org-babel-sh)
|
||||
;;; org-babel-sh.el ends here
|
||||
(provide 'ob-sh)
|
||||
|
||||
;; arch-tag: 416dd531-c230-4b0a-a5bf-8d948f990f2d
|
||||
|
||||
;;; ob-sh.el ends here
|
|
@ -1,28 +1,26 @@
|
|||
;;; org-babel-sql.el --- org-babel functions for sql evaluation
|
||||
;;; ob-sql.el --- org-babel functions for sql evaluation
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
|
@ -45,13 +43,12 @@
|
|||
;;
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
|
||||
(org-babel-add-interpreter "sql")
|
||||
(defvar org-babel-default-header-args:sql '())
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("sql" "sql"))
|
||||
|
||||
(defun org-babel-expand-body:sql (body params &optional processed-params) body)
|
||||
(defun org-babel-expand-body:sql (body params &optional processed-params)
|
||||
"Expand BODY according to PARAMS, return the expanded body." body)
|
||||
|
||||
(defun org-babel-execute:sql (body params)
|
||||
"Execute a block of Sql code with org-babel. This function is
|
||||
|
@ -83,5 +80,8 @@ called by `org-babel-execute-src-block'."
|
|||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
(error "sql sessions not yet implemented"))
|
||||
|
||||
(provide 'org-babel-sql)
|
||||
;;; org-babel-sql.el ends here
|
||||
(provide 'ob-sql)
|
||||
|
||||
;; arch-tag: a43ff944-6de1-4566-a83c-626814e3dad2
|
||||
|
||||
;;; ob-sql.el ends here
|
94
lisp/babel/langs/ob-sqlite.el
Normal file
94
lisp/babel/langs/ob-sqlite.el
Normal file
|
@ -0,0 +1,94 @@
|
|||
;;; ob-sqlite.el --- org-babel functions for sqlite database interaction
|
||||
|
||||
;; Copyright (C) 2010 Free Software Foundation
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Org-Babel support for evaluating sqlite source code.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-default-header-args:sqlite '())
|
||||
|
||||
(defun org-babel-expand-body:sqlite
|
||||
(body params &optional processed-params) body)
|
||||
|
||||
(defvar org-babel-sqlite3-command "sqlite3")
|
||||
|
||||
(defun org-babel-execute:sqlite (body params)
|
||||
"Execute a block of Sqlite code with org-babel. This function is
|
||||
called by `org-babel-execute-src-block'."
|
||||
(message "executing Sqlite source code block")
|
||||
(let ((result-params (split-string (or (cdr (assoc :results params)) "")))
|
||||
(vars (org-babel-ref-variables params))
|
||||
(headers-p (equal "yes" (cdr (assoc :colnames params)))))
|
||||
(with-temp-buffer
|
||||
(insert
|
||||
(shell-command-to-string
|
||||
(format "%s %s -csv %s %S"
|
||||
org-babel-sqlite3-command
|
||||
(if headers-p "-header" "")
|
||||
(cdr (assoc :db params))
|
||||
(org-babel-sqlite-expand-vars body vars))))
|
||||
(if (or (member "scalar" result-params)
|
||||
(member "code" result-params))
|
||||
(buffer-string)
|
||||
(org-table-convert-region (point-min) (point-max))
|
||||
(org-babel-sqlite-table-or-scalar
|
||||
(org-babel-sqlite-offset-colnames
|
||||
(org-table-to-lisp) headers-p))))))
|
||||
|
||||
(defun org-babel-sqlite-expand-vars (body vars)
|
||||
"Expand the variables held in VARS in BODY."
|
||||
(mapc
|
||||
(lambda (pair)
|
||||
(setq body (replace-regexp-in-string
|
||||
(format "\$%s" (car pair))
|
||||
(format "%S" (cdr pair))
|
||||
body)))
|
||||
vars)
|
||||
body)
|
||||
|
||||
(defun org-babel-sqlite-table-or-scalar (result)
|
||||
"If RESULT looks like a trivial table, then unwrap it."
|
||||
(if (and (equal 1 (length result))
|
||||
(equal 1 (length (car result))))
|
||||
(caar result)
|
||||
result))
|
||||
|
||||
(defun org-babel-sqlite-offset-colnames (table headers-p)
|
||||
"If HEADERS-P is non-nil then offset the first row as column names."
|
||||
(if headers-p
|
||||
(cons (car table) (cons 'hline (cdr table)))
|
||||
table))
|
||||
|
||||
(defun org-babel-prep-session:sqlite (session params)
|
||||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
(error "sqlite sessions not yet implemented"))
|
||||
|
||||
(provide 'ob-sqlite)
|
||||
|
||||
;; arch-tag: 5c03d7f2-0f72-48b8-bbd1-35aafea248ac
|
||||
|
||||
;;; ob-sqlite.el ends here
|
139
lisp/babel/ob-comint.el
Normal file
139
lisp/babel/ob-comint.el
Normal file
|
@ -0,0 +1,139 @@
|
|||
;;; ob-comint.el --- org-babel functions for interaction with comint buffers
|
||||
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research, comint
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; These functions build on comint to ease the sending and receiving
|
||||
;; of commands and results from comint buffers.
|
||||
|
||||
;; Note that the buffers in this file are analogous to sessions in
|
||||
;; org-babel at large.
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'comint)
|
||||
|
||||
(defun org-babel-comint-buffer-livep (buffer)
|
||||
"Check if BUFFER is a comint buffer with a live process."
|
||||
(let ((buffer (if buffer (get-buffer buffer))))
|
||||
(and buffer (buffer-live-p buffer) (get-buffer-process buffer) buffer)))
|
||||
|
||||
(defmacro org-babel-comint-in-buffer (buffer &rest body)
|
||||
"Check BUFFER with `org-babel-comint-buffer-livep' then execute
|
||||
body inside the protection of `save-window-excursion' and
|
||||
`save-match-data'."
|
||||
(declare (indent 1))
|
||||
`(save-excursion
|
||||
(save-match-data
|
||||
(unless (org-babel-comint-buffer-livep ,buffer)
|
||||
(error (format "buffer %s doesn't exist or has no process" ,buffer)))
|
||||
(set-buffer ,buffer)
|
||||
,@body)))
|
||||
|
||||
(defmacro org-babel-comint-with-output (meta &rest body)
|
||||
"Evaluate BODY in BUFFER, wait until EOE-INDICATOR appears in
|
||||
output, then return all process output. If REMOVE-ECHO and
|
||||
FULL-BODY are present and non-nil, then strip echo'd body from
|
||||
the returned output. META should be a list containing the
|
||||
following where the last two elements are optional.
|
||||
|
||||
(BUFFER EOE-INDICATOR REMOVE-ECHO FULL-BODY)
|
||||
|
||||
This macro ensures that the filter is removed in case of an error
|
||||
or user `keyboard-quit' during execution of body."
|
||||
(declare (indent 1))
|
||||
(let ((buffer (car meta))
|
||||
(eoe-indicator (cadr meta))
|
||||
(remove-echo (cadr (cdr meta)))
|
||||
(full-body (cadr (cdr (cdr meta)))))
|
||||
`(org-babel-comint-in-buffer ,buffer
|
||||
(let ((string-buffer "") dangling-text)
|
||||
(flet ((my-filt (text)
|
||||
(setq string-buffer (concat string-buffer text))))
|
||||
;; setup filter
|
||||
(add-hook 'comint-output-filter-functions 'my-filt)
|
||||
(unwind-protect
|
||||
(progn
|
||||
;; got located, and save dangling text
|
||||
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
||||
(let ((start (point))
|
||||
(end (point-max)))
|
||||
(setq dangling-text (buffer-substring start end))
|
||||
(delete-region start end))
|
||||
;; pass FULL-BODY to process
|
||||
,@body
|
||||
;; wait for end-of-evaluation indicator
|
||||
(while (progn
|
||||
(goto-char comint-last-input-end)
|
||||
(not (save-excursion
|
||||
(and (re-search-forward
|
||||
comint-prompt-regexp nil t)
|
||||
(re-search-forward
|
||||
(regexp-quote ,eoe-indicator) nil t)))))
|
||||
(accept-process-output (get-buffer-process (current-buffer)))
|
||||
;; thought the following this would allow async
|
||||
;; background running, but I was wrong...
|
||||
;; (run-with-timer .5 .5 'accept-process-output
|
||||
;; (get-buffer-process (current-buffer)))
|
||||
)
|
||||
;; replace cut dangling text
|
||||
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
||||
(insert dangling-text))
|
||||
;; remove filter
|
||||
(remove-hook 'comint-output-filter-functions 'my-filt)))
|
||||
;; remove echo'd FULL-BODY from input
|
||||
(if (and ,remove-echo ,full-body
|
||||
(string-match
|
||||
(replace-regexp-in-string
|
||||
"\n" "[\r\n]+" (regexp-quote ,full-body))
|
||||
string-buffer))
|
||||
(setq raw (substring string-buffer (match-end 0))))
|
||||
(split-string string-buffer comint-prompt-regexp)))))
|
||||
|
||||
(defun org-babel-comint-input-command (buffer cmd)
|
||||
"Pass CMD to BUFFER The input will not be echoed."
|
||||
(org-babel-comint-in-buffer buffer
|
||||
(goto-char (process-mark (get-buffer-process buffer)))
|
||||
(insert cmd)
|
||||
(comint-send-input)
|
||||
(org-babel-comint-wait-for-output buffer)))
|
||||
|
||||
(defun org-babel-comint-wait-for-output (buffer)
|
||||
"Wait until output arrives from BUFFER. Note: this is only
|
||||
safe when waiting for the result of a single statement (not large
|
||||
blocks of code)."
|
||||
(org-babel-comint-in-buffer buffer
|
||||
(while (progn
|
||||
(goto-char comint-last-input-end)
|
||||
(not (and (re-search-forward comint-prompt-regexp nil t)
|
||||
(goto-char (match-beginning 0))
|
||||
(string= (face-name (face-at-point))
|
||||
"comint-highlight-prompt"))))
|
||||
(accept-process-output (get-buffer-process buffer)))))
|
||||
|
||||
(provide 'ob-comint)
|
||||
|
||||
;; arch-tag: 9adddce6-0864-4be3-b0b5-6c5157dc7889
|
||||
|
||||
;;; ob-comint.el ends here
|
|
@ -1,41 +1,52 @@
|
|||
;;; org-babel-exp.el --- Exportation of org-babel source blocks
|
||||
;;; ob-exp.el --- Exportation of org-babel source blocks
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte, Dan Davison
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte, Dan Davison
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; for more information see the comments in org-babel.el
|
||||
;; See the online documentation for more information
|
||||
;;
|
||||
;; http://orgmode.org/worg/org-contrib/babel/
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
(require 'org-exp-blocks)
|
||||
(org-export-blocks-add-block '(src org-babel-exp-src-blocks nil))
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(defvar obe-marker nil)
|
||||
(defvar org-current-export-file)
|
||||
(defvar org-babel-lob-one-liner-regexp)
|
||||
(defvar org-babel-ref-split-regexp)
|
||||
(declare-function org-babel-lob-get-info "ob-lob" ())
|
||||
(declare-function org-babel-ref-literal "ob-ref" (ref))
|
||||
|
||||
(add-to-list 'org-export-interblocks '(src org-babel-exp-inline-src-blocks))
|
||||
(add-to-list 'org-export-interblocks '(lob org-babel-exp-lob-one-liners))
|
||||
(add-hook 'org-export-blocks-postblock-hook 'org-exp-res/src-name-cleanup)
|
||||
|
||||
(org-export-blocks-add-block '(src org-babel-exp-src-blocks nil))
|
||||
|
||||
(defvar org-babel-function-def-export-keyword "function"
|
||||
"When exporting a source block function, this keyword will
|
||||
appear in the exported version in the place of source name
|
||||
|
@ -57,8 +68,6 @@ will be indented by this many characters. See
|
|||
`org-babel-function-def-export-name' for the definition of a
|
||||
source block function.")
|
||||
|
||||
(defvar obe-marker nil)
|
||||
|
||||
(defun org-babel-exp-src-blocks (body &rest headers)
|
||||
"Process src block for export. Depending on the 'export'
|
||||
headers argument in replace the source code block with...
|
||||
|
@ -74,19 +83,18 @@ results - just like none only the block is run on export ensuring
|
|||
none ----- do not display either code or results upon export"
|
||||
(interactive)
|
||||
(message "org-babel-exp processing...")
|
||||
(when (member (first headers) org-babel-interpreters)
|
||||
(save-excursion
|
||||
(goto-char (match-beginning 0))
|
||||
(let* ((info (org-babel-get-src-block-info))
|
||||
(params (third info)))
|
||||
;; expand noweb references in the original file
|
||||
(setf (second info)
|
||||
(if (and (cdr (assoc :noweb params))
|
||||
(string= "yes" (cdr (assoc :noweb params))))
|
||||
(org-babel-expand-noweb-references
|
||||
info (get-file-buffer org-current-export-file))
|
||||
(second info)))
|
||||
(org-babel-exp-do-export info 'block)))))
|
||||
(save-excursion
|
||||
(goto-char (match-beginning 0))
|
||||
(let* ((info (org-babel-get-src-block-info))
|
||||
(params (nth 2 info)))
|
||||
;; expand noweb references in the original file
|
||||
(setf (nth 1 info)
|
||||
(if (and (cdr (assoc :noweb params))
|
||||
(string= "yes" (cdr (assoc :noweb params))))
|
||||
(org-babel-expand-noweb-references
|
||||
info (get-file-buffer org-current-export-file))
|
||||
(nth 1 info)))
|
||||
(org-babel-exp-do-export info 'block))))
|
||||
|
||||
(defun org-babel-exp-inline-src-blocks (start end)
|
||||
"Process inline src blocks between START and END for export.
|
||||
|
@ -98,18 +106,18 @@ options and are taken from `org-babel-defualt-inline-header-args'."
|
|||
(while (and (< (point) end)
|
||||
(re-search-forward org-babel-inline-src-block-regexp end t))
|
||||
(let* ((info (save-match-data (org-babel-parse-inline-src-block-match)))
|
||||
(params (third info))
|
||||
(params (nth 2 info))
|
||||
(replacement
|
||||
(save-match-data
|
||||
(if (org-babel-in-example-or-verbatim)
|
||||
(buffer-substring (match-beginning 0) (match-end 0))
|
||||
;; expand noweb references in the original file
|
||||
(setf (second info)
|
||||
(setf (nth 1 info)
|
||||
(if (and (cdr (assoc :noweb params))
|
||||
(string= "yes" (cdr (assoc :noweb params))))
|
||||
(org-babel-expand-noweb-references
|
||||
info (get-file-buffer org-current-export-file))
|
||||
(second info)))
|
||||
(nth 1 info)))
|
||||
(org-babel-exp-do-export info 'inline)))))
|
||||
(setq end (+ end (- (length replacement) (length (match-string 1)))))
|
||||
(replace-match replacement t t nil 1)))))
|
||||
|
@ -170,13 +178,13 @@ options are taken from `org-babel-default-header-args'."
|
|||
(defun org-babel-exp-do-export (info type)
|
||||
"Return a string containing the exported content of the current
|
||||
code block respecting the value of the :exports header argument."
|
||||
(flet ((silently () (let ((session (cdr (assoc :session (third info)))))
|
||||
(flet ((silently () (let ((session (cdr (assoc :session (nth 2 info)))))
|
||||
(when (and session
|
||||
(not (equal "none" session))
|
||||
(not (assoc :noeval (third info))))
|
||||
(not (assoc :noeval (nth 2 info))))
|
||||
(org-babel-exp-results info type 'silent))))
|
||||
(clean () (org-babel-remove-result info)))
|
||||
(case (intern (or (cdr (assoc :exports (third info))) "code"))
|
||||
(case (intern (or (cdr (assoc :exports (nth 2 info))) "code"))
|
||||
('none (silently) (clean) "")
|
||||
('code (silently) (clean) (org-babel-exp-code info type))
|
||||
('results (org-babel-exp-results info type))
|
||||
|
@ -184,26 +192,27 @@ code block respecting the value of the :exports header argument."
|
|||
"\n\n"
|
||||
(org-babel-exp-results info type))))))
|
||||
|
||||
(defvar backend)
|
||||
(defun org-babel-exp-code (info type)
|
||||
"Return the code the current code block in a manner suitable
|
||||
for exportation by org-mode. This function is called by
|
||||
`org-babel-exp-do-export'. The code block will not be
|
||||
evaluated."
|
||||
(let ((lang (first info))
|
||||
(body (second info))
|
||||
(switches (fourth info))
|
||||
(name (fifth info))
|
||||
(let ((lang (nth 0 info))
|
||||
(body (nth 1 info))
|
||||
(switches (nth 3 info))
|
||||
(name (nth 4 info))
|
||||
(args (mapcar
|
||||
#'cdr
|
||||
(remove-if-not (lambda (el) (eq :var (car el))) (third info)))))
|
||||
(org-remove-if-not (lambda (el) (eq :var (car el))) (nth 2 info)))))
|
||||
(case type
|
||||
('inline (format "=%s=" body))
|
||||
('block
|
||||
(let ((str
|
||||
(let ((str
|
||||
(format "#+BEGIN_SRC %s %s\n%s%s#+END_SRC\n" lang switches body
|
||||
(if (and body (string-match "\n$" body))
|
||||
"" "\n"))))
|
||||
(when name
|
||||
(when name
|
||||
(add-text-properties
|
||||
0 (length str)
|
||||
(list 'org-caption
|
||||
|
@ -214,12 +223,12 @@ evaluated."
|
|||
str))
|
||||
('lob
|
||||
(let ((call-line (and (string-match "results=" (car args))
|
||||
(substring (car args) (match-end 0)))))
|
||||
(cond
|
||||
((eq backend 'html)
|
||||
(format "\n#+HTML: <label class=\"org-src-name\">%s</label>\n"
|
||||
(substring (car args) (match-end 0)))))
|
||||
(cond
|
||||
((eq backend 'html)
|
||||
(format "\n#+HTML: <label class=\"org-src-name\">%s</label>\n"
|
||||
call-line))
|
||||
((t (format ": %s\n" call-line)))))))))
|
||||
((format ": %s\n" call-line))))))))
|
||||
|
||||
(defun org-babel-exp-results (info type &optional silent)
|
||||
"Return the results of the current code block in a manner
|
||||
|
@ -227,8 +236,8 @@ suitable for exportation by org-mode. This function is called by
|
|||
`org-babel-exp-do-export'. The code block will be evaluated.
|
||||
Optional argument SILENT can be used to inhibit insertion of
|
||||
results into the buffer."
|
||||
(let ((lang (first info))
|
||||
(body (second info))
|
||||
(let ((lang (nth 0 info))
|
||||
(body (nth 1 info))
|
||||
(params
|
||||
;; lets ensure that we lookup references in the original file
|
||||
(mapcar
|
||||
|
@ -236,42 +245,48 @@ results into the buffer."
|
|||
(if (and org-current-export-file
|
||||
(eq (car pair) :var)
|
||||
(string-match org-babel-ref-split-regexp (cdr pair))
|
||||
(null (org-babel-ref-literal (match-string 2 (cdr pair)))))
|
||||
(equal :ob-must-be-reference
|
||||
(org-babel-ref-literal (match-string 2 (cdr pair)))))
|
||||
`(:var . ,(concat (match-string 1 (cdr pair))
|
||||
"=" org-current-export-file
|
||||
":" (match-string 2 (cdr pair))))
|
||||
pair))
|
||||
(third info))))
|
||||
(case type
|
||||
('inline
|
||||
(let ((raw (org-babel-execute-src-block
|
||||
nil info '((:results . "silent"))))
|
||||
(result-params (split-string (cdr (assoc :results params)))))
|
||||
(unless silent
|
||||
(cond ;; respect the value of the :results header argument
|
||||
((member "file" result-params)
|
||||
(org-babel-result-to-file raw))
|
||||
((or (member "raw" result-params) (member "org" result-params))
|
||||
(format "%s" raw))
|
||||
((member "code" result-params)
|
||||
(format "src_%s{%s}" lang raw))
|
||||
(t
|
||||
(if (stringp raw)
|
||||
(if (= 0 (length raw)) "=(no results)="
|
||||
(format "%s" raw))
|
||||
(format "%S" raw)))))))
|
||||
('block
|
||||
(org-babel-execute-src-block
|
||||
nil info (org-babel-merge-params
|
||||
params `((:results . ,(if silent "silent" "replace")))))
|
||||
"")
|
||||
('lob
|
||||
(save-excursion
|
||||
(re-search-backward org-babel-lob-one-liner-regexp nil t)
|
||||
(org-babel-execute-src-block
|
||||
nil info (org-babel-merge-params
|
||||
params `((:results . ,(if silent "silent" "replace")))))
|
||||
"")))))
|
||||
(nth 2 info))))
|
||||
;; skip code blocks which we can't evaluate
|
||||
(when (fboundp (intern (concat "org-babel-execute:" lang)))
|
||||
(case type
|
||||
('inline
|
||||
(let ((raw (org-babel-execute-src-block
|
||||
nil info '((:results . "silent"))))
|
||||
(result-params (split-string (cdr (assoc :results params)))))
|
||||
(unless silent
|
||||
(cond ;; respect the value of the :results header argument
|
||||
((member "file" result-params)
|
||||
(org-babel-result-to-file raw))
|
||||
((or (member "raw" result-params) (member "org" result-params))
|
||||
(format "%s" raw))
|
||||
((member "code" result-params)
|
||||
(format "src_%s{%s}" lang raw))
|
||||
(t
|
||||
(if (stringp raw)
|
||||
(if (= 0 (length raw)) "=(no results)="
|
||||
(format "%s" raw))
|
||||
(format "%S" raw)))))))
|
||||
('block
|
||||
(org-babel-execute-src-block
|
||||
nil info (org-babel-merge-params
|
||||
params `((:results . ,(if silent "silent" "replace")))))
|
||||
"")
|
||||
('lob
|
||||
(save-excursion
|
||||
(re-search-backward org-babel-lob-one-liner-regexp nil t)
|
||||
(org-babel-execute-src-block
|
||||
nil info (org-babel-merge-params
|
||||
params `((:results . ,(if silent "silent" "replace")))))
|
||||
""))))))
|
||||
|
||||
(provide 'org-babel-exp)
|
||||
;;; org-babel-exp.el ends here
|
||||
(provide 'ob-exp)
|
||||
|
||||
;; arch-tag: 523abf4c-76d1-44ed-9f27-e3bddf34bf0f
|
||||
|
||||
;;; ob-exp.el ends here
|
|
@ -1,38 +1,36 @@
|
|||
;;; org-babel-keys.el --- key bindings for org-babel
|
||||
;;; ob-keys.el --- key bindings for org-babel
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Add some org-babel keybindings to the org-mode keymap for exposing
|
||||
;; org-babel functions. These will all share the common C-c M-b
|
||||
;; prefix. See the value of `org-babel-key-bindings' for a list of
|
||||
;; interactive functions and their associated keys.
|
||||
;; Add org-babel keybindings to the org-mode keymap for exposing
|
||||
;; org-babel functions. These will all share a common prefix. See
|
||||
;; the value of `org-babel-key-bindings' for a list of interactive
|
||||
;; functions and their associated keys.
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
|
||||
(defvar org-babel-key-prefix "\C-c\C-v"
|
||||
"The `org-babel-key-prefix' variable holds the key prefix
|
||||
|
@ -45,8 +43,7 @@ functions which are assigned key bindings, and see
|
|||
"The keymap holding key bindings for interactive org-babel
|
||||
functions.")
|
||||
|
||||
(define-key org-mode-map org-babel-key-prefix org-babel-map)
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-describe-bindings ()
|
||||
"Describe all key binding placed behind the
|
||||
`org-babel-key-prefix' prefix."
|
||||
|
@ -78,9 +75,8 @@ with keys. Each element of this list will add an entry to the
|
|||
`org-babel-map' using the letter key which is the `car' of the
|
||||
a-list placed behind the generic `org-babel-key-prefix'.")
|
||||
|
||||
(mapc (lambda (pair)
|
||||
(define-key org-babel-map (car pair) (cdr pair)))
|
||||
org-babel-key-bindings)
|
||||
(provide 'ob-keys)
|
||||
|
||||
(provide 'org-babel-keys)
|
||||
;;; org-babel-keys.el ends here
|
||||
;; arch-tag: 01e348ee-4906-46fa-839a-6b7b6f989048
|
||||
|
||||
;;; ob-keys.el ends here
|
|
@ -1,37 +1,36 @@
|
|||
;;; org-babel-lob.el --- The Library of Babel: off-the-shelf functions for data analysis and plotting using org-babel
|
||||
;;; ob-lob.el --- functions supporting the Library of Babel
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte, Dan Davison
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte, Dan Davison
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; See org-babel.org in the parent directory for more information
|
||||
;; See the online documentation for more information
|
||||
;;
|
||||
;; http://orgmode.org/worg/org-contrib/babel/
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'org-babel-table)
|
||||
(require 'org-babel-exp)
|
||||
(require 'ob)
|
||||
(require 'ob-table)
|
||||
|
||||
(defvar org-babel-library-of-babel nil
|
||||
"Library of source-code blocks. This is an association list.
|
||||
|
@ -43,12 +42,13 @@ add files to this list use the `org-babel-lob-ingest' command."
|
|||
:group 'org-babel
|
||||
:type 'list)
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-lob-ingest (&optional file)
|
||||
"Add all source-blocks defined in FILE to `org-babel-library-of-babel'."
|
||||
(interactive "f")
|
||||
(org-babel-map-source-blocks file
|
||||
(let* ((info (org-babel-get-src-block-info))
|
||||
(source-name (intern (fifth info))))
|
||||
(source-name (intern (nth 4 info))))
|
||||
(when source-name
|
||||
(setq org-babel-library-of-babel
|
||||
(cons (cons source-name info)
|
||||
|
@ -67,17 +67,18 @@ add files to this list use the `org-babel-lob-ingest' command."
|
|||
"Regexp to match calls to predefined source block functions")
|
||||
|
||||
;; functions for executing lob one-liners
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-lob-execute-maybe ()
|
||||
"Detect if this is context for a org-babel Library Of Babel
|
||||
src-block and if so then run the appropriate source block from
|
||||
the Library."
|
||||
(interactive)
|
||||
(let ((info (org-babel-lob-get-info)))
|
||||
(if (first info) (progn (org-babel-lob-execute info) t) nil)))
|
||||
(if (nth 0 info) (progn (org-babel-lob-execute info) t) nil)))
|
||||
|
||||
(add-hook 'org-ctrl-c-ctrl-c-hook 'org-babel-lob-execute-maybe)
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-lob-get-info ()
|
||||
"Return the function call supplied on the current Library of
|
||||
Babel line as a string.
|
||||
|
@ -98,6 +99,7 @@ the word 'call'."
|
|||
(list (length (match-string 1))))))))
|
||||
|
||||
(defun org-babel-lob-execute (info)
|
||||
"Execute the lob call specified by INFO."
|
||||
(let ((params (org-babel-merge-params
|
||||
org-babel-default-header-args
|
||||
(org-babel-params-from-buffer)
|
||||
|
@ -106,7 +108,10 @@ the word 'call'."
|
|||
(org-babel-clean-text-properties
|
||||
(concat ":var results=" (mapconcat #'identity (butlast info) " ")))))))
|
||||
(org-babel-execute-src-block
|
||||
nil (list "emacs-lisp" "results" params nil nil (third info)))))
|
||||
nil (list "emacs-lisp" "results" params nil nil (nth 2 info)))))
|
||||
|
||||
(provide 'org-babel-lob)
|
||||
;;; org-babel-lob.el ends here
|
||||
(provide 'ob-lob)
|
||||
|
||||
;; arch-tag: ce0712c9-2147-4019-ba3f-42341b8b474b
|
||||
|
||||
;;; ob-lob.el ends here
|
|
@ -1,58 +1,60 @@
|
|||
;;; org-babel-ref.el --- org-babel functions for referencing external data
|
||||
;;; ob-ref.el --- org-babel functions for referencing external data
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte, Dan Davison
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte, Dan Davison
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Functions for referencing data from the header arguments of a
|
||||
;; org-babel block. The syntax of such a reference should be
|
||||
;;
|
||||
|
||||
;; #+VAR: variable-name=file:resource-id
|
||||
;;
|
||||
|
||||
;; - variable-name :: the name of the variable to which the value
|
||||
;; will be assigned
|
||||
;;
|
||||
|
||||
;; - file :: path to the file containing the resource, or omitted if
|
||||
;; resource is in the current file
|
||||
;;
|
||||
|
||||
;; - resource-id :: the id or name of the resource
|
||||
;;
|
||||
|
||||
;; So an example of a simple src block referencing table data in the
|
||||
;; same file would be
|
||||
;;
|
||||
|
||||
;; #+TBLNAME: sandbox
|
||||
;; | 1 | 2 | 3 |
|
||||
;; | 4 | org-babel | 6 |
|
||||
;;
|
||||
;; #+begin_src emacs-lisp :var table=sandbox
|
||||
;; (message table)
|
||||
;; (message table)
|
||||
;; #+end_src
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(declare-function org-remove-if-not "org" (predicate seq))
|
||||
(declare-function org-at-table-p "org" (&optional table-type))
|
||||
|
||||
(defun org-babel-ref-variables (params)
|
||||
"Takes a parameter alist, and return an alist of variable
|
||||
|
@ -78,8 +80,10 @@ emacs-lisp representation of the value of the variable."
|
|||
(let ((var (match-string 1 assignment))
|
||||
(ref (match-string 2 assignment)))
|
||||
(cons (intern var)
|
||||
(or (org-babel-ref-literal ref)
|
||||
(org-babel-ref-resolve-reference ref params))))))
|
||||
((lambda (val)
|
||||
(if (equal :ob-must-be-reference val)
|
||||
(org-babel-ref-resolve-reference ref params)
|
||||
val)) (org-babel-ref-literal ref))))))
|
||||
|
||||
(defun org-babel-ref-literal (ref)
|
||||
"Determine if the right side of a header argument variable
|
||||
|
@ -90,11 +94,13 @@ return nil."
|
|||
(let ((out (org-babel-read ref)))
|
||||
(if (equal out ref)
|
||||
(if (string-match "^\".+\"$" ref)
|
||||
(read ref))
|
||||
(read ref)
|
||||
:ob-must-be-reference)
|
||||
out)))
|
||||
|
||||
(defvar org-babel-library-of-babel)
|
||||
(defun org-babel-ref-resolve-reference (ref &optional params)
|
||||
"Resolve the reference and return its value"
|
||||
"Resolve the reference REF and return its value."
|
||||
(save-excursion
|
||||
(let ((case-fold-search t)
|
||||
type args new-refere new-referent result lob-info split-file split-ref
|
||||
|
@ -102,7 +108,10 @@ return nil."
|
|||
;; if ref is indexed grab the indices -- beware nested indicies
|
||||
(when (and (string-match "\\[\\(.+\\)\\]" ref)
|
||||
(let ((str (substring ref 0 (match-beginning 0))))
|
||||
(= (count ?( str) (count ?) str))))
|
||||
(= (length (org-remove-if-not
|
||||
(lambda (el) (equal ?( el)) (string-to-list "((eric))")))
|
||||
(length (org-remove-if-not
|
||||
(lambda (el) (equal ?) el)) (string-to-list "((eric))"))))))
|
||||
(setq index (match-string 1 ref))
|
||||
(setq ref (substring ref 0 (match-beginning 0))))
|
||||
;; assign any arguments to pass to source block
|
||||
|
@ -155,7 +164,7 @@ return nil."
|
|||
(case type
|
||||
('results-line (org-babel-read-result))
|
||||
('table (org-babel-read-table))
|
||||
('file (org-babel-read-file))
|
||||
('file (org-babel-read-link))
|
||||
('source-block (org-babel-execute-src-block nil nil params))
|
||||
('lob (org-babel-execute-src-block nil lob-info params))))
|
||||
(if (symbolp result)
|
||||
|
@ -208,6 +217,7 @@ which case the entire range is returned."
|
|||
((or (string= holder ")") (string= holder "]")) (setq depth (- depth 1)))))
|
||||
(mapcar #'org-babel-trim (reverse (cons buffer return)))))
|
||||
|
||||
(defvar org-bracket-link-regexp)
|
||||
(defun org-babel-ref-at-ref-p ()
|
||||
"Return the type of reference located at point or nil if none
|
||||
of the supported reference types are found. Supported reference
|
||||
|
@ -217,5 +227,8 @@ types are tables and source blocks."
|
|||
((looking-at org-bracket-link-regexp) 'file)
|
||||
((looking-at org-babel-result-regexp) 'results-line)))
|
||||
|
||||
(provide 'org-babel-ref)
|
||||
;;; org-babel-ref.el ends here
|
||||
(provide 'ob-ref)
|
||||
|
||||
;; arch-tag: ace4a4f4-ea38-4dac-8fe6-6f52fcc43b6d
|
||||
|
||||
;;; ob-ref.el ends here
|
|
@ -1,43 +1,41 @@
|
|||
;;; org-babel-table.el --- integration for calling org-babel functions from tables
|
||||
;;; ob-table.el --- support for calling org-babel functions from tables
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Should allow calling functions from org-mode tables using the
|
||||
;; function `sbe' as so...
|
||||
;;
|
||||
|
||||
;; #+begin_src emacs-lisp :results silent
|
||||
;; (defun fibbd (n) (if (< n 2) 1 (+ (fibbd (- n 1)) (fibbd (- n 2)))))
|
||||
;; (defun fibbd (n) (if (< n 2) 1 (+ (fibbd (- n 1)) (fibbd (- n 2)))))
|
||||
;; #+end_src
|
||||
;;
|
||||
|
||||
;; #+srcname: fibbd
|
||||
;; #+begin_src emacs-lisp :var n=2 :results silent
|
||||
;; (fibbd n)
|
||||
;; #+end_src
|
||||
;;
|
||||
|
||||
;; | original | fibbd |
|
||||
;; |----------+--------|
|
||||
;; | 0 | |
|
||||
|
@ -53,9 +51,11 @@
|
|||
;; #+TBLFM: $2='(sbe 'fibbd (n $1))
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
|
||||
(defun org-babel-table-truncate-at-newline (string)
|
||||
"If STRING ends in a newline character, then remove the newline
|
||||
character and replace it with ellipses."
|
||||
(if (and (stringp string) (string-match "[\n\r]" string))
|
||||
(concat (substring string 0 (match-beginning 0)) "...")
|
||||
string))
|
||||
|
@ -80,7 +80,7 @@ rather than a single \"$\" (i.e. \"$$2\" instead of \"$2\" in the
|
|||
example above."
|
||||
(let ((variables (mapcar
|
||||
(lambda (var)
|
||||
(if (and (= 3 (length var)) (eq (second var) '$))
|
||||
(if (and (= 3 (length var)) (eq (nth 1 var) '$))
|
||||
(list (car var) (format "\"%s\"" (last var)))
|
||||
var))
|
||||
variables)))
|
||||
|
@ -93,7 +93,7 @@ example above."
|
|||
,source-block
|
||||
"("
|
||||
(mapconcat (lambda (var-spec)
|
||||
(format "%S=%s" (first var-spec) (second var-spec)))
|
||||
(format "%S=%s" (nth 0 var-spec) (nth 1 var-spec)))
|
||||
',variables ", ")
|
||||
")")))))
|
||||
(org-babel-execute-src-block
|
||||
|
@ -101,5 +101,8 @@ example above."
|
|||
(org-babel-merge-params '((:results . "silent")) params))))
|
||||
""))))
|
||||
|
||||
(provide 'org-babel-table)
|
||||
;;; org-babel-table.el ends here
|
||||
(provide 'ob-table)
|
||||
|
||||
;; arch-tag: 4234cc7c-4fc8-4e92-abb0-2892de1a493b
|
||||
|
||||
;;; ob-table.el ends here
|
|
@ -1,59 +1,69 @@
|
|||
;;; org-babel-tangle.el --- Extract source code from org-mode files
|
||||
;;; ob-tangle.el --- extract source code from org-mode files
|
||||
|
||||
;; Copyright (C) 2009 Eric Schulte
|
||||
;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Eric Schulte
|
||||
;; Keywords: literate programming, reproducible research
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 0.01
|
||||
|
||||
;;; License:
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Extract the code from source blocks out into raw source-code files.
|
||||
|
||||
;;; Code:
|
||||
(require 'org-babel)
|
||||
(require 'ob)
|
||||
(require 'org-src)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(defvar org-babel-tangle-langs nil
|
||||
"List of languages supported by `org-babel-tangle'. The first
|
||||
element of each language's list is a string indicating the name
|
||||
of the language, the second element should be the file extension
|
||||
of the language, an optional third element the shebang(#!) line
|
||||
to use when writing out the language to file, and an optional
|
||||
fourth element is a flag which when true indicates that the
|
||||
language does not support comments.")
|
||||
(declare-function org-link-escape "org" (text &optional table))
|
||||
|
||||
(defvar org-babel-tangle-w-comments nil
|
||||
(defcustom org-babel-tangle-w-comments nil
|
||||
"Control the insertion of comments into tangled code. Non-nil
|
||||
value will result in the insertion of comments for those
|
||||
languages with comment support.")
|
||||
languages with comment support."
|
||||
:group 'org-babel-tangle
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-babel-tangle-lang-exts
|
||||
'(("emacs-lisp" . "el"))
|
||||
"Alist mapping languages to their file extensions.
|
||||
The key is the language name, the value is the string that should
|
||||
be inserted as the extension commonly used to identify files
|
||||
written in this language. If no entry is found in this list,
|
||||
then the name of the language is used."
|
||||
:group 'org-babel-tangle
|
||||
:type '(repeat
|
||||
(cons
|
||||
(string "Language name")
|
||||
(string "File Extension"))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-load-file (file)
|
||||
"Load the contents of the Emacs Lisp source code blocks in the
|
||||
org-mode formatted FILE. This function will first export the
|
||||
source code using `org-babel-tangle' and then load the resulting
|
||||
file using `load-file'."
|
||||
(flet ((age (file)
|
||||
(time-to-seconds
|
||||
(float-time
|
||||
(time-subtract (current-time)
|
||||
(sixth (or (file-attributes (file-truename file))
|
||||
(nth 5 (or (file-attributes (file-truename file))
|
||||
(file-attributes file)))))))
|
||||
(let* ((base-name (file-name-sans-extension file))
|
||||
(exported-file (concat base-name ".el")))
|
||||
|
@ -64,6 +74,7 @@ file using `load-file'."
|
|||
(load-file exported-file)
|
||||
(message "loaded %s" exported-file))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-tangle-file (file &optional target-file lang)
|
||||
"Extract the bodies of all source code blocks in FILE with
|
||||
`org-babel-tangle'. Optional argument TARGET-FILE can be used to
|
||||
|
@ -84,6 +95,7 @@ blocks by language."
|
|||
"Tangle FILENAME and place the results in PUB-DIR."
|
||||
(mapc (lambda (el) (copy-file el pub-dir t)) (org-babel-tangle-file filename)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-tangle (&optional target-file lang)
|
||||
"Extract the bodies of all source code blocks from the current
|
||||
file into their own source-specific files. Optional argument
|
||||
|
@ -99,6 +111,7 @@ exported source code blocks by language."
|
|||
(lambda (by-lang)
|
||||
(let* ((lang (car by-lang))
|
||||
(specs (cdr by-lang))
|
||||
(ext (or (cdr (assoc lang org-babel-tangle-lang-exts)) lang))
|
||||
(lang-f (intern
|
||||
(concat
|
||||
(or (and (cdr (assoc lang org-src-lang-modes))
|
||||
|
@ -106,19 +119,14 @@ exported source code blocks by language."
|
|||
(cdr (assoc lang org-src-lang-modes))))
|
||||
lang)
|
||||
"-mode")))
|
||||
(lang-specs (cdr (assoc lang org-babel-tangle-langs)))
|
||||
(ext (first lang-specs))
|
||||
(she-bang (second lang-specs))
|
||||
(commentable (and (fboundp lang-f) (not (third lang-specs))))
|
||||
she-banged)
|
||||
(mapc
|
||||
(lambda (spec)
|
||||
(flet ((get-spec (name)
|
||||
(cdr (assoc name (third spec)))))
|
||||
(cdr (assoc name (nth 2 spec)))))
|
||||
(let* ((tangle (get-spec :tangle))
|
||||
(she-bang (if (> (length (get-spec :shebang)) 0)
|
||||
(get-spec :shebang)
|
||||
she-bang))
|
||||
(she-bang ((lambda (sheb) (when (> (length sheb) 0) sheb))
|
||||
(get-spec :shebang)))
|
||||
(base-name (or (cond
|
||||
((string= "yes" tangle)
|
||||
(file-name-sans-extension
|
||||
|
@ -174,6 +182,7 @@ references."
|
|||
(delete-region (save-excursion (beginning-of-line 1) (point))
|
||||
(save-excursion (end-of-line 1) (forward-char 1) (point)))))
|
||||
|
||||
(defvar org-stored-links)
|
||||
(defun org-babel-tangle-collect-blocks (&optional lang)
|
||||
"Collect all source blocks in the current org-mode file.
|
||||
Return an association list of source-code block specifications of
|
||||
|
@ -187,11 +196,11 @@ code blocks by language."
|
|||
(org-babel-clean-text-properties
|
||||
(car (pop org-stored-links)))))
|
||||
(info (org-babel-get-src-block-info))
|
||||
(source-name (intern (or (fifth info)
|
||||
(source-name (intern (or (nth 4 info)
|
||||
(format "block-%d" block-counter))))
|
||||
(src-lang (first info))
|
||||
(src-lang (nth 0 info))
|
||||
(expand-cmd (intern (concat "org-babel-expand-body:" src-lang)))
|
||||
(params (third info))
|
||||
(params (nth 2 info))
|
||||
by-lang)
|
||||
(unless (string= (cdr (assoc :tangle params)) "no") ;; skip
|
||||
(unless (and lang (not (string= lang src-lang))) ;; limit by language
|
||||
|
@ -217,18 +226,13 @@ code blocks by language."
|
|||
(cdr (assoc :noweb params))))
|
||||
(org-babel-expand-noweb-references
|
||||
info)
|
||||
(second info)))
|
||||
(third
|
||||
(cdr (assoc src-lang
|
||||
org-babel-tangle-langs))))
|
||||
(nth 1 info))))
|
||||
by-lang)) blocks))))))
|
||||
;; ensure blocks in the correct order
|
||||
(setq blocks
|
||||
(mapcar
|
||||
(lambda (by-lang) (cons (car by-lang) (reverse (cdr by-lang))))
|
||||
blocks))
|
||||
;; blocks should contain all source-blocks organized by language
|
||||
;; (message "blocks=%S" blocks) ;; debugging
|
||||
blocks))
|
||||
|
||||
(defun org-babel-spec-to-string (spec)
|
||||
|
@ -238,26 +242,25 @@ assumes that the appropriate major-mode is set. SPEC has the
|
|||
form
|
||||
|
||||
(link source-name params body)"
|
||||
(flet ((insert-comment (text)
|
||||
(when (and commentable
|
||||
org-babel-tangle-w-comments)
|
||||
(insert "\n")
|
||||
(comment-region (point)
|
||||
(progn (insert text) (point)))
|
||||
(end-of-line nil)
|
||||
(insert "\n"))))
|
||||
(let ((link (first spec))
|
||||
(source-name (second spec))
|
||||
(body (fourth spec))
|
||||
(commentable (not (if (> (length (cdr (assoc :comments (third spec))))
|
||||
0)
|
||||
(string= (cdr (assoc :comments (third spec)))
|
||||
"no")
|
||||
(fifth spec)))))
|
||||
(let ((link (nth 0 spec))
|
||||
(source-name (nth 1 spec))
|
||||
(body (nth 3 spec))
|
||||
(commentable (string= (cdr (assoc :comments (nth 2 spec))) "yes")))
|
||||
(flet ((insert-comment (text)
|
||||
(when (and commentable
|
||||
org-babel-tangle-w-comments)
|
||||
(insert "\n")
|
||||
(comment-region (point)
|
||||
(progn (insert text) (point)))
|
||||
(end-of-line nil)
|
||||
(insert "\n"))))
|
||||
(insert-comment (format "[[%s][%s]]" (org-link-escape link) source-name))
|
||||
(insert (format "\n%s\n" (replace-regexp-in-string
|
||||
"^," "" (org-babel-chomp body))))
|
||||
(insert-comment (format "%s ends here" source-name)))))
|
||||
|
||||
(provide 'org-babel-tangle)
|
||||
;;; org-babel-tangle.el ends here
|
||||
(provide 'ob-tangle)
|
||||
|
||||
;; arch-tag: 413ced93-48f5-4216-86e4-3fc5df8c8f24
|
||||
|
||||
;;; ob-tangle.el ends here
|
File diff suppressed because it is too large
Load diff
|
@ -3621,7 +3621,7 @@ in `org-agenda-text-search-extra-files'."
|
|||
|
||||
;;;###autoload
|
||||
(defun org-todo-list (arg)
|
||||
"Show all TODO entries from all agenda file in a single list.
|
||||
"Show all (not done) TODO entries from all agenda file in a single list.
|
||||
The prefix arg can be used to select a specific TODO keyword and limit
|
||||
the list to these. When using \\[universal-argument], you will be prompted
|
||||
for a keyword. A numeric prefix directly selects the Nth keyword in
|
||||
|
@ -4344,7 +4344,7 @@ the documentation of `org-diary'."
|
|||
clockp (and org-agenda-include-inactive-timestamps
|
||||
(or (string-match org-clock-string tmp)
|
||||
(string-match "]-+\\'" tmp)))
|
||||
todo-state (org-get-todo-state)
|
||||
todo-state (ignore-errors (org-get-todo-state))
|
||||
donep (member todo-state org-done-keywords))
|
||||
(if (or scheduledp deadlinep closedp clockp
|
||||
(and donep org-agenda-skip-timestamp-if-done))
|
||||
|
@ -4573,7 +4573,7 @@ be skipped."
|
|||
pos (1- (match-beginning 1))
|
||||
d2 (org-time-string-to-absolute
|
||||
(match-string 1) d1 'past
|
||||
org-agenda-repeating-timestamp-show-all t)
|
||||
org-agenda-repeating-timestamp-show-all)
|
||||
diff (- d2 d1)
|
||||
wdays (if suppress-prewarning
|
||||
(let ((org-deadline-warning-days suppress-prewarning))
|
||||
|
@ -4675,7 +4675,7 @@ FRACTION is what fraction of the head-warning time has passed."
|
|||
pos (1- (match-beginning 1))
|
||||
d2 (org-time-string-to-absolute
|
||||
(match-string 1) d1 'past
|
||||
org-agenda-repeating-timestamp-show-all t)
|
||||
org-agenda-repeating-timestamp-show-all)
|
||||
diff (- d2 d1))
|
||||
(setq pastschedp (and todayp (< diff 0)))
|
||||
;; When to show a scheduled item in the calendar:
|
||||
|
@ -5162,11 +5162,12 @@ HH:MM."
|
|||
(or (match-end 1) (match-end 0)) (match-end 0)
|
||||
(list 'face (org-get-todo-face (match-string 2 x)))
|
||||
x)
|
||||
(setq x (concat (substring x 0 (match-end 1))
|
||||
(format org-agenda-todo-keyword-format
|
||||
(match-string 2 x))
|
||||
(org-add-props " " (text-properties-at 0 x))
|
||||
(substring x (match-end 3)))))
|
||||
(when (match-end 1)
|
||||
(setq x (concat (substring x 0 (match-end 1))
|
||||
(format org-agenda-todo-keyword-format
|
||||
(match-string 2 x))
|
||||
(org-add-props " " (text-properties-at 0 x))
|
||||
(substring x (match-end 3))))))
|
||||
x)))
|
||||
|
||||
(defsubst org-cmp-priority (a b)
|
||||
|
@ -6991,6 +6992,8 @@ The cursor may be at a date in the calendar, or in the Org agenda."
|
|||
(org-agenda-do-action '(org-deadline nil org-overriding-default-time)))
|
||||
((equal ans ?r)
|
||||
(org-agenda-do-action '(org-remember) t))
|
||||
((equal ans ?c)
|
||||
(org-agenda-do-action '(org-capture) t))
|
||||
((equal ans ?\ )
|
||||
(let ((cw (selected-window)))
|
||||
(org-switch-to-buffer-other-window
|
||||
|
|
1218
lisp/org-capture.el
Normal file
1218
lisp/org-capture.el
Normal file
File diff suppressed because it is too large
Load diff
|
@ -314,7 +314,10 @@ of a different task.")
|
|||
(defun org-clock-history-push (&optional pos buffer)
|
||||
"Push a marker to the clock history."
|
||||
(setq org-clock-history-length (max 1 (min 35 org-clock-history-length)))
|
||||
(let ((m (move-marker (make-marker) (or pos (point)) buffer)) n l)
|
||||
(let ((m (move-marker (make-marker)
|
||||
(or pos (point)) (org-base-buffer
|
||||
(or buffer (current-buffer)))))
|
||||
n l)
|
||||
(while (setq n (member m org-clock-history))
|
||||
(move-marker (car n) nil))
|
||||
(setq org-clock-history
|
||||
|
|
|
@ -132,6 +132,12 @@ If DELETE is non-nil, delete all those overlays."
|
|||
(if delete (delete-overlay ov) (push ov found))))
|
||||
found))
|
||||
|
||||
(defun org-get-x-clipboard (value)
|
||||
"Get the value of the x clipboard, compatible with XEmacs, and GNU Emacs 21."
|
||||
(if (eq window-system 'x)
|
||||
(let ((x (org-get-x-clipboard-compat value)))
|
||||
(if x (org-no-properties x)))))
|
||||
|
||||
;; Miscellaneous functions
|
||||
|
||||
(defun org-add-hook (hook function &optional append local)
|
||||
|
|
|
@ -36,8 +36,8 @@
|
|||
(defvar org-datetree-base-level 1
|
||||
"The level at which years should be placed in the date tree.
|
||||
This is normally one, but if the buffer has an entry with a DATE_TREE
|
||||
property, the date tree will become a subtree under that entry, so the
|
||||
base level will be properly adjusted.")
|
||||
property (any value), the date tree will become a subtree under that entry,
|
||||
so the base level will be properly adjusted.")
|
||||
|
||||
;;;###autoload
|
||||
(defun org-datetree-find-date-create (date &optional keep-restriction)
|
||||
|
|
|
@ -506,6 +506,10 @@ Kind can be any of `latex', `html', `ascii', `latin1', or `utf8'."
|
|||
|
||||
(provide 'org-entities)
|
||||
|
||||
;; Local variables:
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
|
||||
;; arch-tag: e6bd163f-7419-4009-9c93-a74623016424
|
||||
|
||||
;;; org-entities.el ends here
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
(require 'org-macs)
|
||||
(require 'org-agenda)
|
||||
(require 'org-exp-blocks)
|
||||
(require 'ob-exp)
|
||||
(require 'org-src)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
@ -2145,7 +2146,7 @@ INDENT was the original indentation of the block."
|
|||
(org-add-props (concat "<programlisting><![CDATA["
|
||||
rtn
|
||||
"]]></programlisting>\n")
|
||||
'(org-protected t))
|
||||
'(org-protected t org-example t))
|
||||
"#+END_DOCBOOK\n"))
|
||||
((eq backend 'html)
|
||||
;; We are exporting to HTML
|
||||
|
@ -2215,7 +2216,7 @@ INDENT was the original indentation of the block."
|
|||
cont rpllbl fmt)))
|
||||
(if (string-match "\\(\\`<[^>]*>\\)\n" rtn)
|
||||
(setq rtn (replace-match "\\1" t nil rtn)))
|
||||
(concat "\n#+BEGIN_HTML\n" (org-add-props rtn '(org-protected t)) "\n#+END_HTML\n\n"))
|
||||
(concat "\n#+BEGIN_HTML\n" (org-add-props rtn '(org-protected t org-example t)) "\n#+END_HTML\n\n"))
|
||||
((eq backend 'latex)
|
||||
(setq rtn (org-export-number-lines rtn 'latex 0 0 num cont rpllbl fmt))
|
||||
(concat "#+BEGIN_LaTeX\n"
|
||||
|
@ -2239,7 +2240,7 @@ INDENT was the original indentation of the block."
|
|||
rtn "\\end{lstlisting}\n")
|
||||
(concat (car org-export-latex-verbatim-wrap)
|
||||
rtn (cdr org-export-latex-verbatim-wrap)))
|
||||
'(org-protected t))
|
||||
'(org-protected t org-example t))
|
||||
"#+END_LaTeX\n"))
|
||||
((eq backend 'ascii)
|
||||
;; This is not HTML or LaTeX, so just make it an example.
|
||||
|
@ -2253,7 +2254,7 @@ INDENT was the original indentation of the block."
|
|||
(org-split-string rtn "\n")
|
||||
"\n")
|
||||
"\n")
|
||||
'(org-protected t))
|
||||
'(org-protected t org-example t))
|
||||
"#+END_ASCII\n"))))
|
||||
(org-add-props rtn nil 'original-indentation indent))))
|
||||
|
||||
|
|
|
@ -2146,11 +2146,17 @@ If there are links in the string, don't modify these."
|
|||
(defvar local-list-indent)
|
||||
(defvar local-list-type)
|
||||
(defun org-export-html-close-lists-maybe (line)
|
||||
"Close local lists based on the original indentation of the line."
|
||||
(let* ((rawhtml (and in-local-list
|
||||
(get-text-property 0 'org-protected line)))
|
||||
(get-text-property 0 'org-protected line)
|
||||
(not (get-text-property 0 'org-example line))))
|
||||
;; rawhtml means: This was between #+begin_html..#+end_html
|
||||
;; originally, thus it excludes stuff that was a source code example
|
||||
;; Actually, this code seems wrong, I don't know why it works, but
|
||||
;; it seems to work.... So keep it like this for now.
|
||||
(ind (if rawhtml
|
||||
(org-get-indentation line)
|
||||
(or (get-text-property 0 'original-indentation line))))
|
||||
(get-text-property 0 'original-indentation line)))
|
||||
didclose)
|
||||
(when ind
|
||||
(while (and in-local-list
|
||||
|
|
|
@ -43,6 +43,11 @@
|
|||
"Return the value of symbol VAR if it is bound, else nil."
|
||||
`(and (boundp (quote ,var)) ,var))
|
||||
|
||||
(defun org-not-nil (v)
|
||||
"If V not nil, and also not the string \"nil\", then return V.
|
||||
Otherwise return nil."
|
||||
(and v (not (equal v "nil")) v))
|
||||
|
||||
(defmacro org-unmodified (&rest body)
|
||||
"Execute body without changing `buffer-modified-p'.
|
||||
Also, do not record undo information."
|
||||
|
|
131
lisp/org-mks.el
Normal file
131
lisp/org-mks.el
Normal file
|
@ -0,0 +1,131 @@
|
|||
;;; org-mks.el --- Multi-key-selection for Org-mode
|
||||
|
||||
;; Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Carsten Dominik <carsten at orgmode dot org>
|
||||
;; Keywords: outlines, hypermedia, calendar, wp
|
||||
;; Homepage: http://orgmode.org
|
||||
;; Version: 6.36trans
|
||||
;;
|
||||
;; This file is part of GNU Emacs.
|
||||
;;
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(require 'org)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
|
||||
(defun org-mks (table title &optional prompt specials)
|
||||
"Select a member of an alist with multiple keys.
|
||||
TABLE is the alist which should contain entries where the car is a string.
|
||||
There should be two types of entries.
|
||||
|
||||
1. prefix descriptions like (\"a\" \"Description\")
|
||||
This indicates that `a' is a prefix key for multi-letter selection, and
|
||||
that there are entries following with keys like \"ab\", \"ax\"...
|
||||
|
||||
2. Selectable members must have more than two elements, with the first
|
||||
being the string of keys that lead to selecting it, and the second a
|
||||
short description string of the item.
|
||||
|
||||
The command will then make a temporary buffer listing all entries
|
||||
that can be selected with a single key, and all the sinke key
|
||||
prefixes. When you press the key for a single-letter enty, it is selected.
|
||||
When you press a prefix key, the commands (and maybe further prefixes)
|
||||
under this key will be shown and offered for selection.
|
||||
|
||||
TITLE will be placed over the selection in the temporary buffer,
|
||||
PROMPT will be used when prompting for a key. SPECIAL is an alist with
|
||||
also (\"key\" \"description\") entries. When one of these is selection,
|
||||
only the bare key is returned."
|
||||
(setq prompt (or prompt "Select: "))
|
||||
(let (tbl orig-table dkey ddesc des-keys allowed-keys
|
||||
current prefix rtn re pressed buffer (inhibit-quit t))
|
||||
(save-window-excursion
|
||||
(setq buffer (org-switch-to-buffer-other-window "*Org Select*"))
|
||||
(setq orig-table table)
|
||||
(catch 'exit
|
||||
(while t
|
||||
(erase-buffer)
|
||||
(insert title "\n\n")
|
||||
(setq tbl table
|
||||
des-keys nil
|
||||
allowed-keys nil)
|
||||
(setq prefix (if current (concat current " ") ""))
|
||||
(while tbl
|
||||
(cond
|
||||
((and (= 2 (length (car tbl))) (= (length (caar tbl)) 1))
|
||||
;; This is a description on this level
|
||||
(setq dkey (caar tbl) ddesc (cadar tbl))
|
||||
(pop tbl)
|
||||
(push dkey des-keys)
|
||||
(push dkey allowed-keys)
|
||||
(insert prefix "[" dkey "]" "..." " " ddesc "..." "\n")
|
||||
;; Skip keys which are below this prefix
|
||||
(setq re (concat "\\`" (regexp-quote dkey)))
|
||||
(while (and tbl (string-match re (caar tbl))) (pop tbl)))
|
||||
((= 2 (length (car tbl)))
|
||||
;; Not yet a usable description, skip it
|
||||
)
|
||||
(t
|
||||
;; usable entry on this level
|
||||
(insert prefix "[" (caar tbl) "]" " " (nth 1 (car tbl)) "\n")
|
||||
(push (caar tbl) allowed-keys)
|
||||
(pop tbl))))
|
||||
(when specials
|
||||
(insert "-------------------------------------------------------------------------------\n")
|
||||
(let ((sp specials))
|
||||
(while sp
|
||||
(insert (format "[%s] %s\n"
|
||||
(caar sp) (nth 1 (car sp))))
|
||||
(push (caar sp) allowed-keys)
|
||||
(pop sp))))
|
||||
(push "\C-g" allowed-keys)
|
||||
(goto-char (point-min))
|
||||
(if (not (pos-visible-in-window-p (point-max)))
|
||||
(org-fit-window-to-buffer))
|
||||
(message prompt)
|
||||
(setq pressed (char-to-string (read-char-exclusive)))
|
||||
(while (not (member pressed allowed-keys))
|
||||
(message "Invalid key `%s'" pressed) (sit-for 1)
|
||||
(message prompt)
|
||||
(setq pressed (char-to-string (read-char-exclusive))))
|
||||
(when (equal pressed "\C-g")
|
||||
(kill-buffer buffer)
|
||||
(error "Abort"))
|
||||
(when (and (not (assoc pressed table))
|
||||
(not (member pressed des-keys))
|
||||
(assoc pressed specials))
|
||||
(throw 'exit (setq rtn pressed)))
|
||||
(unless (member pressed des-keys)
|
||||
(throw 'exit (setq rtn (rassoc (cdr (assoc pressed table))
|
||||
orig-table))))
|
||||
(setq current (concat current pressed))
|
||||
(setq table (mapcar
|
||||
(lambda (x)
|
||||
(if (and (> (length (car x)) 1)
|
||||
(equal (substring (car x) 0 1) pressed))
|
||||
(cons (substring (car x) 1) (cdr x))
|
||||
nil))
|
||||
table))
|
||||
(setq table (remove nil table)))))
|
||||
(when buffer (kill-buffer buffer))
|
||||
rtn))
|
||||
|
||||
(provide 'org-mks)
|
||||
|
||||
;; arch-tag: 4ea90d0e-c6e4-4684-bd61-baf878712f9f
|
||||
|
||||
;;; org-mks.el ends here
|
|
@ -87,12 +87,17 @@
|
|||
;; pushes the browsers URL to the `kill-ring' for yanking. This handler is
|
||||
;; triggered through the sub-protocol \"store-link\".
|
||||
;;
|
||||
;; * Call `org-protocol-remember' by using the sub-protocol \"remember\". If
|
||||
;; Org-mode is loaded, emacs will pop-up a remember buffer and fill the
|
||||
;; * Call `org-protocol-capture' by using the sub-protocol \"capture\". If
|
||||
;; Org-mode is loaded, emacs will pop-up a capture buffer and fill the
|
||||
;; template with the data provided. I.e. the browser's URL is inserted as an
|
||||
;; Org-link of which the page title will be the description part. If text
|
||||
;; was select in the browser, that text will be the body of the entry.
|
||||
;;
|
||||
;; * Call `org-protocol-remember' by using the sub-protocol \"remember\".
|
||||
;; This is provided for backward compatibility.
|
||||
;; You may read `org-capture' as `org-remember' throughout this file if
|
||||
;; you still use `org-remember'.
|
||||
;;
|
||||
;; You may use the same bookmark URL for all those standard handlers and just
|
||||
;; adjust the sub-protocol used:
|
||||
;;
|
||||
|
@ -101,7 +106,7 @@
|
|||
;; encodeURIComponent(document.title)+'/'+
|
||||
;; encodeURIComponent(window.getSelection())
|
||||
;;
|
||||
;; The handler for the sub-protocol \"remember\" detects an optional template
|
||||
;; The handler for the sub-protocol \"capture\" detects an optional template
|
||||
;; char that, if present, triggers the use of a special template.
|
||||
;; Example:
|
||||
;;
|
||||
|
@ -143,6 +148,7 @@ for `org-protocol-the-protocol' and sub-procols defined in
|
|||
|
||||
(defconst org-protocol-protocol-alist-default
|
||||
'(("org-remember" :protocol "remember" :function org-protocol-remember :kill-client t)
|
||||
("org-capture" :protocol "capture" :function org-protocol-capture :kill-client t)
|
||||
("org-store-link" :protocol "store-link" :function org-protocol-store-link)
|
||||
("org-open-source" :protocol "open-source" :function org-protocol-open-source))
|
||||
"Default protocols to use.
|
||||
|
@ -260,7 +266,6 @@ Here is an example:
|
|||
:group 'org-protocol
|
||||
:type 'string)
|
||||
|
||||
|
||||
;;; Helper functions:
|
||||
|
||||
(defun org-protocol-sanitize-uri (uri)
|
||||
|
@ -443,10 +448,6 @@ The sub-protocol used to reach this function is set in
|
|||
(defun org-protocol-remember (info)
|
||||
"Process an org-protocol://remember:// style url.
|
||||
|
||||
The sub-protocol used to reach this function is set in
|
||||
`org-protocol-protocol-alist'.
|
||||
|
||||
This function detects an URL, title and optional text, separated by '/'
|
||||
The location for a browser's bookmark has to look like this:
|
||||
|
||||
javascript:location.href='org-protocol://remember://'+ \\
|
||||
|
@ -454,40 +455,68 @@ The location for a browser's bookmark has to look like this:
|
|||
encodeURIComponent(document.title)+'/'+ \\
|
||||
encodeURIComponent(window.getSelection())
|
||||
|
||||
By default, it uses the character `org-protocol-default-template-key',
|
||||
which should be associated with a template in `org-remember-templates'.
|
||||
But you may prepend the encoded URL with a character and a slash like so:
|
||||
|
||||
javascript:location.href='org-protocol://org-store-link://b/'+ ...
|
||||
|
||||
Now template ?b will be used."
|
||||
See the docs for `org-protocol-capture' for more information."
|
||||
|
||||
(if (and (boundp 'org-stored-links)
|
||||
(fboundp 'org-remember))
|
||||
(let* ((parts (org-protocol-split-data info t))
|
||||
(template (or (and (= 1 (length (car parts))) (pop parts))
|
||||
org-protocol-default-template-key))
|
||||
(url (org-protocol-sanitize-uri (car parts)))
|
||||
(type (if (string-match "^\\([a-z]+\\):" url)
|
||||
(match-string 1 url)))
|
||||
(title (or (cadr parts) ""))
|
||||
(region (or (caddr parts) ""))
|
||||
(orglink (org-make-link-string
|
||||
url (if (string-match "[^[:space:]]" title) title url)))
|
||||
remember-annotation-functions)
|
||||
(setq org-stored-links
|
||||
(cons (list url title) org-stored-links))
|
||||
(kill-new orglink)
|
||||
(org-store-link-props :type type
|
||||
:link url
|
||||
:description title
|
||||
:initial region)
|
||||
(raise-frame)
|
||||
(org-remember nil (string-to-char template)))
|
||||
|
||||
(message "Org-mode not loaded."))
|
||||
(or (fboundp 'org-capture))
|
||||
(org-protocol-do-capture info 'org-remember))
|
||||
(message "Org-mode not loaded."))
|
||||
nil)
|
||||
|
||||
(defun org-protocol-capture (info)
|
||||
"Process an org-protocol://capture:// style url.
|
||||
|
||||
The sub-protocol used to reach this function is set in
|
||||
`org-protocol-protocol-alist'.
|
||||
|
||||
This function detects an URL, title and optional text, separated by '/'
|
||||
The location for a browser's bookmark has to look like this:
|
||||
|
||||
javascript:location.href='org-protocol://capture://'+ \\
|
||||
encodeURIComponent(location.href)+'/' \\
|
||||
encodeURIComponent(document.title)+'/'+ \\
|
||||
encodeURIComponent(window.getSelection())
|
||||
|
||||
By default, it uses the character `org-protocol-default-template-key',
|
||||
which should be associated with a template in `org-capture-templates'.
|
||||
But you may prepend the encoded URL with a character and a slash like so:
|
||||
|
||||
javascript:location.href='org-protocol://capture://b/'+ ...
|
||||
|
||||
Now template ?b will be used."
|
||||
(if (and (boundp 'org-stored-links)
|
||||
(or (fboundp 'org-capture))
|
||||
(org-protocol-do-capture info 'org-capture))
|
||||
(message "Org-mode not loaded."))
|
||||
nil)
|
||||
|
||||
(defun org-protocol-do-capture (info capture-func)
|
||||
"Support `org-capture' and `org-remember' alike.
|
||||
CAPTURE-FUNC is either the symbol `org-remember' or `org-capture'."
|
||||
(let* ((parts (org-protocol-split-data info t))
|
||||
(template (or (and (= 1 (length (car parts))) (pop parts))
|
||||
org-protocol-default-template-key))
|
||||
(url (org-protocol-sanitize-uri (car parts)))
|
||||
(type (if (string-match "^\\([a-z]+\\):" url)
|
||||
(match-string 1 url)))
|
||||
(title(or (cadr parts) ""))
|
||||
(region (or (caddr parts) ""))
|
||||
(orglink (org-make-link-string
|
||||
url (if (string-match "[^[:space:]]" title) title url)))
|
||||
(org-capture-link-is-already-stored t) ;; avoid call to org-store-link
|
||||
remember-annotation-functions)
|
||||
(setq org-stored-links
|
||||
(cons (list url title) org-stored-links))
|
||||
(kill-new orglink)
|
||||
(org-store-link-props :type type
|
||||
:link url
|
||||
:description title
|
||||
:annotation orglink
|
||||
:initial region)
|
||||
(raise-frame)
|
||||
(funcall capture-func nil template)))
|
||||
|
||||
|
||||
(defun org-protocol-open-source (fname)
|
||||
"Process an org-protocol://open-source:// style url.
|
||||
|
||||
|
|
|
@ -392,12 +392,6 @@ RET at beg-of-buf -> Append to file as level 2 headline
|
|||
char0))))))
|
||||
(cddr (assoc char templates)))))
|
||||
|
||||
(defun org-get-x-clipboard (value)
|
||||
"Get the value of the x clipboard, compatible with XEmacs, and GNU Emacs 21."
|
||||
(if (eq window-system 'x)
|
||||
(let ((x (org-get-x-clipboard-compat value)))
|
||||
(if x (org-no-properties x)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-remember-apply-template (&optional use-char skip-interactive)
|
||||
"Initialize *remember* buffer with template, invoke `org-mode'.
|
||||
|
|
|
@ -4226,7 +4226,7 @@ this function is called."
|
|||
(orgtbl-to-generic table (org-combine-plists params2 params))))
|
||||
|
||||
(defun orgtbl-to-html (table params)
|
||||
"Convert the orgtbl-mode TABLE to LaTeX.
|
||||
"Convert the orgtbl-mode TABLE to HTML.
|
||||
TABLE is a list, each entry either the symbol `hline' for a horizontal
|
||||
separator line, or a list of fields for that line.
|
||||
PARAMS is a property list of parameters that can influence the conversion.
|
||||
|
|
177
lisp/org.el
Executable file → Normal file
177
lisp/org.el
Executable file → Normal file
|
@ -104,6 +104,23 @@
|
|||
(require 'org-src)
|
||||
(require 'org-footnote)
|
||||
|
||||
;; babel
|
||||
(let* ((babel-path (expand-file-name
|
||||
"babel"
|
||||
(file-name-directory (or (buffer-file-name)
|
||||
load-file-name))))
|
||||
(babel-langs-path (expand-file-name "langs" babel-path)))
|
||||
(add-to-list 'load-path babel-path)
|
||||
(add-to-list 'load-path babel-langs-path))
|
||||
(require 'ob)
|
||||
(require 'ob-table)
|
||||
(require 'ob-lob)
|
||||
(require 'ob-ref)
|
||||
(require 'ob-tangle)
|
||||
(require 'ob-comint)
|
||||
(require 'ob-keys)
|
||||
(require 'ob-emacs-lisp)
|
||||
|
||||
;;;; Customization variables
|
||||
(defcustom org-clone-delete-id nil
|
||||
"Remove ID property of clones of a subtree.
|
||||
|
@ -3611,6 +3628,11 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
|
|||
'(org-remember-insinuate org-remember-annotation
|
||||
org-remember-apply-template org-remember org-remember-handler)))
|
||||
|
||||
(eval-and-compile
|
||||
(org-autoload "org-capture"
|
||||
'(org-capture org-capture-insert-template-here
|
||||
org-capture-import-remember-templates)))
|
||||
|
||||
;; Autoload org-clock.el
|
||||
|
||||
|
||||
|
@ -4317,7 +4339,11 @@ means to push this value onto the list in the variable.")
|
|||
org-complex-heading-regexp-format
|
||||
(concat "^\\(\\*+\\)[ \t]+\\(?:\\("
|
||||
(mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
|
||||
"\\)\\>\\)?\\(?:[ \t]*\\(\\[#.\\]\\)\\)?[ \t]*\\(%s\\)"
|
||||
"\\)\\>\\)?"
|
||||
"\\(?:[ \t]*\\(\\[#.\\]\\)\\)?"
|
||||
"\\(?:[ \t]*\\(?:\\[[0-9%%/]+\\]\\)\\)?" ;; stats cookie
|
||||
"[ \t]*\\(%s\\)"
|
||||
"\\(?:[ \t]*\\(?:\\[[0-9%%/]+\\]\\)\\)?" ;; stats cookie
|
||||
"\\(?:[ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$")
|
||||
org-nl-done-regexp
|
||||
(concat "\n\\*+[ \t]+"
|
||||
|
@ -4571,10 +4597,8 @@ The following commands are available:
|
|||
'org-block-todo-from-checkboxes))
|
||||
|
||||
;; Comment characters
|
||||
;; (org-set-local 'comment-start "#")
|
||||
(org-set-local 'comment-start "#")
|
||||
(org-set-local 'comment-padding " ")
|
||||
(modify-syntax-entry ?# "<")
|
||||
;; (modify-syntax-entry ?\n ">")
|
||||
|
||||
;; Align options lines
|
||||
(org-set-local
|
||||
|
@ -8611,7 +8635,7 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
|
|||
(save-match-data
|
||||
(if (string-match (concat "^" (regexp-quote
|
||||
(file-name-as-directory
|
||||
(expand-file-name "."))))
|
||||
default-directory)))
|
||||
(expand-file-name path))
|
||||
;; We are linking a file with relative path name.
|
||||
(setq path (substring (expand-file-name path)
|
||||
|
@ -8880,6 +8904,8 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file.
|
|||
With a double prefix argument, try to open outside of Emacs, in the
|
||||
application the system uses for this file type."
|
||||
(interactive "P")
|
||||
;; if in a code block, then open the block's results
|
||||
(unless (call-interactively #'org-babel-open-src-block-result)
|
||||
(org-load-modules-maybe)
|
||||
(move-marker org-open-link-marker (point))
|
||||
(setq org-window-config-before-follow-link (current-window-configuration))
|
||||
|
@ -9061,7 +9087,7 @@ application the system uses for this file type."
|
|||
(t
|
||||
(browse-url-at-point)))))))
|
||||
(move-marker org-open-link-marker nil)
|
||||
(run-hook-with-args 'org-follow-link-hook))
|
||||
(run-hook-with-args 'org-follow-link-hook)))
|
||||
|
||||
(defun org-offer-links-in-entry (&optional nth zero)
|
||||
"Offer links in the current entry and follow the selected link.
|
||||
|
@ -10855,7 +10881,7 @@ changes. Such blocking occurs when:
|
|||
(let* ((pos (point))
|
||||
(parent-pos (and (org-up-heading-safe) (point))))
|
||||
(if (not parent-pos) (throw 'dont-block t)) ; no parent
|
||||
(when (and (org-entry-get (point) "ORDERED")
|
||||
(when (and (org-not-nil (org-entry-get (point) "ORDERED"))
|
||||
(forward-line 1)
|
||||
(re-search-forward org-not-done-heading-regexp pos t))
|
||||
(throw 'dont-block nil)) ; block, there is an older sibling not done.
|
||||
|
@ -10867,7 +10893,7 @@ changes. Such blocking occurs when:
|
|||
(setq pos (point))
|
||||
(setq parent-pos (and (org-up-heading-safe) (point)))
|
||||
(if (not parent-pos) (throw 'dont-block t)) ; no parent
|
||||
(when (and (org-entry-get (point) "ORDERED")
|
||||
(when (and (org-not-nil (org-entry-get (point) "ORDERED"))
|
||||
(forward-line 1)
|
||||
(re-search-forward org-not-done-heading-regexp pos t))
|
||||
(throw 'dont-block nil)))))))) ; block, older sibling not done.
|
||||
|
@ -13252,7 +13278,7 @@ things up because then unnecessary parsing is avoided."
|
|||
(let ((clockstr (substring org-clock-string 0 -1))
|
||||
(excluded '("TODO" "TAGS" "ALLTAGS" "PRIORITY" "BLOCKED"))
|
||||
(case-fold-search nil)
|
||||
beg end range props sum-props key value string clocksum)
|
||||
beg end range props sum-props key key1 value string clocksum)
|
||||
(save-excursion
|
||||
(when (condition-case nil
|
||||
(and (org-mode-p) (org-back-to-heading t))
|
||||
|
@ -13283,23 +13309,35 @@ things up because then unnecessary parsing is avoided."
|
|||
(when (or (not specific) (string= specific "BLOCKED"))
|
||||
(push (cons "BLOCKED" (if (org-entry-blocked-p) "t" "")) props))
|
||||
(when (or (not specific)
|
||||
(member specific org-all-time-keywords)
|
||||
(member specific '("TIMESTAMP" "TIMESTAMP_IA")))
|
||||
(member specific
|
||||
'("SCHEDULED" "DEADLINE" "CLOCK" "CLOSED"
|
||||
"TIMESTAMP" "TIMESTAMP_IA")))
|
||||
(while (re-search-forward org-maybe-keyword-time-regexp end t)
|
||||
(setq key (if (match-end 1) (substring (org-match-string-no-properties 1) 0 -1))
|
||||
(setq key (if (match-end 1)
|
||||
(substring (org-match-string-no-properties 1)
|
||||
0 -1))
|
||||
string (if (equal key clockstr)
|
||||
(org-no-properties
|
||||
(org-trim
|
||||
(buffer-substring
|
||||
(match-beginning 3) (goto-char (point-at-eol)))))
|
||||
(substring (org-match-string-no-properties 3) 1 -1)))
|
||||
(unless key
|
||||
(if (= (char-after (match-beginning 3)) ?\[)
|
||||
(setq key "TIMESTAMP_IA")
|
||||
(setq key "TIMESTAMP")))
|
||||
(when (or (equal key clockstr) (not (assoc key props)))
|
||||
(buffer-substring
|
||||
(match-beginning 3) (goto-char
|
||||
(point-at-eol)))))
|
||||
(substring (org-match-string-no-properties 3)
|
||||
1 -1)))
|
||||
;; Get the correct property name from the key. This is
|
||||
;; necessary if the user has configured time keywords.
|
||||
(setq key1 (concat key ":"))
|
||||
(cond
|
||||
((not key)
|
||||
(setq key
|
||||
(if (= (char-after (match-beginning 3)) ?\[)
|
||||
"TIMESTAMP_IA" "TIMESTAMP")))
|
||||
((equal key1 org-scheduled-string) (setq key "SCHEDULED"))
|
||||
((equal key1 org-deadline-string) (setq key "DEADLINE"))
|
||||
((equal key1 org-closed-string) (setq key "CLOSED"))
|
||||
((equal key1 org-clock-string) (setq key "CLOCK")))
|
||||
(when (or (equal key "CLOCK") (not (assoc key props)))
|
||||
(push (cons key string) props))))
|
||||
|
||||
)
|
||||
|
||||
(when (memq which '(all standard))
|
||||
|
@ -13326,14 +13364,18 @@ things up because then unnecessary parsing is avoided."
|
|||
(push (cons "CATEGORY" value) props))
|
||||
(append sum-props (nreverse props)))))))
|
||||
|
||||
(defun org-entry-get (pom property &optional inherit)
|
||||
(defun org-entry-get (pom property &optional inherit literal-nil)
|
||||
"Get value of PROPERTY for entry at point-or-marker POM.
|
||||
If INHERIT is non-nil and the entry does not have the property,
|
||||
then also check higher levels of the hierarchy.
|
||||
If INHERIT is the symbol `selective', use inheritance only if the setting
|
||||
in `org-use-property-inheritance' selects PROPERTY for inheritance.
|
||||
If the property is present but empty, the return value is the empty string.
|
||||
If the property is not present at all, nil is returned."
|
||||
If the property is not present at all, nil is returned.
|
||||
|
||||
If LITERAL-NIL is set, return the string value \"nil\" as a string,
|
||||
do not interpret it as the list atom nil. This is used for inheritance
|
||||
when a \"nil\" value can supercede a non-nil value higher up the hierarchy."
|
||||
(org-with-point-at pom
|
||||
(if (and inherit (if (eq inherit 'selective)
|
||||
(org-property-inherit-p property)
|
||||
|
@ -13351,7 +13393,9 @@ If the property is not present at all, nil is returned."
|
|||
(cdr range) t))
|
||||
;; Found the property, return it.
|
||||
(if (match-end 1)
|
||||
(org-match-string-no-properties 1)
|
||||
(if literal-nil
|
||||
(org-match-string-no-properties 1)
|
||||
(org-not-nil (org-match-string-no-properties 1)))
|
||||
"")))))))
|
||||
|
||||
(defun org-property-or-variable-value (var &optional inherit)
|
||||
|
@ -13455,15 +13499,16 @@ is set.")
|
|||
(widen)
|
||||
(catch 'ex
|
||||
(while t
|
||||
(when (setq tmp (org-entry-get nil property))
|
||||
(when (setq tmp (org-entry-get nil property nil 'literal-nil))
|
||||
(org-back-to-heading t)
|
||||
(move-marker org-entry-property-inherited-from (point))
|
||||
(throw 'ex tmp))
|
||||
(or (org-up-heading-safe) (throw 'ex nil)))))
|
||||
(or tmp
|
||||
(cdr (assoc property org-file-properties))
|
||||
(cdr (assoc property org-global-properties))
|
||||
(cdr (assoc property org-global-properties-fixed))))))
|
||||
(org-not-nil
|
||||
(or tmp
|
||||
(cdr (assoc property org-file-properties))
|
||||
(cdr (assoc property org-global-properties))
|
||||
(cdr (assoc property org-global-properties-fixed)))))))
|
||||
|
||||
(defvar org-property-changed-functions nil
|
||||
"Hook called when the value of a property has changed.
|
||||
|
@ -13777,7 +13822,7 @@ completion."
|
|||
(skip-chars-forward " \t")
|
||||
(run-hook-with-args 'org-property-changed-functions key nval)))
|
||||
|
||||
(defun org-find-olp (path)
|
||||
(defun org-find-olp (path &optional this-buffer)
|
||||
"Return a marker pointing to the entry at outline path OLP.
|
||||
If anything goes wrong, throw an error.
|
||||
You can wrap this call to cathc the error like this:
|
||||
|
@ -13787,9 +13832,12 @@ You can wrap this call to cathc the error like this:
|
|||
(error (nth 1 msg)))
|
||||
|
||||
The return value will then be either a string with the error message,
|
||||
or a marker if everyhing is OK."
|
||||
(let* ((file (pop path))
|
||||
(buffer (find-file-noselect file))
|
||||
or a marker if everyhing is OK.
|
||||
|
||||
If THIS-BUFFER is set, the putline path does not contain a file,
|
||||
only headings."
|
||||
(let* ((file (if this-buffer buffer-file-name (pop path)))
|
||||
(buffer (if this-buffer (current-buffer) (find-file-noselect file)))
|
||||
(level 1)
|
||||
(lmin 1)
|
||||
(lmax 1)
|
||||
|
@ -14684,20 +14732,18 @@ days in order to avoid rounding problems."
|
|||
(defun org-time-string-to-seconds (s)
|
||||
(org-float-time (org-time-string-to-time s)))
|
||||
|
||||
(defun org-time-string-to-absolute (s &optional daynr prefer show-all ignore-cyclic)
|
||||
(defun org-time-string-to-absolute (s &optional daynr prefer show-all)
|
||||
"Convert a time stamp to an absolute day number.
|
||||
If there is a specifier for a cyclic time stamp, get the closest date to
|
||||
If there is a specifyer for a cyclic time stamp, get the closest date to
|
||||
DAYNR.
|
||||
PREFER and SHOW-ALL are passed through to `org-closest-date'.
|
||||
the variable date is bound by the calendar when this is called.
|
||||
IGNORE-CYCLIC ignores cyclic repeaters so the returned absolute date
|
||||
is based on the original date."
|
||||
the variable date is bound by the calendar when this is called."
|
||||
(cond
|
||||
((and daynr (string-match "\\`%%\\((.*)\\)" s))
|
||||
(if (org-diary-sexp-entry (match-string 1 s) "" date)
|
||||
daynr
|
||||
(+ daynr 1000)))
|
||||
((and (not ignore-cyclic) daynr (string-match "\\+[0-9]+[dwmy]" s))
|
||||
((and daynr (string-match "\\+[0-9]+[dwmy]" s))
|
||||
(org-closest-date s (if (and (boundp 'daynr) (integerp daynr)) daynr
|
||||
(time-to-days (current-time))) (match-string 0 s)
|
||||
prefer show-all))
|
||||
|
@ -14879,7 +14925,7 @@ If the cursor is on the year, change the year. If it is on the month or
|
|||
the day, change that.
|
||||
With prefix ARG, change by that many units."
|
||||
(interactive "p")
|
||||
(org-timestamp-change (prefix-numeric-value arg)))
|
||||
(org-timestamp-change (prefix-numeric-value arg) nil 'updown))
|
||||
|
||||
(defun org-timestamp-down (&optional arg)
|
||||
"Decrease the date item at the cursor by one.
|
||||
|
@ -14887,7 +14933,7 @@ If the cursor is on the year, change the year. If it is on the month or
|
|||
the day, change that.
|
||||
With prefix ARG, change by that many units."
|
||||
(interactive "p")
|
||||
(org-timestamp-change (- (prefix-numeric-value arg))))
|
||||
(org-timestamp-change (- (prefix-numeric-value arg)) nil 'updown))
|
||||
|
||||
(defun org-timestamp-up-day (&optional arg)
|
||||
"Increase the date in the time stamp by one day.
|
||||
|
@ -14896,7 +14942,7 @@ With prefix ARG, change that many days."
|
|||
(if (and (not (org-at-timestamp-p t))
|
||||
(org-on-heading-p))
|
||||
(org-todo 'up)
|
||||
(org-timestamp-change (prefix-numeric-value arg) 'day)))
|
||||
(org-timestamp-change (prefix-numeric-value arg) 'day 'updown)))
|
||||
|
||||
(defun org-timestamp-down-day (&optional arg)
|
||||
"Decrease the date in the time stamp by one day.
|
||||
|
@ -14905,7 +14951,7 @@ With prefix ARG, change that many days."
|
|||
(if (and (not (org-at-timestamp-p t))
|
||||
(org-on-heading-p))
|
||||
(org-todo 'down)
|
||||
(org-timestamp-change (- (prefix-numeric-value arg)) 'day)))
|
||||
(org-timestamp-change (- (prefix-numeric-value arg)) 'day) 'updown))
|
||||
|
||||
(defun org-at-timestamp-p (&optional inactive-ok)
|
||||
"Determine if the cursor is in or at a timestamp."
|
||||
|
@ -14950,7 +14996,7 @@ With prefix ARG, change that many days."
|
|||
(message "Timestamp is now %sactive"
|
||||
(if (equal (char-after beg) ?<) "" "in")))))
|
||||
|
||||
(defun org-timestamp-change (n &optional what)
|
||||
(defun org-timestamp-change (n &optional what updown)
|
||||
"Change the date in the time stamp at point.
|
||||
The date will be changed by N times WHAT. WHAT can be `day', `month',
|
||||
`year', `minute', `second'. If WHAT is not given, the cursor position
|
||||
|
@ -14981,8 +15027,10 @@ in the timestamp determines what will be changed."
|
|||
(if (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts)
|
||||
(setq with-hm t))
|
||||
(setq time0 (org-parse-time-string ts))
|
||||
(when (and (eq org-ts-what 'minute)
|
||||
(eq current-prefix-arg nil))
|
||||
(when (and updown
|
||||
(eq org-ts-what 'minute)
|
||||
(not current-prefix-arg))
|
||||
;; This looks like s-up and s-down. Change by one rounding step.
|
||||
(setq n (* dm (cond ((> n 0) 1) ((< n 0) -1) (t 0))))
|
||||
(when (not (= 0 (setq rem (% (nth 1 time0) dm))))
|
||||
(setcar (cdr time0) (+ (nth 1 time0)
|
||||
|
@ -16000,6 +16048,12 @@ BEG and END default to the buffer boundaries."
|
|||
(org-defkey org-mode-map [(control shift right)] 'org-shiftcontrolright)
|
||||
(org-defkey org-mode-map [(control shift left)] 'org-shiftcontrolleft)
|
||||
|
||||
;; Babel keys
|
||||
(define-key org-mode-map org-babel-key-prefix org-babel-map)
|
||||
(mapc (lambda (pair)
|
||||
(define-key org-babel-map (car pair) (cdr pair)))
|
||||
org-babel-key-bindings)
|
||||
|
||||
;;; Extra keys for tty access.
|
||||
;; We only set them when really needed because otherwise the
|
||||
;; menus don't show the simple keys
|
||||
|
@ -16862,14 +16916,23 @@ See the individual commands for more information."
|
|||
(org-table-paste-rectangle)
|
||||
(org-paste-subtree arg)))
|
||||
|
||||
(defun org-edit-special ()
|
||||
(defun org-edit-special (&optional arg)
|
||||
"Call a special editor for the stuff at point.
|
||||
When at a table, call the formula editor with `org-table-edit-formulas'.
|
||||
When at the first line of an src example, call `org-edit-src-code'.
|
||||
When in an #+include line, visit the include file. Otherwise call
|
||||
`ffap' to visit the file at point."
|
||||
(interactive)
|
||||
(cond
|
||||
;; possibly prep session before editing source
|
||||
(when arg
|
||||
(let* ((info (org-babel-get-src-block-info))
|
||||
(lang (nth 0 info))
|
||||
(params (nth 2 info))
|
||||
(session (cdr (assoc :session params))))
|
||||
(when (and info session) ;; we are in a source-code block with a session
|
||||
(funcall
|
||||
(intern (concat "org-babel-prep-session:" lang)) session params))))
|
||||
(cond ;; proceed with `org-edit-special'
|
||||
((save-excursion
|
||||
(beginning-of-line 1)
|
||||
(looking-at "\\(?:#\\+\\(?:setupfile\\|include\\):?[ \t]+\"?\\|[ \t]*<include\\>.*?file=\"\\)\\([^\"\n>]+\\)"))
|
||||
|
@ -18099,7 +18162,8 @@ return nil."
|
|||
|
||||
(defun org-switch-to-buffer-other-window (&rest args)
|
||||
"Switch to buffer in a second window on the current frame.
|
||||
In particular, do not allow pop-up frames."
|
||||
In particular, do not allow pop-up frames.
|
||||
Returns the newly created buffer."
|
||||
(let (pop-up-frames special-display-buffer-names special-display-regexps
|
||||
special-display-function)
|
||||
(apply 'switch-to-buffer-other-window args)))
|
||||
|
@ -18516,8 +18580,8 @@ beyond the end of the headline."
|
|||
(if (bobp)
|
||||
nil
|
||||
(backward-char 1)
|
||||
(if (org-invisible-p)
|
||||
(while (and (not (bobp)) (org-invisible-p))
|
||||
(if (org-truely-invisible-p)
|
||||
(while (and (not (bobp)) (org-truely-invisible-p))
|
||||
(backward-char 1)
|
||||
(beginning-of-line 1))
|
||||
(forward-char 1))))
|
||||
|
@ -18735,6 +18799,17 @@ interactive command with similar behavior."
|
|||
(outline-invisible-p)
|
||||
(get-char-property (point) 'invisible)))
|
||||
|
||||
(defun org-truely-invisible-p ()
|
||||
"Check if point is at a character currently not visible.
|
||||
This version does not only check the character property, but also
|
||||
`visible-mode'."
|
||||
;; Early versions of noutline don't have `outline-invisible-p'.
|
||||
(if (org-bound-and-true-p visible-mode)
|
||||
nil
|
||||
(if (fboundp 'outline-invisible-p)
|
||||
(outline-invisible-p)
|
||||
(get-char-property (point) 'invisible))))
|
||||
|
||||
(defun org-invisible-p2 ()
|
||||
"Check if point is at a character currently not visible."
|
||||
(save-excursion
|
||||
|
|
Loading…
Reference in a new issue