From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: make orgtbl-ascii-plot easier to install Date: Tue, 26 Aug 2014 22:27:52 +0200 Message-ID: <87vbpfnghj.fsf@nicolasgoaziou.fr> References: <53C2ADB0.2010404@free.fr> <87oaw9wg3s.fsf@bzg.ath.cx> <53E7F088.8010401@free.fr> <87tx4zhcvs.fsf@nicolasgoaziou.fr> <53FCE574.3010307@free.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMNKo-0007CM-8t for emacs-orgmode@gnu.org; Tue, 26 Aug 2014 16:27:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMNKe-0001a9-3B for emacs-orgmode@gnu.org; Tue, 26 Aug 2014 16:27:18 -0400 Received: from relay5-d.mail.gandi.net ([2001:4b98:c:538::197]:42352) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMNKd-0001Zn-TC for emacs-orgmode@gnu.org; Tue, 26 Aug 2014 16:27:08 -0400 In-Reply-To: <53FCE574.3010307@free.fr> (Thierry Banel's message of "Tue, 26 Aug 2014 21:52:20 +0200") 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: Thierry Banel Cc: emacs-orgmode@gnu.org Thierry Banel writes: > I'll change to let-binding. What is the rational for 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. > Can I limit VALUE to numbers ? VALUE comes from a cell in the table. > The formula line of the table looks like this: > > #+TBLFM: $2='(orgtbl-ascii-draw $1 1 3 12) > > VALUE is $1 in this formula. > If (string-to-number VALUE) fails, it will return zero, which is not > very harmful. Nevermind then. > 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 of `mapc' (no funcall > overhead). > > Sure, easier to read. This is also kinda like let vs setq. > Before hard-coding this regexp, I took a look at what was already > there. org-table-number-regexp matches too much, for instance it > matches: > "<345" > "345()" > "345%45" > "0x45" // hexadecimal > "1101#2" // base two > Anyway, the string feeds (string-to-number x) which does not accept > all those variations. So I created a regexp exactly fitted for > (string-to-number). OK. > 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? > 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=1) > | 2 | <-- used > | xx | <-- ignored > | 3 | <-- used (will set max=3) > |--------| <-- 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. Regards, -- Nicolas Goaziou