From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id QM/JJjlFlF+tUgAA0tVLHw (envelope-from ) for ; Sat, 24 Oct 2020 15:16:09 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id QHmcIjlFlF/SagAAbx9fmQ (envelope-from ) for ; Sat, 24 Oct 2020 15:16:09 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 3F2B09401DD for ; Sat, 24 Oct 2020 15:16:09 +0000 (UTC) Received: from localhost ([::1]:51340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kWLH5-00010t-Rn for larch@yhetil.org; Sat, 24 Oct 2020 11:16:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kWLGi-00010g-Id for emacs-orgmode@gnu.org; Sat, 24 Oct 2020 11:15:44 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:35525) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kWLGg-0001Da-RN for emacs-orgmode@gnu.org; Sat, 24 Oct 2020 11:15:44 -0400 Received: by mail-wm1-x330.google.com with SMTP id q5so6055149wmq.0 for ; Sat, 24 Oct 2020 08:15:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=JeBf6/s3LCJRY7Mxqks6EFo1mFxpCeKmaP7wToHBcgM=; b=QM0wL8+Kw7EsQJZ5YOkzXLZ07NKkfdq0Fwy32oFi4M8heX/DR0y/QpEwSbTtRiqqsW hlAIKCQRNmhS++QYHRDgQMBhrwAl1shgst1u1wbGZwchx0bEK5qofzU8IfWmeefYkIiV 71dD7gyJTycL7icIw+7wOcjxDRIwV7aMS2Z4yk8xzU9Fuc9XPrsjo3AsJzGLM1I2I22T K9wTDeYDwkld8tkd8RMpxr4sc/ozZAY9+VoYMgscX7Ie/wyWxsWhxiL6X3Ffh4TtgMgM JvYqbHLVgo3zOWFmEIHc64XeuSomu0wtsks4UCd2087a85Wm/LaVsj9OBTwTSuXYagwb xpcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=JeBf6/s3LCJRY7Mxqks6EFo1mFxpCeKmaP7wToHBcgM=; b=ijaA0QtfJ2Wdhi96fzzQtB793qAwsVIDCd+o/Z/TELWlT0zh11Vr4o8/QPXAiRSrxa B9S8xWK1MJ6K0C/UuNTlb6/PAhTgoxH4ry5O0fApnWFduVuP4I30k/F36RBCr9uRw0tV ts30KHwtDCoh3cG54/GBPVd/uDK5sTDWY4WAH7qm11UmllORLukzFMCuq6fuvsXLK4SY Uwr7zHyoV8kkQNE5plYsuIJyEGjfVlcccUQF2d9B0ESEfwBCXxozToDEk425+UIWH1e+ r6eXATMiQ3TAqAb6pisQpvK9LpgAboD/UpqMGNjWAS7KPsIQXzTveLz7EpmzyiY4eHQL R7uA== X-Gm-Message-State: AOAM533/XZB69Iek6FNSBAhnsYBIim6H9HbA6SFFilc/73SRK5cebJaa Va6/r3RsmpFWRrMxrgo7HhVqKHsZUfM= X-Google-Smtp-Source: ABdhPJw7qGLT1TKyincvVdRNKInW83VXWhH9UOKL68TQSpKzIy+PXJHlUCq327/wDvVJCjTfaUAtng== X-Received: by 2002:a1c:5f84:: with SMTP id t126mr7312117wmb.89.1603552540514; Sat, 24 Oct 2020 08:15:40 -0700 (PDT) Received: from freegnu (24.183.22.109.rev.sfr.net. [109.22.183.24]) by smtp.gmail.com with ESMTPSA id i10sm12570893wrq.27.2020.10.24.08.15.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Oct 2020 08:15:39 -0700 (PDT) From: Jeremie Juste To: Robert Pluim Subject: Re: org-table-sum References: <87a6xex5o1.fsf@kyleam.com> Date: Sat, 24 Oct 2020 17:15:38 +0200 In-Reply-To: (Robert Pluim's message of "Fri, 25 Sep 2020 10:59:42 +0200") Message-ID: <874kmju02t.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=jeremiejuste@gmail.com; helo=mail-wm1-x330.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kein Test , emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=gmail.com header.s=20161025 header.b=QM0wL8+K; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: 0.09 X-TUID: HPOg7dbvfZBi Hello, I have slightly improved the org-table-sum function. It calls directly calc-eval and yield the same result as vsum. It can not handle better floating points. > | 171.00 | > | 4.07 | > | 4.44 | > | 2.61 | > | 12.21 | > | 6.69 | > | 19.72 | > | 23.09 | > | 6.23 | > | 15.28 | > | 250.00 | > | 250.00 | > | 250.00 | > | 78.85 | > |--------| > | | > #+TBLFM:@>$1=vsum(@1$1..@-1$1) diff --git a/lisp/org-table.el b/lisp/org-table.el index a3c49874c..ac237af2c 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -4728,6 +4728,18 @@ blank, and the content is appended to the field above." ((equal n 0) nil) (t n)))) + +(defun org-table-cell-no-prop (x) + "remove property from org-table-cell. If cell is empty output nil. X is a string - a cell from org-table +usage (org-table-cell-no-prop #(\"foo \" 0 2 (face default))) ==> foo +" + (interactive) + (let ( (res (replace-regexp-in-string "\s+" "" + (substring-no-properties x)))) + (when (not (equal res "")) + res) + )) + ;;;###autoload (defun org-table-sum (&optional beg end nlast) "Sum numbers in region of current table column. @@ -4769,9 +4781,9 @@ If NLAST is a number, only the NLAST fields will actually be summed." (t (setq items (reverse items)) (setcdr (nthcdr (1- nlast) items) nil) (nreverse items)))) - (numbers (delq nil (mapcar #'org-table--number-for-summing - items1))) - (res (apply '+ numbers)) + (numbers (delq nil (mapcar 'org-table-cell-no-prop items1 ))) + (res (string-to-number (calc-eval + (combine-and-quote-strings numbers "+")))) Best regards Jeremie Juste