From mboxrd@z Thu Jan 1 00:00:00 1970 From: Juan Reyero Subject: Re: Re: Project management > Dynamic block per tag + [Babel] Date: Wed, 19 Jan 2011 16:15:46 +0100 Message-ID: References: <8739qth38k.fsf@mundaneum.com> <878w0dnput.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=58419 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PfZlF-0005K4-8Q for emacs-orgmode@gnu.org; Wed, 19 Jan 2011 10:15:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PfZlD-0000uI-Mb for emacs-orgmode@gnu.org; Wed, 19 Jan 2011 10:15:49 -0500 Received: from mail-iy0-f169.google.com ([209.85.210.169]:43627) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PfZlD-0000u5-JW for emacs-orgmode@gnu.org; Wed, 19 Jan 2011 10:15:47 -0500 Received: by iyj17 with SMTP id 17so1011382iyj.0 for ; Wed, 19 Jan 2011 07:15:46 -0800 (PST) In-Reply-To: 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: Francesco Pizzolante , mailing-list-org-mode On Thu, Dec 16, 2010 at 1:19 PM, Francesco Pizzolante wrote: > > Another option is to use a babel block and org-map-entries to spit out = a > > simple list of tasks for each person: > I've played a little with the code you've sent and here's what I end up w= ith: > > --8<---------------cut here---------------start------------->8--- > #+source: tasklist > #+begin_src emacs-lisp :var person=3D"FPZ" :results raw > (setq org-agenda-files (list (buffer-file-name))) > (let (tasklist) > =A0(add-to-list 'tasklist "||||" t) > =A0(org-map-entries > =A0 (lambda () > =A0 =A0 (let ((priority (nth 3 (org-heading-components)))) > =A0 =A0 =A0 (add-to-list 'tasklist > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(concat "| *" (nth 2 (org-heading-= components)) "* " > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"|/[#" (char-to-st= ring (if priority > priority ?B)) "]/ " > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"| [[" (nth 4 (org= -heading-components)) "]]|") t))) > =A0 (concat person "/!TODO|STARTED|WAIT") 'agenda) > =A0(mapconcat 'identity tasklist "\n")) > #+end_src > --8<---------------cut here---------------end--------------->8--- > > The next step for me, would be to be able to sort this table against > priorities for instance. > > If you think about a simple way of doing this, please let me know. I had the same problem, and tweaking your code (I think org-mode doesn't like the modification of org-agenda-files) this is what I've ended up with: (defun tasks-with-tag (person &optional scope) (let ((tasklist ())) (org-map-entries (lambda () (let ((priority (nth 3 (org-heading-components)))) (add-to-list 'tasklist (list (if priority (char-to-string priority) "C") (concat "[[" (nth 4 (org-heading-components)) "= ]]")) t))) (concat person "/!TASK") scope) (sort tasklist (lambda (f s) (string-lessp (car f) (car s)))))) The output is sorted and makes a nice table. Scope is passed directly to org-map-entries, so if you leave it out the scope will be the current buffer. Greetings, jm -- http://juanreyero.com/ http://alandair.com