>From 046a2d1793c50c99b5b58b3874540632513e4562 Mon Sep 17 00:00:00 2001 From: Jambunathan K
Date: Mon, 29 Aug 2011 02:33:17 +0530 Subject: [PATCH 2/2] org-odt.el: Put table style and col sizes under direct user control * contrib/lisp/org-lparse.el (org-lparse-table-get-colalign-info): Renamed `org-forced-aligns' to `org-col-cookies'. Renamed local variable `forced-aligns' to `col-cookies'. (org-lparse-format-table-row): With the introduction of `org-col-cookies' property the internal structure of `org-lparse-table-colalign-info' has changed. Do the right thing while setting up col alignment. Pass on the colwidth property as horiz-span arg of `TABLE-CELL' callback. * contrib/lisp/org-odt.el (org-odt-begin-table): Let the table style be settable throught #+ATTR_ODT line. By default tables are configured to occupy 90% of paper width. This is too big for smaller tables. For aesthetic reasons, a user might prefer that such tables of shorter width and thus specify a different style. (org-odt-end-table, org-odt-format-table-cell): Honor colwidth specification. * contrib/lisp/org-xhtml.el (org-xhtml-format-table-cell): Fix signature as mandated by changes in TABLE-CELL callback. See comments in the earlier patch. See also http://lists.gnu.org/archive/html/emacs-orgmode/2011-08/msg01053.html --- contrib/lisp/org-lparse.el | 36 ++++++++++++--------- contrib/lisp/org-odt.el | 75 ++++++++++++++++++++++++++----------------- contrib/lisp/org-xhtml.el | 2 +- 3 files changed, 66 insertions(+), 47 deletions(-) diff --git a/contrib/lisp/org-lparse.el b/contrib/lisp/org-lparse.el index fd0488b..b176378 100755 --- a/contrib/lisp/org-lparse.el +++ b/contrib/lisp/org-lparse.el @@ -1301,13 +1301,12 @@ version." (org-lparse-format-table-table lines)))) (defun org-lparse-table-get-colalign-info (lines) - (let ((forced-aligns (org-find-text-property-in-string - 'org-forced-aligns (car lines)))) - (when (and forced-aligns org-table-clean-did-remove-column) - (setq forced-aligns - (mapcar (lambda (x) (cons (1- (car x)) (cdr x))) forced-aligns))) - - forced-aligns)) + (let ((col-cookies (org-find-text-property-in-string + 'org-col-cookies (car lines)))) + (when (and col-cookies org-table-clean-did-remove-column) + (setq col-cookies + (mapcar (lambda (x) (cons (1- (car x)) (cdr x))) col-cookies))) + col-cookies)) (defvar org-lparse-table-style) (defvar org-lparse-table-ncols) @@ -1945,12 +1944,13 @@ See `org-xhtml-entity-format-callbacks-alist' for more information." (make-vector org-lparse-table-ncols nil)) (let ((c -1)) (while (< (incf c) org-lparse-table-ncols) - (let ((cookie (cdr (assoc (1+ c) org-lparse-table-colalign-info)))) + (let* ((col-cookie (cdr (assoc (1+ c) org-lparse-table-colalign-info))) + (align (nth 0 col-cookie))) (setf (aref org-lparse-table-colalign-vector c) (cond - ((string= cookie "l") "left") - ((string= cookie "r") "right") - ((string= cookie "c") "center") + ((string= align "l") "left") + ((string= align "r") "right") + ((string= align "c") "center") (t nil)))))))) (incf org-lparse-table-rownum) (let ((i -1)) @@ -1961,11 +1961,15 @@ See `org-xhtml-entity-format-callbacks-alist' for more information." (when (and (string= x "") text-for-empty-fields) (setq x text-for-empty-fields)) (incf i) - (and org-lparse-table-is-styled - (< i org-lparse-table-ncols) - (string-match org-table-number-regexp x) - (incf (aref org-lparse-table-num-numeric-items-per-column i))) - (org-lparse-format 'TABLE-CELL x org-lparse-table-rownum i)) + (let (col-cookie horiz-span) + (when org-lparse-table-is-styled + (when (and (< i org-lparse-table-ncols) + (string-match org-table-number-regexp x)) + (incf (aref org-lparse-table-num-numeric-items-per-column i))) + (setq col-cookie (cdr (assoc (1+ i) org-lparse-table-colalign-info)) + horiz-span (nth 1 col-cookie))) + (org-lparse-format + 'TABLE-CELL x org-lparse-table-rownum i (or horiz-span 0)))) fields "\n")))) (defun org-lparse-get (what &optional opt-plist) diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index a5b2d96..491ed44 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -644,15 +644,22 @@ PUB-DIR is set, use this as the publishing directory." (org-lparse-insert-tag "