From: Jason Riedy <jason@acm.org>
To: emacs-orgmode@gnu.org
Subject: [PATCH 2/4] Support last-line specializers.
Date: Wed, 16 Apr 2008 14:39:52 -0700 [thread overview]
Message-ID: <1208381994-7893-3-git-send-email-jason@acm.org> (raw)
In-Reply-To: <1208381994-7893-1-git-send-email-jason@acm.org>
Each of lstart, lend, and lfmt permits a last-line specialization
called llstart, etc. with corresponding heading versions.
Signed-off-by: Jason Riedy <jason@acm.org>
---
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 <jason@acm.org>
+ * 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 <jason@acm.org>
+
* 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
next prev parent reply other threads:[~2008-04-16 21:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-16 21:39 [PATCH 0/4] Generalize orgtbl formatting with functions Jason Riedy
2008-04-16 21:39 ` [PATCH 1/4] Refactor orgtbl-to-generic; explicitly separate heading from body Jason Riedy
2008-04-16 21:39 ` Jason Riedy [this message]
2008-04-16 21:39 ` [PATCH 3/4] Allow functions for some orgtbl parameters Jason Riedy
2008-04-16 21:39 ` [PATCH 4/4] Add a :remove-nil-lines parameter to orgtbl-to-generic Jason Riedy
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
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1208381994-7893-3-git-send-email-jason@acm.org \
--to=jason@acm.org \
--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 public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).