From: Jambunathan K <kjambunathan@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: [PATCH 1/2] Parse and store both col align and col width spec for later use
Date: Mon, 29 Aug 2011 04:10:32 +0530 [thread overview]
Message-ID: <81ipphdusf.fsf_-_@gmail.com> (raw)
In-Reply-To: <81mxetdv47.fsf@gmail.com> (Jambunathan K.'s message of "Mon, 29 Aug 2011 04:03:28 +0530")
[-- Attachment #1: Type: text/plain, Size: 198 bytes --]
> I have worked up a patch which intends to give users more control over
> how tables are formatted. The patch modifies files that I don't own so
> the changes will take sometime to hit the repo.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Parse-and-store-both-col-align-and-col-width-spec-fo.patch --]
[-- Type: text/x-patch, Size: 4655 bytes --]
From 8bae4b059a3063a866260ed2958e6c1e05365901 Mon Sep 17 00:00:00 2001
From: Jambunathan K <kjambunathan@gmail.com>
Date: Mon, 29 Aug 2011 02:00:24 +0530
Subject: [PATCH 1/2] Parse and store both col align and col width spec for later use
* lisp/org-exp.el (org-store-forced-table-alignment): Parse
the column cookie for both alignment and width specification.
Store the resulting value in `org-col-cookies' property.
Retire the previously used `org-forced-aligns' property for
consistency. Renamed local variable `aligns' to `cookies'.
* lisp/org-html.el (org-format-org-table-html): Use
`org-col-cookies'. Renamed local variable forced-aligns to
col-cookies.
This is a preparatory patch. A backend can look at the colwidth
specification and (at it's discretion) use it to control relative
sizes of individual columns in a table. At this moment, it is unclear
whether the widths used to control the display of table in Org buffer
can be overloaded to also control the formatting of table in a
backend.
Refer following discussion with Matt Price:
http://lists.gnu.org/archive/html/emacs-orgmode/2011-08/msg01053.html
---
lisp/org-exp.el | 17 +++++++++++------
lisp/org-html.el | 14 +++++++-------
2 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index f795fbd..7d6bd38 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -1995,23 +1995,28 @@ When it is nil, all comments will be removed."
(defun org-store-forced-table-alignment ()
"Find table lines which force alignment, store the results in properties."
- (let (line cnt aligns)
+ (let (line cnt cookies)
(goto-char (point-min))
- (while (re-search-forward "|[ \t]*<[lrc][0-9]*>[ \t]*|" nil t)
+ (while (re-search-forward "|[ \t]*<\\([lrc]?[0-9]+\\|[lrc]\\)>[ \t]*|"
+ nil t)
;; OK, this looks like a table line with an alignment cookie
(org-if-unprotected
(setq line (buffer-substring (point-at-bol) (point-at-eol)))
(when (and (org-at-table-p)
(org-table-cookie-line-p line))
- (setq cnt 0 aligns nil)
+ (setq cnt 0 cookies nil)
(mapc
(lambda (x)
(setq cnt (1+ cnt))
- (if (string-match "\\`<\\([lrc]\\)" x)
- (push (cons cnt (downcase (match-string 1 x))) aligns)))
+ (when (string-match "\\`<\\([lrc]\\)?\\([0-9]+\\)?>\\'" x)
+ (let ((align (and (match-end 1)
+ (downcase (match-string 1 x))))
+ (width (and (match-end 2)
+ (string-to-number (match-string 2 x)))))
+ (push (cons cnt (list align width)) cookies))))
(org-split-string line "[ \t]*|[ \t]*"))
(add-text-properties (org-table-begin) (org-table-end)
- (list 'org-forced-aligns aligns))))
+ (list 'org-col-cookies cookies))))
(goto-char (point-at-eol)))))
(defun org-export-remove-special-table-lines ()
diff --git a/lisp/org-html.el b/lisp/org-html.el
index 28a0e8f..a6e748a 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -1979,8 +1979,8 @@ for formatting. This is required for the DocBook exporter."
(let* ((caption (org-find-text-property-in-string 'org-caption (car lines)))
(label (org-find-text-property-in-string 'org-label (car lines)))
- (forced-aligns (org-find-text-property-in-string 'org-forced-aligns
- (car lines)))
+ (col-cookies (org-find-text-property-in-string 'org-col-cookies
+ (car lines)))
(attributes (org-find-text-property-in-string 'org-attributes
(car lines)))
(html-table-tag (org-export-splice-attributes
@@ -1993,9 +1993,9 @@ for formatting. This is required for the DocBook exporter."
tbopen line fields html gr colgropen rowstart rowend
ali align aligns n)
(setq caption (and caption (org-html-do-expand caption)))
- (when (and forced-aligns org-table-clean-did-remove-column)
- (setq forced-aligns
- (mapcar (lambda (x) (cons (1- (car x)) (cdr x))) forced-aligns)))
+ (when (and col-cookies org-table-clean-did-remove-column)
+ (setq col-cookies
+ (mapcar (lambda (x) (cons (1- (car x)) (cdr x))) col-cookies)))
(if splice (setq head nil))
(unless splice (push (if head "<thead>" "<tbody>") html))
(setq tbopen t)
@@ -2056,8 +2056,8 @@ for formatting. This is required for the DocBook exporter."
(lambda (x)
(setq gr (pop org-table-colgroup-info)
i (1+ i)
- align (if (assoc i forced-aligns)
- (cdr (assoc (cdr (assoc i forced-aligns))
+ align (if (nth 1 (assoc i col-cookies))
+ (cdr (assoc (nth 1 (assoc i col-cookies))
'(("l" . "left") ("r" . "right")
("c" . "center"))))
(if (> (/ (float x) nline)
--
1.7.2.3
next prev parent reply other threads:[~2011-08-28 22:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-25 15:12 org->odt/html table export: adjusting default behaviour? Matt Price
2011-08-25 15:36 ` Matt Price
2011-08-25 21:40 ` Jambunathan K
2011-08-26 14:24 ` Matt Price
2011-08-28 22:33 ` Jambunathan K
2011-08-28 22:40 ` Jambunathan K [this message]
2011-08-28 22:41 ` [PATCH 2/2] org-odt.el: Put table style and col sizes under direct user control Jambunathan K
2011-09-14 9:56 ` [odt] Support for table templates (was Re: org->odt/html table export: adjusting default behaviour?) Jambunathan K
2011-08-25 22:01 ` org->odt/html table export: adjusting default behaviour? Jambunathan K
2011-08-26 14:13 ` Matt Price
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=81ipphdusf.fsf_-_@gmail.com \
--to=kjambunathan@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.