├── doc ├── .nosearch ├── dir ├── pdflayout.sty ├── .aspell.org.conf └── Makefile ├── contrib ├── scripts │ ├── .gitignore │ ├── staticmathjax │ │ ├── .gitignore │ │ ├── chrome │ │ │ ├── chrome.manifest │ │ │ └── content │ │ │ │ └── main.xul │ │ ├── defaults │ │ │ └── preferences │ │ │ │ └── prefs.js │ │ ├── application.ini │ │ └── README.org │ ├── ditaa.jar │ ├── x11idle.c │ ├── dir2org.zsh │ └── org2hpda ├── lisp │ ├── org-contribdir.el │ ├── org-jira.el │ ├── org-man.el │ ├── org-bookmark.el │ ├── org-notmuch.el │ └── org-screen.el └── babel │ └── langs │ ├── ob-fomus.el │ ├── ob-eukleides.el │ └── ob-tcl.el ├── testing ├── examples │ ├── include2.org │ ├── ob-awk-test.in │ ├── macro-templates.org │ ├── ob-screen-test.org │ ├── include.org │ ├── link-in-heading.org │ ├── no-heading.org │ ├── org-exp.org │ ├── ob-lilypond-broken.ly │ ├── babel-dangerous.org │ ├── ob-lilypond-test.error │ ├── ob-lilypond-broken.org │ ├── ob-lilypond-test.org │ ├── links.org │ ├── normal.org │ ├── property-inheritance.org │ ├── ob-awk-test.org │ ├── ob-lilypond-test.ly │ ├── ob-C-test.org │ ├── ob-octave-test.org │ ├── ob-fortran-test.org │ └── ob-maxima-test.org ├── .gitignore ├── org-test-ob-consts.el ├── lisp │ ├── test-org-exp.el │ ├── test-ob-table.el │ ├── test-org-html.el │ ├── test-ob-awk.el │ ├── test-ob-sh.el │ ├── test-ob-C.el │ ├── test-ob-R.el │ ├── test-ob-octave.el │ ├── test-property-inheritance.el │ ├── test-ob-emacs-lisp.el │ ├── test-org-table.el │ ├── test-ob-maxima.el │ ├── test-ob-python.el │ ├── test-ob-tangle.el │ ├── test-ob-fortran.el │ └── test-ob-lob.el └── README ├── lisp ├── org-freemind.el ├── org-install.el ├── ob-matlab.el ├── ob-css.el ├── ob-makefile.el ├── org-eshell.el ├── Makefile ├── ob-ledger.el ├── ob-org.el ├── ob-sass.el ├── ob-java.el ├── org-info.el ├── ob-shen.el ├── ob-emacs-lisp.el ├── ob-mscgen.el ├── ob-dot.el ├── org-docview.el ├── ob-plantuml.el ├── ob-clojure.el ├── ob-calc.el ├── ob-lisp.el ├── ob-keys.el ├── ob-ditaa.el ├── org-special-blocks.el └── ob-perl.el ├── .gitmodules ├── .dir-locals.el ├── .dir-settings.el ├── etc ├── schema │ ├── schemas.xml │ └── od-manifest-schema-v1.2-cs01.rnc ├── Makefile └── styles │ └── README ├── mk ├── gplmanual.pl ├── list-hooks.pl ├── manfull.pl ├── set-version.pl ├── fake_change_log.pl ├── git-changelog ├── guidesplit.pl ├── mansplit.pl ├── make_emacs_changelog └── orgcard2txt.pl ├── README_ELPA ├── .gitignore ├── request-assign-future.txt ├── README ├── README_git ├── Makefile └── README_contribute /doc/.nosearch: -------------------------------------------------------------------------------- 1 | No search 2 | -------------------------------------------------------------------------------- /contrib/scripts/.gitignore: -------------------------------------------------------------------------------- 1 | plantuml.jar 2 | -------------------------------------------------------------------------------- /testing/examples/include2.org: -------------------------------------------------------------------------------- 1 | Success! 2 | -------------------------------------------------------------------------------- /contrib/scripts/staticmathjax/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | -------------------------------------------------------------------------------- /testing/examples/ob-awk-test.in: -------------------------------------------------------------------------------- 1 | # an input file for awk test 2 | 15 -------------------------------------------------------------------------------- /lisp/org-freemind.el: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tkf/org-mode/HEAD/lisp/org-freemind.el -------------------------------------------------------------------------------- /contrib/scripts/staticmathjax/chrome/chrome.manifest: -------------------------------------------------------------------------------- 1 | content staticmathjax file:content/ 2 | -------------------------------------------------------------------------------- /contrib/scripts/ditaa.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tkf/org-mode/HEAD/contrib/scripts/ditaa.jar -------------------------------------------------------------------------------- /testing/examples/macro-templates.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Macro templates 2 | #+MACRO: included-macro success 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "testing/jump"] 2 | path = testing/jump 3 | url = git://github.com/eschulte/jump.el.git 4 | -------------------------------------------------------------------------------- /contrib/scripts/staticmathjax/defaults/preferences/prefs.js: -------------------------------------------------------------------------------- 1 | pref("toolkit.defaultChromeURI", "chrome://staticmathjax/content/main.xul"); 2 | -------------------------------------------------------------------------------- /testing/.gitignore: -------------------------------------------------------------------------------- 1 | # in case anyone wants to keep ert in the testing directory, e.g., for 2 | # old versions of Emacs 3 | ert 4 | .org-test-id-locations 5 | .test-org-id-locations -------------------------------------------------------------------------------- /testing/examples/ob-screen-test.org: -------------------------------------------------------------------------------- 1 | #+Title: a collection of examples for ob-screen tests 2 | #+begin_src screen :session create-tmpdir 3 | mkdir -p $TMPDIR 4 | cd $TMPDIR 5 | #+end_src 6 | -------------------------------------------------------------------------------- /testing/examples/include.org: -------------------------------------------------------------------------------- 1 | Small Org file with an include keyword. 2 | 3 | #+BEGIN_SRC emacs-lisp :exports results 4 | (+ 2 1) 5 | #+END_SRC 6 | 7 | #+INCLUDE: "include2.org" 8 | 9 | * Heading 10 | body 11 | -------------------------------------------------------------------------------- /contrib/scripts/staticmathjax/application.ini: -------------------------------------------------------------------------------- 1 | [App] 2 | Vendor=Jan Boecker 3 | Name=StaticMathJax 4 | Version=0.2 5 | BuildID=2 6 | Copyright=Copyright (c) 2010 Jan Boecker 7 | ID=xulapp@jboecker.de 8 | 9 | [Gecko] 10 | MinVersion=1.8 11 | 12 | -------------------------------------------------------------------------------- /testing/examples/link-in-heading.org: -------------------------------------------------------------------------------- 1 | this file has a link in it's heading, which can cause problems 2 | 3 | * [[http://www.example.com][example]] 4 | 5 | what a weird heading... 6 | 7 | #+begin_src emacs-lisp 8 | ;; a8b1d111-eca8-49f0-8930-56d4f0875155 9 | (message "my heading has a link") 10 | #+end_src 11 | -------------------------------------------------------------------------------- /testing/examples/no-heading.org: -------------------------------------------------------------------------------- 1 | This is an example file for use by the Org-mode tests. 2 | 3 | This file is special because it has no headings, which can be 4 | erroneously assumed by some code. 5 | 6 | #+begin_src emacs-lisp :tangle no 7 | ;; 94839181-184f-4ff4-a72f-94214df6f5ba 8 | (message "I am code") 9 | #+end_src 10 | -------------------------------------------------------------------------------- /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ;; - keep in sync dir-locals.el (for Emacs >= 24) with .dir-settings.el 2 | ;; (for Emacs < 24) 3 | ;; - don't use a symbolic link to prevent problems on cygwin 4 | ;; distributions (commit 971b9eeacd38959439ddaa7c650430cc2dcb673e) 5 | 6 | ((nil . ((indent-tabs-mode . t) 7 | (tab-width . 8) 8 | (fill-column . 70) 9 | (sentence-end-double-space . t)))) 10 | -------------------------------------------------------------------------------- /.dir-settings.el: -------------------------------------------------------------------------------- 1 | ;; - keep in sync dir-locals.el (for Emacs >= 24) with .dir-settings.el 2 | ;; (for Emacs < 24) 3 | ;; - don't use a symbolic link to prevent problems on cygwin 4 | ;; distributions (commit 971b9eeacd38959439ddaa7c650430cc2dcb673e) 5 | 6 | ((nil . ((indent-tabs-mode . t) 7 | (tab-width . 8) 8 | (fill-column . 70) 9 | (sentence-end-double-space . t)))) 10 | -------------------------------------------------------------------------------- /testing/examples/org-exp.org: -------------------------------------------------------------------------------- 1 | #+Title: a collection of examples for export tests 2 | #+OPTIONS: ^:nil 3 | 4 | * stripping commas from within blocks on export 5 | :PROPERTIES: 6 | :ID: 76d3a083-67fa-4506-a41d-837cc48158b5 7 | :END: 8 | The following commas should not be removed. 9 | 10 | #+begin_src r 11 | a <- c(1 12 | , 2 13 | , 3) 14 | #+end_src 15 | -------------------------------------------------------------------------------- /testing/examples/ob-lilypond-broken.ly: -------------------------------------------------------------------------------- 1 | line 1 2 | line 2 3 | line 3 4 | line 4 5 | line 5 6 | line 6 7 | line 7 8 | line 8 9 | line 9 10 | line 10 11 | line 11 12 | line 12 13 | line 13 14 | line 14 15 | line 15 16 | line 16 17 | line 17 18 | line 18 19 | line 19 20 | line 20 21 | line 21 22 | line 22 23 | line 23 24 | line 24 25 | line 25 26 | line 26 27 | line 27 28 | line 28 29 | line 29 30 | line 30 31 | 32 | -------------------------------------------------------------------------------- /etc/schema/schemas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /testing/examples/babel-dangerous.org: -------------------------------------------------------------------------------- 1 | #+Title: dangerous code block examples which should be isolated 2 | #+OPTIONS: ^:nil 3 | 4 | * no default value for vars 5 | :PROPERTIES: 6 | :ID: f2df5ba6-75fa-4e6b-8441-65ed84963627 7 | :END: 8 | 9 | There is no default value assigned to =x= variable. This is not permitted 10 | anymore. 11 | 12 | #+name: carre(x) 13 | #+begin_src python 14 | return x*x 15 | #+end_src 16 | 17 | #+name: carre 18 | -------------------------------------------------------------------------------- /lisp/org-install.el: -------------------------------------------------------------------------------- 1 | ;;; org-install.el --- backward compatibility file for obsolete configuration 2 | ;; 3 | ;;; Code: 4 | (warn "The file org-install is obsolete. 5 | It is provided here so that (require 'org-install) does not 6 | trigger an error for users with obsolete Emacs configuration. 7 | You can safely remove (require 'org-install) from your config.") 8 | 9 | (provide 'org-install) 10 | 11 | ;; Local Variables: 12 | ;; no-byte-compile: t 13 | ;; coding: utf-8 14 | ;; End: 15 | ;;; org-install.el ends here 16 | -------------------------------------------------------------------------------- /testing/examples/ob-lilypond-test.error: -------------------------------------------------------------------------------- 1 | Processing `xxx' 2 | Parsing... 3 | /path/to/tangled/file/test.ly:25:0: error: syntax error, unexpected \score, expecting '=' 4 | 5 | \score { 6 | Interpreting music... [8][16][24][32] 7 | Preprocessing graphical objects... 8 | Interpreting music... 9 | MIDI output to `xxx' 10 | Finding the ideal number of pages... 11 | Fitting music on 2 or 3 pages... 12 | Drawing systems... 13 | Layout output to `xxx' 14 | Converting to `xxx'... 15 | error: failed files: "/Path/to/tangled/file/test.ly/example.ly" 16 | -------------------------------------------------------------------------------- /contrib/scripts/staticmathjax/chrome/content/main.xul: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 41 | 47 | EOF 48 | 49 | while ($page = shift) { 50 | system "mv $page $page.orig"; 51 | open IN,"<$page.orig" or die "Cannot read from $page.orig\n"; 52 | undef $/; 53 | $all = ; 54 | close IN; 55 | 56 | $all =~ s//$&\n$script/; 57 | $all =~ s/^/\n$contents/m; 58 | 59 | open OUT,">$page" or die "Cannot write to $page\n"; 60 | print OUT $all; 61 | close OUT; 62 | system "rm $page.orig"; 63 | } 64 | -------------------------------------------------------------------------------- /lisp/ob-java.el: -------------------------------------------------------------------------------- 1 | ;;; ob-java.el --- org-babel functions for java evaluation 2 | 3 | ;; Copyright (C) 2011-2012 Free Software Foundation, Inc. 4 | 5 | ;; Author: Eric Schulte 6 | ;; Keywords: literate programming, reproducible research 7 | ;; Homepage: http://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; Currently this only supports the external compilation and execution 27 | ;; of java code blocks (i.e., no session support). 28 | 29 | ;;; Code: 30 | (require 'ob) 31 | (require 'ob-eval) 32 | 33 | (defvar org-babel-tangle-lang-exts) 34 | (add-to-list 'org-babel-tangle-lang-exts '("java" . "java")) 35 | 36 | (defvar org-babel-java-command "java" 37 | "Name of the java command.") 38 | 39 | (defvar org-babel-java-compiler "javac" 40 | "Name of the java compiler.") 41 | 42 | (defun org-babel-execute:java (body params) 43 | (let* ((classname (or (cdr (assoc :classname params)) 44 | (error 45 | "Can't compile a java block without a classname"))) 46 | (packagename (file-name-directory classname)) 47 | (src-file (concat classname ".java")) 48 | (cmpflag (or (cdr (assoc :cmpflag params)) "")) 49 | (cmdline (or (cdr (assoc :cmdline params)) "")) 50 | (full-body (org-babel-expand-body:generic body params)) 51 | (compile 52 | (progn (with-temp-file src-file (insert full-body)) 53 | (org-babel-eval 54 | (concat org-babel-java-compiler 55 | " " cmpflag " " src-file) "")))) 56 | ;; created package-name directories if missing 57 | (unless (or (not packagename) (file-exists-p packagename)) 58 | (make-directory packagename 'parents)) 59 | ((lambda (results) 60 | (org-babel-reassemble-table 61 | (if (member "vector" (cdr (assoc :result-params params))) 62 | (let ((tmp-file (org-babel-temp-file "c-"))) 63 | (with-temp-file tmp-file (insert results)) 64 | (org-babel-import-elisp-from-file tmp-file)) 65 | (org-babel-read results)) 66 | (org-babel-pick-name 67 | (cdr (assoc :colname-names params)) (cdr (assoc :colnames params))) 68 | (org-babel-pick-name 69 | (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))) 70 | (org-babel-eval (concat org-babel-java-command 71 | " " cmdline " " classname) "")))) 72 | 73 | (provide 'ob-java) 74 | 75 | 76 | 77 | ;;; ob-java.el ends here 78 | -------------------------------------------------------------------------------- /lisp/org-info.el: -------------------------------------------------------------------------------- 1 | ;;; org-info.el --- Support for links to Info nodes from within Org-Mode 2 | 3 | ;; Copyright (C) 2004-2012 Free Software Foundation, Inc. 4 | 5 | ;; Author: Carsten Dominik 6 | ;; Keywords: outlines, hypermedia, calendar, wp 7 | ;; Homepage: http://orgmode.org 8 | ;; 9 | ;; This file is part of GNU Emacs. 10 | ;; 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 24 | ;; 25 | ;;; Commentary: 26 | 27 | ;; This file implements links to Info nodes from within Org-mode. 28 | ;; Org-mode loads this module by default - if this is not what you want, 29 | ;; configure the variable `org-modules'. 30 | 31 | ;;; Code: 32 | 33 | (require 'org) 34 | 35 | ;; Declare external functions and variables 36 | 37 | (declare-function Info-find-node "info" (filename nodename 38 | &optional no-going-back)) 39 | (defvar Info-current-file) 40 | (defvar Info-current-node) 41 | 42 | ;; Install the link type 43 | (org-add-link-type "info" 'org-info-open) 44 | (add-hook 'org-store-link-functions 'org-info-store-link) 45 | 46 | ;; Implementation 47 | (defun org-info-store-link () 48 | "Store a link to an Info file and node." 49 | (when (eq major-mode 'Info-mode) 50 | (let (link desc) 51 | (setq link (concat "info:" 52 | (file-name-nondirectory Info-current-file) 53 | "#" Info-current-node)) 54 | (setq desc (concat (file-name-nondirectory Info-current-file) 55 | "#" Info-current-node)) 56 | (org-store-link-props :type "info" :file Info-current-file 57 | :node Info-current-node 58 | :link link :desc desc) 59 | link))) 60 | 61 | (defun org-info-open (path) 62 | "Follow an Info file and node link specified by PATH." 63 | (org-info-follow-link path)) 64 | 65 | 66 | (defun org-info-follow-link (name) 67 | "Follow an Info file and node link specified by NAME." 68 | (if (or (string-match "\\(.*\\)[#:]:?\\(.*\\)" name) 69 | (string-match "\\(.*\\)" name)) 70 | (progn 71 | (require 'info) 72 | (if (match-string 2 name) ; If there isn't a node, choose "Top" 73 | (Info-find-node (match-string 1 name) (match-string 2 name)) 74 | (Info-find-node (match-string 1 name) "Top"))) 75 | (message "Could not open: %s" name))) 76 | 77 | (provide 'org-info) 78 | 79 | ;;; org-info.el ends here 80 | -------------------------------------------------------------------------------- /lisp/ob-shen.el: -------------------------------------------------------------------------------- 1 | ;;; ob-shen.el --- org-babel functions for Shen 2 | 3 | ;; Copyright (C) 2010-2012 Free Software Foundation, Inc. 4 | 5 | ;; Author: Eric Schulte 6 | ;; Keywords: literate programming, reproducible research, shen 7 | ;; Homepage: http://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; Currently this only works using session evaluation as there is no 27 | ;; defined method for executing shen code outside of a session. 28 | 29 | ;;; Requirements: 30 | 31 | ;; - shen-mode and inf-shen will soon be available through the GNU 32 | ;; elpa, however in the interim they are available at 33 | ;; https://github.com/eschulte/shen-mode 34 | 35 | ;;; Code: 36 | (require 'ob) 37 | 38 | (declare-function shen-eval-defun "ext:inf-shen" (&optional and-go)) 39 | 40 | (defvar org-babel-default-header-args:shen '() 41 | "Default header arguments for shen code blocks.") 42 | 43 | (defun org-babel-expand-body:shen (body params) 44 | "Expand BODY according to PARAMS, return the expanded body." 45 | (let ((vars (mapcar #'cdr (org-babel-get-header params :var)))) 46 | (if (> (length vars) 0) 47 | (concat "(let " 48 | (mapconcat (lambda (var) 49 | (format "%s %s" (car var) 50 | (org-babel-shen-var-to-shen (cdr var)))) 51 | vars " ") 52 | body ")") 53 | body))) 54 | 55 | (defun org-babel-shen-var-to-shen (var) 56 | "Convert VAR into a shen variable." 57 | (if (listp var) 58 | (concat "[" (mapconcat #'org-babel-ruby-var-to-ruby var " ") "]") 59 | (format "%S" var))) 60 | 61 | (defun org-babel-execute:shen (body params) 62 | "Execute a block of Shen code with org-babel. 63 | This function is called by `org-babel-execute-src-block'" 64 | (require 'inf-shen) 65 | (let* ((result-type (cdr (assoc :result-type params))) 66 | (result-params (cdr (assoc :result-params params))) 67 | (full-body (org-babel-expand-body:shen body params))) 68 | ((lambda (results) 69 | (if (or (member 'scalar result-params) 70 | (member 'verbatim result-params)) 71 | results 72 | (condition-case nil (org-babel-script-escape results) 73 | (error results)))) 74 | (with-temp-buffer 75 | (insert full-body) 76 | (call-interactively #'shen-eval-defun))))) 77 | 78 | (provide 'ob-shen) 79 | ;;; ob-shen.el ends here 80 | -------------------------------------------------------------------------------- /lisp/ob-emacs-lisp.el: -------------------------------------------------------------------------------- 1 | ;;; ob-emacs-lisp.el --- org-babel functions for emacs-lisp code evaluation 2 | 3 | ;; Copyright (C) 2009-2012 Free Software Foundation, Inc. 4 | 5 | ;; Author: Eric Schulte 6 | ;; Keywords: literate programming, reproducible research 7 | ;; Homepage: http://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; Org-Babel support for evaluating emacs-lisp code 27 | 28 | ;;; Code: 29 | (require 'ob) 30 | (eval-when-compile (require 'ob-comint)) 31 | 32 | (defvar org-babel-default-header-args:emacs-lisp 33 | '((:hlines . "yes") (:colnames . "no")) 34 | "Default arguments for evaluating an emacs-lisp source block.") 35 | 36 | (declare-function orgtbl-to-generic "org-table" (table params)) 37 | 38 | (defun org-babel-expand-body:emacs-lisp (body params) 39 | "Expand BODY according to PARAMS, return the expanded body." 40 | (let* ((vars (mapcar #'cdr (org-babel-get-header params :var))) 41 | (result-params (cdr (assoc :result-params params))) 42 | (print-level nil) (print-length nil) 43 | (body (if (> (length vars) 0) 44 | (concat "(let (" 45 | (mapconcat 46 | (lambda (var) 47 | (format "%S" (print `(,(car var) ',(cdr var))))) 48 | vars "\n ") 49 | ")\n" body "\n)") 50 | (concat body "\n")))) 51 | (if (or (member "code" result-params) 52 | (member "pp" result-params)) 53 | (concat "(pp " body ")") body))) 54 | 55 | (defun org-babel-execute:emacs-lisp (body params) 56 | "Execute a block of emacs-lisp code with Babel." 57 | (save-window-excursion 58 | ((lambda (result) 59 | (if (or (member "scalar" (cdr (assoc :result-params params))) 60 | (member "verbatim" (cdr (assoc :result-params params)))) 61 | (let ((print-level nil) 62 | (print-length nil)) 63 | (format "%S" result)) 64 | (org-babel-reassemble-table 65 | result 66 | (org-babel-pick-name (cdr (assoc :colname-names params)) 67 | (cdr (assoc :colnames params))) 68 | (org-babel-pick-name (cdr (assoc :rowname-names params)) 69 | (cdr (assoc :rownames params)))))) 70 | (eval (read (format (if (member "output" 71 | (cdr (assoc :result-params params))) 72 | "(with-output-to-string %s)" 73 | "(progn %s)") 74 | (org-babel-expand-body:emacs-lisp body params))))))) 75 | 76 | (provide 'ob-emacs-lisp) 77 | 78 | 79 | 80 | ;;; ob-emacs-lisp.el ends here 81 | -------------------------------------------------------------------------------- /lisp/ob-mscgen.el: -------------------------------------------------------------------------------- 1 | ;;; ob-msc.el --- org-babel functions for mscgen evaluation 2 | 3 | ;; Copyright (C) 2010-2012 Free Software Foundation, Inc. 4 | 5 | ;; Author: Juan Pechiar 6 | ;; Keywords: literate programming, reproducible research 7 | ;; Homepage: http://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | ;; 26 | ;; This software provides EMACS org-babel export support for message 27 | ;; sequence charts. The mscgen utility is used for processing the 28 | ;; sequence definition, and must therefore be installed in the system. 29 | ;; 30 | ;; Mscgen is available and documented at 31 | ;; http://www.mcternan.me.uk/mscgen/index.html 32 | ;; 33 | ;; This code is directly inspired by Eric Schulte's ob-dot.el 34 | ;; 35 | ;; Example: 36 | ;; 37 | ;; #+begin_src mscgen :file example.png 38 | ;; msc { 39 | ;; A,B; 40 | ;; A -> B [ label = "send message" ]; 41 | ;; A <- B [ label = "get answer" ]; 42 | ;; } 43 | ;; #+end_src 44 | ;; 45 | ;; Header for alternative file type: 46 | ;; 47 | ;; #+begin_src mscgen :file ex2.svg :filetype svg 48 | 49 | ;; This differs from most standard languages in that 50 | ;; 51 | ;; 1) there is no such thing as a "session" in mscgen 52 | ;; 2) we are generally only going to return results of type "file" 53 | ;; 3) we are adding the "file" and "filetype" header arguments 54 | ;; 4) there are no variables 55 | 56 | ;;; Code: 57 | (require 'ob) 58 | (require 'ob-eval) 59 | 60 | (defvar org-babel-default-header-args:mscgen 61 | '((:results . "file") (:exports . "results")) 62 | "Default arguments to use when evaluating a mscgen source block.") 63 | 64 | (defun org-babel-execute:mscgen (body params) 65 | "Execute a block of Mscgen code with Babel. 66 | This function is called by `org-babel-execute-src-block'. 67 | Default filetype is png. Modify by setting :filetype parameter to 68 | mscgen supported formats." 69 | (let* ((out-file (or (cdr (assoc :file params)) "output.png" )) 70 | (filetype (or (cdr (assoc :filetype params)) "png" ))) 71 | (unless (cdr (assoc :file params)) 72 | (error " 73 | ERROR: no output file specified. Add \":file name.png\" to the src header")) 74 | (org-babel-eval (concat "mscgen -T " filetype " -o " out-file) body) 75 | nil)) ;; signal that output has already been written to file 76 | 77 | (defun org-babel-prep-session:mscgen (session params) 78 | "Raise an error because Mscgen doesn't support sessions." 79 | (error "Mscgen does not support sessions")) 80 | 81 | (provide 'ob-mscgen) 82 | 83 | 84 | 85 | ;;; ob-msc.el ends here 86 | -------------------------------------------------------------------------------- /contrib/scripts/staticmathjax/README.org: -------------------------------------------------------------------------------- 1 | Static MathJax v0.1 README 2 | #+AUTHOR: Jan Böcker 3 | 4 | Static MathJax is a XULRunner application which loads a HTML input 5 | file that uses MathJax into a browser, waits until MathJax is done 6 | processing, and then writes the formatted result to an output HTML 7 | file. 8 | 9 | I have only tested exports from Emacs Org-mode as input files. (As of 10 | 2010-08-14, MathJax is used by default with HTML exports in the 11 | current Org development version.) 12 | 13 | Optionally, references to the math fonts used will be converted to 14 | "data:" URIs, thus embedding the font data into the HTML file itself. 15 | (see [[http://en.wikipedia.org/wiki/Data_URI_scheme]]) 16 | 17 | The code is licensed under the GNU General Public License version 18 | 2, or, at your option, any later version. 19 | 20 | 21 | * Usage 22 | To run Static MathJax, an existing XULRunner installation is 23 | required. From the directory to which you unpacked Static MathJax, 24 | run: 25 | 26 | xulrunner application.ini <--embed-fonts | --final-mathjax-url > 27 | 28 | 29 | If you prefer to call "staticmathjax" instead of "xulrunner 30 | application.ini", link xulrunner-stub into the directory: 31 | ln /usr/lib/xulrunner-1.9.2.8/xulrunner-stub ./staticmathjax 32 | 33 | - input file :: 34 | name of the input file (the result of a HTML export 35 | from Org-mode). It is assumed that this file uses the 36 | UTF-8 character encoding. 37 | 38 | - output file :: 39 | name of the output file. 40 | 41 | - --embed-fonts :: 42 | if specified, the math fonts will be embedded into 43 | the output file using data: URIs 44 | 45 | - --final-mathjax-url :: 46 | if --embed-fonts is not specified, this 47 | must be the URL to a MathJax installation folder (e.g. "MathJax" 48 | if MathJax is installed in a subdirectory, or 49 | "http://orgmode.org/mathjax" to use the version hosted on the Org 50 | website. 51 | 52 | All references to math fonts in the output file will point to 53 | this directory. 54 | 55 | * Caveats 56 | 57 | The input file must not use a MathJax installation on the 58 | web. Otherwise, due to a security feature of Firefox, MathJax will 59 | fallback to image fonts. If you have unpacked MathJax to a 60 | subdirectory "MathJax", specify the following in your Org file: 61 | 62 | #+MathJax: path:"MathJax" 63 | 64 | The math is rendered in Firefox, so MathJax applies its 65 | Firefox-specific settings. When viewing the output files in other 66 | browsers, it will look slightly different than the result that 67 | running MathJax in that browser would produce. 68 | 69 | Internet Explorer does not use the correct font, because it only 70 | supports the EOT font format. For all other browsers (including 71 | Firefox), MathJax uses the OTF font format. 72 | 73 | Embedding fonts into the HTML file wastes some space due to the 74 | base64 encoding used in data: URIs. 75 | 76 | I have found no way to access stdout or set an exit code in an 77 | XULRunner app, so any code which calls Static MathJax has no idea if 78 | processing was successful and when an error occurs, graphical 79 | message boxes are displayed. 80 | -------------------------------------------------------------------------------- /lisp/ob-dot.el: -------------------------------------------------------------------------------- 1 | ;;; ob-dot.el --- org-babel functions for dot evaluation 2 | 3 | ;; Copyright (C) 2009-2012 Free Software Foundation, Inc. 4 | 5 | ;; Author: Eric Schulte 6 | ;; Keywords: literate programming, reproducible research 7 | ;; Homepage: http://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; Org-Babel support for evaluating dot source code. 27 | ;; 28 | ;; For information on dot see http://www.graphviz.org/ 29 | ;; 30 | ;; This differs from most standard languages in that 31 | ;; 32 | ;; 1) there is no such thing as a "session" in dot 33 | ;; 34 | ;; 2) we are generally only going to return results of type "file" 35 | ;; 36 | ;; 3) we are adding the "file" and "cmdline" header arguments 37 | ;; 38 | ;; 4) there are no variables (at least for now) 39 | 40 | ;;; Code: 41 | (require 'ob) 42 | (require 'ob-eval) 43 | 44 | (defvar org-babel-default-header-args:dot 45 | '((:results . "file") (:exports . "results")) 46 | "Default arguments to use when evaluating a dot source block.") 47 | 48 | (defun org-babel-expand-body:dot (body params) 49 | "Expand BODY according to PARAMS, return the expanded body." 50 | (let ((vars (mapcar #'cdr (org-babel-get-header params :var)))) 51 | (mapc 52 | (lambda (pair) 53 | (let ((name (symbol-name (car pair))) 54 | (value (cdr pair))) 55 | (setq body 56 | (replace-regexp-in-string 57 | (concat "\$" (regexp-quote name)) 58 | (if (stringp value) value (format "%S" value)) 59 | body)))) 60 | vars) 61 | body)) 62 | 63 | (defun org-babel-execute:dot (body params) 64 | "Execute a block of Dot code with org-babel. 65 | This function is called by `org-babel-execute-src-block'." 66 | (let* ((result-params (cdr (assoc :result-params params))) 67 | (out-file (cdr (or (assoc :file params) 68 | (error "You need to specify a :file parameter")))) 69 | (cmdline (or (cdr (assoc :cmdline params)) 70 | (format "-T%s" (file-name-extension out-file)))) 71 | (cmd (or (cdr (assoc :cmd params)) "dot")) 72 | (in-file (org-babel-temp-file "dot-"))) 73 | (with-temp-file in-file 74 | (insert (org-babel-expand-body:dot body params))) 75 | (org-babel-eval 76 | (concat cmd 77 | " " (org-babel-process-file-name in-file) 78 | " " cmdline 79 | " -o " (org-babel-process-file-name out-file)) "") 80 | nil)) ;; signal that output has already been written to file 81 | 82 | (defun org-babel-prep-session:dot (session params) 83 | "Return an error because Dot does not support sessions." 84 | (error "Dot does not support sessions")) 85 | 86 | (provide 'ob-dot) 87 | 88 | 89 | 90 | ;;; ob-dot.el ends here 91 | -------------------------------------------------------------------------------- /contrib/lisp/org-bookmark.el: -------------------------------------------------------------------------------- 1 | ;;; org-bookmark.el - Support for links to bookmark 2 | ;; Copyright (C) 2008-2012 Free Software Foundation, Inc. 3 | ;; 4 | ;; Author: Tokuya Kameshima 5 | ;; Version: 1.0 6 | ;; Keywords: outlines, hypermedia, calendar, wp 7 | ;; 8 | ;; This file is not part of GNU Emacs. 9 | ;; 10 | ;; Emacs is free software; you can redistribute it and/or modify 11 | ;; it under the terms of the GNU General Public License as published by 12 | ;; the Free Software Foundation; either version 3, or (at your option) 13 | ;; any later version. 14 | 15 | ;; GNU Emacs is distributed in the hope that it will be useful, 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | ;; GNU General Public License for more details. 19 | 20 | ;; You should have received a copy of the GNU General Public License 21 | ;; along with GNU Emacs; see the file COPYING. If not, write to the 22 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 23 | ;; Boston, MA 02110-1301, USA. 24 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 25 | 26 | (require 'org) 27 | (require 'bookmark) 28 | 29 | (defgroup org-bookmark nil 30 | "Options concerning the bookmark link." 31 | :tag "Org Startup" 32 | :group 'org-link) 33 | 34 | (defcustom org-bookmark-in-dired nil 35 | "Use org-bookmark in dired." 36 | :group 'org-bookmark 37 | :type 'boolean) 38 | 39 | (defcustom org-bookmark-when-visiting-a-file nil 40 | "Use org-bookmark in any buffer visiting a file." 41 | :group 'org-bookmark 42 | :type 'boolean) 43 | 44 | (defcustom org-bookmark-use-first-bookmark nil 45 | "If several bookmarks links to the buffer, take the first one. 46 | Otherwise prompt the user for the right bookmark to use." 47 | :group 'org-bookmark 48 | :type 'boolean) 49 | 50 | (org-add-link-type "bookmark" 'org-bookmark-open) 51 | (add-hook 'org-store-link-functions 'org-bookmark-store-link) 52 | 53 | (defun org-bookmark-open (bookmark) 54 | "Visit the bookmark BOOKMARK." 55 | (bookmark-jump bookmark)) 56 | 57 | (defun org-bookmark-store-link () 58 | "Store a link to the current line's bookmark in bookmark list." 59 | (let (file bookmark bmks) 60 | (cond ((and org-bookmark-in-dired 61 | (eq major-mode 'dired-mode)) 62 | (setq file (abbreviate-file-name (dired-get-filename)))) 63 | ((and org-bookmark-when-visiting-a-file 64 | (buffer-file-name (buffer-base-buffer))) 65 | (setq file (abbreviate-file-name 66 | (buffer-file-name (buffer-base-buffer)))))) 67 | (if (not file) 68 | (when (eq major-mode 'bookmark-bmenu-mode) 69 | (setq bookmark (bookmark-bmenu-bookmark))) 70 | (when (and (setq bmks 71 | (mapcar (lambda (name) 72 | (if (equal file 73 | (abbreviate-file-name 74 | (bookmark-location name))) 75 | name)) 76 | (bookmark-all-names))) 77 | (setq bmks (delete nil bmks))) 78 | (setq bookmark 79 | (if (or (eq 1 (length bmks)) org-bookmark-use-first-bookmark) 80 | (car bmks) 81 | (completing-read "Bookmark: " bmks nil t nil nil (car bmks)))))) 82 | (if bookmark 83 | (org-store-link-props :link (contact "bookmark:" bookmark) 84 | :description bookmark)))) 85 | 86 | (provide 'org-bookmark) 87 | 88 | ;;; org-bookmark.el ends here 89 | -------------------------------------------------------------------------------- /lisp/org-docview.el: -------------------------------------------------------------------------------- 1 | ;;; org-docview.el --- support for links to doc-view-mode buffers 2 | 3 | ;; Copyright (C) 2009-2012 Free Software Foundation, Inc. 4 | 5 | ;; Author: Jan Böcker 6 | ;; Keywords: outlines, hypermedia, calendar, wp 7 | ;; Homepage: http://orgmode.org 8 | ;; 9 | ;; This file is part of GNU Emacs. 10 | ;; 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 24 | ;; 25 | ;;; Commentary: 26 | 27 | ;; This file implements links to open files in doc-view-mode. 28 | ;; Org-mode loads this module by default - if this is not what you want, 29 | ;; configure the variable `org-modules'. 30 | 31 | ;; The links take the form 32 | ;; 33 | ;; docview::: 34 | ;; 35 | ;; for example: [[docview:~/.elisp/org/doc/org.pdf::1][Org-Mode Manual]] 36 | ;; 37 | ;; Autocompletion for inserting links is supported; you will be 38 | ;; prompted for a file and a page number. 39 | ;; 40 | ;; If you use org-store-link in a doc-view mode buffer, the stored 41 | ;; link will point to the current page. 42 | 43 | ;;; Code: 44 | 45 | 46 | (require 'org) 47 | 48 | (declare-function doc-view-goto-page "ext:doc-view" (page)) 49 | (declare-function image-mode-window-get "ext:image-mode" 50 | (prop &optional winprops)) 51 | 52 | (autoload 'doc-view-goto-page "doc-view") 53 | 54 | (org-add-link-type "docview" 'org-docview-open) 55 | (add-hook 'org-store-link-functions 'org-docview-store-link) 56 | 57 | (defun org-docview-open (link) 58 | (when (string-match "\\(.*\\)::\\([0-9]+\\)$" link) 59 | (let* ((path (match-string 1 link)) 60 | (page (string-to-number (match-string 2 link)))) 61 | (org-open-file path 1) ;; let org-mode open the file (in-emacs = 1) 62 | ;; to ensure org-link-frame-setup is respected 63 | (doc-view-goto-page page) 64 | ))) 65 | 66 | (defun org-docview-store-link () 67 | "Store a link to a docview buffer." 68 | (when (eq major-mode 'doc-view-mode) 69 | ;; This buffer is in doc-view-mode 70 | (let* ((path buffer-file-name) 71 | (page (image-mode-window-get 'page)) 72 | (link (concat "docview:" path "::" (number-to-string page))) 73 | (description "")) 74 | (org-store-link-props 75 | :type "docview" 76 | :link link 77 | :description path)))) 78 | 79 | (defun org-docview-complete-link () 80 | "Use the existing file name completion for file. 81 | Links to get the file name, then ask the user for the page number 82 | and append it." 83 | (concat (replace-regexp-in-string "^file:" "docview:" (org-file-complete-link)) 84 | "::" 85 | (read-from-minibuffer "Page:" "1"))) 86 | 87 | 88 | (provide 'org-docview) 89 | 90 | ;;; org-docview.el ends here 91 | -------------------------------------------------------------------------------- /testing/lisp/test-ob-fortran.el: -------------------------------------------------------------------------------- 1 | ;;; test-ob-fortran.el --- tests for ob-fortran.el 2 | 3 | ;; Copyright (c) 2010-2012 Sergey Litvinov 4 | ;; Authors: Sergey Litvinov 5 | 6 | ;; Released under the GNU General Public License version 3 7 | ;; see: http://www.gnu.org/licenses/gpl-3.0.html 8 | 9 | ;;; Code: 10 | (org-test-for-executable "gfortran") 11 | (unless (featurep 'ob-fortran) 12 | (signal 'missing-test-dependency "Support for Fortran code blocks")) 13 | 14 | (ert-deftest ob-fortran/assert () 15 | (should t)) 16 | 17 | (ert-deftest ob-fortran/simple-program () 18 | "Test of hello world program." 19 | (org-test-at-id "459384e8-1797-4f11-867e-dde0473ea7cc" 20 | (org-babel-next-src-block) 21 | (should (equal "Hello world" (org-babel-execute-src-block))))) 22 | 23 | (ert-deftest ob-fortran/fortran-var-program () 24 | "Test a fortran variable" 25 | (org-test-at-id "459384e8-1797-4f11-867e-dde0473ea7cc" 26 | (org-babel-next-src-block 2) 27 | (should (= 10 (org-babel-execute-src-block))))) 28 | 29 | (ert-deftest ob-fortran/input-var () 30 | "Test :var" 31 | (org-test-at-id "d8d1dfd3-5f0c-48fe-b55d-777997e02242" 32 | (org-babel-next-src-block) 33 | (should (= 15 (org-babel-execute-src-block))))) 34 | 35 | (ert-deftest ob-fortran/preprosessor-var () 36 | "Test preprocessed fortran" 37 | (org-test-at-id "d8d1dfd3-5f0c-48fe-b55d-777997e02242" 38 | (org-babel-next-src-block 2) 39 | (should (= 42 (org-babel-execute-src-block))))) 40 | 41 | ;; ;; TODO: test fails 42 | ;; (ert-deftest ob-fortran/character-var () 43 | ;; "Test string input" 44 | ;; (org-test-at-id "d8d1dfd3-5f0c-48fe-b55d-777997e02242" 45 | ;; (org-babel-next-src-block 3) 46 | ;; (should (equal "word" (org-babel-execute-src-block))))) 47 | 48 | (ert-deftest ob-fortran/list-var () 49 | "Test real array input" 50 | (org-test-at-id "c28569d9-04ce-4cad-ab81-1ea29f691465" 51 | (org-babel-next-src-block) 52 | (should (equal "1.00 2.00 3.00" (org-babel-execute-src-block))))) 53 | 54 | (ert-deftest ob-fortran/list-var-from-table () 55 | "Test real array from a table" 56 | (org-test-at-id "c28569d9-04ce-4cad-ab81-1ea29f691465" 57 | (org-babel-next-src-block 2) 58 | (should (equal "1.00 2.00" (org-babel-execute-src-block))))) 59 | 60 | (ert-deftest ob-fortran/no-variables-with-main () 61 | "Test :var with explicit 'program'" 62 | (org-test-at-id "891ead4a-f87a-473c-9ae0-1cf348bcd04f" 63 | (org-babel-next-src-block) 64 | (should-error (org-babel-execute-src-block)) 65 | :type 'error)) 66 | 67 | ;; (ert-deftest ob-fortran/wrong-list () 68 | ;; "Test wrong input list" 69 | ;; (org-test-at-id "891ead4a-f87a-473c-9ae0-1cf348bcd04f" 70 | ;; (org-babel-next-src-block 2) 71 | ;; (should-error (org-babel-execute-src-block)) 72 | ;; :type 'error)) 73 | 74 | ;; (ert-deftest ob-fortran/compiler-flags () 75 | ;; "Test compiler's flags" 76 | ;; (org-test-at-id "891ead4a-f87a-473c-9ae0-1cf348bcd04f" 77 | ;; (org-babel-next-src-block 3) 78 | ;; (should-error (org-babel-execute-src-block)) 79 | ;; :type 'error)) 80 | 81 | (ert-deftest ob-fortran/command-arguments () 82 | "Test real array from a table" 83 | (org-test-at-id "2d5330ea-9934-4737-9ed6-e1d3dae2dfa4" 84 | (org-babel-next-src-block) 85 | (should (= 23 (org-babel-execute-src-block))))) 86 | 87 | (provide 'test-ob-fortran) 88 | 89 | ;;; test-ob-fortran.el ends here 90 | 91 | -------------------------------------------------------------------------------- /lisp/ob-plantuml.el: -------------------------------------------------------------------------------- 1 | ;;; ob-plantuml.el --- org-babel functions for plantuml evaluation 2 | 3 | ;; Copyright (C) 2010-2012 Free Software Foundation, Inc. 4 | 5 | ;; Author: Zhang Weize 6 | ;; Keywords: literate programming, reproducible research 7 | ;; Homepage: http://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; Org-Babel support for evaluating plantuml script. 27 | ;; 28 | ;; Inspired by Ian Yang's org-export-blocks-format-plantuml 29 | ;; http://www.emacswiki.org/emacs/org-export-blocks-format-plantuml.el 30 | 31 | ;;; Requirements: 32 | 33 | ;; plantuml | http://plantuml.sourceforge.net/ 34 | ;; plantuml.jar | `org-plantuml-jar-path' should point to the jar file 35 | 36 | ;;; Code: 37 | (require 'ob) 38 | (require 'ob-eval) 39 | 40 | (defvar org-babel-default-header-args:plantuml 41 | '((:results . "file") (:exports . "results")) 42 | "Default arguments for evaluating a plantuml source block.") 43 | 44 | (defcustom org-plantuml-jar-path nil 45 | "Path to the plantuml.jar file." 46 | :group 'org-babel 47 | :version "24.1" 48 | :type 'string) 49 | 50 | (defun org-babel-execute:plantuml (body params) 51 | "Execute a block of plantuml code with org-babel. 52 | This function is called by `org-babel-execute-src-block'." 53 | (let* ((result-params (split-string (or (cdr (assoc :results params)) ""))) 54 | (out-file (or (cdr (assoc :file params)) 55 | (error "PlantUML requires a \":file\" header argument"))) 56 | (cmdline (cdr (assoc :cmdline params))) 57 | (in-file (org-babel-temp-file "plantuml-")) 58 | (java (or (cdr (assoc :java params)) "")) 59 | (cmd (if (not org-plantuml-jar-path) 60 | (error "`org-plantuml-jar-path' is not set") 61 | (concat "java " java " -jar " 62 | (shell-quote-argument 63 | (expand-file-name org-plantuml-jar-path)) 64 | (if (string= (file-name-extension out-file) "svg") 65 | " -tsvg" "") 66 | (if (string= (file-name-extension out-file) "eps") 67 | " -teps" "") 68 | " -p " cmdline " < " 69 | (org-babel-process-file-name in-file) 70 | " > " 71 | (org-babel-process-file-name out-file))))) 72 | (unless (file-exists-p org-plantuml-jar-path) 73 | (error "Could not find plantuml.jar at %s" org-plantuml-jar-path)) 74 | (with-temp-file in-file (insert (concat "@startuml\n" body "\n@enduml"))) 75 | (message "%s" cmd) (org-babel-eval cmd "") 76 | nil)) ;; signal that output has already been written to file 77 | 78 | (defun org-babel-prep-session:plantuml (session params) 79 | "Return an error because plantuml does not support sessions." 80 | (error "Plantuml does not support sessions")) 81 | 82 | (provide 'ob-plantuml) 83 | 84 | 85 | 86 | ;;; ob-plantuml.el ends here 87 | -------------------------------------------------------------------------------- /contrib/babel/langs/ob-fomus.el: -------------------------------------------------------------------------------- 1 | ;;; ob-fomus.el --- org-babel functions for fomus evaluation 2 | 3 | ;; Copyright (C) 2011-2012 Torsten Anders 4 | 5 | ;; Author: Torsten Anders 6 | ;; Keywords: literate programming, reproducible research 7 | ;; Homepage: http://orgmode.org 8 | ;; Version: 9 | 10 | ;;; License: 11 | 12 | ;; This program is free software; you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation; either version 3, or (at your option) 15 | ;; any later version. 16 | ;; 17 | ;; This program is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | ;; 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with GNU Emacs; see the file COPYING. If not, write to the 24 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 25 | ;; Boston, MA 02110-1301, USA. 26 | 27 | ;;; Commentary: 28 | 29 | ;; Org-Babel support for evaluating Fomus source code. 30 | ;; For information on Fomus see http://fomus.sourceforge.net/ 31 | ;; 32 | ;; This differs from most standard languages in that 33 | ;; 34 | ;; 1) there is no such thing as a "session" in fomus 35 | ;; 36 | ;; 2) we are generally only going to return results of type "file" 37 | ;; 38 | ;; 3) we are adding the "file" and "cmdline" header arguments 39 | ;; 40 | ;; 4) there are no variables (at least for now) 41 | 42 | ;;; Code: 43 | (require 'ob) 44 | (require 'ob-eval) 45 | 46 | (defvar org-babel-default-header-args:fomus 47 | '((:results . "file") (:exports . "results")) 48 | "Default arguments to use when evaluating a fomus source block.") 49 | 50 | (defun org-babel-expand-body:fomus (body params) 51 | "Expand BODY according to PARAMS, return the expanded body." 52 | (let ((vars (mapcar #'cdr (org-babel-get-header params :var)))) 53 | (mapc 54 | (lambda (pair) 55 | (let ((name (symbol-name (car pair))) 56 | (value (cdr pair))) 57 | (setq body 58 | (replace-regexp-in-string 59 | (concat "\$" (regexp-quote name)) 60 | (if (stringp value) value (format "%S" value)) 61 | body)))) 62 | vars) 63 | body)) 64 | 65 | (defun org-babel-execute:fomus (body params) 66 | "Execute a block of Fomus code with org-babel. 67 | This function is called by `org-babel-execute-src-block'." 68 | (let* ((result-params (cdr (assoc :result-params params))) 69 | (out-file (cdr (assoc :file params))) 70 | (cmdline (cdr (assoc :cmdline params))) 71 | (cmd (or (cdr (assoc :cmd params)) "fomus")) 72 | (in-file (org-babel-temp-file "fomus-" ".fms"))) 73 | (with-temp-file in-file 74 | (insert (org-babel-expand-body:fomus body params))) 75 | ;; TMP: testing 76 | ;; (message (concat cmd 77 | ;; " " (org-babel-process-file-name in-file) 78 | ;; " " cmdline 79 | ;; " -o " (org-babel-process-file-name out-file))) 80 | (org-babel-eval 81 | (concat cmd 82 | " " (org-babel-process-file-name in-file) 83 | " " cmdline 84 | " -o " (org-babel-process-file-name out-file)) "") 85 | nil)) ;; signal that output has already been written to file 86 | 87 | (defun org-babel-prep-session:fomus (session params) 88 | "Return an error because Fomus does not support sessions." 89 | (error "Fomus does not support sessions")) 90 | 91 | (provide 'ob-fomus) 92 | 93 | ;;; ob-fomus.el ends here 94 | -------------------------------------------------------------------------------- /mk/mansplit.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # Work on the files that are created by makeinfo for html output 3 | # split into many small files. 4 | 5 | # This will walk though the files listed on the command line, install 6 | # Sebastian Rose's key reader and add a small top-level-only table 7 | # of contents that will be placed into a special region and visible 8 | # in all subfiles. The small contents is a constant and has to be updated 9 | # by hand, currently. 10 | 11 | $contents = < 13 |

