Fix bug in CSV table import

Dan Davison writes:

> If a file contains "-1" followed by a newline and nothing else,
> org-table-import on that file fails. The first commit with this
> property is a commit (below) to do with CVS tables made a few
> days ago. I have given up trying to work out a good solution to
> this :) In case it is useful, the failure occurs when
> org-table-align is called at the end of
> org-table-convert-region. I think it is long-standing behaviour
> that hitting tab inside of
>
> |-1|
>
> doesn't make a table containing "-1", so presumably there is
> something different about the context in which org-table-align is
> now being called.
This commit is contained in:
Carsten Dominik 2009-10-31 09:24:32 +01:00
parent 41b8de9476
commit 535ca7a6b9
2 changed files with 9 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2009-10-31 Carsten Dominik <carsten.dominik@gmail.com>
* org-table.el (org-table-convert-region): Inert spaces around "|"
to avoid line beginnings like "|-1" which will be mistaken as
hlines.
2009-10-30 Carsten Dominik <carsten.dominik@gmail.com> 2009-10-30 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-offer-links-in-entry): Return nil if there are no * org.el (org-offer-links-in-entry): Return nil if there are no

View File

@ -429,15 +429,14 @@ nil When nil, the command tries to be smart and figure out the
(while (<= (point) end) (while (<= (point) end)
;; parse the csv stuff ;; parse the csv stuff
(cond (cond
((looking-at "^") (insert "|")) ((looking-at "^") (insert "| "))
((looking-at "[ \t]*$") (replace-match "|") (beginning-of-line 2)) ((looking-at "[ \t]*$") (replace-match " |") (beginning-of-line 2))
((looking-at "[ \t]*\"\\([^\"\n]*\\)\"") ((looking-at "[ \t]*\"\\([^\"\n]*\\)\"")
(replace-match "\\1") (replace-match "\\1")
(if (looking-at "\"") (insert "\""))) (if (looking-at "\"") (insert "\"")))
((looking-at "[^,\n]+") (goto-char (match-end 0))) ((looking-at "[^,\n]+") (goto-char (match-end 0)))
((looking-at "[ \t]*,") (replace-match " | ")) ((looking-at "[ \t]*,") (replace-match " | "))
(t (beginning-of-line 2) (t (beginning-of-line 2))))
(if (< (point) end) (insert "|")))))
(setq re (cond (setq re (cond
((equal separator '(4)) "^\\|\"?[ \t]*,[ \t]*\"?") ((equal separator '(4)) "^\\|\"?[ \t]*,[ \t]*\"?")
((equal separator '(16)) "^\\|\t") ((equal separator '(16)) "^\\|\t")