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

This commit is contained in:
Carsten Dominik 2010-07-13 13:36:37 +02:00
commit b564a944a7
23 changed files with 98 additions and 70 deletions

View File

@ -83,7 +83,6 @@ header arguments (calls `org-babel-C-expand')."
(defun org-babel-C-execute (body params)
"This function should only be called by `org-babel-execute:C'
or `org-babel-execute:c++'."
(message "executing C source code block")
(let* ((processed-params (org-babel-process-params params))
(tmp-src-file (make-temp-file "org-babel-C-src" nil
(cond

View File

@ -83,7 +83,6 @@
(defun org-babel-execute:R (body params)
"Execute a block of R code with org-babel. This function is
called by `org-babel-execute-src-block'."
(message "executing R source code block...")
(save-excursion
(let* ((processed-params (org-babel-process-params params))
(result-type (nth 3 processed-params))

View File

@ -65,7 +65,6 @@
(defun org-babel-execute:asymptote (body params)
"Execute a block of Asymptote code with org-babel. This function is
called by `org-babel-execute-src-block'."
(message "executing Asymptote source code block")
(let* ((processed-params (org-babel-process-params params))
(result-params (split-string (or (cdr (assoc :results params)) "")))
(out-file (cdr (assoc :file params)))

View File

@ -37,9 +37,7 @@
(defun org-babel-execute:css (body params)
"Execute a block of CSS code with org-babel. This function is
called by `org-babel-execute-src-block'."
(message "executing CSS source code block")
body)
called by `org-babel-execute-src-block'." body)
(defun org-babel-prep-session:css (session params)
"Prepare SESSION according to the header arguments specified in PARAMS."

View File

@ -50,7 +50,6 @@
(defun org-babel-execute:ditaa (body params)
"Execute a block of Ditaa code with org-babel. This function is
called by `org-babel-execute-src-block'."
(message "executing Ditaa source code block")
(let ((result-params (split-string (or (cdr (assoc :results params)) "")))
(out-file (cdr (assoc :file params)))
(cmdline (cdr (assoc :cmdline params)))

View File

@ -52,7 +52,6 @@
(defun org-babel-execute:dot (body params)
"Execute a block of Dot code with org-babel. This function is
called by `org-babel-execute-src-block'."
(message "executing Dot source code block")
(let ((result-params (split-string (or (cdr (assoc :results params)) "")))
(out-file (cdr (assoc :file params)))
(cmdline (cdr (assoc :cmdline params)))

View File

@ -58,7 +58,6 @@
(defun org-babel-execute:emacs-lisp (body params)
"Execute a block of emacs-lisp code with org-babel."
(message "executing emacs-lisp code block...")
(save-window-excursion
(let ((processed-params (org-babel-process-params params)))
(org-babel-reassemble-table

View File

@ -132,7 +132,6 @@ code."
(defun org-babel-execute:gnuplot (body params)
"Execute a block of Gnuplot code with org-babel. This function is
called by `org-babel-execute-src-block'."
(message "executing Gnuplot source code block")
(require 'gnuplot)
(let ((session (cdr (assoc :session params)))
(result-type (cdr (assoc :results params)))

View File

@ -71,7 +71,6 @@
(defun org-babel-execute:haskell (body params)
"Execute a block of Haskell code with org-babel."
(message "executing haskell source code block")
(let* ((processed-params (org-babel-process-params params))
(session (nth 0 processed-params))
(vars (nth 1 processed-params))

View File

@ -60,7 +60,6 @@
(defun org-babel-execute:latex (body params)
"Execute a block of Latex code with org-babel. This function is
called by `org-babel-execute-src-block'."
(message "executing Latex source code block")
(setq body (org-babel-expand-body:latex body params))
(if (cdr (assoc :file params))
(let ((out-file (cdr (assoc :file params)))

View File

@ -70,7 +70,6 @@
is called by `org-babel-execute-src-block'. Default filetype is
png. Modify by setting :filetype parameter to mscgen supported
formats."
(message "executing Mscgen source code block")
(let* ((out-file (or (cdr (assoc :file params)) "output.png" ))
(filetype (or (cdr (assoc :filetype params)) "png" )))
(unless (cdr (assoc :file params))

View File

@ -60,7 +60,6 @@
(defun org-babel-execute:ocaml (body params)
"Execute a block of Ocaml code with org-babel."
(message "executing ocaml source code block")
(let* ((processed-params (org-babel-process-params params))
(vars (nth 1 processed-params))
(full-body (org-babel-expand-body:ocaml body params processed-params))

View File

@ -89,7 +89,6 @@ end")
(org-babel-execute:octave body params 'matlab))
(defun org-babel-execute:octave (body params &optional matlabp)
"Execute a block of octave code with org-babel."
(message "executing %s source code block" (if matlabp "matlab" "octave"))
(let* ((processed-params (org-babel-process-params params))
(session
(funcall (intern (format "org-babel-%s-initiate-session"

View File

@ -52,7 +52,6 @@
(defun org-babel-execute:perl (body params)
"Execute a block of Perl code with org-babel. This function is
called by `org-babel-execute-src-block'."
(message "executing Perl source code block")
(let* ((processed-params (org-babel-process-params params))
(session (nth 0 processed-params))
(vars (nth 1 processed-params))

View File

@ -61,7 +61,6 @@
(defun org-babel-execute:python (body params)
"Execute a block of Python code with org-babel. This function is
called by `org-babel-execute-src-block'."
(message "executing Python source code block")
(let* ((processed-params (org-babel-process-params params))
(session (org-babel-python-initiate-session (first processed-params)))
(result-params (nth 2 processed-params))

View File

@ -67,7 +67,6 @@
(defun org-babel-execute:ruby (body params)
"Execute a block of Ruby code with org-babel. This function is
called by `org-babel-execute-src-block'."
(message "executing Ruby source code block")
(let* ((processed-params (org-babel-process-params params))
(session (org-babel-ruby-initiate-session (first processed-params)))
(result-params (nth 2 processed-params))

View File

@ -49,7 +49,6 @@
(defun org-babel-execute:sass (body params)
"Execute a block of Sass code with org-babel. This function is
called by `org-babel-execute-src-block'."
(message "executing Sass source code block")
(let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
(file (cdr (assoc :file params)))
(out-file (or file (make-temp-file "org-babel-sass-out")))

View File

@ -61,7 +61,6 @@
(defun org-babel-execute:sh (body params)
"Execute a block of Shell commands with org-babel. This
function is called by `org-babel-execute-src-block'."
(message "executing Shell source code block")
(let* ((processed-params (org-babel-process-params params))
(session (org-babel-sh-initiate-session (nth 0 processed-params)))
(result-params (nth 2 processed-params))

View File

@ -56,7 +56,6 @@
(defun org-babel-execute:sql (body params)
"Execute a block of Sql code with org-babel. This function is
called by `org-babel-execute-src-block'."
(message "executing Sql source code block")
(let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
(processed-params (org-babel-process-params params))
(cmdline (cdr (assoc :cmdline params)))

View File

@ -50,7 +50,6 @@
(defun org-babel-execute:sqlite (body params)
"Execute a block of Sqlite code with org-babel. This function is
called by `org-babel-execute-src-block'."
(message "executing Sqlite source code block")
(let ((result-params (split-string (or (cdr (assoc :results params)) "")))
(vars (org-babel-ref-variables params))
(db (cdr (assoc :db params)))

View File

@ -33,6 +33,7 @@
(require 'cl))
(declare-function org-link-escape "org" (text &optional table))
(declare-function org-heading-components "org" ())
(declare-function with-temp-filebuffer "org-interaction" (file &rest body))
(defcustom org-babel-tangle-lang-exts
@ -199,15 +200,23 @@ Return an association list of source-code block specifications of
the form used by `org-babel-spec-to-string' grouped by language.
Optional argument LANG can be used to limit the collected source
code blocks by language."
(let ((block-counter 0) blocks)
(let ((block-counter 1) (current-heading "") blocks)
(org-babel-map-src-blocks (buffer-file-name)
(setq block-counter (+ 1 block-counter))
((lambda (new-heading)
(if (not (string= new-heading current-heading))
(progn
(setq block-counter 1)
(setq current-heading new-heading))
(setq block-counter (+ 1 block-counter))))
(replace-regexp-in-string "[ \t]" "-"
(nth 4 (org-heading-components))))
(let* ((link (progn (call-interactively 'org-store-link)
(org-babel-clean-text-properties
(car (pop org-stored-links)))))
(info (org-babel-get-src-block-info))
(source-name (intern (or (nth 4 info)
(format "block-%d" block-counter))))
(format "%s:%d"
current-heading block-counter))))
(src-lang (nth 0 info))
(expand-cmd (intern (concat "org-babel-expand-body:" src-lang)))
(params (nth 2 info))

View File

@ -143,7 +143,8 @@ added to the header-arguments-alist."
(setq indent (car (last info)))
(setq info (butlast info))
(forward-line -1)
(if (looking-at org-babel-src-name-w-name-regexp)
(if (and (looking-at org-babel-src-name-w-name-regexp)
(match-string 2))
(progn
(setq info (append info (list (org-babel-clean-text-properties
(match-string 2)))))
@ -239,7 +240,7 @@ then run `org-babel-pop-to-session'."
(defconst org-babel-header-arg-names
'(cache cmdline colnames dir exports file noweb results
session tangle var noeval)
session tangle var noeval comments)
"Common header arguments used by org-babel. Note that
individual languages may define their own language specific
header arguments as well.")
@ -349,7 +350,10 @@ block."
(setq result (org-babel-read-result))
(message (replace-regexp-in-string "%" "%%"
(format "%S" result))) result)
(setq result (funcall cmd body params))
(message "executing %s code block%s..."
(capitalize lang)
(if (nth 4 info) (format " (%s)" (nth 4 info)) ""))
(setq result (funcall cmd body params))
(if (eq result-type 'value)
(setq result (if (and (or (member "vector" result-params)
(member "table" result-params))
@ -979,39 +983,65 @@ following the source block."
(name (if on-lob-line
(nth 0 (org-babel-lob-get-info))
(nth 4 (or info (org-babel-get-src-block-info)))))
(head (unless on-lob-line (org-babel-where-is-src-block-head))) end)
(head (unless on-lob-line (org-babel-where-is-src-block-head)))
found beg end)
(when head (goto-char head))
(or (and name (org-babel-find-named-result name))
(and (or on-lob-line (re-search-forward "^[ \t]*#\\+end_src" nil t))
(progn (end-of-line 1)
(if (eobp) (insert "\n") (forward-char 1))
(setq end (point))
(or (and (not name)
(progn ;; unnamed results line already exists
(re-search-forward "[^ \f\t\n\r\v]" nil t)
(beginning-of-line 1)
(looking-at
(concat org-babel-result-regexp "\n"))))
;; or (with optional insert) back up and
;; make one ourselves
(when insert
(goto-char end)
(if (looking-at "[\n\r]")
(forward-char 1) (insert "\n"))
(insert (concat
(if indent
(mapconcat
(lambda (el) " ")
(number-sequence 1 indent) "")
"")
"#+results"
(when hash (concat "["hash"]"))
":"
(when name (concat " " name)) "\n\n"))
(backward-char)
(beginning-of-line 0)
(if hash (org-babel-hide-hash)) t)))
(point))))))
(setq
found ;; was there a result (before we potentially insert one)
(or
(and
;; named results:
;; - return t if it is found, else return nil
;; - if it does not need to be rebuilt, then don't set end
;; - if it does need to be rebuilt then do set end
name (setq beg (org-babel-find-named-result name))
(prog1 beg
(when (and hash (not (string= hash (match-string 3))))
(goto-char beg) (setq end beg) ;; beginning of result
(forward-line 1)
(delete-region end (org-babel-result-end)) nil)))
(and
;; unnamed results:
;; - return t if it is found, else return nil
;; - if it is found, and the hash doesn't match, delete and set end
(or on-lob-line (re-search-forward "^[ \t]*#\\+end_src" nil t))
(progn (end-of-line 1)
(if (eobp) (insert "\n") (forward-char 1))
(setq end (point))
(or (and (not name)
(progn ;; unnamed results line already exists
(re-search-forward "[^ \f\t\n\r\v]" nil t)
(beginning-of-line 1)
(looking-at
(concat org-babel-result-regexp "\n")))
(prog1 (point)
;; must remove and rebuild if hash!=old-hash
(if (and hash (not (string= hash (match-string 3))))
(prog1 nil
(forward-line 1)
(delete-region
end (org-babel-result-end)))
(setq end nil)))))))))
(if (and insert end)
(progn
(goto-char end)
(unless beg
(if (looking-at "[\n\r]") (forward-char 1) (insert "\n")))
(insert (concat
(if indent
(mapconcat
(lambda (el) " ")
(number-sequence 1 indent) "")
"")
"#+results"
(when hash (concat "["hash"]"))
":"
(when name (concat " " name)) "\n"))
(unless beg (insert "\n") (backward-char))
(beginning-of-line 0)
(if hash (org-babel-hide-hash))
(point))
found))))
(defvar org-block-regexp)
(defun org-babel-read-result ()

View File

@ -2107,19 +2107,29 @@ in the list) and remove property and value from the list in LISTVAR."
lang code trans opts indent caption)
(goto-char (point-min))
(while (re-search-forward
"\\(^\\([ \t]*\\)#\\+BEGIN_SRC:?[ \t]+\\([^ \t\n]+\\)\\(.*\\)\n\\([^\000]+?\n\\)[ \t]*#\\+END_SRC.*\n?\\)\\|\\(^\\([ \t]*\\)#\\+BEGIN_EXAMPLE:?\\(?:[ \t]+\\(.*\\)\\)?\n\\([^\000]+?\n\\)[ \t]*#\\+END_EXAMPLE.*\n?\\)"
"\\(^\\([ \t]*\\)#\\+BEGIN_SRC:?\\([ \t]+\\([^ \t\n]+\\)\\)?\\(.*\\)\n\\([^\000]+?\n\\)[ \t]*#\\+END_SRC.*\n?\\)\\|\\(^\\([ \t]*\\)#\\+BEGIN_EXAMPLE:?\\(?:[ \t]+\\(.*\\)\\)?\n\\([^\000]+?\n\\)[ \t]*#\\+END_EXAMPLE.*\n?\\)"
nil t)
(if (match-end 1)
;; src segments
(setq lang (match-string 3)
opts (match-string 4)
code (match-string 5)
indent (length (match-string 2))
caption (get-text-property 0 'org-caption (match-string 0)))
(if (not (match-string 4))
(error "source block missing language specification: %s"
(let* ((body (match-string 6))
(nothing (message "body:%s" body))
(preview (or (and (string-match
"^[ \t]*\\([^\n\r]*\\)" body)
(match-string 1 body)) body)))
(if (> (length preview) 35)
(concat (substring preview 0 32) "...")
preview)))
;; src segments
(setq lang (match-string 4)
opts (match-string 5)
code (match-string 6)
indent (length (match-string 2))
caption (get-text-property 0 'org-caption (match-string 0))))
(setq lang nil
opts (match-string 8)
code (match-string 9)
indent (length (match-string 7))
opts (match-string 9)
code (match-string 10)
indent (length (match-string 8))
caption (get-text-property 0 'org-caption (match-string 0))))
(setq trans (org-export-format-source-code-or-example