From mboxrd@z Thu Jan 1 00:00:00 1970 From: Niels Giesen Subject: Re: lisp/org-clock.el: Add param :properties to list properties in clocktable Date: Wed, 18 May 2011 09:08:11 +0200 Message-ID: References: <874o6pocat.fsf@gmail.com> <628944CC-2759-4E4F-B931-C140AFC9E6CF@gmail.com> <8762pfni74.fsf@gmail.com> <3F653FF2-A5AB-456A-9311-501AC76C9C8A@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:48508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QMard-0003VD-OU for emacs-orgmode@gnu.org; Wed, 18 May 2011 03:08:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QMarc-0001Ae-7n for emacs-orgmode@gnu.org; Wed, 18 May 2011 03:08:13 -0400 Received: from mail-qy0-f169.google.com ([209.85.216.169]:49212) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QMarc-0001AU-38 for emacs-orgmode@gnu.org; Wed, 18 May 2011 03:08:12 -0400 Received: by qyk2 with SMTP id 2so3082682qyk.0 for ; Wed, 18 May 2011 00:08:11 -0700 (PDT) In-Reply-To: <3F653FF2-A5AB-456A-9311-501AC76C9C8A@gmail.com> 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: Carsten Dominik Cc: Bernt Hansen , emacs-orgmode list Hi Carsten, thanks for merging, but today, pulling origin master (from git://orgmode.org/org-mode.git) to start work on such a tutorial & checkout the new documentation, I did not see the patch applied. Should be somewhere near 5 days ago on http://orgmode.org/w/org-mode.git. Am I missing something here? Regards, Niels. On Fri, May 13, 2011 at 2:20 PM, Carsten Dominik wrote: > Hi Niels, I have merged your patch thanks. > A tutorial on Worg for your use case would be really helpful. > > - Carsten > > On May 13, 2011, at 10:00 AM, Niels Giesen wrote: > >> Carsten Dominik writes: >> >>> Dear Niels, >>> >>> I am confused by the three patch pieces applied to the same file. >> >> Hi Carsten. Sorry for the confusion; I thought atomic commits were the >> proper thing to do, but apparently they are not. >> >>> Can you please resubmit, with a single patch, and a proper >>> changelog-like entry? >> >> I hope my current attachment is in the appropriate form. >> >> <0001-org-clock-Implement-columns-of-arbitrary-properties.patch> >>> Thanks. >>> >>> - Carsten >>> >>> On Mar 26, 2011, at 9:29 PM, Niels Giesen wrote: >>> >>>> >>>> Here are a few patches to add property columns in clocktables. These >>>> allow me e.g. to freely set different cost centers which is wanted @ >>>> my work, and also possibly small descriptions. It is generically set >>>> up so I reckon other people may find use in this too. >>>> >>>> The patches together add two parameters to the dynamic block line: >>>> >>>> : :properties ("prop-this" "prop-other") :inherit-props t >>>> >>>> The property columns will be added at the left side of the existing >>>> columns; I did experiment with adding them to the right, but because >>>> of the variable number of levels (being defined both by :maxlevel and >>>> the actual number of found levels), that did not work out well. >>>> >>>> I used the parameter =3D:inherit-props=3D to set inheritance for >>>> properties, as I have learned in the past that >>>> =3Dorg-use-property-inheritance=3D should be used very sparingly. >>>> >>>> #+begin_src diff >>>> From 20346cf661e2b9ba0b4a66b705809e6100d9e8e0 Mon Sep 17 00:00:00 2001 >>>> From: Niels Giesen >>>> Date: Sat, 26 Mar 2011 10:19:08 +0100 >>>> Subject: [PATCH 1/3] org-clock: Add properties param handling to `org-= clock-get-table-data' >>>> >>>> This param should be a list of strings referring to properties. Those >>>> properties will be returned in an alist when found in an entry. >>>> --- >>>> lisp/org-clock.el | =C2=A0 14 +++++++++++--- >>>> 1 files changed, 11 insertions(+), 3 deletions(-) >>>> >>>> diff --git a/lisp/org-clock.el b/lisp/org-clock.el >>>> index c567a26..df096d1 100644 >>>> --- a/lisp/org-clock.el >>>> +++ b/lisp/org-clock.el >>>> @@ -1,6 +1,6 @@ >>>> ;;; org-clock.el --- The time clocking code for Org-mode >>>> >>>> -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 >>>> +;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 >>>> ;; =C2=A0 Free Software Foundation, Inc. >>>> >>>> ;; Author: Carsten Dominik >>>> @@ -2335,6 +2335,7 @@ TIME: =C2=A0 =C2=A0 =C2=A0The sum of all time sp= end in this tree, in minutes. =C2=A0This time >>>> =C2=A0 =C2=A0 =C2=A0(block (plist-get params :block)) >>>> =C2=A0 =C2=A0 =C2=A0(link (plist-get params :link)) >>>> =C2=A0 =C2=A0 =C2=A0(tags (plist-get params :tags)) >>>> + =C2=A0 =C2=A0(properties (plist-get params :properties)) >>>> =C2=A0 =C2=A0 =C2=A0(matcher (if tags (cdr (org-make-tags-matcher tags= )))) >>>> =C2=A0 =C2=A0 =C2=A0cc range-text st p time level hdl props tsp tbl) >>>> >>>> @@ -2388,8 +2389,15 @@ TIME: =C2=A0 =C2=A0 =C2=A0The sum of all time s= pend in this tree, in minutes. =C2=A0This time >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 (or (cdr (assoc "SCHEDULED" props)) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (cdr (assoc "DEADLINE" props)) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (cdr (assoc "TIMESTAMP" props)) >>>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 (cdr (assoc "TIMESTAMP_IA" props))))) >>>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 (when (> time 0) (push (list level hdl t= sp time) tbl)))))) >>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 (cdr (assoc "TIMESTAMP_IA" props)))) >>>> + =C2=A0 =C2=A0 =C2=A0 props (when properties >>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (remove nil >>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (mapcar >>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0(lambda (p) >>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(when (org-entry-get (point) p) >>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(cons p (org-entry-get (point) p)))) >>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0properties)))) >>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 (when (> time 0) (push (list level hdl t= sp time props) tbl)))))) >>>> =C2=A0 =C2=A0 =C2=A0(setq tbl (nreverse tbl)) >>>> =C2=A0 =C2=A0 =C2=A0(list file org-clock-file-total-minutes tbl)))) >>>> >>>> -- >>>> 1.7.1 >>>> #+end_src >>>> >>>> #+begin_src diff >>>> From a5da80e0b42256e1a1ea07e213bcae3685786589 Mon Sep 17 00:00:00 2001 >>>> From: Niels Giesen >>>> Date: Sat, 26 Mar 2011 11:05:33 +0100 >>>> Subject: [PATCH 2/3] org-clock: Add properties param handling to `org-= clocktable-write-default' >>>> >>>> Each property specified in properties will get a column in the clockta= ble. >>>> --- >>>> lisp/org-clock.el | =C2=A0 10 ++++++++++ >>>> 1 files changed, 10 insertions(+), 0 deletions(-) >>>> >>>> diff --git a/lisp/org-clock.el b/lisp/org-clock.el >>>> index df096d1..a330db0 100644 >>>> --- a/lisp/org-clock.el >>>> +++ b/lisp/org-clock.el >>>> @@ -2052,6 +2052,7 @@ from the dynamic block defintion." >>>> =C2=A0 =C2=A0 =C2=A0(emph (plist-get params :emphasize)) >>>> =C2=A0 =C2=A0 =C2=A0(level-p (plist-get params :level)) >>>> =C2=A0 =C2=A0 =C2=A0(timestamp (plist-get params :timestamp)) >>>> + =C2=A0 =C2=A0(properties (plist-get params :properties)) >>>> =C2=A0 =C2=A0 =C2=A0(ntcol (max 1 (or (plist-get params :tcolumns) 100= ))) >>>> =C2=A0 =C2=A0 =C2=A0(rm-file-column (plist-get params :one-file-with-a= rchives)) >>>> =C2=A0 =C2=A0 =C2=A0(indent (plist-get params :indent)) >>>> @@ -2115,6 +2116,7 @@ from the dynamic block defintion." >>>> =C2=A0 =C2=A0 =C2=A0(if multifile "|" "") =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0; file column, maybe >>>> =C2=A0 =C2=A0 =C2=A0(if level-p =C2=A0 "|" "") =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0; level column, maybe >>>> =C2=A0 =C2=A0 =C2=A0(if timestamp "|" "") =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0; timestamp column, maybe >>>> + =C2=A0 =C2=A0(if properties (make-string (length properties) ?|) "")= =C2=A0;properties columns, maybe >>>> =C2=A0 =C2=A0 =C2=A0(format "<%d>| |\n" narrow))) =C2=A0; headline and= time columns >>>> >>>> =C2=A0 =C2=A0 =C2=A0;; Insert the table header line >>>> @@ -2123,6 +2125,7 @@ from the dynamic block defintion." >>>> =C2=A0 =C2=A0 =C2=A0 (if multifile (concat (nth 1 lwords) "|") "") =C2= =A0; file column, maybe >>>> =C2=A0 =C2=A0 =C2=A0 (if level-p =C2=A0 (concat (nth 2 lwords) "|") ""= ) =C2=A0; level column, maybe >>>> =C2=A0 =C2=A0 =C2=A0 (if timestamp (concat (nth 3 lwords) "|") "") =C2= =A0; timestamp column, maybe >>>> + =C2=A0 =C2=A0 =C2=A0 (if properties (concat (mapconcat 'identity pro= perties "|") "|") "") ;properties columns, maybe >>>> =C2=A0 =C2=A0 =C2=A0 (concat (nth 4 lwords) "|" >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(nth 5 lwords) "|\n")) =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ; headline and time colum= ns >>>> >>>> @@ -2134,6 +2137,7 @@ from the dynamic block defintion." >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0; file column= , maybe >>>> =C2=A0 =C2=A0 =C2=A0 (if level-p =C2=A0 "|" =C2=A0 =C2=A0 =C2=A0"") = =C2=A0 =C2=A0 =C2=A0 =C2=A0; level column, maybe >>>> =C2=A0 =C2=A0 =C2=A0 (if timestamp "|" =C2=A0 =C2=A0 =C2=A0"") =C2=A0 = =C2=A0 =C2=A0 =C2=A0; timestamp column, maybe >>>> + =C2=A0 =C2=A0 =C2=A0 (if properties (make-string (length properties)= ?|) "") =C2=A0;properties columns, maybe >>>> =C2=A0 =C2=A0 =C2=A0 (concat "*" (nth 7 lwords) "*| ") ; instead of a = headline >>>> =C2=A0 =C2=A0 =C2=A0 "*" >>>> =C2=A0 =C2=A0 =C2=A0 (org-minutes-to-hh:mm-string (or total-time 0)) ;= the time >>>> @@ -2157,6 +2161,7 @@ from the dynamic block defintion." >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(= file-name-nondirectory (car tbl)) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(= if level-p =C2=A0 "| " "") ; level column, maybe >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(= if timestamp "| " "") ; timestamp column, maybe >>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(if pr= operties (make-string (length properties) ?|) "") =C2=A0;properties columns= , maybe >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(= org-minutes-to-hh:mm-string (nth 1 tbl))))) ; the time >>>> >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; Get the list of node entries and iterat= e over it >>>> @@ -2181,6 +2186,11 @@ from the dynamic block defintion." >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(if multifile "|" "") =C2=A0 = =C2=A0; free space for file name column? >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(if level-p (format "%d|" (ca= r entry)) "") =C2=A0 ; level, maybe >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(if timestamp (concat (nth 2 = entry) "|") "") ; timestamp, maybe >>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(if properties >>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(concat >>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (mapconcat >>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(lambda (p) (= or (cdr (assoc p (nth 4 entry))) "")) >>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0properties "|= ") "|") "") =C2=A0;properties columns, maybe >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(if indent (org-clocktable-in= dent-string level) "") ; indentation >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0hlc headline hlc "|" =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0; headline >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(make-string (min (1- ntcol) = (or (- level 1))) ?|) >>>> -- >>>> 1.7.1 >>>> #+end_src >>>> >>>> #+begin_src diff >>>> From e7b95ec4b61ada44d501e1212d3a3cb80e663911 Mon Sep 17 00:00:00 2001 >>>> From: Niels Giesen >>>> Date: Sat, 26 Mar 2011 14:48:21 +0100 >>>> Subject: [PATCH 3/3] org-clock: Add param :inherit-props >>>> >>>> When non-nil, properties are computed with inheritance. >>>> --- >>>> lisp/org-clock.el | =C2=A0 =C2=A05 +++-- >>>> 1 files changed, 3 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/lisp/org-clock.el b/lisp/org-clock.el >>>> index a330db0..1eecb68 100644 >>>> --- a/lisp/org-clock.el >>>> +++ b/lisp/org-clock.el >>>> @@ -2346,6 +2346,7 @@ TIME: =C2=A0 =C2=A0 =C2=A0The sum of all time sp= end in this tree, in minutes. =C2=A0This time >>>> =C2=A0 =C2=A0 =C2=A0(link (plist-get params :link)) >>>> =C2=A0 =C2=A0 =C2=A0(tags (plist-get params :tags)) >>>> =C2=A0 =C2=A0 =C2=A0(properties (plist-get params :properties)) >>>> + =C2=A0 =C2=A0(inherit-property-p (plist-get params :inherit-props)) >>>> =C2=A0 =C2=A0 =C2=A0(matcher (if tags (cdr (org-make-tags-matcher tags= )))) >>>> =C2=A0 =C2=A0 =C2=A0cc range-text st p time level hdl props tsp tbl) >>>> >>>> @@ -2404,8 +2405,8 @@ TIME: =C2=A0 =C2=A0 =C2=A0The sum of all time sp= end in this tree, in minutes. =C2=A0This time >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (remove nil >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 (mapcar >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0(lambda (p) >>>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(when (org-entry-get (point) p) >>>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(cons p (org-entry-get (point) p)))) >>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(when (org-entry-get (point) p inherit-property-p) >>>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(cons p (org-entry-get (point) p inherit-pro= perty-p)))) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0properties)))) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (when (> time 0) (push (list level = hdl tsp time props) tbl)))))) >>>> =C2=A0 =C2=A0 =C2=A0(setq tbl (nreverse tbl)) >>>> -- >>>> 1.7.1 >>>> #+end_src >>>> >>>> niels >>>> -- >>>> http://pft.github.com >>>> >>> >>> - Carsten >>> >>> >>> >> >> -- >> http://pft.github.com/ > > - Carsten > > > > --=20 http://pft.github.com