|
@@ -424,17 +424,29 @@ nil When nil, the command tries to be smart and figure out the
|
|
|
((not (re-search-forward "^[^\n\t]+$" end t)) '(16))
|
|
|
((not (re-search-forward "^[^\n,]+$" end t)) '(4))
|
|
|
(t 1))))
|
|
|
- (setq re (cond
|
|
|
- ((equal separator '(4)) "^\\|\"?[ \t]*,[ \t]*\"?")
|
|
|
- ((equal separator '(16)) "^\\|\t")
|
|
|
- ((integerp separator)
|
|
|
- (format "^ *\\| *\t *\\| \\{%d,\\}" separator))
|
|
|
- (t (error "This should not happen"))))
|
|
|
(goto-char beg)
|
|
|
- (while (re-search-forward re end t)
|
|
|
- (replace-match "| " t t))
|
|
|
+ (if (equal separator '(4))
|
|
|
+ (while (<= (point) end)
|
|
|
+ ;; parse the csv stuff
|
|
|
+ (cond
|
|
|
+ ((looking-at "^") (insert "|"))
|
|
|
+ ((looking-at "[ \t]*$") (replace-match "|") (beginning-of-line 2))
|
|
|
+ ((looking-at "[ \t]*\"\\([^\"\n]*\\)\"")
|
|
|
+ (replace-match "\\1")
|
|
|
+ (if (looking-at "\"") (insert "\"")))
|
|
|
+ ((looking-at "[^,\n]+") (goto-char (match-end 0)))
|
|
|
+ ((looking-at "[ \t]*,") (replace-match " | "))
|
|
|
+ (t (beginning-of-line 2)
|
|
|
+ (if (< (point) end) (insert "|")))))
|
|
|
+ (setq re (cond
|
|
|
+ ((equal separator '(4)) "^\\|\"?[ \t]*,[ \t]*\"?")
|
|
|
+ ((equal separator '(16)) "^\\|\t")
|
|
|
+ ((integerp separator)
|
|
|
+ (format "^ *\\| *\t *\\| \\{%d,\\}" separator))
|
|
|
+ (t (error "This should not happen"))))
|
|
|
+ (while (re-search-forward re end t)
|
|
|
+ (replace-match "| " t t)))
|
|
|
(goto-char beg)
|
|
|
- (insert " ")
|
|
|
(org-table-align)))
|
|
|
|
|
|
(defun org-table-import (file arg)
|