summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchim Gratz <Stromeko@Stromeko.DE>2013-06-21 20:37:51 (GMT)
committer Achim Gratz <Stromeko@Stromeko.DE>2013-06-27 18:17:22 (GMT)
commit30581835bdfe172744b51130ccc9075ca2080b32 (patch)
treebf0bb20c25ed4002dba6a8e5b787b761c73ff105
parent21d1d4d1371c46f463a113be9fe8f22a18e4e880 (diff)
downloadorg-mode-30581835bdfe172744b51130ccc9075ca2080b32.zip
org-mode-30581835bdfe172744b51130ccc9075ca2080b32.tar.gz
do not use mapcar* for transposing tables
* lisp/ob-core.el (org-babel-get-rownames), lisp/org-table.el (org-table-transpose-table-at-point): Replace the inadvertent use of mapcar* (from cl) by plain mapcar and direct cons manipulation. The error was not caught at compilation time since both source files require cl during compilation for using cl macros. These were the only uses of mapcar* in Org, but I didn't check for other cl _functions_ (as opposed to macros, which would need to be checked if their implementation uses cl functions).
-rw-r--r--lisp/ob-core.el28
-rw-r--r--lisp/org-table.el15
2 files changed, 22 insertions, 21 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 55d8f45..c79fc25 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -1472,22 +1472,18 @@ names."
(defun org-babel-get-rownames (table)
"Return the row names of TABLE.
Return a cons cell, the `car' of which contains the TABLE less
-colnames, and the `cdr' of which contains a list of the column
-names. Note: this function removes any hlines in TABLE."
- (let* ((trans (lambda (table) (apply #'mapcar* #'list table)))
- (width (apply 'max
- (mapcar (lambda (el) (if (listp el) (length el) 0)) table)))
- (table (funcall trans (mapcar (lambda (row)
- (if (not (equal row 'hline))
- row
- (setq row '())
- (dotimes (n width)
- (setq row (cons 'hline row)))
- row))
- table))))
- (cons (mapcar (lambda (row) (if (equal (car row) 'hline) 'hline row))
- (funcall trans (cdr table)))
- (remove 'hline (car table)))))
+rownames, and the `cdr' of which contains a list of the rownames.
+Note: this function removes any hlines in TABLE."
+ (let* ((table (org-babel-del-hlines table))
+ (rownames (funcall (lambda ()
+ (let ((tp table))
+ (mapcar
+ (lambda (row)
+ (prog1
+ (pop (car tp))
+ (setq tp (cdr tp))))
+ table))))))
+ (cons table rownames)))
(defun org-babel-put-colnames (table colnames)
"Add COLNAMES to TABLE if they exist."
diff --git a/lisp/org-table.el b/lisp/org-table.el
index cd7609d..7b91f36 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -1859,11 +1859,16 @@ will be transposed as
Note that horizontal lines disappeared."
(interactive)
- (let ((contents
- (apply #'mapcar* #'list
- ;; remove 'hline from list
- (delq nil (mapcar (lambda (x) (when (listp x) x))
- (org-table-to-lisp))))))
+ (let* ((table (delete 'hline (org-table-to-lisp)))
+ (contents (mapcar (lambda (p)
+ (let ((tp table))
+ (mapcar
+ (lambda (rown)
+ (prog1
+ (pop (car tp))
+ (setq tp (cdr tp))))
+ table)))
+ (car table))))
(delete-region (org-table-begin) (org-table-end))
(insert (mapconcat (lambda(x) (concat "| " (mapconcat 'identity x " | " ) " |\n" ))
contents ""))