[Top][All Lists]

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

Re: [O] using dates as property?

From: Samuel Wales
Subject: Re: [O] using dates as property?
Date: Mon, 31 Aug 2015 14:52:48 -0700

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
   (ecase major-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)
             ;; 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)
     ((org-mode) (point)))

reply via email to

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