diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-01-03 15:26:38 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-01-03 15:26:38 +0100 |
commit | 837e1b4249f8dcabd25e40cff765a5bb91b9dae5 (patch) | |
tree | f1fa22b7c3566d4ce303f3d68d38a64b55b3a58f | |
parent | d6369e9ac69ce367e862a9678bb46cdc60b77f1f (diff) | |
parent | 7e8e12be21e3fca4351748c3780b486e4daedf16 (diff) | |
download | org-mode-837e1b4249f8dcabd25e40cff765a5bb91b9dae5.tar.gz |
Merge branch 'maint'
-rw-r--r-- | lisp/org-table.el | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el index 2a1d9a0..c346888 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -672,17 +672,30 @@ nil When nil, the command tries to be smart and figure out the (org-table-align)))) ;;;###autoload -(defun org-table-import (file arg) +(defun org-table-import (file separator) "Import FILE as a table. -The file is assumed to be tab-separated. Such files can be produced by most -spreadsheet and database applications. If no tabs (at least one per line) -are found, lines will be split on whitespace into fields." + +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 + - when each line contains a comma, assume CSV material + - else, assume one or more SPACE characters as separator. + +When non-nil, SEPARATOR specifies the field separator in the +lines. It can have the following values: + +(4) Use the comma as a field separator +(16) Use a TAB as field separator +(64) Prompt for a regular expression as field separator +integer When a number, use that many spaces, or a TAB, as field separator +regexp When a regular expression, use it to match the separator." (interactive "f\nP") - (or (bolp) (newline)) + (unless (bolp) (insert "\n")) (let ((beg (point)) (pm (point-max))) (insert-file-contents file) - (org-table-convert-region beg (+ (point) (- (point-max) pm)) arg))) + (org-table-convert-region beg (+ (point) (- (point-max) pm)) separator))) ;;;###autoload |