Browse Source

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

Carsten Dominik 16 years ago
parent
commit
df3fca503e

+ 18 - 5
contrib/babel/lisp/langs/org-babel-asymptote.el

@@ -34,10 +34,18 @@
 ;;
 ;;
 ;; 2) we are generally only going to return results of type "file"
 ;; 2) we are generally only going to return results of type "file"
 ;;
 ;;
-;; 3) we are adding the "file" and "cmdline" header arguments
+;; 3) we are adding the "file" and "cmdline" header arguments, if file
+;;    is omitted then the -V option is passed to the asy command for
+;;    interactive viewing
 ;;
 ;;
 ;; 4) there are no variables (at least for now)
 ;; 4) there are no variables (at least for now)
 
 
+;;; Requirements:
+
+;; - The asymptote program :: http://asymptote.sourceforge.net/
+;;
+;; - asy-mode :: Major mode for editing asymptote files
+
 ;;; Code:
 ;;; Code:
 (require 'org-babel)
 (require 'org-babel)
 
 
@@ -54,14 +62,19 @@ called by `org-babel-execute-src-block'."
   (message "executing Asymptote source code block")
   (message "executing Asymptote source code block")
   (let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
   (let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
          (out-file (cdr (assoc :file params)))
          (out-file (cdr (assoc :file params)))
-         (format (or (and (string-match ".+\\.\\(.+\\)" out-file)
+         (format (or (and out-file
+                          (string-match ".+\\.\\(.+\\)" out-file)
                           (match-string 1 out-file))
                           (match-string 1 out-file))
                      "pdf"))
                      "pdf"))
          (cmdline (cdr (assoc :cmdline params)))
          (cmdline (cdr (assoc :cmdline params)))
-         (in-file (make-temp-file "org-babel-asymptote")))
+         (in-file (make-temp-file "org-babel-asymptote"))
+         (cmd (concat "asy "
+                      (if out-file
+                          (concat "-globalwrite -f " format " -o " out-file)
+                        "-V")
+                      " " cmdline " " in-file)))
     (with-temp-file in-file (insert body))
     (with-temp-file in-file (insert body))
-    (message (concat "asy -globalwrite -f " format " -o " out-file " " cmdline " " in-file))
-    (shell-command (concat "asy -globalwrite -f " format " -o " out-file " " cmdline " " in-file))
+    (message cmd) (shell-command cmd)
     out-file))
     out-file))
 
 
 (defun org-babel-prep-session:asymptote (session params)
 (defun org-babel-prep-session:asymptote (session params)

+ 2 - 1
contrib/babel/lisp/org-babel.el

@@ -412,7 +412,8 @@ If the point is not on a source block then return nil."
         (re-search-backward "#\\+begin_src" nil t) (setq top (point))
         (re-search-backward "#\\+begin_src" nil t) (setq top (point))
         (re-search-forward "#\\+end_src" nil t) (setq bottom (point))
         (re-search-forward "#\\+end_src" nil t) (setq bottom (point))
         (< top initial) (< initial bottom)
         (< top initial) (< initial bottom)
-        (goto-char top) (looking-at org-babel-src-block-regexp)
+        (goto-char top) (move-beginning-of-line 1)
+        (looking-at org-babel-src-block-regexp)
         (point))))))
         (point))))))
 
 
 (defun org-babel-goto-named-source-block (&optional name)
 (defun org-babel-goto-named-source-block (&optional name)

+ 5 - 5
contrib/lisp/org-babel-init.el

@@ -35,11 +35,11 @@
                     "babel"
                     "babel"
                     (expand-file-name
                     (expand-file-name
                      ".." (file-name-directory (or load-file-name buffer-file-name))))))
                      ".." (file-name-directory (or load-file-name buffer-file-name))))))
-       
-       (langs-dir (expand-file-name "langs" babel-dir))
-       (load-path (append
-                   (list babel-dir langs-dir)
-                   (or load-path nil))))
+
+       (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
   ;; org-babel core
   (require 'cl)
   (require 'cl)

+ 2 - 1
lisp/org-src.el

@@ -110,7 +110,8 @@ or similar things which you want to have when editing a source code file,
 but which mess up the display of a snippet in Org exported files.")
 but which mess up the display of a snippet in Org exported files.")
 
 
 (defcustom org-src-lang-modes
 (defcustom org-src-lang-modes
-  '(("ocaml" . tuareg) ("elisp" . emacs-lisp) ("ditaa" . artist))
+  '(("ocaml" . tuareg) ("elisp" . emacs-lisp) ("ditaa" . artist)
+    ("asymptote" . asy))
   "Alist mapping languages to their major mode.
   "Alist mapping languages to their major mode.
 The key is the language name, the value is the string that should
 The key is the language name, the value is the string that should
 be inserted as the name of the major mode.  For many languages this is
 be inserted as the name of the major mode.  For many languages this is