From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: Creating hline in table from source block? Date: Tue, 26 Nov 2013 01:47:00 +0100 Message-ID: <878uwcng57.fsf@gmx.us> References: <8738mkiwhx.fsf@hornfels.zedat.fu-berlin.de> <87hab0novk.fsf@gmx.us> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vl6lF-0003gj-2u for emacs-orgmode@gnu.org; Mon, 25 Nov 2013 19:44:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vl6l8-0003uy-Uv for emacs-orgmode@gnu.org; Mon, 25 Nov 2013 19:44:17 -0500 Received: from plane.gmane.org ([80.91.229.3]:40388) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vl6l8-0003uq-MW for emacs-orgmode@gnu.org; Mon, 25 Nov 2013 19:44:10 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Vl6l7-0002Y0-7j for emacs-orgmode@gnu.org; Tue, 26 Nov 2013 01:44:09 +0100 Received: from dynamic-adsl-94-39-217-142.clienti.tiscali.it ([94.39.217.142]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 26 Nov 2013 01:44:09 +0100 Received: from rasmus by dynamic-adsl-94-39-217-142.clienti.tiscali.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 26 Nov 2013 01:44:09 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Rasmus writes: > Probably you can remove the require 'cl. Also, you can generalize the > code to take arbitrarily hline positions. Here's a more fun :post function (again depending on cl). #+NAME: add_hline #+BEGIN_SRC emacs-lisp :var data='((a b c) (d e f) (h i j)) h='(0 -2 100 last) (let* ((d (copy-list data)) (h0 (delq nil (mapcar (lambda (e) (when (or (not (numberp e)) (< (abs e) (length data))) (cond ((equal e 'last) (length data)) ((and (numberp e) (< e 0)) (+ (length data) e)) (t e)))) (if (listp h) h (list h))))) (h1 (number-sequence 0 (1- (length h0)))) (H (mapcar* '+ h0 h1))) (dolist (x H) (push 'hline (nthcdr x d))) d) #+END_SRC #+BEGIN_SRC sh :post add_hline(data=*this*, h='(0 1 last)) echo "a b c d" echo "1 2 3 4" echo "5 6 7 8" #+END_SRC #+RESULTS: |---+---+---+---| | a | b | c | d | |---+---+---+---| | 1 | 2 | 3 | 4 | | 5 | 6 | 7 | 8 | |---+---+---+---| -- In theory, practice and theory are the same. In practice they are not