From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mikael Fornius Subject: Re: [PATCH] Add min/max/mean age operators to column view. Date: Sat, 31 Oct 2009 14:41:25 +0100 Message-ID: <87k4ybel4q.fsf@eee.in> References: <1256515485-28476-1-git-send-email-ahktenzero@mohorovi.cc> <4AD87891-4DD3-4B80-9FD3-2B6B65653E5B@gmail.com> <20091028193607.GY72276@yog-sothoth.mohorovi.cc> <87pr865u9b.fsf@eee.in> <87d4465oh4.fsf@eee.in> <20091029211543.GZ72276@yog-sothoth.mohorovi.cc> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N4EBc-0003Gf-RU for emacs-orgmode@gnu.org; Sat, 31 Oct 2009 09:40:08 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N4EBX-0003Ev-Gy for emacs-orgmode@gnu.org; Sat, 31 Oct 2009 09:40:07 -0400 Received: from [199.232.76.173] (port=58588 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N4EBX-0003Es-7z for emacs-orgmode@gnu.org; Sat, 31 Oct 2009 09:40:03 -0400 Received: from violet.abc.se ([62.80.200.155]:55615) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N4EBW-0000KQ-28 for emacs-orgmode@gnu.org; Sat, 31 Oct 2009 09:40:02 -0400 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: James TD Smith Cc: emacs-orgmode@gnu.org, Carsten Dominik --=-=-= Thanks for a very good explanation, now I understand and I have tested it successfully. Looks like it works perfectly well to me. The interactive function org-columns-new also works as expected. This is a very good addition and I think it can be useful in many different areas. It also opens for more advanced calculations in colview mode due to the extension of `org-columns-compile-map'. Personally I prefer using colview to tables for temporary views of dynamic and alive data (like my running exercise diary) and want to use it more then I do now. I have modified the patch with one missing parenthesis and a more extensive documentation string to the important variable `org-columns-format-compile-map' which I wrote most for my own recapitulation of the subject and understanding your patch. Also org-columns-new had a reference to free variable `funcs' and I changed it to `fun' (member of functions argument list) which I believe is the right one?, you have to check me on this. Two other references, probably older, to free variables I have also tried to fix by let binding them. Feel free to use it if you want. (Attached patch to this messages. Difference is against your misc-new-features branch pulled today.) As an ending parenthesis commenting column view in general: I see three small problems with org-colview that I (or someone else interested) should fix some day: 1. A annoying problem is not being able to have multiple columns summarizing the same property but with different operators. #+COLUMNS: %TIMESTAMP_IA{@min} %TIMESTAMP_IA{@max} This will result only in min calculations for both columns. I remember that I have looked at this before and think it is non trivial to fix because of the internal way data is collected and calculated. Almost a rewrite of this part is necessary. 2. Being able to use Emacs calc HMS forms (info "(Calc) HMS forms") for calculating and presenting time as I can to in the org-mode spreadsheet. I use this time format to manipulate my exercise data now days. Maybe this be added easily with the new `calc' slot in the `org-columns-compile-map' structure. 3. More intelligent handling of property values like automatic detection of times, dates or numbers to simplify the definitions and have only one 'max' summary option instead of now three (max, :max, @max). Cheers! --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=diff Content-Description: patch diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 2c16d0b..ba99ff7 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -733,10 +733,20 @@ around it." ("@max" max_age max (lambda (x) (- org-columns-time x))) ("@mean" mean_age (lambda (&rest x) (/ (apply '+ x) (float (length x)))) - (lambda (x) (- org-columns-time x))) - "Operator <-> format,function map. + (lambda (x) (- org-columns-time x)))) + "Operator <-> format,function,calc map. Used to compile/uncompile columns format and completing read in -interactive function org-columns-new.") +interactive function org-columns-new. + +operator string used in #+COLUMNS definition describing the + summary type +format symbol describing summary type selected interactively in + org-columns-new and internally in + org-columns-number-to-string and + org-columns-string-to-number +function called with a list of values as argument to calculate + the summary value +calc function called on every element before summarizing") (defun org-columns-new (&optional prop title width op fmt fun &rest rest) "Insert a new column, to the left of the current column." @@ -757,7 +767,7 @@ interactive function org-columns-new.") org-columns-compile-map) nil t)) (setq fmt (intern fmt) - funcs (cdr (assoc fmt (mapcar 'cdr org-columns-compile-map)))) + fun (cdr (assoc fmt (mapcar 'cdr org-columns-compile-map)))) (if (eq fmt 'none) (setq fmt nil)) (if editp (progn @@ -766,7 +776,7 @@ interactive function org-columns-new.") (setq cell (nthcdr (1- (current-column)) org-columns-current-fmt-compiled)) (setcdr cell (cons (list prop title width nil fmt nil - (car funcs) (cadr funcs)) + (car fun) (cadr fun)) (cdr cell)))) (org-columns-store-format) (org-columns-redo))) @@ -1050,7 +1060,7 @@ Don't set this, this is meant for dynamic scoping.") (defun org-columns-uncompile-format (cfmt) "Turn the compiled columns format back into a string representation." - (let ((rtn "") e s prop title op op-match width fmt printf fun) + (let ((rtn "") e s prop title op op-match width fmt printf fun calc) (while (setq e (pop cfmt)) (setq prop (car e) title (nth 1 e) @@ -1295,7 +1305,7 @@ and tailing newline characters." (org-columns-remove-overlays) (move-marker org-columns-begin-marker (point)) (let ((org-columns-time (time-to-number-of-days (current-time))) - cache maxwidths m p a d) + cache maxwidths m p a d fmt) (cond ((and (boundp 'org-agenda-overriding-columns-format) org-agenda-overriding-columns-format) --=-=-= (And don't forget to patch the bastard colview-xemacs ;-), could be made effectively with a ediff manual merging I think.) -- Mikael Fornius --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--