[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [PATCH] Improve org-table-convert-region in order to use any string
From: |
Francesco Pizzolante |
Subject: |
[O] [PATCH] Improve org-table-convert-region in order to use any string as separator |
Date: |
Tue, 07 Apr 2015 12:07:53 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (cygwin) |
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 <address@hidden>
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
- [O] [PATCH] Improve org-table-convert-region in order to use any string as separator,
Francesco Pizzolante <=