From: francois@avalenn.eu
To: Carsten Dominik <carsten.dominik@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] [org-table] user-chosen separator in org-table-convert-region
Date: Fri, 27 Sep 2013 11:39:20 +0200 [thread overview]
Message-ID: <064f5306b490bfab71d4cc2ceb69f229@avalenn.eu> (raw)
In-Reply-To: <09BDF76D-7B88-45FB-B0B6-C587D2C3787B@gmail.com>
On Tue, 24 Sep 2013 15:08:10 +0200, Carsten Dominik
<carsten.dominik@gmail.com> 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 "<f5>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
next prev parent reply other threads:[~2013-09-27 9:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-03 10:20 [PATCH] [org-table] user-chosen separator in org-table-convert-region francois
2013-09-24 13:08 ` Carsten Dominik
2013-09-27 9:39 ` francois [this message]
2013-09-29 10:28 ` Carsten Dominik
-- strict thread matches above, loose matches on Subject: below --
2013-09-03 14:25 francois
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=064f5306b490bfab71d4cc2ceb69f229@avalenn.eu \
--to=francois@avalenn.eu \
--cc=carsten.dominik@gmail.com \
--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).