emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Samuel Loury <konubinix@gmail.com>
To: Alan Schmitt <alan.schmitt@polytechnique.org>, Rene <jlr_0@yahoo.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Is OrgMode really GTD compliant?
Date: Tue, 29 Apr 2014 12:30:26 +0200	[thread overview]
Message-ID: <877g68jum5.fsf@konixwork.incubateur.ens-lyon.fr> (raw)
In-Reply-To: <m2iopsocgo.fsf@polytechnique.org>

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

Hi,
Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> On 2014-04-28 19:18, Rene <jlr_0@yahoo.com> writes:
> I have not defined an Energy property, but I recently played with date
> properties (and a user defined sorting function). If it's helpful to
> you, the code is there:
> https://github.com/brabalan/org-review/blob/master/org-review.el#L156
I looked at the code and I don't get what means the part of the code
getting the org-marker text property of a:
--8<---------------cut here---------------start------------->8---
(get-text-property (point-min) 'org-marker a)
--8<---------------cut here---------------end--------------->8---
In this part, the point-min returns the point-min of the current buffer
(the agenda buffer in that case) while the function looks for the
property into a.

I tried launching this code into a custom agenda compare function and I
get the error:
--8<---------------cut here---------------start------------->8---
Args out of range: 1197, 1197
--8<---------------cut here---------------end--------------->8---
This makes sense since the agenda appears to be narrowed at that time so
that (point-min) returns 1197 and the a string at this time is not 1197
characters long.

Replacing (point-min) by 0 appears to work (I assumed the 0th character
of the string has the wanted text property).

My first guess of an energy cmp function is:

--8<---------------cut here---------------start------------->8---
(defun org-energy-compare (a b)
  (let* (
		 (ma (or (get-text-property 0 'org-marker a)
				 (get-text-property 0 'org-hd-marker a)))
		 (mb (or (get-text-property 0 'org-marker b)
				 (get-text-property 0 'org-hd-marker b)))
		 (energy_a (org-entry-get ma "Energy"))
		 (energy_b (org-entry-get mb "Energy"))
		 )
	(cond
	 ((and
	   (not energy_a)
	   (not energy_b)
	   )
	  nil
	  )
	 ((and
	   energy_a
	   (not energy_b)
	   )
	  1
	  )
	 ((and
	   (not energy_a)
	   energy_b
	   )
	  -1
	  )
	 ((> energy_a energy_b)
	  1
	  )
	 ((< energy_a energy_b)
	  -1
	  )
	 (t
	  nil
	  )
	 )
	)
  )
--8<---------------cut here---------------end--------------->8---

Incidentally, I don't manage to have edebug triggered in a custom org
agenda cmp function. I load the function with C-u C-M-x. the message
"Edebug: org-energy-compare" appears as usual. When I launch the agenda
I can see the function has been called since the entries are correctly
sorted. But I was never given the input to debug it. Do you know why?

--
Konubinix
GPG Key    : 7439106A
Fingerprint: 5993 BE7A DA65 E2D9 06CE  5C36 75D2 3CED 7439 106A

[-- Attachment #2: Type: application/pgp-signature, Size: 472 bytes --]

  reply	other threads:[~2014-04-29 10:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-27 20:51 Is OrgMode really GTD compliant? Rene
2014-04-28  0:21 ` Richard Lawrence
2014-04-28 17:18   ` Rene
2014-04-29  6:51     ` Alan Schmitt
2014-04-29 10:30       ` Samuel Loury [this message]
2014-04-29 10:49         ` Alan Schmitt
2014-04-29 13:26           ` Samuel Loury
2014-04-29 13:31             ` Bastien
2014-04-29 13:37               ` Alan Schmitt
2014-04-29 13:42                 ` Bastien

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=877g68jum5.fsf@konixwork.incubateur.ens-lyon.fr \
    --to=konubinix@gmail.com \
    --cc=alan.schmitt@polytechnique.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=jlr_0@yahoo.com \
    /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).