Browse Source

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

Carsten Dominik 14 years ago
parent
commit
4a48a04905
5 changed files with 62 additions and 50 deletions
  1. 32 32
      EXPERIMENTAL/org-latex.el
  2. 26 14
      contrib/lisp/org-export.el
  3. 1 1
      lisp/ob-ref.el
  4. 2 2
      lisp/ob.el
  5. 1 1
      lisp/org-publish.el

+ 32 - 32
EXPERIMENTAL/org-latex.el

@@ -1698,43 +1698,43 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
             (format "\\begin{center}\n%s\n\\end{center}" output)
             (format "\\begin{center}\n%s\n\\end{center}" output)
           output)))
           output)))
      ;; Case 3: Standard table.
      ;; Case 3: Standard table.
-     (t (let* (
-               (info (org-export-table-format-info raw-table))
-               (clean-table (org-export-clean-table
-                             raw-table (plist-get info :special-column-p)))
-               (columns-number (length (plist-get info :alignment))))
-          ;; Convert ROWS to send them to `orgtbl-to-latex'.  In
-          ;; particular, send each cell to
-          ;; `org-element-parse-secondary-string' to expand any Org
-          ;; object within.  Eventually, flesh the format string out with
-          ;; the table.
-          (format (org-latex-table--format-string table info)
-                  (orgtbl-to-latex
-                   (mapcar
-                    (lambda (row)
-                      (if (string-match org-table-hline-regexp row)
-                          'hline
-                        (mapcar
-                         (lambda (cell)
-                           (org-export-secondary-string
-                            (org-element-parse-secondary-string
-                             cell
-                             (cdr (assq 'table org-element-string-restrictions)))
-                            'latex info))
-                         (org-split-string row "[ \t]*|[ \t]*"))))
-                    (org-split-string clean-table "\n"))
-                   `(:tstart nil :tend nil
-                             ;; Longtable environment requires specific
-                             ;; header line end.
-                             :hlend ,(and attr
-                                          (string-match "\\<longtable\\>" attr)
-                                          (format "\\\\
+     (t
+      (let* ((table-info (org-export-table-format-info raw-table))
+	     (clean-table (org-export-clean-table
+			   raw-table (plist-get table-info :special-column-p)))
+	     (columns-number (length (plist-get table-info :alignment))))
+	;; Convert ROWS to send them to `orgtbl-to-latex'.  In
+	;; particular, send each cell to
+	;; `org-element-parse-secondary-string' to expand any Org
+	;; object within.  Eventually, flesh the format string out with
+	;; the table.
+	(format (org-latex-table--format-string table table-info)
+		(orgtbl-to-latex
+		 (mapcar
+		  (lambda (row)
+		    (if (string-match org-table-hline-regexp row)
+			'hline
+		      (mapcar
+		       (lambda (cell)
+			 (org-export-secondary-string
+			  (org-element-parse-secondary-string
+			   cell
+			   (cdr (assq 'table org-element-string-restrictions)))
+			  'latex info))
+		       (org-split-string row "[ \t]*|[ \t]*"))))
+		  (org-split-string clean-table "\n"))
+		 `(:tstart nil :tend nil
+			   ;; Longtable environment requires specific
+			   ;; header line end.
+			   :hlend ,(and attr
+					(string-match "\\<longtable\\>" attr)
+					(format "\\\\
 \\hline
 \\hline
 \\endhead
 \\endhead
 \\hline\\multicolumn{%d}{r}{Continued on next page}\\\\
 \\hline\\multicolumn{%d}{r}{Continued on next page}\\\\
 \\endfoot
 \\endfoot
 \\endlastfoot"
 \\endlastfoot"
-                                                  columns-number))))))))))
+						columns-number))))))))))
 
 
 
 
 ;;;; Target
 ;;;; Target

+ 26 - 14
contrib/lisp/org-export.el

@@ -2466,23 +2466,31 @@ Return new code as a string."
   "Extract info from TABLE.
   "Extract info from TABLE.
 Return a plist whose properties and values are:
 Return a plist whose properties and values are:
 `:alignment'        vector of strings among \"r\", \"l\" and \"c\",
 `:alignment'        vector of strings among \"r\", \"l\" and \"c\",
