From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Wales Subject: Re: custom sorting of agenda items Date: Tue, 17 Aug 2010 09:51:46 -0700 Message-ID: References: <87r5ie2dpx.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: Received: from [140.186.70.92] (port=58341 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OlPOA-0002Vz-Ry for emacs-orgmode@gnu.org; Tue, 17 Aug 2010 12:51:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OlPO9-0007Zm-EP for emacs-orgmode@gnu.org; Tue, 17 Aug 2010 12:51:50 -0400 Received: from mail-ww0-f49.google.com ([74.125.82.49]:38162) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OlPO9-0007ZZ-7b for emacs-orgmode@gnu.org; Tue, 17 Aug 2010 12:51:49 -0400 Received: by wwi14 with SMTP id 14so6817984wwi.30 for ; Tue, 17 Aug 2010 09:51:46 -0700 (PDT) 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: Ilya Shlyakhter Cc: emacs-orgmode , Bastien On 2010-08-04, Ilya Shlyakhter 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 wrote: >> Hi Ilya, >> >> Ilya Shlyakhter 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. > Emacs-orgmode@gnu.org > 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.