From mboxrd@z Thu Jan 1 00:00:00 1970 From: jason@acm.org Subject: [respun PATCH 2/3] Support last-line specializers. Date: Sun, 02 Mar 2008 21:36:50 -0800 Message-ID: <87hcfo8j2l.fsf@sparse.yi.org> References: <87fxv8iqw1.fsf@sparse.yi.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JW3MR-0005Fp-Jw for emacs-orgmode@gnu.org; Mon, 03 Mar 2008 00:37:15 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JW3MM-0005AI-US for emacs-orgmode@gnu.org; Mon, 03 Mar 2008 00:37:15 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JW3MM-00059m-DV for emacs-orgmode@gnu.org; Mon, 03 Mar 2008 00:37:10 -0500 Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JW3ML-0002fH-Ta for emacs-orgmode@gnu.org; Mon, 03 Mar 2008 00:37:10 -0500 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JW3MB-0001kr-Cn for emacs-orgmode@gnu.org; Mon, 03 Mar 2008 05:36:59 +0000 Received: from 76.191.193.207 ([76.191.193.207]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 03 Mar 2008 05:36:59 +0000 Received: from jason by 76.191.193.207 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 03 Mar 2008 05:36:59 +0000 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Each of lstart, lend, and lfmt permits a last-line specialization called llstart, etc. with corresponding heading versions. Signed-off-by: Jason Riedy --- Argh. Already found one problem: I didn't fall back to non-last-line properties when appropriate. org.el | 34 ++++++++++++++++++++++++++-------- 1 files changed, 26 insertions(+), 8 deletions(-) diff --git a/org.el b/org.el index 64121c9..f38f6ae 100644 --- a/org.el +++ b/org.el @@ -11792,9 +11792,13 @@ 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 table) section-stopper)) - (orgtbl-format-line (pop table))))) + (let (prevline) + (progn + (while (not (eq (car table) section-stopper)) + (if prevline (orgtbl-format-line prevline)) + (setq prevline (pop table))) + (if prevline (let ((lstart llstart) (lend llend) (lfmt llfmt)) + (orgtbl-format-line prevline)))))) (defun orgtbl-to-generic (table params) "Convert the orgtbl-mode TABLE to some other format. @@ -11818,17 +11822,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 :hsep :hlfmt :hfmt +:hlstart :hllstart :hlend :hllend :hsep :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. @@ -11847,8 +11854,11 @@ directly by `orgtbl-send-table'. See manual." (sep (plist-get params :sep)) (efmt (plist-get params :efmt)) (lstart (plist-get params :lstart)) + (llstart (or (plist-get params :llstart) lstart)) (lend (plist-get params :lend)) + (llend (or (plist-get params :llend) lend)) (lfmt (plist-get params :lfmt)) + (llfmt (or (plist-get params :llfmt) lfmt)) (fmt (plist-get params :fmt)) rtn) @@ -11860,10 +11870,15 @@ directly by `orgtbl-send-table'. See manual." ;; trailing hline. (if (and (not splicep) (listp (car table)) (memq 'hline table)) (progn - (let* ((lstart (or (plist-get params :hlstart) lstart)) - (lend (or (plist-get params :hlend) lend)) - (lfmt (or (plist-get params :hlfmt) lfmt)) - (fmt (or (plist-get params :hfmt) fmt))) + (let ((lstart (or (plist-get params :hlstart) lstart)) + (llstart (or (plist-get params :hllstart) llstart)) + (lend (or (plist-get params :hlend) lend)) + (llend (or (plist-get params :hllend) + (plist-get params :hlend) llend)) + (lfmt (or (plist-get params :hlfmt) lfmt)) + (llfmt (or (plist-get params :hllfmt) + (plist-get params :hlfmt) llfmt)) + (fmt (or (plist-get params :hfmt) fmt))) (orgtbl-format-section 'hline)) (if hline (push hline rtn)) (pop table))) @@ -11897,6 +11912,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.4.3