Alan Schmitt <alan.schm...@polytechnique.org> writes:

> On 2014-04-29 12:30, Samuel Loury <konubi...@gmail.com> writes:
>> Alan Schmitt <alan.schm...@polytechnique.org> writes:
>>> On 2014-04-28 19:18, Rene <jl...@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:
>> (get-text-property (point-min) 'org-marker a)
>> 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:
>> Args out of range: 1197, 1197
>> 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).
>
> I used to have `1' instead of `point-min', but I changed it following
> a suggestion from Bastien
> (http://thread.gmane.org/gmane.emacs.orgmode/85217/focus=85241).
Thanks for the link.

I am not a good lisp hacker, so I cannot be sure of this, but I suppose
Bastien did not notice the last argument 'a'. Indeed, the function is
defined as:

--8<---------------cut here---------------start------------->8---
(get-text-property POSITION PROP &optional OBJECT)
Return the value of POSITION's property PROP, in OBJECT.
OBJECT should be a buffer or a string; if omitted or nil, it defaults
to the current buffer.
If POSITION is at the end of OBJECT, the value is nil.
--8<---------------cut here---------------end--------------->8---

Then, the POSITION argument is the position in OBJECT to look for the
property. Therefore, the use of a function related to the current buffer
(like point-min) seems to strongly assume that OBJECT is the current
buffer (or nil).

In that case, OBJECT is not the current buffer but a string called
'a'. Thus, IIUC, it makes no sense to use OBJECT=a and
POSITION=(point-min).

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

Attachment: pgpO58u27dsZj.pgp
Description: PGP signature

Reply via email to