From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: [PATCH] org-table: several cleanups Date: Sun, 12 May 2013 15:55:18 +0200 Message-ID: <05483A29-C4C4-4E80-B4D1-28165CA5964E@gmail.com> References: <87li7k5zrr.fsf@Rainer.invalid> Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:57861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UbWkG-0003mV-CK for emacs-orgmode@gnu.org; Sun, 12 May 2013 09:55:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UbWkD-0001FY-VZ for emacs-orgmode@gnu.org; Sun, 12 May 2013 09:55:24 -0400 Received: from mail-wi0-x232.google.com ([2a00:1450:400c:c05::232]:62776) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UbWkD-0001FQ-Lu for emacs-orgmode@gnu.org; Sun, 12 May 2013 09:55:21 -0400 Received: by mail-wi0-f178.google.com with SMTP id ey16so58909wid.11 for ; Sun, 12 May 2013 06:55:20 -0700 (PDT) In-Reply-To: <87li7k5zrr.fsf@Rainer.invalid> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Achim Gratz Cc: emacs-orgmode@gnu.org Hi Achim, this looks allright for me. Please go ahead and apply when you have = tested it. - Carsten On 12.5.2013, at 11:11, Achim Gratz wrote: > =46rom 5972eaf924c726c1791fe6968e5b5b5abf053431 Mon Sep 17 00:00:00 = 2001 > From: Achim Gratz > Date: Sun, 12 May 2013 11:09:31 +0200 > Subject: [PATCH] org-table: several cleanups >=20 > * lisp/org.el (org-table-clean-did-remove-column), > lisp/org-table.el (org-table-clean-did-remove-column): Move defvar, > this dynamic variable is only used in org-table. > * lisp/org-table.el (org-table-colgroup-info): Remove unused defvar > for `org-table-colgroup-info'. > (org-table-clean-before-export): Let-bind regular expression strings > and remove unused matching group. Let-bind `remove-column-p' and > use in cond statement rather than branching via if (also remove code > duplication across the two branches). Remove the code associated > with the unused `org-table-colgroup-info'. > (orgtbl-export): Remove unused internal function. > --- > lisp/org-table.el | 82 = ++++++++++++++++++------------------------------------- > lisp/org.el | 1 - > 2 files changed, 27 insertions(+), 56 deletions(-) >=20 > diff --git a/lisp/org-table.el b/lisp/org-table.el > index 8e461c8..fd58187 100644 > --- a/lisp/org-table.el > +++ b/lisp/org-table.el > @@ -419,69 +419,41 @@ (defun org-table-cookie-line-p (line) > (org-split-string (match-string 1 line) > "[ \t]*|[ \t]*"))))))) >=20 > -(defvar org-table-colgroup-info nil) ; Dynamically scoped. > +(defvar org-table-clean-did-remove-column nil) ; dynamically scoped > (defun org-table-clean-before-export (lines &optional maybe-quoted) > "Check if the table has a marking column. > If yes remove the column and the special lines." > - (setq org-table-colgroup-info nil) > - (if (memq nil > - (mapcar > - (lambda (x) (or (string-match "^[ \t]*|-" x) > - (string-match > - (if maybe-quoted > - "^[ \t]*| *\\\\?\\([\#!$*_^ /]\\) *|" > - "^[ \t]*| *\\([\#!$*_^ /]\\) *|") > - x))) > - lines)) > - ;; No special marking column > - (progn > - (setq org-table-clean-did-remove-column nil) > - (delq nil > - (mapcar > - (lambda (x) > - (cond > - ((org-table-colgroup-line-p x) > - ;; This line contains colgroup info, extract it > - ;; and then discard the line > - (setq org-table-colgroup-info > - (mapcar (lambda (x) > - (cond ((member x '("<" "<")) = :start) > - ((member x '(">" ">")) :end) > - ((member x '("<>" "<>")) = :startend))) > - (org-split-string x "[ \t]*|[ \t]*"))) > - nil) > - ((org-table-cookie-line-p x) > - ;; This line contains formatting cookies, discard it > - nil) > - (t x))) > - lines))) > - ;; there is a special marking column > - (setq org-table-clean-did-remove-column t) > + (let* > + ((special (if maybe-quoted > + "^[ \t]*| *\\\\?[\#!$*_^/ ] *|" > + "^[ \t]*| *[\#!$*_^/ ] *|")) > + (ignore (if maybe-quoted > + "^[ \t]*| *\\\\?[!$_^/] *|" > + "^[ \t]*| *[!$_^/] *|")) > + (remove-column-p > + (not (memq nil > + (mapcar > + (lambda (line) > + (or (string-match "^[ \t]*|-" line) > + (string-match special line))) > + lines))))) > (delq nil > (mapcar > - (lambda (x) > + (lambda (line) > (cond > - ((org-table-colgroup-line-p x) > - ;; This line contains colgroup info, extract it > - ;; and then discard the line > - (setq org-table-colgroup-info > - (mapcar (lambda (x) > - (cond ((member x '("<" "<")) :start) > - ((member x '(">" ">")) :end) > - ((member x '("<>" "<>")) = :startend))) > - (cdr (org-split-string x "[ \t]*|[ = \t]*")))) > + ((or (org-table-colgroup-line-p line) ;; colgroup info > + (org-table-cookie-line-p line) ;; formatting = cookies > + (and remove-column-p > + (string-match ignore line))) ;; non-exportable = data > nil) > - ((org-table-cookie-line-p x) > - ;; This line contains formatting cookies, discard it > - nil) > - ((string-match "^[ \t]*| *\\([!_^/$]\\|\\\\\\$\\) *|" x) > - ;; ignore this line > - nil) > - ((or (string-match "^\\([ \t]*\\)|-+\\+" x) > - (string-match "^\\([ \t]*\\)|[^|]*|" x)) > + ((and remove-column-p > + (or (string-match "^\\([ \t]*\\)|-+\\+" line) > + (string-match "^\\([ \t]*\\)|[^|]*|" line))) > ;; remove the first column > - (replace-match "\\1|" t nil x)))) > - lines)))) > + (replace-match "\\1|" t nil line)) > + (t line))) > + lines)) > + (setq org-table-clean-did-remove-column remove-column-p))) >=20 > (defconst org-table-translate-regexp > (concat "\\(" "@[-0-9I$]+" "\\|" "[a-zA-Z]\\{1,2\\}\\([0-9]+\\|&\\)" = "\\)") > diff --git a/lisp/org.el b/lisp/org.el > index b9d3894..6e4a6b4 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -4292,7 +4292,6 @@ (defun org-at-table-hline-p () > (looking-at org-table-hline-regexp)) > nil)) >=20 > -(defvar org-table-clean-did-remove-column nil) > (defun org-table-map-tables (function &optional quietly) > "Apply FUNCTION to the start of all tables in the buffer." > (save-excursion > --=20 > 1.8.2.2 >=20 >=20 > Regards, > Achim. > --=20 > +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ >=20 > SD adaptations for Waldorf Q V3.00R3 and Q+ V3.54R2: > http://Synth.Stromeko.net/Downloads.html#WaldorfSDada