Improve interactive use and documentation of table export.
This commit is contained in:
parent
0a9c180b63
commit
1e042b511a
|
@ -1554,7 +1554,8 @@ exchange with, for example, spreadsheet or database programs. The format
|
||||||
used to export the file can be configured in the variable
|
used to export the file can be configured in the variable
|
||||||
@code{org-table-export-default-format}. You may also use properties
|
@code{org-table-export-default-format}. You may also use properties
|
||||||
@code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
|
@code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
|
||||||
name and the format for table export in a subtree.
|
name and the format for table export in a subtree. For the possible export
|
||||||
|
transformations, see @ref{Translator functions}.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
If you don't like the automatic table editor because it gets in your
|
If you don't like the automatic table editor because it gets in your
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
2008-05-10 Carsten Dominik <dominik@science.uva.nl>
|
||||||
|
|
||||||
|
* org-table.el (org-table-export-default-format): Remove :splice
|
||||||
|
from default format, we get the same effect by not specifying
|
||||||
|
:tstart and :tend.
|
||||||
|
(org-table-export): Improve setup, distinguish better between
|
||||||
|
interactive and non-interactive use, allow specifying the format
|
||||||
|
on the fly, better protection against wrong file names.
|
||||||
|
(orgtbl-to-generic): Fix documentation. Do not require :tstart
|
||||||
|
and :tend when :splice is omitted.
|
||||||
|
|
||||||
2008-05-09 Bernt Hansen <bernt@norang.ca>
|
2008-05-09 Bernt Hansen <bernt@norang.ca>
|
||||||
|
|
||||||
* org-clock.el (org-clock-select-task): Make sure the selection
|
* org-clock.el (org-clock-select-task): Make sure the selection
|
||||||
|
|
|
@ -249,12 +249,11 @@ Automatically means, when TAB or RET or C-c C-c are pressed in the line."
|
||||||
:tag "Org Table Import Export"
|
:tag "Org Table Import Export"
|
||||||
:group 'org-table)
|
:group 'org-table)
|
||||||
|
|
||||||
(defcustom org-table-export-default-format
|
(defcustom org-table-export-default-format "orgtbl-to-generic :sep \"\t\""
|
||||||
"orgtbl-to-generic :splice t :sep \"\t\""
|
|
||||||
"Default export parameters for org-table-export. These can be
|
"Default export parameters for org-table-export. These can be
|
||||||
overridden on for a specific table by setting the
|
overridden on for a specific table by setting the TABLE_EXPORT_FORMAT
|
||||||
TABLE_EXPORT_FORMAT parameter. See orgtbl-export for the
|
property. See the manual section on orgtbl radio tables for the different
|
||||||
different export transforms and available parameters."
|
export transformations and available parameters."
|
||||||
:group 'org-table-import-export
|
:group 'org-table-import-export
|
||||||
:type 'string)
|
:type 'string)
|
||||||
|
|
||||||
|
@ -428,7 +427,7 @@ are found, lines will be split on whitespace into fields."
|
||||||
(defvar org-table-last-alignment)
|
(defvar org-table-last-alignment)
|
||||||
(defvar org-table-last-column-widths)
|
(defvar org-table-last-column-widths)
|
||||||
(defun org-table-export (&optional file format)
|
(defun org-table-export (&optional file format)
|
||||||
"Export table as a tab-separated file.
|
"Export table to a file, with configurable format.
|
||||||
Such a file can be imported into a spreadsheet program like Excel.
|
Such a file can be imported into a spreadsheet program like Excel.
|
||||||
FILE can be the output file name. If not given, it will be taken from
|
FILE can be the output file name. If not given, it will be taken from
|
||||||
a TABLE_EXPORT_FILE property in the current entry or higher up in the
|
a TABLE_EXPORT_FILE property in the current entry or higher up in the
|
||||||
|
@ -439,19 +438,31 @@ be found in the variable `org-table-export-default-format', but the function
|
||||||
first checks if there is an export format specified in a TABLE_EXPORT_FORMAT
|
first checks if there is an export format specified in a TABLE_EXPORT_FORMAT
|
||||||
property, locally or anywhere up in the hierarchy."
|
property, locally or anywhere up in the hierarchy."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
(require 'org-exp)
|
||||||
(org-table-align) ;; make sure we have everything we need
|
(org-table-align) ;; make sure we have everything we need
|
||||||
(let* ((beg (org-table-begin))
|
(let* ((beg (org-table-begin))
|
||||||
(end (org-table-end))
|
(end (org-table-end))
|
||||||
(txt (buffer-substring-no-properties beg end))
|
(txt (buffer-substring-no-properties beg end))
|
||||||
(file (or file (org-entry-get beg "TABLE_EXPORT_FILE" t)
|
(file (or file (org-entry-get beg "TABLE_EXPORT_FILE" t)))
|
||||||
(read-file-name "Export table to: ")))
|
(format (or format (org-entry-get beg "TABLE_EXPORT_FORMAT" t)))
|
||||||
(format (or (org-entry-get beg "TABLE_EXPORT_FORMAT" t)
|
buf deffmt-readable)
|
||||||
org-table-export-default-format))
|
(unless file
|
||||||
buf)
|
(setq file (read-file-name "Export table to: "))
|
||||||
(unless (or (not (file-exists-p file))
|
(unless (or (not (file-exists-p file))
|
||||||
(y-or-n-p (format "Overwrite file %s? " file)))
|
(y-or-n-p (format "Overwrite file %s? " file)))
|
||||||
(error "Abort"))
|
(error "Abort")))
|
||||||
(message format)
|
(if (file-directory-p file)
|
||||||
|
(error "This is a directory path, not a file"))
|
||||||
|
(if (equal (file-truename file)
|
||||||
|
(file-truename (buffer-file-name)))
|
||||||
|
(error "Please specify a file name that is different from current"))
|
||||||
|
(unless format
|
||||||
|
(setq deffmt-readable org-table-export-default-format)
|
||||||
|
(while (string-match "\t" deffmt-readable)
|
||||||
|
(setq deffmt-readable (replace-match "\\t" t t deffmt-readable)))
|
||||||
|
(while (string-match "\n" deffmt-readable)
|
||||||
|
(setq deffmt-readable (replace-match "\\n" t t deffmt-readable)))
|
||||||
|
(setq format (read-string "Format: " deffmt-readable)))
|
||||||
|
|
||||||
(if (string-match "\\([^ \t\r\n]+\\)\\( +.*\\)?" format)
|
(if (string-match "\\([^ \t\r\n]+\\)\\( +.*\\)?" format)
|
||||||
(let* ((transform (intern (match-string 1 format)))
|
(let* ((transform (intern (match-string 1 format)))
|
||||||
|
@ -3701,8 +3712,7 @@ TABLE is a list, each entry either the symbol `hline' for a horizontal
|
||||||
separator line, or a list of fields for that line.
|
separator line, or a list of fields for that line.
|
||||||
PARAMS is a property list of parameters that can influence the conversion.
|
PARAMS is a property list of parameters that can influence the conversion.
|
||||||
For the generic converter, some parameters are obligatory: You need to
|
For the generic converter, some parameters are obligatory: You need to
|
||||||
specify either :lfmt, or all of (:lstart :lend :sep). If you do not use
|
specify either :lfmt, or all of (:lstart :lend :sep).
|
||||||
:splice, you must have :tstart and :tend.
|
|
||||||
|
|
||||||
Valid parameters are
|
Valid parameters are
|
||||||
|
|
||||||
|
@ -3771,8 +3781,7 @@ directly by `orgtbl-send-table'. See manual."
|
||||||
|
|
||||||
;; Put header
|
;; Put header
|
||||||
(unless splicep
|
(unless splicep
|
||||||
(if (not (plist-member params :tstart))
|
(when (plist-member params :tstart)
|
||||||
(push "ERROR: no :tstart" *orgtbl-rtn*)
|
|
||||||
(let ((tstart (orgtbl-eval-str (plist-get params :tstart))))
|
(let ((tstart (orgtbl-eval-str (plist-get params :tstart))))
|
||||||
(if tstart (push tstart *orgtbl-rtn*)))))
|
(if tstart (push tstart *orgtbl-rtn*)))))
|
||||||
|
|
||||||
|
@ -3801,8 +3810,7 @@ directly by `orgtbl-send-table'. See manual."
|
||||||
(orgtbl-format-section nil)
|
(orgtbl-format-section nil)
|
||||||
|
|
||||||
(unless splicep
|
(unless splicep
|
||||||
(if (not (plist-member params :tend))
|
(when (plist-member params :tend)
|
||||||
(push "ERROR: no :tend" *orgtbl-rtn*)
|
|
||||||
(let ((tend (orgtbl-eval-str (plist-get params :tend))))
|
(let ((tend (orgtbl-eval-str (plist-get params :tend))))
|
||||||
(if tend (push tend *orgtbl-rtn*)))))
|
(if tend (push tend *orgtbl-rtn*)))))
|
||||||
|
|
||||||
|
|
|
@ -9580,7 +9580,8 @@ but in some other way.")
|
||||||
|
|
||||||
(defconst org-default-properties
|
(defconst org-default-properties
|
||||||
'("ARCHIVE" "CATEGORY" "SUMMARY" "DESCRIPTION"
|
'("ARCHIVE" "CATEGORY" "SUMMARY" "DESCRIPTION"
|
||||||
"LOCATION" "LOGGING" "COLUMNS" "VISIBILITY")
|
"LOCATION" "LOGGING" "COLUMNS" "VISIBILITY"
|
||||||
|
"TABLE_EXPORT_FORMAT" "TABLE_EXPORT_FILE")
|
||||||
"Some properties that are used by Org-mode for various purposes.
|
"Some properties that are used by Org-mode for various purposes.
|
||||||
Being in this list makes sure that they are offered for completion.")
|
Being in this list makes sure that they are offered for completion.")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue