Browse Source

Merge branch 'master' of orgmode.org:org-mode

Carsten Dominik 12 years ago
parent
commit
1a527400da
6 changed files with 166 additions and 66 deletions
  1. 9 10
      doc/org.texi
  2. 87 0
      lisp/ob-ebnf.el
  3. 16 24
      lisp/org-element.el
  4. 2 1
      lisp/org.el
  5. 33 5
      lisp/ox-latex.el
  6. 19 26
      testing/lisp/test-org-element.el

+ 9 - 10
doc/org.texi

@@ -10115,13 +10115,11 @@ the sun is R_@{sun@} = 6.96 x 10^8 m.
 @end example
 @end example
 
 
 @vindex org-use-sub-superscripts
 @vindex org-use-sub-superscripts
-To avoid interpretation as raised or lowered text, you can quote @samp{^} and
-@samp{_} with a backslash: @samp{\^} and @samp{\_}.  If you write a text
-where the underscore is often used in a different context, Org's convention
-to always interpret these as subscripts can get in your way.  Configure the
-variable @code{org-use-sub-superscripts} to change this convention.  For
-example, when setting this variable to @code{@{@}}, @samp{a_b} will not be
-interpreted as a subscript, but @samp{a_@{b@}} will.
+If you write a text where the underscore is often used in a different
+context, Org's convention to always interpret these as subscripts can get in
+your way.  Configure the variable @code{org-use-sub-superscripts} to change
+this convention.  For example, when setting this variable to @code{@{@}},
+@samp{a_b} will not be interpreted as a subscript, but @samp{a_@{b@}} will.
 
 
 @table @kbd
 @table @kbd
 @kindex C-c C-x \
 @kindex C-c C-x \
@@ -10847,9 +10845,10 @@ data between frames, or to properly close a @code{column} environment.
 Headlines also support @code{BEAMER_ACT} and @code{BEAMER_OPT} properties.
 Headlines also support @code{BEAMER_ACT} and @code{BEAMER_OPT} properties.
 The former is translated as an overlay/action specification, or a default
 The former is translated as an overlay/action specification, or a default
 overlay specification when enclosed within square brackets.  The latter
 overlay specification when enclosed within square brackets.  The latter
-specifies options for the current frame.  Though, @code{fragile} option is
-added automatically if it contains source code that uses any verbatim
-environment.
+specifies options@footnote{The @code{fragile} option is added automatically
+if it contains code that requires a verbatim environment, though.} for the
+current frame or block.  The export back-end will automatically wrap
+properties within angular or square brackets when appropriate.
 
 
 @cindex property, BEAMER_COL
 @cindex property, BEAMER_COL
 Moreover, headlines handle the @code{BEAMER_COL} property.  Its value should
 Moreover, headlines handle the @code{BEAMER_COL} property.  Its value should

+ 87 - 0
lisp/ob-ebnf.el