-`:column-groups'    vector of symbols among `start', `end', `startend',
-`:special-column-p' boolean."
+`:column-groups'    vector of symbols among `start', `end', `start-end',
+`:row-groups'       list of integers representing row groups.
+`:special-column-p' non-nil if table has a special column.
+`:width'            vector of integers representing desired width of
+                    current column, or nil."
   (with-temp-buffer
   (with-temp-buffer
     (insert table)
     (insert table)
     (goto-char 1)
     (goto-char 1)
     (org-table-align)
     (org-table-align)
     (let ((align (vconcat (mapcar (lambda (c) (if c "r" "l"))
     (let ((align (vconcat (mapcar (lambda (c) (if c "r" "l"))
                                   org-table-last-alignment)))
                                   org-table-last-alignment)))
-          (colgroups (make-vector (length org-table-last-alignment) nil))
+          (width (make-vector (length org-table-last-alignment) nil))
+	  (colgroups (make-vector (length org-table-last-alignment) nil))
+	  (row-group 0)
+	  (rowgroups)
           (special-column-p 'empty))
           (special-column-p 'empty))
       (mapc (lambda (row)
       (mapc (lambda (row)
-              ;; Determine if a special column is present by looking
-              ;; for special markers in the first column.  More
-              ;; accurately, the first column is considered special if
-              ;; it only contains special markers and, maybe, empty
-              ;; cells.
-              (unless (string-match "^[ \t]*|[-+]+|[ \t]*$" row)
+              (if (string-match "^[ \t]*|[-+]+|[ \t]*$" row)
+		  (incf row-group)
+		(push row-group rowgroups)
+		;; Determine if a special column is present by looking
+		;; for special markers in the first column.  More
+		;; accurately, the first column is considered special
+		;; if it only contains special markers and, maybe,
+		;; empty cells.
                 (setq special-column-p
                 (setq special-column-p
                       (cond
                       (cond
                        ((not special-column-p) nil)
                        ((not special-column-p) nil)
@@ -2490,13 +2498,15 @@ Return a plist whose properties and values are:
                                       row) 'special)
                                       row) 'special)
                        ((string-match "^[ \t]*| +|" row) special-column-p))))
                        ((string-match "^[ \t]*| +|" row) special-column-p))))
               (cond
               (cond
+	       ;; Read forced alignment and width information, if any,
+	       ;; and determine final alignment for the table.
                ((org-table-cookie-line-p row)
                ((org-table-cookie-line-p row)
-                ;; Read forced alignment information, if any, and
-                ;; determine final alignment for the table.
                 (let ((col 0))
                 (let ((col 0))
                   (mapc (lambda (field)
                   (mapc (lambda (field)
-                          (when (string-match "<\\([lrc]\\)[0-9]*>" field)
-                            (aset align col (match-string 1 field)))
+                          (when (string-match "<\\([lrc]\\)\\([0-9]+\\)?>" field)
+                            (aset align col (match-string 1 field))
+			    (aset width col (let ((w (match-string 2 field)))
+					      (and w (string-to-number w)))))
                           (incf col))
                           (incf col))
                         (org-split-string row "[ \t]*|[ \t]*"))))
                         (org-split-string row "[ \t]*|[ \t]*"))))
                ;; Read column groups information.
                ;; Read column groups information.
@@ -2513,7 +2523,9 @@ Return a plist whose properties and values are:
       ;; Return plist.
       ;; Return plist.
       (list :alignment align
       (list :alignment align
             :column-groups colgroups
             :column-groups colgroups
-            :special-column-p (eq special-column-p 'special)))))
+	    :row-groups (reverse rowgroups)
+            :special-column-p (eq special-column-p 'special)
+	    :width width))))
 
 
 (defun org-export-clean-table (table specialp)
 (defun org-export-clean-table (table specialp)
   "Clean string TABLE from its formatting elements.
   "Clean string TABLE from its formatting elements.

+ 1 - 1
lisp/ob-ref.el

@@ -73,7 +73,7 @@
   "Parse a variable ASSIGNMENT in a header argument.
   "Parse a variable ASSIGNMENT in a header argument.
 If the right hand side of the assignment has a literal value
 If the right hand side of the assignment has a literal value
 return that value, otherwise interpret as a reference to an
 return that value, otherwise interpret as a reference to an
-external resource and find it's value using
+external resource and find its value using
 `org-babel-ref-resolve'.  Return a list with two elements.  The
 `org-babel-ref-resolve'.  Return a list with two elements.  The
 first element of the list will be the name of the variable, and
 first element of the list will be the name of the variable, and
 the second will be an emacs-lisp representation of the value of
 the second will be an emacs-lisp representation of the value of

+ 2 - 2
lisp/ob.el

@@ -540,7 +540,7 @@ block."
 
 
 (defun org-babel-expand-body:generic (body params &optional var-lines)
 (defun org-babel-expand-body:generic (body params &optional var-lines)
   "Expand BODY with PARAMS.
   "Expand BODY with PARAMS.
-Expand a block of code with org-babel according to it's header
+Expand a block of code with org-babel according to its header
 arguments.  This generic implementation of body expansion is
 arguments.  This generic implementation of body expansion is
 called for languages which have not defined their own specific
 called for languages which have not defined their own specific
 org-babel-expand-body:lang function."
 org-babel-expand-body:lang function."
@@ -2217,7 +2217,7 @@ appropriate."
     cell))
     cell))
 
 
 (defun org-babel-number-p (string)
 (defun org-babel-number-p (string)
-  "If STRING represents a number return it's value."
+  "If STRING represents a number return its value."
   (if (and (string-match "^-?[0-9]*\\.?[0-9]*$" string)
   (if (and (string-match "^-?[0-9]*\\.?[0-9]*$" string)
            (= (length (substring string (match-beginning 0)
            (= (length (substring string (match-beginning 0)
 				 (match-end 0)))
 				 (match-end 0)))

+ 1 - 1
lisp/org-publish.el

@@ -717,7 +717,7 @@ If :auto-sitemap is set, publish the sitemap too.
 If :makeindex is set, also produce a file theindex.org."
 If :makeindex is set, also produce a file theindex.org."
   (mapc
   (mapc
    (lambda (project)
    (lambda (project)
-     ;; Each project uses it's own cache file:
+     ;; Each project uses its own cache file:
      (org-publish-initialize-cache (car project))
      (org-publish-initialize-cache (car project))
      (let*
      (let*
 	 ((project-plist (cdr project))
 	 ((project-plist (cdr project))