From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?iso-8859-1?Q?Vincent_Bela=EFche?= Newsgroups: gmane.emacs.devel Subject: Re: Contribution to SES (resend) Date: Sun, 20 Jun 2010 19:34:29 +0200 Message-ID: <80hbkx38wq.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1277055303 6368 80.91.229.12 (20 Jun 2010 17:35:03 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 20 Jun 2010 17:35:03 +0000 (UTC) To: emacs-devel@gnu.org , Stefan Monnier , Jonathan Yavner Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jun 20 19:35:01 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OQOQ5-0005Tp-7d for ged-emacs-devel@m.gmane.org; Sun, 20 Jun 2010 19:34:58 +0200 Original-Received: from localhost ([127.0.0.1]:38033 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OQOQ2-0005CQ-NU for ged-emacs-devel@m.gmane.org; Sun, 20 Jun 2010 13:34:54 -0400 Original-Received: from [140.186.70.92] (port=46400 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OQOPv-0005CB-7u for emacs-devel@gnu.org; Sun, 20 Jun 2010 13:34:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OQOPt-00011B-OZ for emacs-devel@gnu.org; Sun, 20 Jun 2010 13:34:47 -0400 Original-Received: from smtp20.orange.fr ([80.12.242.26]:25631) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OQOPt-000112-Df for emacs-devel@gnu.org; Sun, 20 Jun 2010 13:34:45 -0400 Original-Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2028.orange.fr (SMTP Server) with ESMTP id 2E46A2005594; Sun, 20 Jun 2010 19:34:44 +0200 (CEST) Original-Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2028.orange.fr (SMTP Server) with ESMTP id 1FDFE2005596; Sun, 20 Jun 2010 19:34:44 +0200 (CEST) Original-Received: from CHOUNEK (ARennes-353-1-36-110.w92-135.abo.wanadoo.fr [92.135.243.110]) by mwinf2028.orange.fr (SMTP Server) with ESMTP id 5F90E2005594; Sun, 20 Jun 2010 19:34:43 +0200 (CEST) X-ME-UUID: 20100620173443391.5F90E2005594@mwinf2028.orange.fr X-Antivirus: avast! (VPS 100620-0, 20/06/2010), Outbound message X-Antivirus-Status: Clean X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:126272 Archived-At: --=-=-= Content-Disposition: inline Hello, I just wanted to know what the status of my contribution is. To my recollection we had agreed that it was not an issue to change the default order of cells returned by ses-range, because this order was not documented, so anyhow it was not safe to rely on any specific order. There was also that Stefan did not wanted the #N= ... #N# construct, I had removed most of them. Here is attached an update with *all* of them removed by using an flet --- so SES will need cl. Hopefully this will not make the code less efficient Now the only remaining open point was that Jonathan did not like the `v>' kind of unevaluated symbols, I proposed to replace `v>' by `:v>', sorry if there was an answer, I missed it. I would be happy if we could conclude on this, and have this contribution agreed. Vincent. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=ses.el.diff Content-Description: Updated contribution with removal of #N= ... #N# constructs *** ses.el.old Wed Apr 21 21:34:40 2010 --- ses.el Sun Jun 20 17:17:06 2010 *************** *** 1,4 **** ! ;;; ses.el -- Simple Emacs Spreadsheet -*- coding: utf-8 -*- ;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 ;; Free Software Foundation, Inc. --- 1,4 ---- ! ;; ses.el -- Simple Emacs Spreadsheet -*- coding: utf-8 -*- ;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 ;; Free Software Foundation, Inc. *************** *** 41,47 **** ;;; Code: (require 'unsafep) ! ;;---------------------------------------------------------------------------- ;; User-customizable variables --- 41,47 ---- ;;; Code: (require 'unsafep) ! (eval-when-compile (require 'cl)) ;;---------------------------------------------------------------------------- ;; User-customizable variables *************** *** 2886,2900 **** ;; Standard formulas ;;---------------------------------------------------------------------------- ! (defmacro ses-range (from to) ! "Expands to a list of cell-symbols for the range. The range automatically ! expands to include any new row or column inserted into its middle. The SES ! library code specifically looks for the symbol `ses-range', so don't create an ! alias for this macro!" ! (let (result) (ses-dorange (cons from to) ! (push (ses-cell-symbol row col) result)) ! (cons 'list result))) (defun ses-delete-blanks (&rest args) "Return ARGS reversed, with the blank elements (nil and *skip*) removed." --- 2886,3015 ---- ;; Standard formulas ;;---------------------------------------------------------------------------- ! (defun ses--clean-! (&rest x) ! "Clean by delq list X from any occurrence of `nil' or `*skip*'" ! (delq nil (delq '*skip* x))) ! ! (defun ses--clean-_ (x y) ! "Clean list X by replacing by Y any occurrence of `nil' or `*skip*'. ! This will change X by making setcar on its cons cells." ! (let ((ret x) ret-elt) ! (while ret ! (setq ret-elt (car ret)) ! (when (memq ret-elt '(nil *skip*)) ! (setcar ret y)) ! (setq ret (cdr ret)))) ! x) ! ! (defmacro ses-range (from to &rest rest) ! "Expands to a list of cell-symbols for the range groing from ! FROM up to TO. The range automatically expands to include any ! new row or column inserted into its middle. The SES library code ! specifically looks for the symbol `ses-range', so don't create an ! alias for this macro! ! ! By passing in REST some flags one can configure the way the range ! is read and how it is formatted. ! ! In the sequel we assume that cells A1, B1, A2 B2 have respective values ! 1 2 3 and 4 for examplication. ! ! Readout direction is specified by a `>v', '`>^', `', `v<', `^>', `^<' flag. For historical reasons, in absence ! of such a flag, a default direction of `^<' is assumed. This ! way `(ses-range A1 B2 ^>)' will evaluate to `(1 3 2 4)', ! while `(ses-range A1 B2 >^)' will evaluate to (3 4 1 2). ! ! If the range is one row, then `>' can be used as a shorthand to ! `>v' or `>^', and `<' to `' or `v<', and `^' to `^>' or `v<'. ! ! A `!' flag will remove all cells whose value is nil or `*skip*'. ! ! A `_' flag will replace nil or `*skip*' by the value following ! the `_' flag. If the `_' flag is the last argument, then they are ! replaced by integer 0. ! ! A `*', `*1' or `*2' flag will vectorize the range in the sense of ! Calc. See info node `(Calc) Top'. Flag `*' will output either a ! vector or a matrix depending on the number of rows, `*1' will ! flatten the result to a one row vector, and `*2' will make a ! matrix whatever the number of rows. ! ! Warning: interaction with Calc is expermimental and may produce ! confusing results if you are not aware of Calc data format. Use ! `math-format-value' as a printer for Calc objects." ! (let (result-row ! result ! (prev-row -1) ! (reorient-x t) ! (reorient-y t) ! transpose vectorize ! (clean 'list)) (ses-dorange (cons from to) ! (when (/= prev-row row) ! (push result-row result) ! (setq result-row nil)) ! (push (ses-cell-symbol row col) result-row) ! (setq prev-row row)) ! (push result-row result) ! (while rest ! (let ((x (pop rest))) ! (case x ! ((>v) (setq transpose nil reorient-x nil reorient-y nil)) ! ((>^)(setq transpose nil reorient-x nil reorient-y t)) ! ((<^)(setq transpose nil reorient-x t reorient-y t)) ! (()(setq transpose t reorient-x nil reorient-y t)) ! ((^>)(setq transpose t reorient-x nil reorient-y nil)) ! ((^<)(setq transpose t reorient-x t reorient-y nil)) ! ((v<)(setq transpose t reorient-x t reorient-y t)) ! ((* *2 *1) (setq vectorize x)) ! ((!) (setq clean 'ses--clean-!)) ! ((_) (setq clean `(lambda (&rest x) (ses--clean-_ x ,(if rest (pop rest) 0))))) ! (t ! (cond ! ; shorthands one row ! ((and (null (cddr result)) (memq x '(> <))) ! (push (intern (concat (symbol-name x) "v")) rest)) ! ; shorthands one col ! ((and (null (cdar result)) (memq x '(v ^))) ! (push (intern (concat (symbol-name x) ">")) rest)) ! (t (error "Unexpected flag `%S' in ses-range" x))))))) ! (if reorient-y ! (setcdr (last result 2) nil) ! (setq result (cdr (nreverse result)))) ! (unless reorient-x ! (setq result (mapcar 'nreverse result))) ! (when transpose ! (let ((ret (mapcar (lambda (x) (list x)) (pop result))) iter) ! (while result ! (setq iter ret) ! (dolist (elt (pop result)) ! (setcar iter (cons elt (car iter))) ! (setq iter (cdr iter)))) ! (setq result ret))) ! ! (flet ((vectorize-*1 ! (clean result) ! (cons clean (cons (quote 'vec) (apply 'append result)))) ! (vectorize-*2 ! (clean result) ! (cons clean (cons (quote 'vec) (mapcar (lambda (x) ! (cons clean (cons (quote 'vec) x))) ! result))))) ! (cons clean (cons (quote 'vec) (apply 'append result))) ! (case vectorize ! (nil (cons clean (apply 'append result))) ! (*1 (vectorize-*1 clean result)) ! (*2 (vectorize-*2 clean result)) ! (* (if (cdr result) ! (vectorize-*2 clean result) ! (vectorize-*1 clean result))))))) ! ! (defun ses-delete-blanks (&rest args) "Return ARGS reversed, with the blank elements (nil and *skip*) removed." --=-=-=--