thinking about and stubbing out functions for referencing external resources

This commit is contained in:
Eric Schulte 2009-03-23 17:01:11 -07:00
parent a95cf1c442
commit 74498d6055
4 changed files with 36 additions and 4 deletions

View File

@ -37,7 +37,8 @@
"Execute a block of emacs-lisp code with litorgy. This
function is called by `litorgy-execute-src-block'."
(save-window-excursion
(let ((print-level nil) (print-length nil) results)
(let ((vars (litorgy-reference-variables params))
(print-level nil) (print-length nil) results)
(message "executing emacs-lisp code block...")
(format "%S" (eval (read body))))))

View File

@ -29,7 +29,7 @@
;; Functions for referencing data from the header arguments of a
;; litorgical block. The syntax of such a reference should be
;;
;; #+VAR: variable-name file resource-id:name
;; #+VAR: variable-name=file:resource-id
;;
;; - variable-name :: the name of the variable to which the value
;; will be assigned
@ -53,5 +53,31 @@
;;; Code:
(require 'litorgy)
(defun litorgy-reference-variables (params)
"Takes a parameter alist, and return an alist of variable
names, and the string representation of the related value."
(mapcar #'litorgy-reference-parse
(delq nil (mapcar (lambda (pair) (if (= (car pair) :var) (cdr pair))) params))))
(defun litorgy-reference-parse (reference)
"Parse a reference to an external resource returning a list
with two elements. The first element of the list will be the
name of the variable, and the second will be an emacs-lisp
representation of the value of the variable."
(save-excursion
(if (string-match "(.+)=(.+)" reference)
(let ((var (match-string 1 reference))
(ref (match-string 2 reference)))
(when (string-match "(.+):(.+)" reference)
(find-file (match-string 1 reference))
(setf ref (match-string 2 reference)))
;; follow the reference in the current file
(case ref
("previous"
)
("next")
(t ))
))))
(provide 'litorgy-reference)
;;; litorgy-reference.el ends here

View File

@ -32,8 +32,8 @@
(require 'org)
(defun litorgy-execute-src-block-maybe ()
"Detect if this is context for a litorgical src-block and run if
so then run `litorgy-execute-src-block'."
"Detect if this is context for a litorgical src-block and if so
then run `litorgy-execute-src-block'."
(let ((case-fold-search t))
(if (save-excursion
(beginning-of-line 1)

View File

@ -238,6 +238,11 @@ internal to the source-code evaluation process?
need to look more closely at that and we should try to come up with a
formats for referencing data from source-code in such a way that it
will be as source-code-language independent as possible.
Org tables already have a sophisticated reference system in place
that allows referencing table ranges in other files, as well as
specifying constants in the header arguments of a table. This is
described in [[info:org:References]].
**** Dan: thinking aloud re: referencing data from R
Suppose in some R code, we want to reference data in an org