Browse Source

Merge branch 'master' of git+ssh://repo.or.cz/srv/git/org-mode

Carsten Dominik 14 years ago
parent
commit
294527373e
3 changed files with 34 additions and 34 deletions
  1. 14 21
      contrib/babel/library-of-babel.org
  2. 7 5
      doc/org.texi
  3. 13 8
      lisp/ob-lob.el

+ 14 - 21
contrib/babel/library-of-babel.org

@@ -33,8 +33,8 @@ Read the contents of the file at =file=.  The =:results vector= and
 =:results scalar= header arguments can be used to read the contents of
 file as either a table or a string.
 #+srcname: read
-#+begin_src emacs-lisp :var file=""
-  (if (member "vector" result-params)
+#+begin_src emacs-lisp :var file="" :var format=""
+  (if (string= format "csv")
       (with-temp-buffer
         (org-table-import (expand-file-name file) nil)
         (org-table-to-lisp))
@@ -82,14 +82,13 @@ The =google= command seems to be throwing "Moved Temporarily" errors
 when trying to download textual documents, but this is working fine
 for spreadsheets.
 #+source: gdoc-read
-#+begin_src emacs-lisp :var title="example"
-  (let* ((format (if (member "vector" result-params) "csv" "txt"))
-         (file (concat title "." format))
+#+begin_src emacs-lisp :var title="example" :var format="csv"
+  (let* ((file (concat title "." format))
          (cmd (format "google docs get --format %S --title %S" format title)))
     (message cmd) (message (shell-command-to-string cmd))
     (prog1 (if (string= format "csv")
                (with-temp-buffer
-                 (org-table-import (shell-quote-argument file) nil)
+                 (org-table-import (shell-quote-argument file) '(4))
                  (org-table-to-lisp))
              (with-temp-buffer
                (insert-file-contents (shell-quote-argument file))
@@ -99,15 +98,11 @@ for spreadsheets.
 
 For example, a line like the following can be used to read the
 contents of a spreadsheet named =num-cells= into a table.
-#+begin_src org
-  ,#+call: gdoc-read(title="num-cells"") :results vector
-#+end_src
+: #+call: gdoc-read(title="num-cells"")
 
 A line like the following can be used to read the contents of a
 document as a string.
-#+begin_src org
-  ,#+call: gdoc-read(title="loremi") :results scalar
-#+end_src
+: #+call: gdoc-read(title="loremi", :format "txt")
 
 ****** write a document to a Google docs
 Write =data= to a google document named =title=.  If =data= is tabular
@@ -129,15 +124,13 @@ normal document.
 #+end_src
 
 example usage
-#+begin_src org
-  ,#+source: fibs
-  ,#+begin_src emacs-lisp :var n=8
-  ,  (flet ((fib (m) (if (< m 2) 1 (+ (fib (- m 1)) (fib (- m 2))))))
-  ,    (mapcar (lambda (el) (list el (fib el))) (number-sequence 0 (- n 1))))
-  ,#+end_src
-  
-  ,#+call: gdoc-write(title="fibs", data=fibs(n=10))
-#+end_src
+: #+source: fibs
+: #+begin_src emacs-lisp :var n=8
+:   (flet ((fib (m) (if (< m 2) 1 (+ (fib (- m 1)) (fib (- m 2))))))
+:     (mapcar (lambda (el) (list el (fib el))) (number-sequence 0 (- n 1))))
+: #+end_src
+: 
+: #+call: gdoc-write(title="fibs", data=fibs(n=10))
 
 * Plotting code
 

+ 7 - 5
doc/org.texi

@@ -10979,9 +10979,9 @@ e.g.
 
 Org-mode provides a number of features for working with live source code,
 including editing of code blocks in their native major-mode, evaluation of
-code blocks, tangling of code blocks, and exporting code blocks and
-their results in several formats.  This functionality was contributed by Dan
-Davison and Eric Schulte, and was originally named Org-babel.
+code blocks, tangling of code blocks, and exporting code blocks and their
+results in several formats.  This functionality was contributed by Eric
+Schulte and Dan Davison, and was originally named Org-babel.
 
 The following sections describe Org-mode's code block handling facilities.
 
@@ -13286,8 +13286,10 @@ Also the @kbd{M-cursor} and @kbd{M-S-cursor} keys have this property.
 Add-ons can tap into this functionality by providing a function that detects
 special context for that add-on and executes functionality appropriate for
 the context.  Here is an example from Dan Davison's @file{org-R.el} which
-allows you to evaluate commands based on the @file{R} programming language.  For
-this package, special contexts are lines that start with @code{#+R:} or
+allows you to evaluate commands based on the @file{R} programming language
+@footnote{@file{org-R.el} has been replaced by the org-mode functionality
+described in @ref{Working With Source Code} and is now obsolete.}.  For this
+package, special contexts are lines that start with @code{#+R:} or
 @code{#+RR:}.
 
 @lisp

+ 13 - 8
lisp/ob-lob.el

@@ -61,9 +61,10 @@ If you change the value of this variable then your files may
   become unusable by other org-babel users, and vice versa.")
 
 (defconst org-babel-lob-one-liner-regexp
-  (concat "^\\([ \t]*\\)#\\+\\(?:"
-	  (mapconcat #'regexp-quote org-babel-lob-call-aliases "\\|")
-	  "\\):[ \t]+\\([^\(\)\n]+\\)\(\\([^\n]*\\)\)[ \t]*\\([^\n]*\\)")
+  (concat
+   "^\\([ \t]*\\)#\\+\\(?:"
+   (mapconcat #'regexp-quote org-babel-lob-call-aliases "\\|")
+   "\\):[ \t]+\\([^\(\)\n]+\\)\(\\([^\n]*\\)\)\\(\\[.+\\]\\)[ \t]*\\([^\n]*\\)")
   "Regexp to match calls to predefined source block functions.")
 
 ;; functions for executing lob one-liners
@@ -92,10 +93,13 @@ the word 'call'."
     (save-excursion
       (beginning-of-line 1)
       (if (looking-at org-babel-lob-one-liner-regexp)
-          (append (mapcar #'org-babel-clean-text-properties 
-			  (list (format "%s(%s)" (match-string 2) (match-string 3))
-				(match-string 4)))
-		  (list (length (match-string 1))))))))
+          (append
+	   (mapcar #'org-babel-clean-text-properties 
+		   (list
+		    (format "%s(%s)%s"
+			    (match-string 2) (match-string 3) (match-string 4))
+		    (match-string 5)))
+	   (list (length (match-string 1))))))))
   
 (defun org-babel-lob-execute (info)
   "Execute the lob call specified by INFO."
@@ -105,7 +109,8 @@ the word 'call'."
                  (org-babel-params-from-properties)
 		 (org-babel-parse-header-arguments
 		  (org-babel-clean-text-properties
-		   (concat ":var results=" (mapconcat #'identity (butlast info) " ")))))))
+		   (concat ":var results="
+			   (mapconcat #'identity (butlast info) " ")))))))
     (org-babel-execute-src-block
      nil (list "emacs-lisp" "results" params nil nil (nth 2 info)))))