From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adam Elliott Subject: [PATCH] Add tags filter parameter to clock table Date: Tue, 23 Feb 2010 02:13:40 -0500 Message-ID: <4B838024.8000006@hgn.ca> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050204020003070507010608" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Njoxx-0002sT-MH for emacs-orgmode@gnu.org; Tue, 23 Feb 2010 02:13:57 -0500 Received: from [140.186.70.92] (port=54376 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Njoxo-0002pp-6m for emacs-orgmode@gnu.org; Tue, 23 Feb 2010 02:13:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Njoxh-00080p-K0 for emacs-orgmode@gnu.org; Tue, 23 Feb 2010 02:13:48 -0500 Received: from cymlink-stage.hgn.ca ([64.26.151.4]:40310) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Njoxh-00080Z-6Q for emacs-orgmode@gnu.org; Tue, 23 Feb 2010 02:13:41 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) by cymlink-stage.hgn.ca (Postfix) with ESMTP id 1365E13CE9 for ; Tue, 23 Feb 2010 02:13:37 -0500 (EST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org This is a multi-part message in MIME format. --------------050204020003070507010608 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit I have attached a git patch against master that implements a new parameter to clock tables, "tags". This parameter is a tags-query as a string and is used to filter the headlines which are consulted when building the clock table. In my search of the archives to see if this feature already existed, I found a reference here: http://article.gmane.org/gmane.emacs.orgmode/17304 suggesting it was difficult. The patch is not so large, though, so perhaps I am missing something. My rationale in implementing this feature was to keep track of the occasional task item that is not billable, yet still makes sense to include in the overall project structure. Of course I could just avoid clocking the task item, or manually delete clock lines before generating a report, but this feature reduces the chance for error; no doubt there are other workflows enabled with this feature as well. I don't make significant use of tags myself, but I know many do. In order to maintain a sensible report, headlines that don't match the tag filter may be included if they have descendants that do. Any time clocked directly on non-matching headlines, however, is excluded. Specifying even a simple filter noticeably slows down clock table generation for non-toy reports, particularly for clock table reports with :step. If there is no filter, though, there is no degradation in performance. Tag filter syntax is the standard one, as described at: http://orgmode.org/manual/Matching-tags-and-properties.html Only tags are considered at the moment, although I suspect querying against all properties would be possible (if even slower). Examples: * development CLOCK: => 1:00 *** task 1 CLOCK: => 1:00 *** task 2 :must: ***** task 2a CLOCK: => 1:00 ***** task 2b :mustnot: CLOCK: => 1:00 Note I am using an unconventional but legal(ish) clock format for brevity. Clock tables are also pruned to only relevant lines. [1] #+BEGIN: clocktable | | *Total time* | *4:00* | | | |---+--------------+--------+------+------| | 1 | development | 4:00 | | | | 2 | task 1 | | 1:00 | | | 2 | task 2 | | 2:00 | | | 3 | task 2a | | | 1:00 | | 3 | task 2b | | | 1:00 | [2] #+BEGIN: clocktable :tags "must" | | *Total time* | *2:00* | | | |---+--------------+--------+------+------| | 1 | development | 2:00 | | | | 2 | task 2 | | 2:00 | | | 3 | task 2a | | | 1:00 | | 3 | task 2b | | | 1:00 | [3] #+BEGIN: clocktable :tags "-mustnot" | | *Total time* | *3:00* | | | |---+--------------+--------+------+------| | 1 | development | 3:00 | | | | 2 | task 1 | | 1:00 | | | 2 | task 2 | | 1:00 | | | 3 | task 2a | | | 1:00 | [4] #+BEGIN: clocktable :tags "must-mustnot" | | *Total time* | *1:00* | | | |---+--------------+--------+------+------| | 1 | development | 1:00 | | | | 2 | task 2 | | 1:00 | | | 3 | task 2a | | | 1:00 | [5] #+BEGIN: clocktable :tags "must+mustnot" | | *Total time* | *1:00* | | | |---+--------------+--------+------+------| | 1 | development | 1:00 | | | | 2 | task 2 | | 1:00 | | | 3 | task 2b | | | 1:00 | As you can see, in examples 2, 4, and 5, the time clocked on "development" itself is being removed. Example 2 illustrates the effect of tag inheritance. Adam --------------050204020003070507010608 Content-Type: text/plain; name="0001-Add-tags-filter-parameter-to-clocktables.patch" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="0001-Add-tags-filter-parameter-to-clocktables.patch" RnJvbSA4MGZiN2IwMWM1ODk4OWVkNjliNWExNzY3ODRkNzFmZTU1N2ZjNGM2IE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBBZGFtIEVsbGlvdHQgPGFlbGxpb3R0QGhnbi5jYT4K RGF0ZTogTW9uLCAyMiBGZWIgMjAxMCAwMDo1NzoyMiAtMDUwMApTdWJqZWN0OiBbUEFUQ0hd IEFkZCB0YWdzIGZpbHRlciBwYXJhbWV0ZXIgdG8gY2xvY2t0YWJsZXMuCgotLS0KIGxpc3Av b3JnLWNsb2NrLmVsIHwgICA1OSArKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysr KysrKysrKy0tLS0tLS0tLS0tCiAxIGZpbGVzIGNoYW5nZWQsIDQ2IGluc2VydGlvbnMoKyks IDEzIGRlbGV0aW9ucygtKQogbW9kZSBjaGFuZ2UgMTAwNjQ0ID0+IDEwMDc1NSBsaXNwL29y Zy1jbG9jay5lbAoKZGlmZiAtLWdpdCBhL2xpc3Avb3JnLWNsb2NrLmVsIGIvbGlzcC9vcmct Y2xvY2suZWwKb2xkIG1vZGUgMTAwNjQ0Cm5ldyBtb2RlIDEwMDc1NQppbmRleCBlMzg2NmJl Li5mYjg1MzgwCi0tLSBhL2xpc3Avb3JnLWNsb2NrLmVsCisrKyBiL2xpc3Avb3JnLWNsb2Nr LmVsCkBAIC0xMjg5LDEwICsxMjg5LDEzIEBAIFdpdGggcHJlZml4IGFyZyBTRUxFQ1QsIG9m ZmVyIHJlY2VudGx5IGNsb2NrZWQgdGFza3MgZm9yIHNlbGVjdGlvbi4iCiA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luZQotCSAg KHNldHEgbGV2ZWwgKC0gKG1hdGNoLWVuZCAxKSAobWF0Y2gtYmVnaW5uaW5nIDEpKSkKLQkg ICh3aGVuIChvciAoPiB0MSAwKSAoPiAoYXJlZiBsdGltZXMgbGV2ZWwpIDApKQotCSAgICAo bG9vcCBmb3IgbCBmcm9tIDAgdG8gbGV2ZWwgZG8KLQkJICAoYXNldCBsdGltZXMgbCAoKyAo YXJlZiBsdGltZXMgbCkgdDEpKSkKLQkgICAgKHNldHEgdDEgMCB0aW1lIChhcmVmIGx0aW1l cyBsZXZlbCkpCi0JICAgIChsb29wIGZvciBsIGZyb20gbGV2ZWwgdG8gKDEtIGxtYXgpIGRv Ci0JCSAgKGFzZXQgbHRpbWVzIGwgMCkpCi0JICAgIChnb3RvLWNoYXIgKG1hdGNoLWJlZ2lu bmluZyAwKSkKLQkgICAgKHB1dC10ZXh0LXByb3BlcnR5IChwb2ludCkgKHBvaW50LWF0LWVv bCkgOm9yZy1jbG9jay1taW51dGVzIHRpbWUpKSkpKQorCSAgKGxldCogKChoZWFkbGluZS1m b3JjZWQKKyAgICAgICAgICAgICAgICAgIChnZXQtdGV4dC1wcm9wZXJ0eSAocG9pbnQpCisg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOm9yZy1jbG9jay1mb3JjZS1o ZWFkbGluZS1pbmNsdXNpb24pKQorICAgICAgICAgICAgICAgICAoaGVhZGxpbmUtaW5jbHVk ZWQKKyAgICAgICAgICAgICAgICAgIChvciAobnVsbCBoZWFkbGluZS1maWx0ZXIpCisgICAg ICAgICAgICAgICAgICAgICAgKHNhdmUtZXhjdXJzaW9uCisgICAgICAgICAgICAgICAgICAg ICAgICAoc2F2ZS1tYXRjaC1kYXRhIChmdW5jYWxsIGhlYWRsaW5lLWZpbHRlcikpKSkpKQor CSAgICAoc2V0cSBsZXZlbCAoLSAobWF0Y2gtZW5kIDEpIChtYXRjaC1iZWdpbm5pbmcgMSkp KQorCSAgICAod2hlbiAob3IgKD4gdDEgMCkgKD4gKGFyZWYgbHRpbWVzIGxldmVsKSAwKSkK KwkgICAgICAod2hlbiAob3IgaGVhZGxpbmUtaW5jbHVkZWQgaGVhZGxpbmUtZm9yY2VkKQor ICAgICAgICAgICAgICAgIChpZiBoZWFkbGluZS1pbmNsdWRlZAorICAgICAgICAgICAgICAg ICAgICAobG9vcCBmb3IgbCBmcm9tIDAgdG8gbGV2ZWwgZG8KKyAgICAgICAgICAgICAgICAg ICAgICAgICAgKGFzZXQgbHRpbWVzIGwgKCsgKGFyZWYgbHRpbWVzIGwpIHQxKSkpKQorCQko c2V0cSB0aW1lIChhcmVmIGx0aW1lcyBsZXZlbCkpCisJCShnb3RvLWNoYXIgKG1hdGNoLWJl Z2lubmluZyAwKSkKKwkJKHB1dC10ZXh0LXByb3BlcnR5IChwb2ludCkgKHBvaW50LWF0LWVv bCkgOm9yZy1jbG9jay1taW51dGVzIHRpbWUpCisgICAgICAgICAgICAgICAgKGlmIGhlYWRs aW5lLWZpbHRlcgorICAgICAgICAgICAgICAgICAgICAoc2F2ZS1leGN1cnNpb24KKyAgICAg ICAgICAgICAgICAgICAgICAoc2F2ZS1tYXRjaC1kYXRhCisgICAgICAgICAgICAgICAgICAg ICAgICAod2hpbGUKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAoPiAoZnVuY2FsbCBv dXRsaW5lLWxldmVsKSAxKQorICAgICAgICAgICAgICAgICAgICAgICAgICAob3V0bGluZS11 cC1oZWFkaW5nIDEgdCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgKHB1dC10ZXh0LXBy b3BlcnR5CisgICAgICAgICAgICAgICAgICAgICAgICAgICAocG9pbnQpIChwb2ludC1hdC1l b2wpCisgICAgICAgICAgICAgICAgICAgICAgICAgICA6b3JnLWNsb2NrLWZvcmNlLWhlYWRs aW5lLWluY2x1c2lvbiB0KSkpKSkpCisJICAgICAgKHNldHEgdDEgMCkKKwkgICAgICAobG9v cCBmb3IgbCBmcm9tIGxldmVsI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ICgodGFncy1saXN0CisJCQkJICAgIChvcmct c3BsaXQtc3RyaW5nCisJCQkJICAgICAob3IgKG9yZy1lbnRyeS1nZXQgKHBvaW50KSAiQUxM VEFHUyIpICIiKQorCQkJCSAgICAgIjoiKSkpCisJCQkgICAgICAgKGV2YWwgbWF0Y2hlcikp KSkpCiAJICAoZ290by1jaGFyIChwb2ludC1taW4pKQogCSAgKHNldHEgc3QgdCkKIAkgICh3 aGlsZSAob3IgKGFuZCAoYm9icCkgKHByb2cxIHN0IChzZXRxIHN0IG5pbCkpCi0tIAoxLjYu Ni4xCgo= --------------050204020003070507010608 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --------------050204020003070507010608--