summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2012-07-31 15:40:05 +0200
committerBastien Guerry <bzg@altern.org>2012-07-31 15:40:05 +0200
commite3f30e12d27932d8330df1ca94657baa8097ed90 (patch)
tree74b3f4ea8f0fbf286c554b228a023897a3348b0e
parent64de70e1be6eaa1dc5696e1b43a580561b0848f6 (diff)
downloadorg-mode-e3f30e12d27932d8330df1ca94657baa8097ed90.tar.gz
Add `orgtbl-to-table.el' and `orgtbl-to-unicode'.
* org-table.el (orgtbl-radio-table-templates): Add a template for org-mode. (orgtbl-to-orgtbl): Complete and align the table created with orgtbl-to-orgtbl, in case the user use the function for radio tables. (orgtbl-to-table.el): New function to export a table to another one using the table.el format. (orgtbl-to-unicode): New function to export a table using unicode characters.
-rw-r--r--lisp/org-table.el42
1 files changed, 38 insertions, 4 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el
index d0b7d5d..e8b7f19 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -85,7 +85,13 @@ this variable requires a restart of Emacs to become effective."
<!--
#+ORGTBL: SEND %n orgtbl-to-html :splice nil :skip 0
| | |
--->\n"))
+-->\n")
+ (org-mode "#+ BEGIN RECEIVE ORGTBL %n
+#+ END RECEIVE ORGTBL %n
+
+#+ORGTBL: SEND %n orgtbl-to-orgtbl :splice nil :skip 0
+| | |
+"))
"Templates for radio tables in different major modes.
All occurrences of %n in a template will be replaced with the name of the
table, obtained by prompting the user."
@@ -4526,8 +4532,6 @@ This may be either a string or a function of two arguments:
In addition to this, the parameters :skip and :skipcols are always handled
directly by `orgtbl-send-table'. See manual."
- (interactive)
-
(let* ((splicep (plist-get params :splice))
(hline (plist-get params :hline))
(skipheadrule (plist-get params :skipheadrule))
@@ -4726,7 +4730,37 @@ provide ORGTBL directives for the generated table."
:lstart "| "
:lend " |"))
(params (org-combine-plists params2 params)))
- (orgtbl-to-generic table params)))
+ (with-temp-buffer
+ (insert (orgtbl-to-generic table params))
+ (goto-char (point-min))
+ (while (re-search-forward org-table-hline-regexp nil t)
+ (org-table-align))
+ (buffer-substring 1 (buffer-size)))))
+
+(defun orgtbl-to-table.el (table params)
+ "Convert the orgtbl-mode TABLE into a table.el table."
+ (with-temp-buffer
+ (insert (orgtbl-to-orgtbl table params))
+ (org-table-align)
+ (replace-regexp-in-string
+ "-|" "-+"
+ (replace-regexp-in-string "|-" "+-" (buffer-substring 1 (buffer-size))))))
+
+(defun orgtbl-to-unicode (table params)
+ "Convert the orgtbl-mode TABLE into a table with unicode characters.
+You need the ascii-art-to-unicode.el package for this. You can download
+it here: http://gnuvola.org/software/j/aa2u/ascii-art-to-unicode.el."
+ (with-temp-buffer
+ (insert (orgtbl-to-table.el table params))
+ (goto-char (point-min))
+ (if (or (featurep 'ascii-art-to-unicode)
+ (require 'ascii-art-to-unicode nil t))
+ (aa2u)
+ (unless (delq nil (mapcar (lambda (l) (string-match "aa2u" (car l))) org-stored-links))
+ (push '("http://gnuvola.org/software/j/aa2u/ascii-art-to-unicode.el"
+ "Link to ascii-art-to-unicode.el") org-stored-links))
+ (error "Please download ascii-art-to-unicode.el (use C-c C-l to insert the link to it)"))
+ (buffer-string)))
(defun org-table-get-remote-range (name-or-id form)
"Get a field value or a list of values in a range from table at ID.