diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ab05fd048..aa32074d3 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2009-10-26 Carsten Dominik + * org-table.el (org-table-convert-region): Correctly interpret + quoting in csv import. + * org.el (org-icompleting-read): Make iswitchb completion work with lists and tables. diff --git a/lisp/org-table.el b/lisp/org-table.el index 83ec3a3fa..4608cd318 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -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)