From mboxrd@z Thu Jan 1 00:00:00 1970 From: francois@avalenn.eu Subject: Re: [PATCH] [org-table] user-chosen separator in org-table-convert-region Date: Fri, 27 Sep 2013 11:39:20 +0200 Message-ID: <064f5306b490bfab71d4cc2ceb69f229@avalenn.eu> References: <8aac63099d110d297d0ada9ff87cb93b@avalenn.eu> <09BDF76D-7B88-45FB-B0B6-C587D2C3787B@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPUWf-00029G-Jz for emacs-orgmode@gnu.org; Fri, 27 Sep 2013 05:40:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VPUWY-0003N9-92 for emacs-orgmode@gnu.org; Fri, 27 Sep 2013 05:39:53 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:52815) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPUWY-0003MX-2Y for emacs-orgmode@gnu.org; Fri, 27 Sep 2013 05:39:46 -0400 In-Reply-To: <09BDF76D-7B88-45FB-B0B6-C587D2C3787B@gmail.com> 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: Carsten Dominik Cc: emacs-orgmode@gnu.org On Tue, 24 Sep 2013 15:08:10 +0200, Carsten Dominik wrote: > could you please explain what this does and show an example on how > this should be used? It adds the possibility of a string argument used as a regexp for arbitrary field separator. It can be used as following : (defun my-fjd/convert (beg0 end0 arg) (interactive "r\nsSeparator: ") (let* ((beg (min beg0 end0)) (end (max beg0 end0)) re) (org-table-convert-region beg0 end0 arg) )) (global-set-key (kbd "T") 'my-fjd/convert) It permits for example to convert in place csv-like table with semi-colon separator if I pass ";" as argument. I modified the patch to add correct documentation in the function. --- lisp/org-table.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/org-table.el b/lisp/org-table.el index 246cf8d..4883fc6 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -548,6 +548,7 @@ (defun org-table-convert-region (beg0 end0 &optional separator) '(4) Use the comma as a field separator '(16) Use a TAB as field separator integer When a number, use that many spaces as field separator +string When a string, use it as a regexp for field separator nil When nil, the command tries to be smart and figure out the separator in the following way: - when each line contains a TAB, assume TAB-separated material @@ -591,6 +592,8 @@ (defun org-table-convert-region (beg0 end0 &optional separator) (if (< separator 1) (user-error "Number of spaces in separator must be >= 1") (format "^ *\\| *\t *\\| \\{%d,\\}" separator))) + ((stringp separator) + (format "^ *\\|%s" separator)) (t (error "This should not happen")))) (while (re-search-forward re end t) (replace-match "| " t t))) -- 1.7.10.4