From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Conditional summing in column-mode? Date: Fri, 01 Sep 2017 23:29:11 +0200 Message-ID: <87d17a2jmg.fsf@nicolasgoaziou.fr> References: <87bmn4ytce.fsf@nicolasgoaziou.fr> <87shgfxvzr.fsf@nicolasgoaziou.fr> <87tw0qrgqd.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dntV8-0005Zl-Qh for emacs-orgmode@gnu.org; Fri, 01 Sep 2017 17:29:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dntV4-0001Kk-Rb for emacs-orgmode@gnu.org; Fri, 01 Sep 2017 17:29:18 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:49347) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dntV4-0001Jq-L7 for emacs-orgmode@gnu.org; Fri, 01 Sep 2017 17:29:14 -0400 In-Reply-To: (Stig Brautaset's message of "Fri, 01 Sep 2017 01:07:07 +0100") 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" To: Stig Brautaset Cc: emacs-org list Hello, Stig Brautaset writes: > I think I like it. So I could then do something like: > > (defun sb/org-collect-confirmed-days () > "Return `DAYS' for `CONFIRMED' entries, otherwise return 0" > (let ((days (org-entry-get nil "DAYS")) > (confirmed (org-entry-get nil "CONFIRMED"))) > (if (and days (string= "[X]" confirmed)) > days > "0"))) > > (setq org-columns-summary-types > '(("X+" org-columns--summary-sum > sb/org-collect-confirmed-days))) That's the idea, expect it should take one argument, the property being summarized. > That seems quite elegant! I guess the COLLECT function would be called > in `org-agenda-colview-summarize' such that the existing summary > functions would not need to change? No, it wouldn't. It would be called in `org-columns--compute-spec' where `value' is bound. Actually, we could write a getter, `org-columns--collect', which would return COLLECT, as defined in the summary, or (lambda (p) (org-entry-get (point) p)) Note that COLLECT function is called on a headline. Returning an empty string means the property has no value (per `value-set' in the function `org-columns--compute-spec'). > Though, there will then be a tight coupling between the "X+" label and > the column name, which is not ideal. Perhaps the COLLECT function could > (optionally?) take the column name Indeed. > I don't mind having a go at adding support for this, Great. Implementation-wise, I think there is not much to do. But it needs to be documented and tested in "test-org-colview.el". Thank you! Regards, -- Nicolas Goaziou