[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] [PATCH 2/4] Support last-line specializers.
From: |
Jason Riedy |
Subject: |
[Orgmode] [PATCH 2/4] Support last-line specializers. |
Date: |
Wed, 16 Apr 2008 14:39:52 -0700 |
Each of lstart, lend, and lfmt permits a last-line specialization
called llstart, etc. with corresponding heading versions.
Signed-off-by: Jason Riedy <address@hidden>
---
ChangeLog | 10 ++++++++++
lisp/org-table.el | 32 ++++++++++++++++++++++++++++----
2 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4569d3a..13980bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2008-04-15 Jason Riedy <address@hidden>
+ * lisp/org-table.el (*orgtbl-llfmt*, *orgtbl-llstart*)
+ (*orgtbl-llend*): Dynamic variables for last-line formatting.
+ (orgtbl-format-section): Shift formatting to support detecting the
+ last line and formatting it specially.
+ (orgtbl-to-generic): Document :ll* formats. Set to the non-ll
+ formats unless overridden.
+ (orgtbl-to-latex): Suggest using :llend to suppress the final \\.
+
+2008-04-15 Jason Riedy <address@hidden>
+
* lisp/org-table.el (*orgtbl-table*, *orgtbl-rtn*): Dynamically
bound variables to hold the input collection of lines and output
formatted text.
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 3cc70c1..2eb9938 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -3613,8 +3613,11 @@ First element has index 0, or I0 if given."
(defvar *orgtbl-fmt* nil "Format for each entry")
(defvar *orgtbl-efmt* nil "Format for numbers")
(defvar *orgtbl-lfmt* nil "Format for an entire line, overrides fmt")
+(defvar *orgtbl-llfmt* nil "Specializes lfmt for the last row")
(defvar *orgtbl-lstart* nil "Text starting a row")
+(defvar *orgtbl-llstart* nil "Specializes lstart for the last row")
(defvar *orgtbl-lend* nil "Text ending a row")
+(defvar *orgtbl-llend* nil "Specializes lend for the last row")
(defun orgtbl-format-line (line)
"Format LINE as a table row."
@@ -3644,9 +3647,15 @@ First element has index 0, or I0 if given."
(defun orgtbl-format-section (section-stopper)
"Format lines until the first occurrence of SECTION-STOPPER."
- (progn
- (while (not (eq (car *orgtbl-table*) section-stopper))
- (orgtbl-format-line (pop *orgtbl-table*)))))
+ (let (prevline)
+ (progn
+ (while (not (eq (car *orgtbl-table*) section-stopper))
+ (if prevline (orgtbl-format-line prevline))
+ (setq prevline (pop *orgtbl-table*)))
+ (if prevline (let ((*orgtbl-lstart* *orgtbl-llstart*)
+ (*orgtbl-lend* *orgtbl-llend*)
+ (*orgtbl-lfmt* *orgtbl-llfmt*))
+ (orgtbl-format-line prevline))))))
(defun orgtbl-to-generic (table params)
"Convert the orgtbl-mode TABLE to some other format.
@@ -3670,17 +3679,20 @@ Valid parameters are
May be nil to ignore hlines.
:lstart String to start a new table line.
+:llstart String to start the last table line, defaults to :lstart.
:lend String to end a table line
+:llend String to end the last table line, defaults to :lend.
:sep Separator between two fields
:lfmt Format for entire line, with enough %s to capture all fields.
If this is present, :lstart, :lend, and :sep are ignored.
+:llfmt Format for the entire last line, defaults to :lfmt.
:fmt A format to be used to wrap the field, should contain
%s for the original field value. For example, to wrap
everything in dollars, you could use :fmt \"$%s$\".
This may also be a property list with column numbers and
formats. For example :fmt (2 \"$%s$\" 4 \"%s%%\")
-:hlstart :hlend :hlsep :hlfmt :hfmt
+:hlstart :hllstart :hlend :hllend :hlsep :hlfmt :hllfmt :hfmt
Same as above, specific for the header lines in the table.
All lines before the first hline are treated as header.
If any of these is not present, the data line value is used.
@@ -3700,8 +3712,11 @@ directly by `orgtbl-send-table'. See manual."
(*orgtbl-sep* (plist-get params :sep))
(*orgtbl-efmt* (plist-get params :efmt))
(*orgtbl-lstart* (plist-get params :lstart))
+ (*orgtbl-llstart* (or (plist-get params :llstart) *orgtbl-lstart*))
(*orgtbl-lend* (plist-get params :lend))
+ (*orgtbl-llend* (or (plist-get params :llend) *orgtbl-lend*))
(*orgtbl-lfmt* (plist-get params :lfmt))
+ (*orgtbl-llfmt* (or (plist-get params :llfmt) *orgtbl-lfmt*))
(*orgtbl-fmt* (plist-get params :fmt))
*orgtbl-rtn*)
@@ -3716,8 +3731,14 @@ directly by `orgtbl-send-table'. See manual."
(progn
(let* ((*orgtbl-lstart* (or (plist-get params :hlstart)
*orgtbl-lstart*))
+ (*orgtbl-llstart* (or (plist-get params :hllstart)
+ *orgtbl-llstart*))
(*orgtbl-lend* (or (plist-get params :hlend) *orgtbl-lend*))
+ (*orgtbl-llend* (or (plist-get params :hllend)
+ (plist-get params :hlend) *orgtbl-llend*))
(*orgtbl-lfmt* (or (plist-get params :hlfmt) *orgtbl-lfmt*))
+ (*orgtbl-llfmt* (or (plist-get params :hllfmt)
+ (plist-get params :hlfmt) *orgtbl-llfmt*))
(*orgtbl-sep* (or (plist-get params :hlsep) *orgtbl-sep*))
(*orgtbl-fmt* (or (plist-get params :hfmt) *orgtbl-fmt*)))
(orgtbl-format-section 'hline))
@@ -3753,6 +3774,9 @@ LaTeX are:
example \"%s\\\\times10^{%s}\". LaTeX default is \"%s\\\\,(%s)\".
This may also be a property list with column numbers and formats.
+:llend If you find too much space below the last line of a table,
+ pass a value of \"\" for :llend to suppress the final \\\\.
+
The general parameters :skip and :skipcols have already been applied when
this function is called."
(let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
--
1.5.5.rc1.121.g1594