فهرست منبع

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

Carsten Dominik 15 سال پیش
والد
کامیت
df3fca503e
4فایلهای تغییر یافته به همراه27 افزوده شده و 12 حذف شده
  1. 18 5
      contrib/babel/lisp/langs/org-babel-asymptote.el
  2. 2 1
      contrib/babel/lisp/org-babel.el
  3. 5 5
      contrib/lisp/org-babel-init.el
  4. 2 1
      lisp/org-src.el

+ 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"
 ;;
-;; 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)
 
+;;; Requirements:
+
+;; - The asymptote program :: http://asymptote.sourceforge.net/
+;;
+;; - asy-mode :: Major mode for editing asymptote files
+
 ;;; Code:
 (require 'org-babel)
 
@@ -54,14 +62,19 @@ called by `org-babel-execute-src-block'."
   (message "executing Asymptote source code block")
   (let* ((result-params (split-string (or (cdr (assoc :results 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))
                      "pdf"))
          (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))
-    (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))
 
 (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-forward "#\\+end_src" nil t) (setq bottom (point))
         (< 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))))))
 
 (defun org-babel-goto-named-source-block (&optional name)

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

@@ -35,11 +35,11 @@
                     "babel"
                     (expand-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
   (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.")
 
 (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.
 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