From 92d305092a60c221ea263107dfba335543cac602 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 6 Dec 2011 19:20:21 +0100 Subject: [PATCH 1/3] Fix typos (already fixed in Emacs trunk.) Thanks to Juanma Barranquero for spotting and fixing them in Emacs. --- lisp/ob-ref.el | 2 +- lisp/ob.el | 4 ++-- lisp/org-publish.el | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/ob-ref.el b/lisp/ob-ref.el index 0ce5e8649..fdfff329b 100644 --- a/lisp/ob-ref.el +++ b/lisp/ob-ref.el @@ -73,7 +73,7 @@ "Parse a variable ASSIGNMENT in a header argument. If the right hand side of the assignment has a literal value 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 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 diff --git a/lisp/ob.el b/lisp/ob.el index a8be6d511..5610924c4 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -540,7 +540,7 @@ block." (defun org-babel-expand-body:generic (body params &optional var-lines) "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 called for languages which have not defined their own specific org-babel-expand-body:lang function." @@ -2217,7 +2217,7 @@ appropriate." cell)) (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) (= (length (substring string (match-beginning 0) (match-end 0))) diff --git a/lisp/org-publish.el b/lisp/org-publish.el index 4b4f857e4..1518efe59 100644 --- a/lisp/org-publish.el +++ b/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." (mapc (lambda (project) - ;; Each project uses it's own cache file: + ;; Each project uses its own cache file: (org-publish-initialize-cache (car project)) (let* ((project-plist (cdr project)) From b377e54c6a5831c70d543693e5aaf860953c40ee Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 7 Dec 2011 17:39:51 +0100 Subject: [PATCH 2/3] contrib/lisp/org-export: Extract more properties from tables * contrib/lisp/org-export.el (org-export-table-format-info): Extract column width and and row groups. --- contrib/lisp/org-export.el | 40 +++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el index b5c681f32..3ad5f77b5 100644 --- a/contrib/lisp/org-export.el +++ b/contrib/lisp/org-export.el @@ -2466,23 +2466,31 @@ Return new code as a string." "Extract info from TABLE. Return a plist whose properties and values are: `: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 (insert table) (goto-char 1) (org-table-align) (let ((align (vconcat (mapcar (lambda (c) (if c "r" "l")) 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)) (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 (cond ((not special-column-p) nil) @@ -2490,13 +2498,15 @@ Return a plist whose properties and values are: row) 'special) ((string-match "^[ \t]*| +|" row) special-column-p)))) (cond + ;; Read forced alignment and width information, if any, + ;; and determine final alignment for the table. ((org-table-cookie-line-p row) - ;; Read forced alignment information, if any, and - ;; determine final alignment for the table. (let ((col 0)) (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)) (org-split-string row "[ \t]*|[ \t]*")))) ;; Read column groups information. @@ -2513,7 +2523,9 @@ Return a plist whose properties and values are: ;; Return plist. (list :alignment align :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) "Clean string TABLE from its formatting elements. From da566e9fe20129e8ed2320bc7b355a37f065b923 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 7 Dec 2011 21:03:05 +0100 Subject: [PATCH 3/3] EXPERIMENTAL/org-latex: Fix bug in table transcoding * EXPERIMENTAL/org-latex.el (org-latex-table): Fix confusion between communication channel and table information plists. --- EXPERIMENTAL/org-latex.el | 64 +++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/EXPERIMENTAL/org-latex.el b/EXPERIMENTAL/org-latex.el index 7831b9e2a..61cfa7c5d 100644 --- a/EXPERIMENTAL/org-latex.el +++ b/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) output))) ;; 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 "\\" 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 "\\" attr) + (format "\\\\ \\hline \\endhead \\hline\\multicolumn{%d}{r}{Continued on next page}\\\\ \\endfoot \\endlastfoot" - columns-number)))))))))) + columns-number)))))))))) ;;;; Target