This is the official manual for the latest Org-mode release.

14 |

Table of Contents

15 | 41 | 42 | 43 | EOF 44 | 45 | 46 | $script = <<'EOF'; 47 | 48 | 49 | 55 | EOF 56 | 57 | while ($page = shift) { 58 | system "mv $page $page.orig"; 59 | open IN,"<$page.orig" or die "Cannot read from $page.orig\n"; 60 | undef $/; 61 | $all = ; 62 | close IN; 63 | 64 | $all =~ s//$&\n$script/; 65 | $all =~ s/^/\n$contents/m; 66 | 67 | open OUT,">$page" or die "Cannot write to $page\n"; 68 | print OUT $all; 69 | close OUT; 70 | system "rm $page.orig"; 71 | } 72 | -------------------------------------------------------------------------------- /lisp/ob-clojure.el: -------------------------------------------------------------------------------- 1 | ;;; ob-clojure.el --- org-babel functions for clojure evaluation 2 | 3 | ;; Copyright (C) 2009-2012 Free Software Foundation, Inc. 4 | 5 | ;; Author: Joel Boehland 6 | ;; Eric Schulte 7 | ;; Keywords: literate programming, reproducible research 8 | ;; Homepage: http://orgmode.org 9 | 10 | ;; This file is part of GNU Emacs. 11 | 12 | ;; GNU Emacs is free software: you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation, either version 3 of the License, or 15 | ;; (at your option) any later version. 16 | 17 | ;; GNU Emacs is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with GNU Emacs. If not, see . 24 | 25 | ;;; Commentary: 26 | 27 | ;;; support for evaluating clojure code, relies on slime for all eval 28 | 29 | ;;; Requirements: 30 | 31 | ;;; - clojure (at least 1.2.0) 32 | ;;; - clojure-mode 33 | ;;; - slime 34 | 35 | ;;; By far, the best way to install these components is by following 36 | ;;; the directions as set out by Phil Hagelberg (Technomancy) on the 37 | ;;; web page: http://technomancy.us/126 38 | 39 | ;;; Code: 40 | (require 'ob) 41 | 42 | (declare-function slime-eval "ext:slime" (sexp &optional package)) 43 | 44 | (defvar org-babel-tangle-lang-exts) 45 | (add-to-list 'org-babel-tangle-lang-exts '("clojure" . "clj")) 46 | 47 | (defvar org-babel-default-header-args:clojure '()) 48 | (defvar org-babel-header-args:clojure '((package . :any))) 49 | 50 | (defun org-babel-expand-body:clojure (body params) 51 | "Expand BODY according to PARAMS, return the expanded body." 52 | (let* ((vars (mapcar #'cdr (org-babel-get-header params :var))) 53 | (result-params (cdr (assoc :result-params params))) 54 | (print-level nil) (print-length nil) 55 | (body (org-babel-trim 56 | (if (> (length vars) 0) 57 | (concat "(let [" 58 | (mapconcat 59 | (lambda (var) 60 | (format "%S (quote %S)" (car var) (cdr var))) 61 | vars "\n ") 62 | "]\n" body ")") 63 | body)))) 64 | (cond ((or (member "code" result-params) (member "pp" result-params)) 65 | (format (concat "(let [org-mode-print-catcher (java.io.StringWriter.)] " 66 | "(clojure.pprint/with-pprint-dispatch clojure.pprint/%s-dispatch " 67 | "(clojure.pprint/pprint (do %s) org-mode-print-catcher) " 68 | "(str org-mode-print-catcher)))") 69 | (if (member "code" result-params) "code" "simple") body)) 70 | ;; if (:results output), collect printed output 71 | ((member "output" result-params) 72 | (format "(clojure.core/with-out-str %s)" body)) 73 | (t body)))) 74 | 75 | (defun org-babel-execute:clojure (body params) 76 | "Execute a block of Clojure code with Babel." 77 | (require 'slime) 78 | (with-temp-buffer 79 | (insert (org-babel-expand-body:clojure body params)) 80 | ((lambda (result) 81 | (let ((result-params (cdr (assoc :result-params params)))) 82 | (if (or (member "scalar" result-params) 83 | (member "verbatim" result-params)) 84 | result 85 | (condition-case nil (org-babel-script-escape result) 86 | (error result))))) 87 | (slime-eval 88 | `(swank:eval-and-grab-output 89 | ,(buffer-substring-no-properties (point-min) (point-max))) 90 | (cdr (assoc :package params)))))) 91 | 92 | (provide 'ob-clojure) 93 | 94 | 95 | 96 | ;;; ob-clojure.el ends here 97 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Makefile - for the org-mode distribution 2 | # GNU make is required 3 | # 4 | # This file is not part of GNU Emacs 5 | 6 | # set up environment 7 | include mk/default.mk # defaults, customizable via "local.mk" 8 | -include local.mk # optional local customization, use default.mk as template 9 | 10 | # default target is "all" unless overridden in local.mk 11 | all:: 12 | 13 | # Describe valid make targets for org-mode. 14 | .PHONY: targets help helpall 15 | targets: help 16 | help helpall:: 17 | $(info ) 18 | $(info Getting Help) 19 | $(info ============) 20 | $(info ) 21 | $(info make help - show brief help) 22 | $(info make targets - ditto) 23 | $(info make helpall - show extended help) 24 | $(info ) 25 | $(info Build and Check) 26 | $(info ===============) 27 | $(info make - build Org ELisp and all documentation) 28 | $(info make all - ditto) 29 | $(info make compile - build Org ELisp files) 30 | $(info make single - build Org ELisp files, single Emacs per source) 31 | $(info make autoloads - create org-loaddefs.el to load Org in-place) 32 | $(info make test - build Org ELisp files and run test suite) 33 | helpall:: 34 | $(info make test-dirty - check without building first) 35 | $(info make compile-dirty - build only stale Org ELisp files) 36 | $(info ) 37 | $(info Compatibility) 38 | $(info =============) 39 | $(info make oldorg - what the old make did: compile autoloads info) 40 | $(info ) 41 | $(info Cleaning) 42 | $(info ========) 43 | $(info make clean - remove built Org ELisp files and documentation) 44 | $(info make cleanall - remove everything that can be built and all remnants) 45 | $(info make clean-install - remove previous Org installation) 46 | $(info ) 47 | $(info Configuration Check) 48 | $(info ===================) 49 | help helpall:: 50 | $(info make config - check main configuration) 51 | helpall:: 52 | $(info make config-version - check Org version) 53 | $(info make config-test - check test configuration) 54 | $(info make config-exe - check executables configuration) 55 | $(info make config-cmd - check command configuration) 56 | $(info make config-all - check all configuration) 57 | $(info ) 58 | $(info Documentation) 59 | $(info =============) 60 | help helpall:: 61 | $(info make doc - build all documentation) 62 | helpall:: 63 | $(info make docs - ditto) 64 | help helpall:: 65 | $(info make info - build Info documentation) 66 | helpall:: 67 | $(info make html - build HTML documentation) 68 | $(info make pdf - build PDF documentation) 69 | $(info make card - build reference cards) 70 | $(info make refcard - ditto) 71 | help helpall:: 72 | $(info ) 73 | $(info Installation) 74 | $(info ============) 75 | $(info make install - build and install Org) 76 | helpall:: 77 | $(info make install-etc - build and install files in /etc) 78 | $(info make install-lisp - build and install Org Elisp files) 79 | $(info make install-info - build and install Info documentation) 80 | $(info ) 81 | $(info Convenience) 82 | $(info ===========) 83 | $(info make up0 - pull from upstream) 84 | $(info make up1 - pull from upstream, build and check) 85 | $(info make up2 - pull from upstream, build, check and install) 86 | $(info make update - pull from upstream and build) 87 | $(info make update2 - pull from upstream, build and install) 88 | $(info make uncompiled - combine cleanlisp and autoloads) 89 | $(info make local.mk - create new local.mk as template for adaptation) 90 | help helpall:: 91 | $(info ) 92 | $(info Full documentation on Worg) 93 | $(info ==========================) 94 | $(info http://orgmode.org/worg/dev/org-build-system.html) 95 | @echo "" 96 | 97 | include mk/targets.mk # toplevel make machinery 98 | -------------------------------------------------------------------------------- /README_contribute: -------------------------------------------------------------------------------- 1 | -*- mode: org; fill-column:65 -*- 2 | 3 | This is the GIT repository for the development of Org-mode, an 4 | Emacs mode for organizing your life. 5 | 6 | The text below explains the rules for participating in Org-mode 7 | development. 8 | 9 | * Main rules 10 | 11 | 1. The master git repository is hosted publicly at orgmode.org. 12 | Anyone can get a clone of the current repository state using 13 | the command 14 | 15 | git clone git://orgmode.org/org-mode.git 16 | 17 | Having a clone is sufficient to start hacking and to produce 18 | patches that can easily and consistently be applied to the 19 | main repository. 20 | 21 | 2. There is a mirror hosted publicly at repo.or.cz. Anyone can 22 | get a clone of the current repository state using the command 23 | 24 | git clone git://repo.or.cz/org-mode.git 25 | 26 | 3. People who are interested to participate in the Org-mode 27 | development can to so by sending patches to this address: 28 | 29 | [[mailto:emacs-orgmode@gnu.org][emacs-orgmode@gnu.org]] 30 | 31 | 4. An interested developer can also request push access to the 32 | central repository by sending her/his user-info to the 33 | maintainer of Org-mode or the webmaster of orgmode.org. 34 | 35 | After you have been added as a user with push privileges, 36 | clone the repository through ssh using 37 | 38 | git clone orgmode@orgmode.org:org-mode.git 39 | 40 | By requesting push access, you acknowledge that you have read 41 | and agreed with the following rules: 42 | 43 | - Org-mode is part of GNU Emacs. Therefore, we need to be 44 | very conscious about changes moving into the Org-mode core. 45 | These can originate only from people who have signed the 46 | appropriate papers with the Free Software Foundation. The 47 | files to which this applies are: 48 | 49 | - all *.el files in the lisp directory of the repository 50 | - org.texi, orgcard.tex in the doc directory 51 | - the corresponding ChangeLog files 52 | 53 | - Before making any significant changes, please explain and 54 | discuss them on the mailing list emacs-orgmode@gnu.org. 55 | 56 | This does obviously not apply to people who are maintaining 57 | their own contributions to Org-mode. Please, just use the 58 | new mechanism to make sure all changes end up in the right 59 | place. 60 | 61 | - Creating and pushing a change to the Org-mode core requires 62 | you also to provide ChangeLog entries. Just press `C-x 4 a' 63 | in each function or variable you have modified and describe 64 | the change you made in the ChangeLog buffer/file. 65 | 66 | - Among other things, Org-mode is widely appreciated because 67 | of its simplicity, cleanness and consistency. We should try 68 | hard to preserve this and I would like to ask everyone to 69 | keep this in mind when developing changes. 70 | 71 | * The contrib directory 72 | 73 | The git repository contains a contrib directory. This directory 74 | is the playing field for any developer, also people who have not 75 | (yet) signed the papers with the FSF. You are free to add files 76 | to this directory, implementing extensions, new link types etc. 77 | Also non-Lisp extensions like scripts to process Org-mode files 78 | in different ways are welcome in this directory. You should 79 | provide documentation with your extensions, at least in the form 80 | of commentary in the file, better on worg. Please discuss your 81 | extensions on [[mailto:emacs-orgmode@gnu.org][emacs-orgmode@gnu.org]]. 82 | 83 | After files have been tested in contrib and found to be generally 84 | useful, we may decide to clarify copyright questions and then 85 | move the file into the Org-mode core. This means they will be 86 | moved up to the root directory and will also eventually be added 87 | to GNU Emacs bzr repository. The final decision about this rests 88 | with the maintainer. 89 | -------------------------------------------------------------------------------- /mk/make_emacs_changelog: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | $commitrange = shift @ARGV; 4 | if (!$commitrange) { 5 | print STDERR "Enter commitrange: "; 6 | $commitrange = <>; 7 | $commitrange =~ s/\s*(.*?)\s+/$1/; 8 | } 9 | 10 | $syncdate = shift @ARGV; 11 | if (!$syncdate) { 12 | print STDERR "Enter syncdate YYYY-MM-DD: "; 13 | $syncdate = <>; 14 | $syncdate =~ s/\s*(.*?)\s+/$1/; 15 | } 16 | 17 | $kind = shift @ARGV; 18 | if (!$kind) { 19 | print STDERR 'Enter kind ("lisp" or "texi" or "card" or press RET): '; 20 | $kind = <>; 21 | $kind =~ s/\s*(.*?)\s+/$1/; 22 | $kind =~ s/"(.*?)"/$1/; 23 | } 24 | 25 | if ($kind ne "lisp" and $kind ne "texi" and $kind ne "card" 26 | and $kind ne "") { 27 | die "Invalid Changelog kind"; 28 | } 29 | 30 | # commit must touch these paths or files to be considered 31 | $fpath = "lisp/ doc/"; 32 | 33 | # Run git log to get the commits the messages 34 | open IN,"git log --no-merges --format='%aN%n<%aE>%n%b%x0c' $commitrange -- $fpath|"; 35 | undef $/; 36 | $log = ; 37 | @commits = split(/\f/,$log); 38 | 39 | my %entries; 40 | 41 | foreach my $commit (@commits) { 42 | $name = ( $commit=~ s/([^\n]+)\n//m ) ? $1 : "N/A"; 43 | $address = ( $commit=~ s/([^\n]+)\n//m ) ? $1 : "N/A"; 44 | $tiny = $commit =~ s/TINYCHANGE//mg ? " (tiny change)" : ""; 45 | $entry = $commit; 46 | 47 | if ($entry) { 48 | 49 | # remove whitespace at beginning of line 50 | $entry =~ s/^[ \t]*//mg; 51 | 52 | # add linebreaks before each starred line except the very first 53 | $entry =~ s/\A[\n\t]*/@/mg; 54 | $entry =~ s/^\*/\n\n*/mg; 55 | $entry =~ s/\A@//mg; 56 | 57 | # normalize starred lines 58 | $entry =~ s/^(\*[^(]*\S)\(/\1 (/mg; 59 | 60 | # remove blocks of more than one empty line 61 | $entry =~s/\n{3,}/\n\n/mg; 62 | 63 | # Fix the path when directories have been omitted 64 | $entry =~ s/^\* ([-a-zA-Z]+\.el)/* lisp\/$1/mg; 65 | $entry =~ s/^\* (org[a-z]*\.texi?)/* doc\/$1/mg; 66 | 67 | # remove stuff which is not for this output 68 | if ($kind =~ /\S/) { 69 | # do not delete or rename directories from the list as long as 70 | # Changelog entries referring to them exist! 71 | remove_parts(qw( contrib/ testing/ xemacs/ mk/ etc/ )); 72 | remove_parts(qw( .*Makefile README .+\.mk )); 73 | } 74 | if ($kind eq "lisp") { remove_parts("doc/") } 75 | if ($kind eq "texi") { remove_parts("lisp/","doc/orgcard","doc/orgguide") } 76 | if ($kind eq "card") { remove_parts("lisp/","doc/org\\.","doc/orgguide") } 77 | 78 | # remove/replace parts of the path 79 | $entry =~ s:^\* lisp/:* :mg; 80 | $entry =~ s:^\* doc/orgcard:* refcards/orgcard:mg; 81 | $entry =~ s:^\* doc/:* misc/:mg; 82 | 83 | # remove empty space at beginning and end 84 | $entry =~ s/\A\s*//; 85 | $entry =~ s/\s*\Z//; 86 | 87 | # remove everything that is not a starred entry 88 | my @entries = grep( /^\*/, split( /\n\n/, $entry )); 89 | 90 | # If there is anything left in the entry, print it 91 | if (scalar @entries) { 92 | push @{ $entries{"$syncdate $name $address$tiny"} }, @entries; 93 | } 94 | } 95 | } 96 | foreach my $key ( sort keys %entries ) { 97 | next if (! exists $entries{"$key"} ); 98 | print "$key\n"; 99 | if ( exists $entries{"$key (tiny change)"} ) { 100 | push @{ $entries{"$key"} }, @{ $entries{"$key (tiny change)"} }; 101 | delete $entries{"$key (tiny change)"}; 102 | } 103 | my @entries = @{ $entries{"$key"} }; 104 | foreach my $entry ( @entries ) { 105 | # indent each line by exactly one TAB 106 | $entry =~ s/^/\t/mg; 107 | print "\n$entry\n"; 108 | } 109 | print "\n\n"; 110 | } 111 | 112 | sub remove_parts { 113 | foreach $path (@_) { 114 | $re = "^[ \t]*\\*\\s+" . $path . "[^\\000]*?(?=^[ \\t]*\\*|\\Z)"; 115 | $entry =~ s/$re/\n$1/mg; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /lisp/ob-calc.el: -------------------------------------------------------------------------------- 1 | ;;; ob-calc.el --- org-babel functions for calc code evaluation 2 | 3 | ;; Copyright (C) 2010-2012 Free Software Foundation, Inc. 4 | 5 | ;; Author: Eric Schulte 6 | ;; Keywords: literate programming, reproducible research 7 | ;; Homepage: http://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; Org-Babel support for evaluating calc code 27 | 28 | ;;; Code: 29 | (require 'ob) 30 | (require 'calc) 31 | (unless (featurep 'xemacs) 32 | (require 'calc-trail) 33 | (require 'calc-store)) 34 | (eval-when-compile (require 'ob-comint)) 35 | 36 | (declare-function calc-store-into "calc-store" (&optional var)) 37 | (declare-function calc-recall "calc-store" (&optional var)) 38 | (declare-function math-evaluate-expr "calc-ext" (x)) 39 | 40 | (defvar org-babel-default-header-args:calc nil 41 | "Default arguments for evaluating an calc source block.") 42 | 43 | (defun org-babel-expand-body:calc (body params) 44 | "Expand BODY according to PARAMS, return the expanded body." body) 45 | 46 | (defun org-babel-execute:calc (body params) 47 | "Execute a block of calc code with Babel." 48 | (unless (get-buffer "*Calculator*") 49 | (save-window-excursion (calc) (calc-quit))) 50 | (let* ((vars (mapcar #'cdr (org-babel-get-header params :var))) 51 | (var-syms (mapcar #'car vars)) 52 | (var-names (mapcar #'symbol-name var-syms))) 53 | (mapc 54 | (lambda (pair) 55 | (calc-push-list (list (cdr pair))) 56 | (calc-store-into (car pair))) 57 | vars) 58 | (mapc 59 | (lambda (line) 60 | (when (> (length line) 0) 61 | (cond 62 | ;; simple variable name 63 | ((member line var-names) (calc-recall (intern line))) 64 | ;; stack operation 65 | ((string= "'" (substring line 0 1)) 66 | (funcall (lookup-key calc-mode-map (substring line 1)) nil)) 67 | ;; complex expression 68 | (t 69 | (calc-push-list 70 | (list ((lambda (res) 71 | (cond 72 | ((numberp res) res) 73 | ((math-read-number res) (math-read-number res)) 74 | ((listp res) (error "Calc error \"%s\" on input \"%s\"" 75 | (cadr res) line)) 76 | (t (replace-regexp-in-string 77 | "'" "" 78 | (calc-eval 79 | (math-evaluate-expr 80 | ;; resolve user variables, calc built in 81 | ;; variables are handled automatically 82 | ;; upstream by calc 83 | (mapcar #'org-babel-calc-maybe-resolve-var 84 | ;; parse line into calc objects 85 | (car (math-read-exprs line))))))))) 86 | (calc-eval line)))))))) 87 | (mapcar #'org-babel-trim 88 | (split-string (org-babel-expand-body:calc body params) "[\n\r]")))) 89 | (save-excursion 90 | (with-current-buffer (get-buffer "*Calculator*") 91 | (calc-eval (calc-top 1))))) 92 | 93 | (defvar var-syms) ; Dynamically scoped from org-babel-execute:calc 94 | (defun org-babel-calc-maybe-resolve-var (el) 95 | (if (consp el) 96 | (if (and (equal 'var (car el)) (member (cadr el) var-syms)) 97 | (progn 98 | (calc-recall (cadr el)) 99 | (prog1 (calc-top 1) 100 | (calc-pop 1))) 101 | (mapcar #'org-babel-calc-maybe-resolve-var el)) 102 | el)) 103 | 104 | (provide 'ob-calc) 105 | 106 | 107 | 108 | ;;; ob-calc.el ends here 109 | -------------------------------------------------------------------------------- /mk/orgcard2txt.pl: -------------------------------------------------------------------------------- 1 | # orgcard2txt.pl - a script to generate orgcard.txt from orgcard.tex 2 | # Copyright (C) 2010 Osamu OKANO 3 | # 4 | # Version: 0.1 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # Usage: 20 | # ====== 21 | # perl orgcard2txt.pl orgcard.tex > orgcard.txt 22 | use strict; 23 | use warnings; 24 | 25 | sub rep_esc{ 26 | my $s = shift @_; 27 | $s =~ s/\\kbd{([^}]+)}/$1/g; 28 | $s =~ s/\$\^([0-9])\$/[$1]/g; 29 | $s =~ s/\\rm //g; 30 | $s =~ s/\\\///g; 31 | $s =~ s/\\\^{}/^/g; 32 | $s =~ s/\\}/}/g; 33 | $s =~ s/\\{/{/g; 34 | $s =~ s/\\\#/#/g; 35 | $s =~ s/\\\^/^/g; 36 | $s =~ s/\\\%/%/g; 37 | $s =~ s/\\\_/_/g; 38 | $s =~ s/\\\&/&/g; 39 | $s =~ s/\\\$/\$/g; 40 | $s =~ s/\$\\leftrightarrow\$/<->/g; 41 | $s =~ s/\$\\pm 1\$/±1/g; 42 | $s =~ s/``{\\tt ([^}]+)}''/`$1'/g; 43 | return $s; 44 | } 45 | my $page=0; 46 | my $orgversionnumber; 47 | 48 | open(IN,$ARGV[0]); 49 | while(){ 50 | last if(/\f/); 51 | $orgversionnumber = $1 if /\\def\\orgversionnumber{([^}]+)}/; 52 | } 53 | close(IN); 54 | 55 | print <){ 71 | if(/\f/){ 72 | $page = $page + 1; 73 | next; 74 | } 75 | next if($page != 1); 76 | next if(/^%/); 77 | next if /Org-Mode Reference Card \([12]\/2\)/; 78 | next if /\\centerline{\(for version \\orgversionnumber\)}/; 79 | next if /\(for version \)/; 80 | next if /\\newcolumn/; 81 | next if /\\copyrightnotice/; 82 | next if /\\bye/; 83 | next if /\\title{([^}]+)}/; 84 | chomp; 85 | # print "b:$_\n"; 86 | s/([^\\])\%.+$/$1/; 87 | # print "a:$_\n"; 88 | if (/\\section{(.+)}/){ 89 | my $sec = rep_esc($1); 90 | print "================================================================================\n"; 91 | print "$sec\n"; 92 | print "================================================================================\n"; 93 | next; 94 | } 95 | if (/{\\bf (.+)}/){ 96 | my $bf = rep_esc($1); 97 | print "--------------------------------------------------------------------------------\n"; 98 | print "$bf\n"; 99 | print "--------------------------------------------------------------------------------\n"; 100 | next; 101 | } 102 | if (/^{\\it (.+)}/){ 103 | my $it = rep_esc($1); 104 | print "--------------------------------------------------------------------------------\n"; 105 | print "$it\n"; 106 | print "--------------------------------------------------------------------------------\n"; 107 | next; 108 | } 109 | if(/^\\key{(.+)}\s*$/||/^\\metax{(.+)}\s*$/){ 110 | my ($k,$v) = split(/}{/,$1); 111 | my $k2 = &rep_esc($k); 112 | my $v2 = &rep_esc($v); 113 | # print "$k2\t$v2\n"; 114 | ($key,$value)=($k2,$v2); 115 | write; 116 | next; 117 | } 118 | my $line = rep_esc($_); 119 | $line =~ s/{\\it ([^}]+)}/$1/g; 120 | $line =~ s/{\\tt ([^}]+)}/$1/g; 121 | print "$line\n"; 122 | } 123 | close(IN); 124 | -------------------------------------------------------------------------------- /lisp/ob-lisp.el: -------------------------------------------------------------------------------- 1 | ;;; ob-lisp.el --- org-babel functions for common lisp evaluation 2 | 3 | ;; Copyright (C) 2009-2012 Free Software Foundation, Inc. 4 | 5 | ;; Authors: Joel Boehland 6 | ;; Eric Schulte 7 | ;; David T. O'Toole 8 | ;; Keywords: literate programming, reproducible research 9 | ;; Homepage: http://orgmode.org 10 | 11 | ;; This file is part of GNU Emacs. 12 | 13 | ;; GNU Emacs is free software: you can redistribute it and/or modify 14 | ;; it under the terms of the GNU General Public License as published by 15 | ;; the Free Software Foundation, either version 3 of the License, or 16 | ;; (at your option) any later version. 17 | 18 | ;; GNU Emacs is distributed in the hope that it will be useful, 19 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | ;; GNU General Public License for more details. 22 | 23 | ;; You should have received a copy of the GNU General Public License 24 | ;; along with GNU Emacs. If not, see . 25 | 26 | ;;; Commentary: 27 | 28 | ;;; support for evaluating common lisp code, relies on slime for all eval 29 | 30 | ;;; Requirements: 31 | 32 | ;; Requires SLIME (Superior Lisp Interaction Mode for Emacs.) 33 | ;; See http://common-lisp.net/project/slime/ 34 | 35 | ;;; Code: 36 | (require 'ob) 37 | 38 | (declare-function slime-eval "ext:slime" (sexp &optional package)) 39 | 40 | (defvar org-babel-tangle-lang-exts) 41 | (add-to-list 'org-babel-tangle-lang-exts '("lisp" . "lisp")) 42 | 43 | (defvar org-babel-default-header-args:lisp '()) 44 | (defvar org-babel-header-args:lisp '((package . :any))) 45 | 46 | (defcustom org-babel-lisp-dir-fmt 47 | "(let ((*default-pathname-defaults* #P%S)) %%s)" 48 | "Format string used to wrap code bodies to set the current directory. 49 | For example a value of \"(progn ;; %s\\n %%s)\" would ignore the 50 | current directory string." 51 | :group 'org-babel 52 | :version "24.1" 53 | :type 'string) 54 | 55 | (defun org-babel-expand-body:lisp (body params) 56 | "Expand BODY according to PARAMS, return the expanded body." 57 | (let* ((vars (mapcar #'cdr (org-babel-get-header params :var))) 58 | (result-params (cdr (assoc :result-params params))) 59 | (print-level nil) (print-length nil) 60 | (body (org-babel-trim 61 | (if (> (length vars) 0) 62 | (concat "(let (" 63 | (mapconcat 64 | (lambda (var) 65 | (format "(%S (quote %S))" (car var) (cdr var))) 66 | vars "\n ") 67 | ")\n" body ")") 68 | body)))) 69 | (if (or (member "code" result-params) 70 | (member "pp" result-params)) 71 | (format "(pprint %s)" body) 72 | body))) 73 | 74 | (defun org-babel-execute:lisp (body params) 75 | "Execute a block of Common Lisp code with Babel." 76 | (require 'slime) 77 | (org-babel-reassemble-table 78 | ((lambda (result) 79 | (if (member "output" (cdr (assoc :result-params params))) 80 | (car result) 81 | (condition-case nil 82 | (read (org-babel-lisp-vector-to-list (cadr result))) 83 | (error (cadr result))))) 84 | (with-temp-buffer 85 | (insert (org-babel-expand-body:lisp body params)) 86 | (slime-eval `(swank:eval-and-grab-output 87 | ,(let ((dir (if (assoc :dir params) 88 | (cdr (assoc :dir params)) 89 | default-directory))) 90 | (format 91 | (if dir (format org-babel-lisp-dir-fmt dir) "(progn %s)") 92 | (buffer-substring-no-properties 93 | (point-min) (point-max))))) 94 | (cdr (assoc :package params))))) 95 | (org-babel-pick-name (cdr (assoc :colname-names params)) 96 | (cdr (assoc :colnames params))) 97 | (org-babel-pick-name (cdr (assoc :rowname-names params)) 98 | (cdr (assoc :rownames params))))) 99 | 100 | (defun org-babel-lisp-vector-to-list (results) 101 | ;; TODO: better would be to replace #(...) with [...] 102 | (replace-regexp-in-string "#(" "(" results)) 103 | 104 | (provide 'ob-lisp) 105 | 106 | 107 | 108 | ;;; ob-lisp.el ends here 109 | -------------------------------------------------------------------------------- /etc/schema/od-manifest-schema-v1.2-cs01.rnc: -------------------------------------------------------------------------------- 1 | # Open Document Format for Office Applications (OpenDocument) Version 1.2 2 | # Committee Specification (CS) 01, 17 March 2011 3 | # Manifest Relax-NG Schema 4 | # 5 | # Copyright (c) OASIS Open 2002-2011. All Rights Reserved. 6 | # 7 | # All capitalized terms in the following text have the meanings assigned to them 8 | # in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The 9 | # full Policy may be found at the OASIS website. 10 | # 11 | # This document and translations of it may be copied and furnished to others, and 12 | # derivative works that comment on or otherwise explain it or assist in its 13 | # implementation may be prepared, copied, published, and distributed, in whole or 14 | # in part, without restriction of any kind, provided that the above copyright 15 | # notice and this section are included on all such copies and derivative works. 16 | # However, this document itself may not be modified in any way, including by 17 | # removing the copyright notice or references to OASIS, except as needed for the 18 | # purpose of developing any document or deliverable produced by an OASIS 19 | # Technical Committee (in which case the rules applicable to copyrights, as set 20 | # forth in the OASIS IPR Policy, must be followed) or as required to translate it 21 | # into languages other than English. 22 | # 23 | # The limited permissions granted above are perpetual and will not be revoked by 24 | # OASIS or its successors or assigns. 25 | # 26 | # This document and the information contained herein is provided on an "AS IS" 27 | # basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT 28 | # LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT 29 | # INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR 30 | # FITNESS FOR A PARTICULAR PURPOSE. 31 | 32 | namespace manifest = 33 | "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" 34 | 35 | start = manifest 36 | manifest = element manifest:manifest { manifest-attlist, file-entry+ } 37 | manifest-attlist = attribute manifest:version { "1.2" } 38 | file-entry = 39 | element manifest:file-entry { file-entry-attlist, encryption-data? } 40 | file-entry-attlist = 41 | attribute manifest:full-path { \string } 42 | & attribute manifest:size { nonNegativeInteger }? 43 | & attribute manifest:media-type { \string } 44 | & attribute manifest:preferred-view-mode { 45 | "edit" | "presentation-slide-show" | "read-only" | namespacedToken 46 | }? 47 | & attribute manifest:version { \string }? 48 | encryption-data = 49 | element manifest:encryption-data { 50 | encryption-data-attlist, 51 | algorithm, 52 | start-key-generation?, 53 | key-derivation 54 | } 55 | encryption-data-attlist = 56 | attribute manifest:checksum-type { "SHA1/1K" | anyURI } 57 | & attribute manifest:checksum { base64Binary } 58 | algorithm = 59 | element manifest:algorithm { algorithm-attlist, anyElements } 60 | algorithm-attlist = 61 | attribute manifest:algorithm-name { "Blowfish CFB" | anyURI } 62 | & attribute manifest:initialisation-vector { base64Binary } 63 | anyAttListOrElements = 64 | attribute * { text }*, 65 | anyElements 66 | anyElements = 67 | element * { 68 | mixed { anyAttListOrElements } 69 | }* 70 | key-derivation = 71 | element manifest:key-derivation { key-derivation-attlist, empty } 72 | key-derivation-attlist = 73 | attribute manifest:key-derivation-name { "PBKDF2" | anyURI } 74 | & attribute manifest:salt { base64Binary } 75 | & attribute manifest:iteration-count { nonNegativeInteger } 76 | & attribute manifest:key-size { nonNegativeInteger }? 77 | start-key-generation = 78 | element manifest:start-key-generation { 79 | start-key-generation-attlist, empty 80 | } 81 | start-key-generation-attlist = 82 | attribute manifest:start-key-generation-name { "SHA1" | anyURI } 83 | & attribute manifest:key-size { nonNegativeInteger }? 84 | base64Binary = xsd:base64Binary 85 | namespacedToken = xsd:QName { pattern = "[^:]+:[^:]+" } 86 | nonNegativeInteger = xsd:nonNegativeInteger 87 | \string = xsd:string 88 | anyURI = xsd:anyURI 89 | -------------------------------------------------------------------------------- /contrib/lisp/org-notmuch.el: -------------------------------------------------------------------------------- 1 | ;;; org-notmuch.el --- Support for links to notmuch messages from within Org-mode 2 | 3 | ;; Copyright (C) 2010-2012 Matthieu Lemerre 4 | 5 | ;; Author: Matthieu Lemerre 6 | ;; Keywords: outlines, hypermedia, calendar, wp 7 | ;; Homepage: http://orgmode.org 8 | 9 | ;; This file is not part of GNU Emacs. 10 | 11 | ;; This file is free software; you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation; either version 2, or (at your option) 14 | ;; any later version. 15 | 16 | ;; This file is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs; see the file COPYING. If not, write to 23 | ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | ;; Boston, MA 02110-1301, USA. 25 | 26 | ;;; Commentary: 27 | 28 | ;; This file implements links to notmuch messages and "searchs". A 29 | ;; search is a query to be performed by notmuch; it is the equivalent 30 | ;; to folders in other mail clients. Similarly, mails are refered to 31 | ;; by a query, so both a link can refer to several mails. 32 | 33 | ;; Links have one the following form 34 | ;; notmuch: 35 | ;; notmuch-search:. 36 | 37 | ;; The first form open the queries in notmuch-show mode, whereas the 38 | ;; second link open it in notmuch-search mode. Note that queries are 39 | ;; performed at the time the link is opened, and the result may be 40 | ;; different from whet the link was stored. 41 | 42 | ;;; Code: 43 | 44 | (require 'org) 45 | 46 | ;; Install the link type 47 | (org-add-link-type "notmuch" 'org-notmuch-open) 48 | (add-hook 'org-store-link-functions 'org-notmuch-store-link) 49 | 50 | (defun org-notmuch-store-link () 51 | "Store a link to a notmuch search or message." 52 | (when (eq major-mode 'notmuch-show-mode) 53 | (let* ((message-id (notmuch-show-get-prop :id)) 54 | (subject (notmuch-show-get-subject)) 55 | (to (notmuch-show-get-to)) 56 | (from (notmuch-show-get-from)) 57 | desc link) 58 | (org-store-link-props :type "notmuch" :from from :to to 59 | :subject subject :message-id message-id) 60 | (setq desc (org-email-link-description)) 61 | (setq link (concat "notmuch:" "id:" message-id)) 62 | (org-add-link-props :link link :description desc) 63 | link))) 64 | 65 | (defun org-notmuch-open (path) 66 | "Follow a notmuch message link specified by PATH." 67 | (org-notmuch-follow-link path)) 68 | 69 | (defun org-notmuch-follow-link (search) 70 | "Follow a notmuch link to SEARCH. 71 | 72 | Can link to more than one message, if so all matching messages are shown." 73 | (require 'notmuch) 74 | (notmuch-show (org-link-unescape search))) 75 | 76 | 77 | 78 | 79 | (org-add-link-type "notmuch-search" 'org-notmuch-search-open) 80 | (add-hook 'org-store-link-functions 'org-notmuch-search-store-link) 81 | 82 | (defun org-notmuch-search-store-link () 83 | "Store a link to a notmuch search or message." 84 | (when (eq major-mode 'notmuch-search-mode) 85 | (let ((link (concat "notmuch-search:" 86 | (org-link-escape notmuch-search-query-string))) 87 | (desc (concat "Notmuch search: " notmuch-search-query-string))) 88 | (org-store-link-props :type "notmuch-search" 89 | :link link 90 | :description desc) 91 | link))) 92 | 93 | (defun org-notmuch-search-open (path) 94 | "Follow a notmuch message link specified by PATH." 95 | (message path) 96 | (org-notmuch-search-follow-link path)) 97 | 98 | (defun org-notmuch-search-follow-link (search) 99 | "Follow a notmuch link by displaying SEARCH in notmuch-search mode." 100 | (require 'notmuch) 101 | (notmuch-search (org-link-unescape search))) 102 | 103 | (provide 'org-notmuch) 104 | 105 | ;;; org-notmuch.el ends here 106 | -------------------------------------------------------------------------------- /contrib/babel/langs/ob-eukleides.el: -------------------------------------------------------------------------------- 1 | ;;; ob-eukleides.el --- org-babel functions for eukleides evaluation 2 | 3 | ;; Copyright (C) 2010-2012 Free Software Foundation, Inc. 4 | 5 | ;; Author: Luis Anaya 6 | ;; Keywords: literate programming, reproducible research 7 | ;; Homepage: http://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; Org-Babel support for evaluating eukleides script. 27 | ;; 28 | ;; Inspired by Ian Yang's org-export-blocks-format-eukleides 29 | ;; http://www.emacswiki.org/emacs/org-export-blocks-format-eukleides.el 30 | 31 | ;;; Requirements: 32 | 33 | ;; eukleides | http://eukleides.org 34 | ;; eukleides | `org-eukleides-path' should point to the eukleides executablexs 35 | 36 | ;;; Code: 37 | (require 'ob) 38 | (require 'ob-eval) 39 | 40 | (defvar org-babel-default-header-args:eukleides 41 | '((:results . "file") (:exports . "results")) 42 | "Default arguments for evaluating a eukleides source block.") 43 | 44 | (defcustom org-eukleides-path nil 45 | "Path to the eukleides executable file." 46 | :group 'org-babel 47 | :version "24.1" 48 | :type 'string) 49 | 50 | 51 | (defcustom org-eukleides-eps-to-raster nil 52 | "Command used to convert EPS to raster. Nil for no conversion." 53 | :group 'org-babel 54 | :type '(choice 55 | (repeat :tag "Shell Command Sequence" (string :tag "Shell Command")) 56 | (const :tag "sam2p" "a=%s;b=%s;sam2p ${a} ${b}" ) 57 | (const :tag "NetPNM" "a=%s;b=%s;pstopnm -stdout ${a} | pnmtopng > ${b}" ) 58 | (const :tag "None" nil))) 59 | 60 | 61 | (defun org-babel-execute:eukleides (body params) 62 | "Execute a block of eukleides code with org-babel. 63 | This function is called by `org-babel-execute-src-block'." 64 | (let* ((result-params (split-string (or (cdr (assoc :results params)) ""))) 65 | (out-file (or (cdr (assoc :file params)) 66 | (error "Eukleides requires a \":file\" header argument"))) 67 | (cmdline (cdr (assoc :cmdline params))) 68 | (in-file (org-babel-temp-file "eukleides-")) 69 | (java (or (cdr (assoc :java params)) "")) 70 | (cmd (if (not org-eukleides-path) 71 | (error "`org-eukleides-path' is not set") 72 | (concat (expand-file-name org-eukleides-path) 73 | " -b --output=" 74 | (org-babel-process-file-name 75 | (concat 76 | (file-name-sans-extension out-file) ".eps")) 77 | " " 78 | (org-babel-process-file-name in-file))))) 79 | (unless (file-exists-p org-eukleides-path) 80 | (error "Could not find eukleides at %s" org-eukleides-path)) 81 | 82 | (if (string= (file-name-extension out-file) "png") 83 | (if org-eukleides-eps-to-raster 84 | (shell-command (format org-eukleides-eps-to-raster 85 | (concat (file-name-sans-extension out-file) ".eps") 86 | (concat (file-name-sans-extension out-file) ".png"))) 87 | (error "Conversion to PNG not supported. use a file with an EPS name"))) 88 | 89 | (with-temp-file in-file (insert body)) 90 | (message "%s" cmd) (org-babel-eval cmd "") 91 | nil)) ;; signal that output has already been written to file 92 | 93 | (defun org-babel-prep-session:eukleides (session params) 94 | "Return an error because eukleides does not support sessions." 95 | (error "Eukleides does not support sessions")) 96 | 97 | (provide 'ob-eukleides) 98 | 99 | 100 | 101 | ;;; ob-eukleides.el ends here 102 | -------------------------------------------------------------------------------- /testing/lisp/test-ob-lob.el: -------------------------------------------------------------------------------- 1 | ;;; test-ob-lob.el 2 | 3 | ;; Copyright (c) 2010-2012 Eric Schulte 4 | ;; Authors: Eric Schulte 5 | 6 | ;; Released under the GNU General Public License version 3 7 | ;; see: http://www.gnu.org/licenses/gpl-3.0.html 8 | 9 | ;;;; Comments: 10 | 11 | 12 | ;;; Tests 13 | (org-babel-lob-ingest 14 | (expand-file-name 15 | "library-of-babel.org" 16 | (expand-file-name 17 | "babel" 18 | (expand-file-name 19 | "contrib" 20 | (expand-file-name 21 | ".." 22 | (expand-file-name 23 | ".." 24 | (file-name-directory 25 | (or load-file-name buffer-file-name)))))))) 26 | 27 | (ert-deftest test-ob-lob/ingest () 28 | "Test the ingestion of an org-mode file." 29 | (should (< 0 (org-babel-lob-ingest 30 | (expand-file-name "babel.org" org-test-example-dir))))) 31 | 32 | (ert-deftest test-ob-lob/call-with-header-arguments () 33 | "Test the evaluation of a library of babel #+call: line." 34 | (org-test-at-id "fab7e291-fde6-45fc-bf6e-a485b8bca2f0" 35 | (move-beginning-of-line 1) 36 | (forward-line 6) 37 | (message (buffer-substring (point-at-bol) (point-at-eol))) 38 | (should (string= "testing" (org-babel-lob-execute 39 | (org-babel-lob-get-info)))) 40 | (forward-line 1) 41 | (should (string= "testing" (caar (org-babel-lob-execute 42 | (org-babel-lob-get-info))))) 43 | (forward-line 1) 44 | (should (string= "testing" (org-babel-lob-execute 45 | (org-babel-lob-get-info)))) 46 | (forward-line 1) 47 | (should (string= "testing" (caar (org-babel-lob-execute 48 | (org-babel-lob-get-info))))) 49 | (forward-line 1) 50 | (should (string= "testing" (org-babel-lob-execute 51 | (org-babel-lob-get-info)))) 52 | (forward-line 1) 53 | (should (string= "testing" (caar (org-babel-lob-execute 54 | (org-babel-lob-get-info))))) 55 | (forward-line 1) (beginning-of-line) (forward-char 27) 56 | (should (string= "testing" (org-babel-lob-execute 57 | (org-babel-lob-get-info)))) 58 | (forward-line 1) (beginning-of-line) (forward-char 27) 59 | (should (string= "testing" (caar (org-babel-lob-execute 60 | (org-babel-lob-get-info))))) 61 | (forward-line 1) (beginning-of-line) 62 | (should (= 4 (org-babel-lob-execute (org-babel-lob-get-info)))) 63 | (forward-line 1) 64 | (should (string= "testing" (org-babel-lob-execute 65 | (org-babel-lob-get-info)))) 66 | (forward-line 1) 67 | (should (string= "123" (org-babel-lob-execute (org-babel-lob-get-info)))))) 68 | 69 | (ert-deftest test-ob-lob/export-lob-lines () 70 | "Test the export of a variety of library babel call lines." 71 | (org-test-at-id "72ddeed3-2d17-4c7f-8192-a575d535d3fc" 72 | (org-narrow-to-subtree) 73 | (let ((html (org-export-as-html nil nil nil 'string 'body-only))) 74 | ;; check the location of each exported number 75 | (with-temp-buffer 76 | (insert html) (goto-char (point-min)) 77 | ;; 0 should be on a line by itself 78 | (should (re-search-forward "0" nil t)) 79 | (should (string= "0" (buffer-substring (point-at-bol) (point-at-eol)))) 80 | ;; 2 should be in tags 81 | (should (re-search-forward "2" nil t)) 82 | (should (re-search-forward (regexp-quote "") (point-at-eol) t)) 83 | (should (re-search-backward (regexp-quote "") (point-at-bol) t)) 84 | ;; 4 should not be exported 85 | (should (not (re-search-forward "4" nil t))) 86 | ;; 6 should also be inline 87 | (should (re-search-forward "6" nil t)) 88 | (should (re-search-forward (regexp-quote "") (point-at-eol) t)) 89 | (should (re-search-backward (regexp-quote "") (point-at-bol) t)) 90 | ;; 8 should not be quoted 91 | (should (re-search-forward "8" nil t)) 92 | (should (not (= ?= (char-after (point))))) 93 | (should (not (= ?= (char-before (- (point) 1))))) 94 | ;; 10 should export 95 | (should (re-search-forward "10" nil t)))))) 96 | 97 | (ert-deftest test-ob-lob/do-not-eval-lob-lines-in-example-blocks-on-export () 98 | (org-test-with-temp-text-in-file " 99 | for export 100 | #+begin_example 101 | #+call: rubbish() 102 | #+end_example" 103 | (org-export-as-html nil))) 104 | 105 | (provide 'test-ob-lob) 106 | 107 | ;;; test-ob-lob.el ends here 108 | -------------------------------------------------------------------------------- /lisp/ob-keys.el: -------------------------------------------------------------------------------- 1 | ;;; ob-keys.el --- key bindings for org-babel 2 | 3 | ;; Copyright (C) 2009-2012 Free Software Foundation, Inc. 4 | 5 | ;; Author: Eric Schulte 6 | ;; Keywords: literate programming, reproducible research 7 | ;; Homepage: http://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; Add org-babel keybindings to the org-mode keymap for exposing 27 | ;; org-babel functions. These will all share a common prefix. See 28 | ;; the value of `org-babel-key-bindings' for a list of interactive 29 | ;; functions and their associated keys. 30 | 31 | ;;; Code: 32 | (require 'ob) 33 | 34 | (defvar org-babel-key-prefix "\C-c\C-v" 35 | "The key prefix for Babel interactive key-bindings. 36 | See `org-babel-key-bindings' for the list of interactive babel 37 | functions which are assigned key bindings, and see 38 | `org-babel-map' for the actual babel keymap.") 39 | 40 | (defvar org-babel-map (make-sparse-keymap) 41 | "The keymap for interactive Babel functions.") 42 | 43 | ;;;###autoload 44 | (defun org-babel-describe-bindings () 45 | "Describe all keybindings behind `org-babel-key-prefix'." 46 | (interactive) 47 | (describe-bindings org-babel-key-prefix)) 48 | 49 | (defvar org-babel-key-bindings 50 | '(("p" . org-babel-previous-src-block) 51 | ("\C-p" . org-babel-previous-src-block) 52 | ("n" . org-babel-next-src-block) 53 | ("\C-n" . org-babel-next-src-block) 54 | ("e" . org-babel-execute-maybe) 55 | ("\C-e" . org-babel-execute-maybe) 56 | ("o" . org-babel-open-src-block-result) 57 | ("\C-o" . org-babel-open-src-block-result) 58 | ("\C-v" . org-babel-expand-src-block) 59 | ("v" . org-babel-expand-src-block) 60 | ("u" . org-babel-goto-src-block-head) 61 | ("\C-u" . org-babel-goto-src-block-head) 62 | ("g" . org-babel-goto-named-src-block) 63 | ("r" . org-babel-goto-named-result) 64 | ("\C-r" . org-babel-goto-named-result) 65 | ("\C-b" . org-babel-execute-buffer) 66 | ("b" . org-babel-execute-buffer) 67 | ("\C-s" . org-babel-execute-subtree) 68 | ("s" . org-babel-execute-subtree) 69 | ("\C-d" . org-babel-demarcate-block) 70 | ("d" . org-babel-demarcate-block) 71 | ("\C-t" . org-babel-tangle) 72 | ("t" . org-babel-tangle) 73 | ("\C-f" . org-babel-tangle-file) 74 | ("f" . org-babel-tangle-file) 75 | ("\C-c" . org-babel-check-src-block) 76 | ("c" . org-babel-check-src-block) 77 | ("\C-j" . org-babel-insert-header-arg) 78 | ("j" . org-babel-insert-header-arg) 79 | ("\C-l" . org-babel-load-in-session) 80 | ("l" . org-babel-load-in-session) 81 | ("\C-i" . org-babel-lob-ingest) 82 | ("i" . org-babel-lob-ingest) 83 | ("\C-I" . org-babel-view-src-block-info) 84 | ("I" . org-babel-view-src-block-info) 85 | ("\C-z" . org-babel-switch-to-session) 86 | ("z" . org-babel-switch-to-session-with-code) 87 | ("\C-a" . org-babel-sha1-hash) 88 | ("a" . org-babel-sha1-hash) 89 | ("h" . org-babel-describe-bindings) 90 | ("\C-x" . org-babel-do-key-sequence-in-edit-buffer) 91 | ("x" . org-babel-do-key-sequence-in-edit-buffer) 92 | ("\C-\M-h" . org-babel-mark-block)) 93 | "Alist of key bindings and interactive Babel functions. 94 | This list associates interactive Babel functions 95 | with keys. Each element of this list will add an entry to the 96 | `org-babel-map' using the letter key which is the `car' of the 97 | a-list placed behind the generic `org-babel-key-prefix'.") 98 | 99 | (provide 'ob-keys) 100 | 101 | ;; Local variables: 102 | ;; generated-autoload-file: "org-loaddefs.el" 103 | ;; End: 104 | 105 | ;;; ob-keys.el ends here 106 | -------------------------------------------------------------------------------- /contrib/lisp/org-screen.el: -------------------------------------------------------------------------------- 1 | ;;; org-screen.el --- Integreate Org-mode with screen. 2 | 3 | ;; Copyright (c) 2008-2012 Andrew Hyatt 4 | ;; 5 | ;; Author: Andrew Hyatt 6 | ;; Maintainer: Carsten Dominik 7 | ;; 8 | ;; This file is not yet part of GNU Emacs. 9 | ;; 10 | ;; GNU Emacs is free software; you can redistribute it and/or modify 11 | ;; it under the terms of the GNU General Public License as published by 12 | ;; the Free Software Foundation; either version 3, or (at your option) 13 | ;; any later version. 14 | 15 | ;; GNU Emacs is distributed in the hope that it will be useful, 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | ;; GNU General Public License for more details. 19 | 20 | ;; You should have received a copy of the GNU General Public License 21 | ;; along with GNU Emacs; see the file COPYING. If not, write to the 22 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 23 | ;; Boston, MA 02110-1301, USA. 24 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 25 | ;; 26 | ;;; Commentary: 27 | ;; 28 | ;; This file contains functionality to integrate screen and org-mode. 29 | ;; When using org-mode, it is often useful to take tasks that have 30 | ;; some command-line work associated with them, and associate them 31 | ;; with a screen session. Screen is used rather than a direct 32 | ;; terminal to facilitate portability of the resulting session. 33 | ;; 34 | ;; To use screen in org, in your .emacs file, simply put this file in 35 | ;; a directory in your load-path and write: 36 | ;; 37 | ;; (require 'org-screen) 38 | ;; 39 | ;; When have a task and want to start some command-line activity 40 | ;; associated with that task, go to the end of your item and type: 41 | ;; 42 | ;; M-x org-screen 43 | ;; 44 | ;; This will prompt you for a name of a screen session. Type in a 45 | ;; name and it will insert a link into your org file at your current 46 | ;; location. 47 | ;; 48 | ;; When you want to visit the link, go to the link and type C-c C-o to 49 | ;; open the link. 50 | ;; 51 | ;; You may want to get rid of the constant queries about whether you 52 | ;; really want to execute lisp code. Do so by adding to your .emacs: 53 | ;; 54 | ;; (setq org-confirm-elisp-link-function nil) 55 | 56 | (require 'term) 57 | (require 'org) 58 | 59 | (defcustom org-screen-program-name "/usr/bin/screen" 60 | "Full location of the screen executable." 61 | :group 'org-screen 62 | :type 'string) 63 | 64 | (defun org-screen (name) 65 | "Start a screen session with name" 66 | (interactive "MScreen name: ") 67 | (save-excursion 68 | (org-screen-helper name "-S")) 69 | (insert-string (concat "[[screen:" name "]]"))) 70 | 71 | (defun org-screen-buffer-name (name) 72 | "Returns the buffer name corresponding to the screen name given." 73 | (concat "*screen " name "*")) 74 | 75 | (defun org-screen-helper (name arg) 76 | "This method will create a screen session with a specified name 77 | and taking the specified screen arguments. Much of this function 78 | is copied from ansi-term method." 79 | 80 | ;; Pick the name of the new buffer. 81 | (let ((term-ansi-buffer-name 82 | (generate-new-buffer-name 83 | (org-screen-buffer-name name)))) 84 | (setq term-ansi-buffer-name 85 | (term-ansi-make-term 86 | term-ansi-buffer-name org-screen-program-name nil arg name)) 87 | (set-buffer term-ansi-buffer-name) 88 | (term-mode) 89 | (term-char-mode) 90 | (term-set-escape-char ?\C-x) 91 | term-ansi-buffer-name)) 92 | 93 | (defun org-screen-goto (name) 94 | "Open the screen with the specified name in the window" 95 | (interactive "MScreen name: ") 96 | (let ((screen-buffer-name (org-screen-buffer-name name))) 97 | (if (member screen-buffer-name 98 | (mapcar 'buffer-name (buffer-list))) 99 | (org-pop-to-buffer-same-window screen-buffer-name) 100 | (org-pop-to-buffer-same-window (org-screen-helper name "-dr"))))) 101 | 102 | (if org-link-abbrev-alist 103 | (add-to-list 'org-link-abbrev-alist 104 | '("screen" . "elisp:(org-screen-goto \"%s\")")) 105 | (setq org-link-abbrev-alist 106 | '(("screen" . "elisp:(org-screen-goto \"%s\")")))) 107 | 108 | (provide 'org-screen) 109 | -------------------------------------------------------------------------------- /lisp/ob-ditaa.el: -------------------------------------------------------------------------------- 1 | ;;; ob-ditaa.el --- org-babel functions for ditaa evaluation 2 | 3 | ;; Copyright (C) 2009-2012 Free Software Foundation, Inc. 4 | 5 | ;; Author: Eric Schulte 6 | ;; Keywords: literate programming, reproducible research 7 | ;; Homepage: http://orgmode.org 8 | 9 | ;; This file is part of GNU Emacs. 10 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; GNU Emacs is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with GNU Emacs. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; Org-Babel support for evaluating ditaa source code. 27 | ;; 28 | ;; This differs from most standard languages in that 29 | ;; 30 | ;; 1) there is no such thing as a "session" in ditaa 31 | ;; 32 | ;; 2) we are generally only going to return results of type "file" 33 | ;; 34 | ;; 3) we are adding the "file" and "cmdline" header arguments 35 | ;; 36 | ;; 4) there are no variables (at least for now) 37 | 38 | ;;; Code: 39 | (require 'ob) 40 | (require 'org-compat) 41 | 42 | (defvar org-babel-default-header-args:ditaa 43 | '((:results . "file") 44 | (:exports . "results") 45 | (:java . "-Dfile.encoding=UTF-8")) 46 | "Default arguments for evaluating a ditaa source block.") 47 | 48 | (defcustom org-ditaa-jar-path (expand-file-name 49 | "ditaa.jar" 50 | (file-name-as-directory 51 | (expand-file-name 52 | "scripts" 53 | (file-name-as-directory 54 | (expand-file-name 55 | "../contrib" 56 | (file-name-directory (org-find-library-dir "org"))))))) 57 | "Path to the ditaa jar executable." 58 | :group 'org-babel 59 | :type 'string) 60 | 61 | (defcustom org-ditaa-eps-jar-path 62 | (expand-file-name "DitaaEps.jar" (file-name-directory org-ditaa-jar-path)) 63 | "Path to the DitaaEps.jar executable." 64 | :group 'org-babel 65 | :type 'string) 66 | 67 | (defcustom org-ditaa-jar-option "-jar" 68 | "Option for the ditaa jar file. 69 | Do not leave leading or trailing spaces in this string." 70 | :group 'org-babel 71 | :version "24.1" 72 | :type 'string) 73 | 74 | (defun org-babel-execute:ditaa (body params) 75 | "Execute a block of Ditaa code with org-babel. 76 | This function is called by `org-babel-execute-src-block'." 77 | (let* ((result-params (split-string (or (cdr (assoc :results params)) ""))) 78 | (out-file ((lambda (el) 79 | (or el 80 | (error 81 | "ditaa code block requires :file header argument"))) 82 | (cdr (assoc :file params)))) 83 | (cmdline (cdr (assoc :cmdline params))) 84 | (java (cdr (assoc :java params))) 85 | (in-file (org-babel-temp-file "ditaa-")) 86 | (eps (cdr (assoc :eps params))) 87 | (cmd (concat "java " java " " org-ditaa-jar-option " " 88 | (shell-quote-argument 89 | (expand-file-name 90 | (if eps org-ditaa-eps-jar-path org-ditaa-jar-path))) 91 | " " cmdline 92 | " " (org-babel-process-file-name in-file) 93 | " " (org-babel-process-file-name out-file))) 94 | (pdf-cmd (when (and (or (string= (file-name-extension out-file) "pdf") 95 | (cdr (assoc :pdf params)))) 96 | (concat 97 | "epstopdf" 98 | " " (org-babel-process-file-name (concat in-file ".eps")) 99 | " -o=" (org-babel-process-file-name out-file))))) 100 | (unless (file-exists-p org-ditaa-jar-path) 101 | (error "Could not find ditaa.jar at %s" org-ditaa-jar-path)) 102 | (with-temp-file in-file (insert body)) 103 | (message cmd) (shell-command cmd) 104 | (when pdf-cmd (message pdf-cmd) (shell-command pdf-cmd)) 105 | nil)) ;; signal that output has already been written to file 106 | 107 | (defun org-babel-prep-session:ditaa (session params) 108 | "Return an error because ditaa does not support sessions." 109 | (error "Ditaa does not support sessions")) 110 | 111 | (provide 'ob-ditaa) 112 | 113 | 114 | 115 | ;;; ob-ditaa.el ends here 116 | -------------------------------------------------------------------------------- /lisp/org-special-blocks.el: -------------------------------------------------------------------------------- 1 | ;;; org-special-blocks.el --- handle Org special blocks 2 | ;; Copyright (C) 2009-2012 Free Software Foundation, Inc. 3 | 4 | ;; Author: Chris Gray 5 | 6 | ;; This file is part of GNU Emacs. 7 | 8 | ;; GNU Emacs is free software: you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation, either version 3 of the License, or 11 | ;; (at your option) any later version. 12 | 13 | ;; GNU Emacs is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with GNU Emacs. If not, see . 20 | 21 | ;;; Commentary: 22 | ;; 23 | 24 | ;; This package generalizes the #+begin_foo and #+end_foo tokens. 25 | 26 | ;; To use, put the following in your init file: 27 | ;; 28 | ;; (require 'org-special-blocks) 29 | 30 | ;; The tokens #+begin_center, #+begin_verse, etc. existed previously. 31 | ;; This package generalizes them (at least for the LaTeX and html 32 | ;; exporters). When a #+begin_foo token is encountered by the LaTeX 33 | ;; exporter, it is expanded into \begin{foo}. The text inside the 34 | ;; environment is not protected, as text inside environments generally 35 | ;; is. When #+begin_foo is encountered by the html exporter, a div 36 | ;; with class foo is inserted into the HTML file. It is up to the 37 | ;; user to add this class to his or her stylesheet if this div is to 38 | ;; mean anything. 39 | 40 | (require 'org-html) 41 | (require 'org-compat) 42 | 43 | (declare-function org-open-par "org-html" ()) 44 | (declare-function org-close-par-maybe "org-html" ()) 45 | 46 | (defvar org-special-blocks-ignore-regexp "^\\(LaTeX\\|HTML\\)$" 47 | "A regexp indicating the names of blocks that should be ignored 48 | by org-special-blocks. These blocks will presumably be 49 | interpreted by other mechanisms.") 50 | 51 | (defvar org-export-current-backend) ; dynamically bound in org-exp.el 52 | (defun org-special-blocks-make-special-cookies () 53 | "Adds special cookies when #+begin_foo and #+end_foo tokens are 54 | seen. This is run after a few special cases are taken care of." 55 | (when (or (eq org-export-current-backend 'html) 56 | (eq org-export-current-backend 'latex)) 57 | (goto-char (point-min)) 58 | (while (re-search-forward "^[ \t]*#\\+\\(begin\\|end\\)_\\(.*\\)$" nil t) 59 | (unless (org-string-match-p org-special-blocks-ignore-regexp (match-string 2)) 60 | (replace-match 61 | (if (equal (downcase (match-string 1)) "begin") 62 | (concat "ORG-" (match-string 2) "-START") 63 | (concat "ORG-" (match-string 2) "-END")) 64 | t t))))) 65 | 66 | (add-hook 'org-export-preprocess-after-blockquote-hook 67 | 'org-special-blocks-make-special-cookies) 68 | 69 | (defun org-special-blocks-convert-latex-special-cookies () 70 | "Converts the special cookies into LaTeX blocks." 71 | (goto-char (point-min)) 72 | (while (re-search-forward "^ORG-\\([^ \t\n]*\\)[ \t]*\\(.*\\)-\\(START\\|END\\)$" nil t) 73 | (replace-match 74 | (if (equal (match-string 3) "START") 75 | (concat "\\begin{" (match-string 1) "}" (match-string 2)) 76 | (concat "\\end{" (match-string 1) "}")) 77 | t t))) 78 | 79 | 80 | (add-hook 'org-export-latex-after-blockquotes-hook 81 | 'org-special-blocks-convert-latex-special-cookies) 82 | 83 | (defvar org-line) 84 | (defun org-special-blocks-convert-html-special-cookies () 85 | "Converts the special cookies into div blocks." 86 | ;; Uses the dynamically-bound variable `org-line'. 87 | (when (and org-line (string-match "^ORG-\\(.*\\)-\\(START\\|END\\)$" org-line)) 88 | (message "%s" (match-string 1)) 89 | (when (equal (match-string 2 org-line) "START") 90 | (org-close-par-maybe) 91 | (insert "\n
") 92 | (org-open-par)) 93 | (when (equal (match-string 2 org-line) "END") 94 | (org-close-par-maybe) 95 | (insert "\n
") 96 | (org-open-par)) 97 | (throw 'nextline nil))) 98 | 99 | (add-hook 'org-export-html-after-blockquotes-hook 100 | 'org-special-blocks-convert-html-special-cookies) 101 | 102 | (provide 'org-special-blocks) 103 | 104 | ;;; org-special-blocks.el ends here 105 | -------------------------------------------------------------------------------- /lisp/ob-perl.el: -------------------------------------------------------------------------------- 1 | ;;; ob-perl.el --- org-babel functions for perl evaluation 2 | 3 | ;; Copyright (C) 2009-2012 Free Software Foundation, Inc. 4 | 5 | ;; Authors: Dan Davison 6 | ;; Eric Schulte 7 | ;; Keywords: literate programming, reproducible research 8 | ;; Homepage: http://orgmode.org 9 | 10 | ;; This file is part of GNU Emacs. 11 | 12 | ;; GNU Emacs is free software: you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation, either version 3 of the License, or 15 | ;; (at your option) any later version. 16 | 17 | ;; GNU Emacs is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with GNU Emacs. If not, see . 24 | 25 | ;;; Commentary: 26 | 27 | ;; Org-Babel support for evaluating perl source code. 28 | 29 | ;;; Code: 30 | (require 'ob) 31 | (require 'ob-eval) 32 | (eval-when-compile (require 'cl)) 33 | 34 | (defvar org-babel-tangle-lang-exts) 35 | (add-to-list 'org-babel-tangle-lang-exts '("perl" . "pl")) 36 | 37 | (defvar org-babel-default-header-args:perl '()) 38 | 39 | (defvar org-babel-perl-command "perl" 40 | "Name of command to use for executing perl code.") 41 | 42 | (defun org-babel-execute:perl (body params) 43 | "Execute a block of Perl code with Babel. 44 | This function is called by `org-babel-execute-src-block'." 45 | (let* ((session (cdr (assoc :session params))) 46 | (result-params (cdr (assoc :result-params params))) 47 | (result-type (cdr (assoc :result-type params))) 48 | (full-body (org-babel-expand-body:generic 49 | body params (org-babel-variable-assignments:perl params))) 50 | (session (org-babel-perl-initiate-session session))) 51 | (org-babel-reassemble-table 52 | (org-babel-perl-evaluate session full-body result-type) 53 | (org-babel-pick-name 54 | (cdr (assoc :colname-names params)) (cdr (assoc :colnames params))) 55 | (org-babel-pick-name 56 | (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))) 57 | 58 | (defun org-babel-prep-session:perl (session params) 59 | "Prepare SESSION according to the header arguments in PARAMS." 60 | (error "Sessions are not supported for Perl")) 61 | 62 | (defun org-babel-variable-assignments:perl (params) 63 | "Return list of perl statements assigning the block's variables." 64 | (mapcar 65 | (lambda (pair) 66 | (format "$%s=%s;" 67 | (car pair) 68 | (org-babel-perl-var-to-perl (cdr pair)))) 69 | (mapcar #'cdr (org-babel-get-header params :var)))) 70 | 71 | ;; helper functions 72 | 73 | (defun org-babel-perl-var-to-perl (var) 74 | "Convert an elisp value to a perl variable. 75 | The elisp value, VAR, is converted to a string of perl source code 76 | specifying a var of the same value." 77 | (if (listp var) 78 | (concat "[" (mapconcat #'org-babel-perl-var-to-perl var ", ") "]") 79 | (format "%S" var))) 80 | 81 | (defvar org-babel-perl-buffers '(:default . nil)) 82 | 83 | (defun org-babel-perl-initiate-session (&optional session params) 84 | "Return nil because sessions are not supported by perl." 85 | nil) 86 | 87 | (defvar org-babel-perl-wrapper-method 88 | " 89 | sub main { 90 | %s 91 | } 92 | @r = main; 93 | open(o, \">%s\"); 94 | print o join(\"\\n\", @r), \"\\n\"") 95 | 96 | (defvar org-babel-perl-pp-wrapper-method 97 | nil) 98 | 99 | (defun org-babel-perl-evaluate (session body &optional result-type) 100 | "Pass BODY to the Perl process in SESSION. 101 | If RESULT-TYPE equals 'output then return a list of the outputs 102 | of the statements in BODY, if RESULT-TYPE equals 'value then 103 | return the value of the last statement in BODY, as elisp." 104 | (when session (error "Sessions are not supported for Perl")) 105 | (case result-type 106 | (output (org-babel-eval org-babel-perl-command body)) 107 | (value (let ((tmp-file (org-babel-temp-file "perl-"))) 108 | (org-babel-eval 109 | org-babel-perl-command 110 | (format org-babel-perl-wrapper-method body 111 | (org-babel-process-file-name tmp-file 'noquote))) 112 | (org-babel-eval-read-file tmp-file))))) 113 | 114 | (provide 'ob-perl) 115 | 116 | 117 | 118 | ;;; ob-perl.el ends here 119 | -------------------------------------------------------------------------------- /contrib/scripts/org2hpda: -------------------------------------------------------------------------------- 1 | # org2hpda - a small utility to generate hipster pda style printouts from org mode 2 | # Copyright (C) 2007-2012 Christian Egli 3 | # 4 | # Version: 0.6 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | # Commentary: 20 | # =========== 21 | # 22 | # set cal-tex-diary to true so that diary entries show up in the calendar 23 | # 24 | # Usage: 25 | # ====== 26 | # 27 | # run this makefile with 28 | # 29 | # make -f org2hpda 30 | # 31 | # The makfile will take the entries from your diary file and generate 32 | # two PDFs containing nicely printed weekly and monthly calendars. One 33 | # is done in the style of a pocketMod (http://www.pocketmod.com/) and 34 | # the other is done in the style of the Hipster PDA 35 | # (http://en.wikipedia.org/wiki/Hipster_PDA). 36 | # 37 | # Requirements: 38 | # ============= 39 | # 40 | # the pdf* commands are part of the pdfjam package which can be found 41 | # at http://www.warwick.ac.uk/go/pdfjam 42 | 43 | EMACS = emacs -batch -l ~/.emacs 44 | LATEX = latex 45 | DIARY = $($(EMACS) -eval "diary-file") 46 | 47 | # Number of weeks to be printed. Should be a multiple of 4, because 4 48 | # of them are merged on one page. Can be set when invoking the script 49 | # as follows: make NUMBER_OF_WEEKS=8 -f org2hpda 50 | NUMBER_OF_WEEKS = 4 51 | 52 | hipsterFiles = weekCalendar.pdf yearCalendar.pdf monthCalendar3.pdf monthCalendar2.pdf monthCalendar1.pdf 53 | pocketModFiles = weekCalendar.pdf yearCalendar-rotated.pdf \ 54 | monthCalendar3-rotated.pdf monthCalendar2-rotated.pdf monthCalendar1-rotated.pdf 55 | 56 | all: pocketMod.pdf hipsterPDA.pdf 57 | 58 | %.dvi: %.tex 59 | # Quick hack to massage the LaTeX produced by cal-tex 60 | # quote '@', then increase font size of week calendars, 61 | # increase font of diary entries in moth calendar and 62 | # finally reduce links to their destination, i.e. 63 | # change '[[http://foo][bar]]' to 'bar' 64 | sed -e 's/\\verb|@|/\@/g' \ 65 | -e 's/documentclass\[11pt\]/documentclass[12pt]/g' \ 66 | -e 's/{\\tiny \\raggedright #3}/{\\small \\raggedright #3}/g' \ 67 | -e 's/\[\[[^]]\+\]\[\([^]]\+\)\]\]/\1/g' \ 68 | < $< > /tmp/temp-org-file.$$$$; mv /tmp/temp-org-file.$$$$ $< 69 | $(LATEX) $^ 70 | 71 | %.pdf: %.dvi 72 | dvipdf $^ 73 | 74 | %-rotated.pdf: %.pdf 75 | cp $^ $@ 76 | for n in 1 2 3; do \ 77 | pdf90 --quiet --outfile tmp.pdf $@; mv tmp.pdf $@; \ 78 | done 79 | 80 | weekCalendar.tex: $(DIARY) 81 | $(EMACS) -eval "(progn (calendar) (cal-tex-cursor-week-iso $(NUMBER_OF_WEEKS)) (with-current-buffer cal-tex-buffer (write-file \"$@\")))" 82 | 83 | monthCalendar1.tex: $(DIARY) 84 | $(EMACS) -eval "(progn (calendar) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))" 85 | 86 | monthCalendar2.tex: $(DIARY) 87 | $(EMACS) -eval "(progn (calendar) (calendar-forward-month 1) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))" 88 | 89 | monthCalendar3.tex: $(DIARY) 90 | $(EMACS) -eval "(progn (calendar) (calendar-forward-month 2) (cal-tex-cursor-month-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))" 91 | 92 | yearCalendar.tex: $(DIARY) 93 | $(EMACS) -eval "(progn (calendar) (calendar-forward-month 2) (cal-tex-cursor-year-landscape 1) (with-current-buffer cal-tex-buffer (write-file \"$@\")))" 94 | 95 | pocketMod.pdf: $(pocketModFiles) 96 | pdfjoin --quiet --outfile tmp.pdf $^ 97 | pdfnup tmp.pdf --quiet --outfile $@ --nup 4x2 --frame true 98 | 99 | hipsterPDA.pdf: $(hipsterFiles) 100 | pdfnup weekCalendar.pdf --quiet --outfile page1.pdf --batch --nup 2x2 --frame true --no-landscape 101 | pdfjoin --quiet --outfile tmp.pdf monthCalendar[1-3]-rotated.pdf yearCalendar-rotated.pdf 102 | pdfnup tmp.pdf --quiet --outfile page2.pdf --batch --nup 2x2 --frame true --no-landscape 103 | pdfjoin --quiet --outfile $@ page1.pdf page2.pdf 104 | 105 | clean: 106 | rm -rf *.aux *.dvi *.tex *.log *.pdf 107 | -------------------------------------------------------------------------------- /contrib/babel/langs/ob-tcl.el: -------------------------------------------------------------------------------- 1 | ;;; ob-tcl.el --- org-babel functions for tcl evaluation 2 | 3 | ;; Copyright (C) 2009-2012 Free Software Foundation, Inc. 4 | 5 | ;; Authors: Dan Davison 6 | ;; Eric Schulte 7 | ;; Luis Anaya (tcl) 8 | ;; 9 | ;; Keywords: literate programming, reproducible research 10 | ;; Homepage: http://orgmode.org 11 | 12 | ;; This file is part of GNU Emacs. 13 | 14 | ;; GNU Emacs is free software: you can redistribute it and/or modify 15 | ;; it under the terms of the GNU General Public License as published by 16 | ;; the Free Software Foundation, either version 3 of the License, or 17 | ;; (at your option) any later version. 18 | 19 | ;; GNU Emacs is distributed in the hope that it will be useful, 20 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | ;; GNU General Public License for more details. 23 | 24 | ;; You should have received a copy of the GNU General Public License 25 | ;; along with GNU Emacs. If not, see . 26 | 27 | ;;; Commentary: 28 | 29 | ;; Org-Babel support for evaluating tcl source code. 30 | 31 | ;;; Code: 32 | (require 'ob) 33 | (require 'ob-eval) 34 | (eval-when-compile (require 'cl)) 35 | 36 | (defvar org-babel-tangle-lang-exts) 37 | (add-to-list 'org-babel-tangle-lang-exts '("tcl" . "tcl")) 38 | 39 | (defvar org-babel-default-header-args:tcl nil) 40 | 41 | (defcustom org-babel-tcl-command "tclsh" 42 | "Name of command to use for executing Tcl code." 43 | :group 'org-babel 44 | :type 'string) 45 | 46 | 47 | (defun org-babel-execute:tcl (body params) 48 | "Execute a block of Tcl code with Babel. 49 | This function is called by `org-babel-execute-src-block'." 50 | (let* ((session (cdr (assoc :session params))) 51 | (result-params (cdr (assoc :result-params params))) 52 | (result-type (cdr (assoc :result-type params))) 53 | (full-body (org-babel-expand-body:generic 54 | body params (org-babel-variable-assignments:tcl params))) 55 | (session (org-babel-tcl-initiate-session session))) 56 | (org-babel-reassemble-table 57 | (org-babel-tcl-evaluate session full-body result-type) 58 | (org-babel-pick-name 59 | (cdr (assoc :colname-names params)) (cdr (assoc :colnames params))) 60 | (org-babel-pick-name 61 | (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))) 62 | 63 | (defun org-babel-prep-session:tcl (session params) 64 | "Prepare SESSION according to the header arguments in PARAMS." 65 | (error "Sessions are not supported for Tcl.")) 66 | 67 | (defun org-babel-variable-assignments:tcl (params) 68 | "Return list of tcl statements assigning the block's variables." 69 | (mapcar 70 | (lambda (pair) 71 | (format "set %s %s" 72 | (car pair) 73 | (org-babel-tcl-var-to-tcl (cdr pair)))) 74 | (mapcar #'cdr (org-babel-get-header params :var)))) 75 | 76 | ;; helper functions 77 | 78 | (defun org-babel-tcl-var-to-tcl (var) 79 | "Convert an elisp value to a tcl variable. 80 | The elisp value, VAR, is converted to a string of tcl source code 81 | specifying a var of the same value." 82 | (if (listp var) 83 | (concat "{" (mapconcat #'org-babel-tcl-var-to-tcl var " ") "}") 84 | (format "%s" var))) 85 | 86 | (defvar org-babel-tcl-buffers '(:default . nil)) 87 | 88 | (defun org-babel-tcl-initiate-session (&optional session params) 89 | "Return nil because sessions are not supported by tcl." 90 | nil) 91 | 92 | (defvar org-babel-tcl-wrapper-method 93 | " 94 | proc main {} { 95 | %s 96 | } 97 | 98 | set r [eval main] 99 | set o [open \"%s\" \"w\"]; 100 | puts $o $r 101 | flush $o 102 | close $o 103 | 104 | ") 105 | 106 | (defvar org-babel-tcl-pp-wrapper-method 107 | nil) 108 | 109 | (defun org-babel-tcl-evaluate (session body &optional result-type) 110 | "Pass BODY to the Tcl process in SESSION. 111 | If RESULT-TYPE equals 'output then return a list of the outputs 112 | of the statements in BODY, if RESULT-TYPE equals 'value then 113 | return the value of the last statement in BODY, as elisp." 114 | (when session (error "Sessions are not supported for Tcl.")) 115 | (case result-type 116 | (output (org-babel-eval org-babel-tcl-command body)) 117 | (value (let ((tmp-file (org-babel-temp-file "tcl-"))) 118 | (org-babel-eval 119 | org-babel-tcl-command 120 | (format org-babel-tcl-wrapper-method body 121 | (org-babel-process-file-name tmp-file 'noquote))) 122 | (org-babel-eval-read-file tmp-file))))) 123 | 124 | (provide 'ob-tcl) 125 | 126 | 127 | 128 | ;;; ob-tcl.el ends here 129 | --------------------------------------------------------------------------------