emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Improve org-table-convert-region in order to use any string as separator
@ 2015-04-07 10:07 Francesco Pizzolante
  2015-04-07 10:29 ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: Francesco Pizzolante @ 2015-04-07 10:07 UTC (permalink / raw)
  To: mailing-list-org-mode

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-13  7:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-07 10:07 [PATCH] Improve org-table-convert-region in order to use any string as separator Francesco Pizzolante
2015-04-07 10:29 ` Nicolas Goaziou
     [not found]   ` <87vbh8p6xt.fsf-Gpy5sJQTEQHwkn9pgDnJRVAUjnlXr6A1@public.gmane.org>
2015-04-13  7:37     ` Francesco Pizzolante

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).