emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Francesco Pizzolante" <fpz-djc/iPCCuDYQheJpep6IedvLeJWuRmrY@public.gmane.org>
To: mailing-list-org-mode <emacs-orgmode-mXXj517/zsQ@public.gmane.org>
Subject: [PATCH] Improve org-table-convert-region in order to use any string as separator
Date: Tue, 07 Apr 2015 12:07:53 +0200	[thread overview]
Message-ID: <vrivd23gw8sm.fsf@example.com> (raw)

Hi,

European CSV files may use semi-colon as separator. As it was missing in
`org-table-convert-region', I improved it in order to define any string
as separator.

Best regards,
 Francesco

From: Francesco Pizzolante <fpz-djc/iPCCuDYQheJpep6IedvLeJWuRmrY@public.gmane.org>
Date: Tue, 7 Apr 2015 11:53:45 +0200
Subject: [PATCH] Improve org-table-convert-region in order to use any string
 as separator

* org-table.el (org-table-convert-region): Improve
`org-table-convert-region' in order to use any string as
separator. Remove useless line of code.

---
 lisp/org-table.el | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lisp/org-table.el b/lisp/org-table.el
index 30a66c9..985a877 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -1,6 +1,6 @@
 ;;; org-table.el --- The table editor for Org-mode
 
-;; Copyright (C) 2004-2014 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2015 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -548,6 +548,7 @@ following values:
 '(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 that string as 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
@@ -585,15 +586,17 @@ nil      When nil, the command tries to be smart and figure out the
 	   ((looking-at "[ \t]*,") (replace-match " | "))
 	   (t (beginning-of-line 2))))
       (setq re (cond
-		((equal separator '(4)) "^\\|\"?[ \t]*,[ \t]*\"?")
 		((equal separator '(16)) "^\\|\t")
 		((integerp 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)))
+      (let (case-fold-search)
+        (while (re-search-forward re end t)
+          (replace-match "| " t t))))
     (goto-char beg)
     (org-table-align)))
 
-- 
2.1.4

             reply	other threads:[~2015-04-07 10:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07 10:07 Francesco Pizzolante [this message]
2015-04-07 10:29 ` [PATCH] Improve org-table-convert-region in order to use any string as separator Nicolas Goaziou
     [not found]   ` <87vbh8p6xt.fsf-Gpy5sJQTEQHwkn9pgDnJRVAUjnlXr6A1@public.gmane.org>
2015-04-13  7:37     ` Francesco Pizzolante

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=vrivd23gw8sm.fsf@example.com \
    --to=fpz-djc/ipccudyqhejpep6iedvlejwurmry@public.gmane.org \
    --cc=emacs-orgmode-mXXj517/zsQ@public.gmane.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).