OK, I'm getting confused in magit and committing only a single hunk
when I intended several. Hence, the commit note for this commit is the
commit note filed with the previous commit: da82dae939
This commit is contained in:
parent
da82dae939
commit
b300b62b9c
|
@ -29,43 +29,44 @@
|
||||||
;; See org-babel.org in the parent directory for more information
|
;; See org-babel.org in the parent directory for more information
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
(require 'org)
|
(require 'org-babel)
|
||||||
|
|
||||||
|
(org-babel-add-interpreter "babel")
|
||||||
|
|
||||||
(defun org-babel-execute:babel (body params)
|
(defun org-babel-execute:babel (body params)
|
||||||
"Execute a library-of-babel block.
|
"Execute a library-of-babel block.
|
||||||
|
|
||||||
These blocks do not have their own body. Instead they use a :srcname
|
These blocks do not have their own body. Instead they use
|
||||||
header argument to reference a different source block, whose body
|
a :srcname header argument to reference a different source
|
||||||
they use. Source blocks in the library of babel should use a
|
block, whose body they use. Source blocks in the library of
|
||||||
standard naming scheme for the variable containing the input data
|
babel should use a standard naming scheme for the variable
|
||||||
for analysis / plotting. E.g. if that variable is always called
|
containing the input data for analysis / plotting. E.g. if that
|
||||||
__data__ then one of these bodyless babel blocks will call a library
|
variable is always called __data__ then one of these bodyless
|
||||||
of babel block using :var __data__=<some reference>
|
babel blocks will call a library of babel block using :var
|
||||||
|
__data__=<some reference>. The header args from a babel block
|
||||||
|
are appended to the header args from the target block.
|
||||||
|
|
||||||
This function is called by `org-babel-execute-src-block'."
|
This function is called by `org-babel-execute-src-block'."
|
||||||
(message "executing babel source code block...")
|
(message "executing babel source code block...")
|
||||||
(save-window-excursion
|
(save-window-excursion
|
||||||
(let ((srcname (cdr (assoc :srcname params))))
|
(save-excursion
|
||||||
|
(org-babel-goto-srcname (cdr (assoc :srcname params))))
|
||||||
|
(forward-line 1)
|
||||||
|
(insert (match-string 0))
|
||||||
|
(org-babel-execute-src-block nil nil params)))
|
||||||
|
|
||||||
;; now locate the source block specified by srcname (it might be
|
(defun org-babel-lob-parse-buffer ()
|
||||||
;; in the library of babel), and construct a new source block
|
"Read all source-code blocks in buffer into memory."
|
||||||
;; as follows:
|
(save-excursion
|
||||||
;;
|
(goto-char (point-min))
|
||||||
;; 1. The lang is the lang of the referenced source block
|
(let ((blocks (make-hash-table)))
|
||||||
;; 2. The header args are those from the current #+begin_src babel block
|
(while (re-search-forward
|
||||||
;; 3. The body is from the reference source block
|
org-babel-named-src-block-regexp nil t)
|
||||||
|
(puthash (match-string-no-properties 1) ;; srcname
|
||||||
;; If using a library of babel function, then the
|
(list (cons :lang (match-string-no-properties 2))
|
||||||
;; resposnsibility id on the caller to name the :var arg(s)
|
(cons :body (match-string-no-properties 3))
|
||||||
;; correctly. We could adopt a standard name such as __data__
|
(cons :params (match-string-no-properties 4)))
|
||||||
;; for the input data for plotting / analysis. Thus in lob
|
blocks))
|
||||||
;; source blocks the data variable would be referred to as
|
blocks)))
|
||||||
;; __data__ in the code, and the babel block would use :var
|
|
||||||
;; __data__=<some reference>
|
|
||||||
|
|
||||||
;; Now execute the constructed source block, ensuring that this
|
|
||||||
;; buffer receives the appropriate output, and only receives a
|
|
||||||
;; copy of the referenced source block if requested
|
|
||||||
)))
|
|
||||||
|
|
||||||
(provide 'org-babel-lob)
|
(provide 'org-babel-lob)
|
||||||
|
|
Loading…
Reference in New Issue