1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2025-01-20 19:24:20 +00:00

New function to convert a table to a lisp structure.

This commit is contained in:
Carsten Dominik 2008-07-17 10:08:53 -07:00
parent 323b54472e
commit ea71ffc237
2 changed files with 22 additions and 0 deletions

View File

@ -1,5 +1,7 @@
2008-07-17 Carsten Dominik <dominik@science.uva.nl>
* org-table.el (org-table-to-lisp): New function.
* org.el (org-narrow-to-subtree): Do not include the final newline
into the narrowed region.

View File

@ -3552,6 +3552,26 @@ a radio table."
(delete-region beg (point))))
(insert txt "\n")))
(defun org-table-to-lisp (&optional txt)
"Convert the table at point to a Lisp structure.
The structure will be a list. Each item is either the symbol `hline'
for a horizontal separator line, or a list of field values as strings.
The table is taken from the parameter TXT, or from the buffer at point."
(unless txt
(unless (org-at-table-p)
(error "No table at point")))
(let* ((txt (or txt
(buffer-substring-no-properties (org-table-begin)
(org-table-end))))
(lines (org-split-string txt "[ \t]*\n[ \t]*")))
(mapcar
(lambda (x)
(if (string-match org-table-hline-regexp x)
'hline
(org-split-string (org-trim x) "\\s-*|\\s-*")))
lines)))
(defun orgtbl-send-table (&optional maybe)
"Send a tranformed version of this table to the receiver position.
With argument MAYBE, fail quietly if no transformation is defined for