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

This commit is contained in:
Carsten Dominik 2010-11-12 23:56:52 -06:00
commit 0766085d9a
6 changed files with 96 additions and 12 deletions

View File

@ -125,6 +125,7 @@ LISPF = org.el \
ob-eval.el \ ob-eval.el \
ob-keys.el \ ob-keys.el \
ob-C.el \ ob-C.el \
ob-calc.el \
ob-ditaa.el \ ob-ditaa.el \
ob-haskell.el \ ob-haskell.el \
ob-perl.el \ ob-perl.el \

View File

@ -286,11 +286,85 @@ are optional.
#+begin_src python #+begin_src python
a a
#+end_src #+end_src
#+srcname: python-add(a=1, b=2) #+srcname: python-add(a=1, b=2)
#+begin_src python #+begin_src python
a + b a + b
#+end_src #+end_src
* GANTT Charts
The =elispgantt= source block was sent to the mailing list by Eric
Fraga. It was modified slightly by Tom Dye.
#+source: elispgantt
#+begin_src emacs-lisp :var table=gantttest
(let ((dates "")
(entries (nthcdr 2 table))
(milestones "")
(nmilestones 0)
(ntasks 0)
(projecttime 0)
(tasks "")
(xlength 1))
(message "Initial: %s\n" table)
(message "Entries: %s\n" entries)
(while entries
(let ((entry (first entries)))
(if (listp entry)
(let ((id (first entry))
(type (nth 1 entry))
(label (nth 2 entry))
(task (nth 3 entry))
(dependencies (nth 4 entry))
(start (nth 5 entry))
(duration (nth 6 entry))
(end (nth 7 entry))
(alignment (nth 8 entry)))
(if (> start projecttime) (setq projecttime start))
(if (string= type "task")
(let ((end (+ start duration))
(textposition (+ start (/ duration 2)))
(flush ""))
(if (string= alignment "left")
(progn
(setq textposition start)
(setq flush "[left]"))
(if (string= alignment "right")
(progn
(setq textposition end)
(setq flush "[right]"))))
(setq tasks
(format "%s \\gantttask{%s}{%s}{%d}{%d}{%d}{%s}\n"
tasks label task start end textposition flush))
(setq ntasks (+ 1 ntasks))
(if (> end projecttime)
(setq projecttime end)))
(if (string= type "milestone")
(progn
(setq milestones
(format
"%s \\ganttmilestone{$\\begin{array}{c}\\mbox{%s}\\\\ \\mbox{%s}\\end{array}$}{%d}\n"
milestones label task start))
(setq nmilestones (+ 1 nmilestones)))
(if (string= type "date")
(setq dates (format "%s \\ganttdateline{%s}{%d}\n"
dates label start))
(message "Ignoring entry with type %s\n" type)))))
(message "Ignoring non-list entry %s\n" entry)) ; end if list entry
(setq entries (cdr entries)))) ; end while entries left
(format "\\pgfdeclarelayer{background}
\\pgfdeclarelayer{foreground}
\\pgfsetlayers{background,foreground}
\\renewcommand{\\ganttprojecttime}{%d}
\\renewcommand{\\ganttntasks}{%d}
\\noindent
\\begin{tikzpicture}[y=-0.75cm,x=0.75\\textwidth]
\\begin{pgfonlayer}{background}
\\draw[very thin, red!10!white] (0,1+\\ganttntasks) grid [ystep=0.75cm,xstep=1/\\ganttprojecttime] (1,0);
\\draw[\\ganttdatelinecolour] (0,0) -- (1,0);
\\draw[\\ganttdatelinecolour] (0,1+\\ganttntasks) -- (1,1+\\ganttntasks);
\\end{pgfonlayer}
%s
%s
%s
\\end{tikzpicture}" projecttime ntasks tasks milestones dates))
#+end_src

View File

@ -40,6 +40,8 @@
(defun org-babel-execute:calc (body params) (defun org-babel-execute:calc (body params)
"Execute a block of calc code with Babel." "Execute a block of calc code with Babel."
(unless (get-buffer "*Calculator*")
(save-window-excursion (calc) (calc-quit)))
(let* ((vars (mapcar #'cdr (org-babel-get-header params :var))) (let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
(var-syms (mapcar #'car vars)) (var-syms (mapcar #'car vars))
(var-names (mapcar #'symbol-name var-syms))) (var-names (mapcar #'symbol-name var-syms)))
@ -48,7 +50,7 @@
(calc-push-list (list (cdr pair))) (calc-push-list (list (cdr pair)))
(calc-store-into (car pair))) (calc-store-into (car pair)))
vars) vars)
(mapcar (mapc
(lambda (line) (lambda (line)
(when (> (length line) 0) (when (> (length line) 0)
(cond (cond
@ -80,13 +82,13 @@
(calc-pop 1))) (calc-pop 1)))
el)) el))
;; parse line into calc objects ;; parse line into calc objects
(first (math-read-exprs line)))))))) (car (math-read-exprs line))))))))
(calc-eval line)))))))) (calc-eval line))))))))
(mapcar #'org-babel-trim (mapcar #'org-babel-trim
(split-string (org-babel-expand-body:calc body params) "[\n\r]")))) (split-string (org-babel-expand-body:calc body params) "[\n\r]"))))
(save-excursion (save-excursion
(set-buffer (get-buffer "*Calculator*")) (with-current-buffer (get-buffer "*Calculator*")
(calc-eval (calc-top 1)))) (calc-eval (calc-top 1)))))
(provide 'ob-calc) (provide 'ob-calc)

