From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Wales Subject: need function to extract time from timestamp in the description of the first link in an entry Date: Thu, 1 Nov 2018 16:29:04 -0700 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40507) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIMOr-0003Pc-0N for emacs-orgmode@gnu.org; Thu, 01 Nov 2018 19:29:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gIMOp-00058w-1Q for emacs-orgmode@gnu.org; Thu, 01 Nov 2018 19:29:16 -0400 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]:42382) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gIMOm-00053w-Sj for emacs-orgmode@gnu.org; Thu, 01 Nov 2018 19:29:13 -0400 Received: by mail-lj1-x233.google.com with SMTP id f3-v6so136498ljk.9 for ; Thu, 01 Nov 2018 16:29:07 -0700 (PDT) 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" To: emacs-orgmode@gnu.org timestamps in link descriptions use {} instead of []. are there functions to get the time from those? org-entry-get on "TIMESTAMP_IA" will get the time from this: * CONVERSATION [2018-11-01 Thu 11:09] cleaned using generic cetaphil analogously, if the keyword is CONVLINK, i want to get the time from this: * CONVLINK [[id:8d3b3ad4-784a-4049-ba42-8409b24e4e7e][{2018-11-01 Thu 11:09} cleaned uvex with generic cetaphil]] but there is no org-entry-get property for "TIMESTAMP_LINK". suggestions? p.s. i have always used org-entry-get in this old code to sort in both agenda and outline. i don't know if this is good code or not. but it works wonderfully to abstract over outline and agenda. (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 in the code below to get to the outline and do manual parsing or use some other function. The idea is to use this as a single way to get most metadata no matter where you are. " (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. ;; ;; thus presumably the buffer substring only gets called ;; for outline. otherwise we could maybe do ;; (get-text-property (point-at-bol) 'org-marker) ;; ;; 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. ;; fixme 0 is a total guess. i had had 1. (m (or (get-text-property 0 'org-marker s) (get-text-property 0 '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))