Переглянути джерело

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

Carsten Dominik 14 роки тому
батько
коміт
ee629299c0
3 змінених файлів з 27 додано та 19 видалено
  1. 20 17
      contrib/babel/library-of-babel.org
  2. 4 2
      lisp/babel/langs/ob-python.el
  3. 3 0
      lisp/babel/ob.el

+ 20 - 17
contrib/babel/library-of-babel.org

@@ -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

+ 4 - 2
lisp/babel/langs/ob-python.el

@@ -96,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
@@ -110,7 +110,9 @@ 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))

+ 3 - 0
lisp/babel/ob.el

@@ -30,6 +30,9 @@
 
 ;;; Code:
 (eval-when-compile (require 'cl))
+(eval-and-compile
+  (unless (fboundp 'declare-function)
+    (defmacro declare-function (fn file &optional arglist fileonly))))
 
 (defvar org-babel-call-process-region-original)
 (declare-function show-all "outline" ())