View File

@ -41,13 +41,18 @@
(require 'ob-ref) (require 'ob-ref)
(require 'ob-comint) (require 'ob-comint)
(require 'ob-eval) (require 'ob-eval)
(require 'slime)
(declare-function slime-eval "ext:slime" (sexp &optional package))
(declare-function slime-process "ext:slime" (&optional connection))
(declare-function slime-connected-p "ext:slime" ())
(defvar org-babel-default-header-args:lisp '() (defvar org-babel-default-header-args:lisp '()
"Default header arguments for lisp code blocks.") "Default header arguments for lisp code blocks.")
(defcustom org-babel-lisp-cmd "sbcl --script" (defcustom org-babel-lisp-cmd "sbcl --script"
"Name of command used to evaluate lisp blocks.") "Name of command used to evaluate lisp blocks."
:group 'org-babel
:type 'string)
(defun org-babel-expand-body:lisp (body params) (defun org-babel-expand-body:lisp (body params)
"Expand BODY according to PARAMS, return the expanded body." "Expand BODY according to PARAMS, return the expanded body."
@ -63,6 +68,7 @@
(defun org-babel-execute:lisp (body params) (defun org-babel-execute:lisp (body params)
"Execute a block of Lisp code with org-babel. "Execute a block of Lisp code with org-babel.
This function is called by `org-babel-execute-src-block'" This function is called by `org-babel-execute-src-block'"
(require 'slime)
(message "executing Lisp source code block") (message "executing Lisp source code block")
(let* ((session (org-babel-lisp-initiate-session (let* ((session (org-babel-lisp-initiate-session
(cdr (assoc :session params)))) (cdr (assoc :session params))))
@ -94,6 +100,7 @@ This function is called by `org-babel-execute-src-block'"
(defun org-babel-lisp-initiate-session (&optional session) (defun org-babel-lisp-initiate-session (&optional session)
"If there is not a current inferior-process-buffer in SESSION "If there is not a current inferior-process-buffer in SESSION
then create. Return the initialized session." then create. Return the initialized session."
(require 'slime)
(unless (string= session "none") (unless (string= session "none")
(save-window-excursion (save-window-excursion
(or (slime-connected-p) (or (slime-connected-p)

View File

@ -201,9 +201,6 @@ which defaults to the value of `org-export-blocks-witheld'."
(interblock start (point-max)) (interblock start (point-max))
(run-hooks 'org-export-blocks-postblock-hook))))) (run-hooks 'org-export-blocks-postblock-hook)))))
(add-hook 'org-export-preprocess-after-include-files-hook
'org-export-blocks-preprocess)
;;================================================================================ ;;================================================================================
;; type specific functions ;; type specific functions

View File

@ -1080,6 +1080,9 @@ on this string to produce the exported version."
;; Mark end of lists ;; Mark end of lists
(org-export-mark-list-ending backend) (org-export-mark-list-ending backend)
;; Export code blocks
(org-export-blocks-preprocess)
;; Handle source code snippets ;; Handle source code snippets
(org-export-replace-src-segments-and-examples backend) (org-export-replace-src-segments-and-examples backend)