diff options
Diffstat (limited to 'lisp/org/org-table.el')
-rw-r--r-- | lisp/org/org-table.el | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el index 0ba7165abe9..3932671e8b7 100644 --- a/lisp/org/org-table.el +++ b/lisp/org/org-table.el @@ -644,17 +644,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 @@ -1166,7 +1179,7 @@ to a number. In the case of a timestamp, increment by days." (- (org-time-string-to-absolute txt) (org-time-string-to-absolute txt-up))) ((string-match org-ts-regexp3 txt) 1) - ((string-match "\\([-+]\\)?[0-9]+\\(?:\.[0-9]+\\)?" txt-up) + ((string-match "\\([-+]\\)?\\(?:[0-9]+\\)?\\(?:\.[0-9]+\\)?" txt-up) (- (string-to-number txt) (string-to-number (match-string 0 txt-up)))) (t 1))) @@ -4311,14 +4324,14 @@ FACE, when non-nil, for the highlight." ;;;###autoload (define-minor-mode orgtbl-mode - "The `org-mode' table editor as a minor mode for use in other modes." + "The Org mode table editor as a minor mode for use in other modes." :lighter " OrgTbl" :keymap orgtbl-mode-map (org-load-modules-maybe) (cond ((derived-mode-p 'org-mode) - ;; Exit without error, in case some hook functions calls this - ;; by accident in org-mode. - (message "Orgtbl-mode is not useful in org-mode, command ignored")) + ;; Exit without error, in case some hook functions calls this by + ;; accident in Org mode. + (message "Orgtbl mode is not useful in Org mode, command ignored")) (orgtbl-mode (and (orgtbl-setup) (defun orgtbl-setup () nil)) ;; FIXME: Yuck!?! ;; Make sure we are first in minor-mode-map-alist |