emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: Achim Gratz <Stromeko@nexgo.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] org-table: several cleanups
Date: Sun, 12 May 2013 15:55:18 +0200	[thread overview]
Message-ID: <05483A29-C4C4-4E80-B4D1-28165CA5964E@gmail.com> (raw)
In-Reply-To: <87li7k5zrr.fsf@Rainer.invalid>

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 <Stromeko@nexgo.de> wrote:

> From 5972eaf924c726c1791fe6968e5b5b5abf053431 Mon Sep 17 00:00:00 2001
> From: Achim Gratz <Stromeko@Stromeko.DE>
> Date: Sun, 12 May 2013 11:09:31 +0200
> Subject: [PATCH] org-table: several cleanups
> 
> * 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(-)
> 
> 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]*")))))))
> 
> -(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 '("<" "&lt;")) :start)
> -					 ((member x '(">" "&gt;")) :end)
> -					 ((member x '("<>" "&lt;&gt;")) :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 '("<" "&lt;")) :start)
> -				     ((member x '(">" "&gt;")) :end)
> -				     ((member x '("<>" "&lt;&gt;")) :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)))
> 
> (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))
> 
> -(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
> -- 
> 1.8.2.2
> 
> 
> Regards,
> Achim.
> -- 
> +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
> 
> SD adaptations for Waldorf Q V3.00R3 and Q+ V3.54R2:
> http://Synth.Stromeko.net/Downloads.html#WaldorfSDada

  reply	other threads:[~2013-05-12 13:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-12  9:11 [PATCH] org-table: several cleanups Achim Gratz
2013-05-12 13:55 ` Carsten Dominik [this message]
2013-05-12 19:19   ` Achim Gratz

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=05483A29-C4C4-4E80-B4D1-28165CA5964E@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=Stromeko@nexgo.de \
    --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).