emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] custom sorting of agenda items


From: Samuel Wales
Subject: Re: [Orgmode] custom sorting of agenda items
Date: Tue, 17 Aug 2010 09:51:46 -0700

On 2010-08-04, Ilya Shlyakhter <address@hidden> wrote:
> When giving a user-defined function for org-agenda-cmp-user-defined,
> the function gets two agenda entries.   Is there a way from an agenda entry
> to get to the original org entry?

Here is code of a general nature.

(defun alpha-org-entry-get (property &optional sg inherit)
  "Return the value of PROPERTY, whether you are in the outline
or the agenda, by calling `org-entry-get'.

SG is the agenda header string provided by user-defined agenda
sorting, or nil.  If it is nil and you are in the outline, use
the current headline directly.  If it is nil and you are in the
agenda, use the current headline by going to the outline.

INHERIT is the inherit argument for org-entry-get.

According to the manual at the time of this writing, possible
properties include these.

     TODO         The TODO keyword of the entry.
     TAGS         The tags defined directly in the headline.
     ALLTAGS      All tags, including inherited ones.
     CATEGORY     The category of an entry.
     PRIORITY     The priority of the entry, a string with a single letter.
     DEADLINE     The deadline time string, without the angular brackets.
     SCHEDULED    The scheduling timestamp, without the angular brackets.
     CLOSED       When was this entry closed?
     TIMESTAMP    The first keyword-less timestamp in the entry.
       - this works even in the headline
     TIMESTAMP_IA The first inactive timestamp in the entry.
       - this works even in the headline
       - it does not seem to report CLOSED ts -- use CLOSED
     CLOCKSUM     The sum of CLOCK intervals in the subtree.  org-clock-sum
                  must be run first to compute the values.
     ITEM         The content of the entry.

For anything else, you can use marker-buffer to get to the
outline and do manual parsing or use some other function.  Or
possibly modify org-entry-get to understand it and send a patch
to the org mailing list.

The idea is to use this as a single way to get most metadata no
matter where you are.
"
  (org-entry-get
   (cond
     ((eq major-mode 'org-agenda-mode)
      (let* ((s (or sg (buffer-substring (point-at-bol) (point-at-eol))))
             (m (or (get-text-property 1 'org-marker s)
                    (get-text-property 1 'org-hd-marker s))))
        ;;do this to get to the buffer if you need other data that
        ;;org-entry-get cannot extract
        ;;(b (and m (marker-buffer m))))
;;;        (if b
;;;            (with-current-buffer b
;;;              (goto-char m)
        m))
     ((eq major-mode 'org-mode) (point))
     (t (error "Not in an org-mode buffer")))
   property
   inherit))


>
> Best would be if, besides a user-defined sort function, you could also
> provide
> a function that takes the org entry and the agenda item (i.e. is run with
> point
> on the org entry and is passed the agenda item), and can then store anything
> it wants about the org entry as text properties on the agenda item.
> The companion user-defined sorting function could then use these stored
> text properties for ordering the agenda items.   Could you add such a hook?
>
> thanks,
>
> ilya
>
> On Wed, Aug 4, 2010 at 6:51 PM, Bastien <address@hidden> wrote:
>> Hi Ilya,
>>
>> Ilya Shlyakhter <address@hidden> writes:
>>
>>> I'd like to sort agenda entries in a custom agenda view by the value
>>> of a text property that I put on the headlines.
>>> Is there a way to do that?
>>
>> Well, no.
>>
>> Maybe playing around with org-map-entries could yield some result.
>>
>> --
>>  Bastien
>>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> address@hidden
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>


-- 
Q: How many CDC "scientists" does it take to change a lightbulb?
A: "You only think it's dark." [CDC has denied a deadly disease for 25 years]
==========
Retrovirus: http://www.wpinstitute.org/xmrv/index.html -- PLEASE DONATE
===
PNAS must publish the original Lo and Alter NIH/FDA XMRV paper
verbatim along with the new paper.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]