From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Banel Subject: Re: make orgtbl-ascii-plot easier to install Date: Tue, 26 Aug 2014 23:42:31 +0200 Message-ID: <53FCFF47.4060805@free.fr> References: <53C2ADB0.2010404@free.fr> <87oaw9wg3s.fsf@bzg.ath.cx> <53E7F088.8010401@free.fr> <87tx4zhcvs.fsf@nicolasgoaziou.fr> <53FCE574.3010307@free.fr> <87vbpfnghj.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMOVl-0000B2-RR for emacs-orgmode@gnu.org; Tue, 26 Aug 2014 17:42:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMOVd-000772-KJ for emacs-orgmode@gnu.org; Tue, 26 Aug 2014 17:42:41 -0400 Received: from smtp2-g21.free.fr ([212.27.42.2]:4939) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMOVd-00076p-C7 for emacs-orgmode@gnu.org; Tue, 26 Aug 2014 17:42:33 -0400 Received: from [IPv6:2a01:e35:2e21:def0:f485:fae9:2cf9:1f52] (unknown [IPv6:2a01:e35:2e21:def0:f485:fae9:2cf9:1f52]) by smtp2-g21.free.fr (Postfix) with ESMTP id 4428C4B0054 for ; Tue, 26 Aug 2014 23:42:32 +0200 (CEST) In-Reply-To: <87vbpfnghj.fsf@nicolasgoaziou.fr> 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
Le 26/08/2014 22:27, Nicolas Goaziou a =E9crit=A0:
Thierry Banel <tbanelwebmin@free.fr> writes=
:

I'll change to let-binding. What is the rational f=
or that ? Better
byte-code ?
This is faster, indeed. Also, the scope of the binding is explicit. It
is sometimes hard to tell where the value of a setq'ed variable comes
from.
Good !


Actually this should be `cl-most-positive-float', =
because everything
here works in floating point values. Thanks for the clue.
Oh, right. Then, I wouldn't bother in this case. Org supports Emacs 23
and cl-lib is not easily available.

Small nitpick: I suggest to use `dolist' instead o=
f `mapc' (no funcall
overhead).

Sure, easier to read.
This is also kinda like let vs setq.
Do you recommend to stay away from CL & CL-LIB for ORG stuff ? `DOLIST' comes from CL as well...

IOW, you need to eliminate the leading 'hline, if =
any,and skip until
the next 'hline if there is one and if there is something after it.

Ok. Not completely fool-proof, but better.
Do you think of another case that wouldn't be covered by this?

1st case: a header and several hlines.
In this case, values 1,2,3 will be ignored.

| header |
|--------| <-- leading hline: skipped
|=A0=A0=A0=A0=A0 1 |
|=A0=A0=A0=A0=A0 2 |
|=A0=A0=A0=A0=A0 3 |
|--------| <-- next hline: ignore whatever is before
|=A0=A0=A0=A0=A0 4 |
|=A0=A0=A0=A0=A0 5 |
|=A0=A0=A0=A0=A0 6 |

2nd case: no header at all, values in boxes.
Values 1,2,3 will be ignored as well.

|--------| <-- leading hline: skipped
|=A0=A0=A0=A0=A0 1 |
|=A0=A0=A0=A0=A0 2 |
|=A0=A0=A0=A0=A0 3 |
|--------| <-- next hline:
ignore whatever is before
|=A0=A0=A0=A0=A0 4 |
|=A0=A0=A0=A0=A0 5 |
|=A0=A0=A0=A0=A0 6 |
|--------| <-- last hline



On the other hand, this loop searches for the min =
and the max of
a column, ignoring entries which are not numbers. So it could just
iterate over the full column, including any kind of headers.

| header | <-- ignored
|--------| <-- ignored
| 1 | <-- used (will set min=3D1)
| 2 | <-- used
| xx | <-- ignored
| 3 | <-- used (will set max=3D3)
|--------| <-- ignored
But header and the rest of the column may be both numbers but expressed
in different units, e.g. header could be a year and column inhabitants.
FWIW, I think skipping header (when there is one) is a good idea.

Good use-case !
Now I am not sure what to do anymore.
There is already a heuristic algorithm in org-table to apply column-formulas. It does a good job at avoiding computing the formula for headers. Maybe I should mimic it.

Header surrounded by hlines:

|--------+----|
| Header |=A0=A0=A0 | <-- formula not applied |--------+----|
|=A0=A0=A0=A0=A0 1 | 10 | <-- $1*10
|=A0=A0=A0=A0=A0 2 | 20 | <-- $1*10
|--------+----|
|=A0=A0=A0=A0=A0 3 | 30 | <-- $1*10
|=A0=A0=A0=A0=A0 4 | 40 | <-- $1*10
#+TBLFM: $2=3D$1*10


Header over several lines, no top-hline:

| Head1 |=A0=A0=A0 | <-- formula not applied
| Head2 |=A0=A0=A0 | <-- formula not applied
|-------+----|
|=A0=A0=A0=A0 3 | 30 | <-- $1*10
|=A0=A0=A0=A0 4 | 40 | <-- $1*10
#+TBLFM: $2=3D$1*10


No header, just values

| 3 | 30 | <-- $1*10
| 4 | 40 | <-- $1*10
#+TBLFM: $2=3D$1*10


The only ill-interpreted case is this one, with no header.
The first values are considered as headers:

|---+----|
| 3 |=A0=A0=A0 | <-- formula not applied
| 4 |=A0=A0=A0 | <-- formula not applied
|---+----|
| 5 | 50 |
| 6 | 60 |
|---+----|
#+TBLFM: $2=3D$1*10


Thanks for all this feedback.
Thierry