@@ -0,0 +1,87 @@
+;;; ob-ebnf.el --- org-babel functions for ebnf evaluation
+
+;; Copyright (C) your name here
+
+;; Author: Michael Gauland
+;; Keywords: literate programming, reproducible research
+;; Homepage: http://orgmode.org
+;; Version: 1.00
+
+;;; License:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+
+;;; Org-Babel support for using ebnf2ps to generate encapsulated postscript
+;;; railroad diagrams. It recogises these arguments:
+;;;
+;;;     :file is required; it must include the extension '.eps.' All the rules
+;;;           in the block will be drawn in the same file. This is done by
+;;;           inserting a '[<file>' comment at the start of the block (see the
+;;;           documentation for ebnf-eps-buffer for more information).
+;;;
+;;;     :style specifies a value in ebnf-style-database. This provides the
+;;;            ability to customise the output. The style can also specify the
+;;;            gramnmar syntax (by setting ebnf-syntax); note that only ebnf,
+;;;            iso-ebnf, and yacc are supported by this file.
+
+;;; Requirements:
+
+;;; Code:
+(require 'ob)
+(require 'ebnf2ps)
+
+;; optionally declare default header arguments for this language
+(defvar org-babel-default-header-args:ebnf '((:style . nil)))
+
+;; Use ebnf-eps-buffer to produce an encapsulated postscript file.
+;;
+(defun org-babel-execute:ebnf (body params)
+  "Execute a block of Ebnf code with org-babel.  This function is
+called by `org-babel-execute-src-block'"
+  (save-excursion
+    (let* ((dest-file (cdr (assoc :file params)))
+	   (dest-dir (file-name-directory dest-file))
+	   (dest-root (file-name-sans-extension
+		       (file-name-nondirectory dest-file)))
+           (dest-ext  (file-name-extension dest-file))
+	   (style (cdr (assoc :style params)))
+	   (current-dir default-directory)
+	   (result nil))
+      (with-temp-buffer
+	(when style (ebnf-push-style style))
+	(let 
+	    ((comment-format
+	      (cond ((string= ebnf-syntax 'yacc) "/*%s*/")
+		    ((string= ebnf-syntax 'ebnf) ";%s")
+		    ((string= ebnf-syntax 'iso-ebnf) "(*%s*)")
+		    (t (setq result
+			     (format "EBNF error: format %s not supported."
+				     ebnf-syntax))))))
+	  (setq ebnf-eps-prefix dest-dir)
+	  (insert (format comment-format (format "[%s" dest-root)))
+	  (newline)
+	  (insert body)
+	  (newline)
+	  (insert (format comment-format (format "]%s" dest-root)))
+	  (ebnf-eps-buffer)
+	  (when style (ebnf-pop-style))))
+      result
+      )))
+
+(provide 'ob-ebnf)
+;;; ob-ebnf.el ends here

+ 16 - 24
lisp/org-element.el

@@ -2706,16 +2706,12 @@ Return value is a cons cell whose CAR is `entity' or
 `latex-fragment' and CDR is beginning position."
 `latex-fragment' and CDR is beginning position."
   (save-excursion
   (save-excursion
     (unless (bolp) (backward-char))
     (unless (bolp) (backward-char))
-    (let ((matchers
-	   (remove "begin" (plist-get org-format-latex-options :matchers)))
+    (let ((matchers (cdr org-latex-regexps))
 	  ;; ENTITY-RE matches both LaTeX commands and Org entities.
 	  ;; ENTITY-RE matches both LaTeX commands and Org entities.
 	  (entity-re
 	  (entity-re
 	   "\\\\\\(there4\\|sup[123]\\|frac[13][24]\\|[a-zA-Z]+\\)\\($\\|{}\\|[^[:alpha:]]\\)"))
 	   "\\\\\\(there4\\|sup[123]\\|frac[13][24]\\|[a-zA-Z]+\\)\\($\\|{}\\|[^[:alpha:]]\\)"))
       (when (re-search-forward
       (when (re-search-forward
-	     (concat (mapconcat (lambda (e) (nth 1 (assoc e org-latex-regexps)))
-				matchers "\\|")
-		     "\\|" entity-re)
-	     nil t)
+	     (concat (mapconcat #'cadr matchers "\\|") "\\|" entity-re) nil t)
 	(goto-char (match-beginning 0))
 	(goto-char (match-beginning 0))
 	(if (looking-at entity-re)
 	(if (looking-at entity-re)
 	    ;; Determine if it's a real entity or a LaTeX command.
 	    ;; Determine if it's a real entity or a LaTeX command.
@@ -2725,12 +2721,9 @@ Return value is a cons cell whose CAR is `entity' or
 	  ;; Determine its type to get the correct beginning position.
 	  ;; Determine its type to get the correct beginning position.
 	  (cons 'latex-fragment
 	  (cons 'latex-fragment
 		(catch 'return
 		(catch 'return
-		  (mapc (lambda (e)
-			  (when (looking-at (nth 1 (assoc e org-latex-regexps)))
-			    (throw 'return
-				   (match-beginning
-				    (nth 2 (assoc e org-latex-regexps))))))
-			matchers)
+		  (dolist (e matchers)
+		    (when (looking-at (nth 1 e))
+		      (throw 'return (match-beginning (nth 2 e)))))
 		  (point))))))))
 		  (point))))))))
 
 
 
 
@@ -2977,29 +2970,28 @@ CONTENTS is the contents of the object."
 ;;;; Latex Fragment
 ;;;; Latex Fragment
 
 
 (defun org-element-latex-fragment-parser ()
 (defun org-element-latex-fragment-parser ()
-  "Parse latex fragment at point.
+  "Parse LaTeX fragment at point.
 
 
 Return a list whose CAR is `latex-fragment' and CDR a plist with
 Return a list whose CAR is `latex-fragment' and CDR a plist with
 `:value', `:begin', `:end', and `:post-blank' as keywords.
 `:value', `:begin', `:end', and `:post-blank' as keywords.
 
 
-Assume point is at the beginning of the latex fragment."
+Assume point is at the beginning of the LaTeX fragment."
   (save-excursion
   (save-excursion
     (let* ((begin (point))
     (let* ((begin (point))
 	   (substring-match
 	   (substring-match
 	    (catch 'exit
 	    (catch 'exit
-	      (mapc (lambda (e)
-		      (let ((latex-regexp (nth 1 (assoc e org-latex-regexps))))
-			(when (or (looking-at latex-regexp)
-				  (and (not (bobp))
-				       (save-excursion
-					 (backward-char)
-					 (looking-at latex-regexp))))
-			  (throw 'exit (nth 2 (assoc e org-latex-regexps))))))
-		    (plist-get org-format-latex-options :matchers))
+	      (dolist (e (cdr org-latex-regexps))
+		(let ((latex-regexp (nth 1 e)))
+		  (when (or (looking-at latex-regexp)
+			    (and (not (bobp))
+				 (save-excursion
+				   (backward-char)
+				   (looking-at latex-regexp))))
+		    (throw 'exit (nth 2 e)))))
 	      ;; None found: it's a macro.
 	      ;; None found: it's a macro.
 	      (looking-at "\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\\|\\({[^{}\n]*}\\)\\)*")
 	      (looking-at "\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\\|\\({[^{}\n]*}\\)\\)*")
 	      0))
 	      0))
-	   (value (match-string-no-properties substring-match))
+	   (value (org-match-string-no-properties substring-match))
 	   (post-blank (progn (goto-char (match-end substring-match))
 	   (post-blank (progn (goto-char (match-end substring-match))
 			      (skip-chars-forward " \t")))
 			      (skip-chars-forward " \t")))
 	   (end (point)))
 	   (end (point)))

+ 2 - 1
lisp/org.el

@@ -262,7 +262,8 @@ requirements) is loaded."
 		 (const :tag "Shell Script" sh)
 		 (const :tag "Shell Script" sh)
 		 (const :tag "Shen" shen)
 		 (const :tag "Shen" shen)
 		 (const :tag "Sql" sql)
 		 (const :tag "Sql" sql)
-		 (const :tag "Sqlite" sqlite))
+		 (const :tag "Sqlite" sqlite)
+		 (const :tag "ebnf2ps" ebnf2ps))
 		:value-type (boolean :tag "Activate" :value t)))
 		:value-type (boolean :tag "Activate" :value t)))
 
 
 ;;;; Customization variables
 ;;;; Customization variables

+ 33 - 5
lisp/ox-latex.el

@@ -525,6 +525,19 @@ When nil, no transformation is made."
 	  (string :tag "Format string")
 	  (string :tag "Format string")
 	  (const :tag "No formatting")))
 	  (const :tag "No formatting")))
 
 
+(defcustom org-latex-longtable-continued-on "Continued on next page"
+  "String to indicate table continued on next page."
+  :group 'org-export-latex
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
+(defcustom org-latex-longtable-continued-from "Continued from previous page"
+  "String to indicate table continued from previous page."
+  :group 'org-export-latex
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
 
 
 ;;;; Text markup
 ;;;; Text markup
 
 
@@ -691,8 +704,8 @@ a list containing two strings: the name of the option, and the
 value.  For example,
 value.  For example,
 
 
   (setq org-latex-listings-options
   (setq org-latex-listings-options
-    '((\"basicstyle\" \"\\small\")
-      (\"keywordstyle\" \"\\color{black}\\bfseries\\underbar\")))
+    '((\"basicstyle\" \"\\\\small\")
+      (\"keywordstyle\" \"\\\\color{black}\\\\bfseries\\\\underbar\")))
 
 
 will typeset the code in a small size font with underlined, bold
 will typeset the code in a small size font with underlined, bold
 black keywords.
 black keywords.
@@ -2621,18 +2634,33 @@ a communication channel."
 	     ((and (memq 'top borders) (memq 'above borders)) "\\hline\n"))
 	     ((and (memq 'top borders) (memq 'above borders)) "\\hline\n"))
        contents "\\\\\n"
        contents "\\\\\n"
        (cond
        (cond
-	;; Special case for long tables. Define header and footers.
+	;; Special case for long tables.  Define header and footers.
 	((and longtablep (org-export-table-row-ends-header-p table-row info))
 	((and longtablep (org-export-table-row-ends-header-p table-row info))
 	 (format "%s
 	 (format "%s
+\\endfirsthead
+\\multicolumn{%d}{l}{%s} \\\\
+%s
+%s \\\\\n
+%s
 \\endhead
 \\endhead
-%s\\multicolumn{%d}{r}{Continued on next page} \\\\
+%s\\multicolumn{%d}{r}{%s} \\\\
 \\endfoot
 \\endfoot
 \\endlastfoot"
 \\endlastfoot"
+		 (if booktabsp "\\midrule" "\\hline")
+		 (cdr (org-export-table-dimensions
+		       (org-export-get-parent-table table-row) info))
+		 org-latex-longtable-continued-from
+		 (cond ((and booktabsp (memq 'top borders)) "\\toprule\n")
+		       ((and (memq 'top borders)
+			     (memq 'above borders)) "\\hline\n")
+		       (t ""))
+		 contents
 		 (if booktabsp "\\midrule" "\\hline")
 		 (if booktabsp "\\midrule" "\\hline")
 		 (if booktabsp "\\midrule" "\\hline")
 		 (if booktabsp "\\midrule" "\\hline")
 		 ;; Number of columns.
 		 ;; Number of columns.
 		 (cdr (org-export-table-dimensions
 		 (cdr (org-export-table-dimensions
-		       (org-export-get-parent-table table-row) info))))
+		       (org-export-get-parent-table table-row) info))
+		 org-latex-longtable-continued-on))
 	;; When BOOKTABS are activated enforce bottom rule even when
 	;; When BOOKTABS are activated enforce bottom rule even when
 	;; no hline was specifically marked.
 	;; no hline was specifically marked.
 	((and booktabsp (memq 'bottom borders)) "\\bottomrule")
 	((and booktabsp (memq 'bottom borders)) "\\bottomrule")

+ 19 - 26
testing/lisp/test-org-element.el

@@ -1155,32 +1155,25 @@ e^{i\\pi}+1=0
 
 
 (ert-deftest test-org-element/latex-fragment-parser ()
 (ert-deftest test-org-element/latex-fragment-parser ()
   "Test `latex-fragment' parser."
   "Test `latex-fragment' parser."
-  (let ((org-latex-regexps
-	 '(("begin" "^[ 	]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^]+?\\\\end{\\2}\\)" 1 t)
-	   ("$1" "\\([^$]\\|^\\)\\(\\$[^ 	
\n,;.$]\\$\\)\\([- 	.,?;:'\")]\\|$\\)" 2 nil)
-	   ("$" "\\([^$]\\|^\\)\\(\\(\\$\\([^ 	
\n,;.$][^$\n
]*?\\(\n[^$\n
]*?\\)\\{0,2\\}[^ 	
\n,.$]\\)\\$\\)\\)\\([- 	.,?;:'\")]\\|$\\)" 2 nil)
-	   ("\\(" "\\\\([^]*?\\\\)" 0 nil)
-	   ("\\[" "\\\\\\[[^]*?\\\\\\]" 0 nil)
-	   ("$$" "\\$\\$[^]*?\\$\\$" 0 nil))))
-    (should
-     (org-test-with-temp-text "$a$"
-       (org-element-map (org-element-parse-buffer) 'latex-fragment 'identity)))
-    (should
-     (org-test-with-temp-text "$$a$$"
-       (org-element-map (org-element-parse-buffer) 'latex-fragment 'identity)))
-    (should
-     (org-test-with-temp-text "\\(a\\)"
-       (org-element-map (org-element-parse-buffer) 'latex-fragment 'identity)))
-    (should
-     (org-test-with-temp-text "\\[a\\]"
-       (org-element-map
-	(org-element-parse-buffer) 'latex-fragment 'identity)))
-    ;; Test fragment at the beginning of an item.
-    (should
-     (eq 'latex-fragment
-	 (org-test-with-temp-text "- $x$"
-	   (progn (search-forward "$")
-		  (org-element-type (org-element-context))))))))
+  (should
+   (org-test-with-temp-text "$a$"
+     (org-element-map (org-element-parse-buffer) 'latex-fragment 'identity)))
+  (should
+   (org-test-with-temp-text "$$a$$"
+     (org-element-map (org-element-parse-buffer) 'latex-fragment 'identity)))
+  (should
+   (org-test-with-temp-text "\\(a\\)"
+     (org-element-map (org-element-parse-buffer) 'latex-fragment 'identity)))
+  (should
+   (org-test-with-temp-text "\\[a\\]"
+     (org-element-map
+	 (org-element-parse-buffer) 'latex-fragment 'identity)))
+  ;; Test fragment at the beginning of an item.
+  (should
+   (eq 'latex-fragment
+       (org-test-with-temp-text "- $x$"
+	 (progn (search-forward "$")
+		(org-element-type (org-element-context)))))))
 
 
 
 
 ;;;; Line Break
 ;;;; Line Break