From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Brand Subject: Re: Table formula and text properties Date: Thu, 8 Jan 2015 18:26:50 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9GrE-0000lQ-PZ for emacs-orgmode@gnu.org; Thu, 08 Jan 2015 12:26:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y9GrD-00034e-L6 for emacs-orgmode@gnu.org; Thu, 08 Jan 2015 12:26:52 -0500 Received: from mail-qg0-x230.google.com ([2607:f8b0:400d:c04::230]:61494) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9GrD-00034Y-GW for emacs-orgmode@gnu.org; Thu, 08 Jan 2015 12:26:51 -0500 Received: by mail-qg0-f48.google.com with SMTP id j5so3400763qga.7 for ; Thu, 08 Jan 2015 09:26:51 -0800 (PST) In-Reply-To: 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: Willem Rein Oudshoorn Cc: Org Mode Hi Wim On Wed, Jan 7, 2015 at 6:11 PM, Willem Rein Oudshoorn wrote: > I am trying to insert an image into a table by using a table formula. > My basic approach is by using a string with a display property like: > > > (propertize "TEXT" 'display (list image)) > > > Or to be more precise > > (propertize "SPARKLINE" 'display > (list (sparkline-make-sparkline > 100 10 > '(1 20 12 13 141 13 24 90)))) > > In which the `sparkline-make-sparkline' function returns an image. Very interesting. Your package to insert a sparkline image http://en.wikipedia.org/wiki/Sparkline into an Emacs buffer is nice: https://github.com/woudshoo/sparkline > Inserting the resulting string with `insert' into a buffer will ensure > the image is displayed. > > However org mode table formula code seems to strip the display property > from the string returned by the formula. So this trick will not work. I think this is by design. If someone wants to change current behavior then there are other issues to be considered: An 80 by 8 pixel image that is inserted with (insert-image (sparkline-make-sparkline 80 8 '(1 20 12 13 141 13 24 90)) "SPARKLINE") with point in a table is first visible as an image but will change to the text "SPARKLINE" after e. g. table realignment. And determining column width around an image for table realignment would not be trivial. > Is there a way to insert a calculated image into an org table? Below is a unicode ASCII art solution with Zach Holman's shell script package Spark: https://github.com/holman/spark | Measurement | t0 | t1 | t2 | t3 | t4 | t5 | t6 | t7 | Sparkline | |-------------+----+----+----+----+-----+----+----+----+-----------| | 1 | 1 | 20 | 12 | 13 | 141 | 13 | 24 | 90 | =E2=96=81=E2=96=81= =E2=96=81=E2=96=81=E2=96=88=E2=96=81=E2=96=82=E2=96=85 | | 2 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | =E2=96=81=E2=96=82= =E2=96=83=E2=96=84=E2=96=85=E2=96=86=E2=96=87=E2=96=88 | | 3 | 0 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | =E2=96=81=E2=96=82= =E2=96=83=E2=96=84=E2=96=85=E2=96=86=E2=96=87=E2=96=88 | | 4 | -7 | -6 | -5 | -4 | -3 | -2 | -1 | 0 | =E2=96=81=E2=96=82= =E2=96=83=E2=96=84=E2=96=85=E2=96=86=E2=96=87=E2=96=88 | | 5 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | =E2=96=85=E2=96=85= =E2=96=85=E2=96=85=E2=96=85=E2=96=85=E2=96=85=E2=96=85 | #+TBLFM: $10 =3D '(org-trim (shell-command-to-string "spark $2..$9")); L It would be nice if in your package someone could support one of (sparkline-make-sparkline nil nil '(1 20 12 13 141 13 24 90)) =3D> "=E2=96=81= =E2=96=81=E2=96=81=E2=96=81=E2=96=88=E2=96=81=E2=96=82=E2=96=85" (sparkline-make-unicode 1 20 12 13 141 13 24 90) =3D> "=E2=96=81=E2=96= =81=E2=96=81=E2=96=81=E2=96=88=E2=96=81=E2=96=82=E2=96=85" to work like Zach Holman's Spark to replace the above TBLFM with one of #+TBLFM: $10 =3D '(sparkline-make-sparkline nil nil '($2..$9)); L #+TBLFM: $10 =3D '(sparkline-make-unicode $2..$9); L For completeness I would like to mention Thierry Banel's orgtbl-ascii-plot which has been added to Org core meanwhile: http://orgmode.org/worg/org-contrib/orgtbl-ascii-plot.html Michael