From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Wales Subject: Re: using dates as property? Date: Mon, 31 Aug 2015 14:52:48 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWX0U-0005a4-Sk for emacs-orgmode@gnu.org; Mon, 31 Aug 2015 17:52:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWX0T-0006z3-MH for emacs-orgmode@gnu.org; Mon, 31 Aug 2015 17:52:50 -0400 Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]:32893) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWX0T-0006x2-Bv for emacs-orgmode@gnu.org; Mon, 31 Aug 2015 17:52:49 -0400 Received: by wicmc4 with SMTP id mc4so13420296wic.0 for ; Mon, 31 Aug 2015 14:52:48 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: John Kitchin Cc: Org Mode and here is my get function, likewise documented only for me and written a long time ago but works well for me: (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 \(string given\) is the agenda header string to use \(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'. There are a few questions about Org properties: 1) What does it mean to get alltags without inheritance or tags with inheritance? I guess org-entry-get was originally meant for properties, not tags, so you don't use inherit? 2) How do you get the first timestamp in an entry? There seems to be no way without specifying the type of timestamp. 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, along with an update of this docstring. The idea is to use this as a single way to get most metadata no matter where you are. " ;;=doubtful do we want the literal-nil argument so that we can ;;ret "nil" as string? check elsewhere here for nil vs. string ;;for todo kw or whatever. we only need it if it helps with ;;consistency. not important and prob useless for this ;;purpose. (other ways of getting todo kw will not obey it so ;;it might not help.) ;; ;; fixme org-cached-entry-get (org-entry-get (ecase major-mode ((org-agenda-mode) ;;; ;;; will this work faster? or is this for something other than ;;; agenda? ;;; ;;; my guess is it is just for doing things not getting things ;;; ;;; (org-with-point-at (org-get-at-bol 'org-hd-marker) ;;; ;; do here what you need to do at the location of the entry ;;; ) ;; sg is provided by programmatic agenda use in sorting. ;; ;; should also be provided in sorting filter. ;; ;; is the buffer substring only needed for outline? could ;; we get property from the agenda for sorting to avoid the ;; buffer substring? ;; ;; fixme for speed maybe we can get from the agenda buffer ;; if sg is not provided. fixme check if sg is provided. ;; however, if we use ;; org-agenda-before-sorting-filter-function, it is ;; provided i guess. (let* ((s (or sg (buffer-substring (point-at-bol) (point-at-eol)))) ;; get marker from sg or string ;; ;; what is the difference between these? supposedly ;; hd-marker is not always there. (m (or (get-text-property 1 'org-marker s) (get-text-property 1 'org-hd-marker s)))) ;;do this to get to the org outline buffer from the ;;agenda 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)) ((org-mode) (point))) property inherit))