emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien <bastienguerry@googlemail.com>
To: James TD Smith <ahktenzero@mohorovi.cc>
Cc: emacs-orgmode@gnu.org
Subject: Re: [misc-new-features 1/5] Add two new special properties, SINCE and SINCE_IA.
Date: Sat, 18 Jul 2009 11:35:48 +0200	[thread overview]
Message-ID: <87ws66jpu3.fsf@bzg.ath.cx> (raw)
In-Reply-To: <20090717182243.GB15275@yog-sothoth.mohorovi.cc> (James TD Smith's message of "Fri, 17 Jul 2009 19:22:43 +0100")

[-- Attachment #1: Type: text/plain, Size: 1043 bytes --]

Hi James, 

this small patch against current org-colview.el lets you have a custom
function for computing a "summary" of a property and displaying it in
the column.

To compute the time since the timestamp, you can use this patch and some
of your code like this:

--8<---------------cut here---------------start------------->8---
(setq org-columns-custom-summary-function 
      'my-org-compute-since)

(defun org-time-since (time)
  "Get the number of days since `time'"
  (time-to-number-of-days 
  (time-since (apply 'encode-time
		     (org-parse-time-string time)))))

(defun my-org-compute-since (&rest values)
  "Eval elapsted days since the entry's timestamp."
  (let* ((ts (org-entry-get (point) "TIMESTAMP")))
    (when ts (org-time-since ts))))
--8<---------------cut here---------------end--------------->8---

This patch is just a workaround, though.  I think we should have a way
of adding more than one custom function, as Mikael Fornius suggested
when sending his first patch.

Let's see what's Carsten take on this.

Thanks!


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-colview.el.patch --]
[-- Type: text/x-diff, Size: 1959 bytes --]

diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index d132bf6..b312d35 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -698,20 +698,30 @@ around it."
 		(org-columns-display-here (cdr x)))
 	      cache)))))
 
+(defcustom org-columns-custom-summary-function nil
+  "A user-defined custom summary function.
+This function takes one argument: a list containing the values of
+all children for the summarized property.  This function should
+return a number."
+  :group 'org-link
+  :type 'function)
+
 (defvar org-columns-compile-map
-  '(("none"  none              +)
-    (":"     add_times         +)
-    ("+"     add_numbers       +)
-    ("$"     currency          +)
-    ("X"     checkbox          +)
-    ("X/"    checkbox-n-of-m   +)
-    ("X%"    checkbox-percent  +)
-    ("max"   max_numbers       max)
-    ("min"   min_numbers       min)
-    ("mean"  mean_numbers      (lambda (&rest x) (/ (apply '+ x) (float (length x)))))
-    (":max"  max_times         max)
-    (":min"  min_times         min)
-    (":mean" mean_times        (lambda (&rest x) (/ (apply '+ x) (float (length x))))))
+  '(("none"   none              +)
+    (":"      add_times         +)
+    ("+"      add_numbers       +)
+    ("$"      currency          +)
+    ("X"      checkbox          +)
+    ("X/"     checkbox-n-of-m   +)
+    ("X%"     checkbox-percent  +)
+    ("max"    max_numbers       max)
+    ("min"    min_numbers       min)
+    ("mean"   mean_numbers      (lambda (&rest x) (/ (apply '+ x) (float (length x)))))
+    (":max"   max_times         max)
+    (":min"   min_times         min)
+    (":mean"  mean_times        (lambda (&rest x) (/ (apply '+ x) (float (length x)))))
+    ("custom" custom_function   (lambda (&rest x) 
+				  (funcall org-columns-custom-summary-function x))))
   "Operator <-> format,function map.
 Used to compile/uncompile columns format and completing read in
 interactive function org-columns-new.")

[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
 Bastien

[-- Attachment #4: Type: text/plain, Size: 204 bytes --]

_______________________________________________
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

  reply	other threads:[~2009-07-18  9:36 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-13  8:27 Working on org again James TD Smith
2009-07-13  8:27 ` [misc-new-features 1/5] Add two new special properties, SINCE and SINCE_IA James TD Smith
2009-07-13  8:27   ` [misc-new-features 2/5] Bugfixes, documentation and custom options for org-checklist James TD Smith
2009-07-13  8:28     ` [misc-new-features 3/5] Add an option to sort tags automatically James TD Smith
2009-07-13  8:28       ` [misc-new-features 4/5] Allow org-insert-link to check the X clipboard and the Emacs kill-ring for links, as well as the stored links. This makes getting URLs into org from a browser much easier, as you don't have to paste the URL into the minibuffer to insert a link James TD Smith
2009-07-13  8:28         ` [misc-new-features 5/5] Fix a problem I was having with plots using a script. Org-plot was deleting the data file before gnuplot read it in. I've moved the deletion of the temporary data file to an idle timer, which has fixed the problem James TD Smith
2009-07-13 11:56           ` Bernt Hansen
2009-07-14 11:57           ` Bastien
2009-07-17 17:03           ` Bastien
2009-07-13 11:55         ` [misc-new-features 4/5] Allow org-insert-link to check the X clipboard and the Emacs kill-ring for links, as well as the stored links. This makes getting URLs into org from a browser much easier, as you don't have to paste the URL into the minibuffer to insert a link Bernt Hansen
2009-07-13 12:13           ` [misc-new-features 4/5] extra long subject lines James TD Smith
2009-07-13 15:35             ` Bernt Hansen
2009-07-14 12:07         ` [misc-new-features 4/5] Allow org-insert-link to check the X clipboard and the Emacs kill-ring for links, as well as the stored links. This makes getting URLs into org from a browser much easier, as you don't have to paste the URL into the minibuffer to insert a link Bastien
2009-07-17 17:20         ` Bastien
2009-07-14 11:59       ` [misc-new-features 3/5] Add an option to sort tags automatically Bastien
2009-07-14 16:01         ` James TD Smith
2009-07-17 17:04           ` Bastien
2009-07-17 16:38       ` Bastien
2009-07-14 12:09     ` [misc-new-features 2/5] Bugfixes, documentation and custom options for org-checklist Bastien
2009-07-14  8:52       ` James TD Smith
2009-08-03 14:47     ` Carsten Dominik
2009-08-03 21:17       ` James TD Smith
2009-07-14 11:48   ` [misc-new-features 1/5] Add two new special properties, SINCE and SINCE_IA Bastien
2009-07-14 17:44     ` James TD Smith
2009-07-17 16:55   ` Bastien
2009-07-17 18:22     ` James TD Smith
2009-07-18  9:35       ` Bastien [this message]
2009-08-27 15:50         ` Manish
2009-08-28 17:59           ` James TD Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ws66jpu3.fsf@bzg.ath.cx \
    --to=bastienguerry@googlemail.com \
    --cc=ahktenzero@mohorovi.cc \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).