From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcel van der Boom Subject: [PATCH] Allow inactive timestamps in org-expiry (copy of lost patch) Date: Mon, 28 Mar 2011 20:21:49 +0200 Message-ID: <20110328202149.67a32bdc@hsdev.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/yohhjVbGx0tKdaNpv1N=n9y" Return-path: Received: from [140.186.70.92] (port=41562 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4H4w-0000kt-4A for emacs-orgmode@gnu.org; Mon, 28 Mar 2011 14:22:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4H4Y-00086v-Nk for emacs-orgmode@gnu.org; Mon, 28 Mar 2011 14:21:52 -0400 Received: from router2.hsdev.com ([213.125.12.138]:36501 helo=mrb.hsdev.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4H4Y-00085d-F3 for emacs-orgmode@gnu.org; Mon, 28 Mar 2011 14:21:50 -0400 Received: from hsdev.com (unknown [IPv6:::1]) by mrb.hsdev.com (Postfix) with ESMTPS id 7B7A4744DA for ; Mon, 28 Mar 2011 20:21:49 +0200 (CEST) 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: emacs-orgmode@gnu.org --MP_/yohhjVbGx0tKdaNpv1N=n9y Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, Attached is a patch to org-expiry.el in contrib/lisp to allow a customization of the timestamps inserted by org-expiry for 'CREATED' and 'EXPIRED' properties. This patch is what is attached to the message displayed at [1]. I have been using this patch for a while and it works fine. From searching it looks like this patch was 'forgotten', but I may have overlooked something. If the patch was rejected, you can ignore me. If it was forgotten I'd like to request to include it. Thx, marcel [1] http://www.mail-archive.com/emacs-orgmode@gnu.org/msg20882.html -- Marcel van der Boom -- http://hsdev.com/mvdb.vcf HS-Development BV -- http://www.hsdev.com So! web applications -- http://make-it-so.info Cobra build -- http://cobra.mrblog.nl --MP_/yohhjVbGx0tKdaNpv1N=n9y Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=org-expiry.el.diff diff --git a/contrib/lisp/org-expiry.el b/contrib/lisp/org-expiry.el index 4a49399..930b921 100644 --- a/contrib/lisp/org-expiry.el +++ b/contrib/lisp/org-expiry.el @@ -81,6 +81,11 @@ :tag "Org Expiry" :group 'org) +(defcustom org-expiry-inactive-timestamps nil + "Insert inactive timestamps for the created and expired time properties" + :type 'boolean + :group 'org-expiry) + (defcustom org-expiry-created-property-name "CREATED" "The name of the property for setting the creation date." :type 'string @@ -283,21 +288,25 @@ to today's date. With two `C-u' prefixes, prompt the user for to update the date." (interactive "P") (let* ((d (org-entry-get (point) org-expiry-created-property-name)) - d-time d-hour) + d-time d-hour timestr) (when (or (null d) arg) ;; update if no date or non-nil prefix argument ;; FIXME Use `org-time-string-to-time' - (setq d-time (if d (apply 'encode-time (org-parse-time-string d)) + (setq d-time (if d (org-time-string-to-time d) (current-time))) (setq d-hour (format-time-string "%H:%M" d-time)) + (setq timestr + ;; two C-u prefixes will call org-read-date + (if (equal arg '(16)) + (concat "<" (org-read-date + nil nil nil nil d-time d-hour) ">") + (format-time-string (cdr org-time-stamp-formats)))) + ;; maybe transform to inactive timestamp + (if org-expiry-inactive-timestamps + (setq timestr (concat "[" (substring timestr 1 -1) "]"))) (save-excursion (org-entry-put - (point) org-expiry-created-property-name - ;; two C-u prefixes will call org-read-date - (if (equal arg '(16)) - (concat "<" (org-read-date - nil nil nil nil d-time d-hour) ">") - (format-time-string (cdr org-time-stamp-formats)))))))) + (point) org-expiry-created-property-name timestr))))) (defun org-expiry-insert-expiry (&optional today) "Insert a property with the expiry date. @@ -306,15 +315,20 @@ and insert today's date." (interactive "P") (let* ((d (org-entry-get (point) org-expiry-expiry-property-name)) d-time d-hour) - (setq d-time (if d (apply 'encode-time (org-parse-time-string d)) + (setq d-time (if d (org-time-string-to-time d) (current-time))) (setq d-hour (format-time-string "%H:%M" d-time)) + (setq timestr (if today + (format-time-string (cdr org-time-stamp-formats)) + (concat "<" (org-read-date + nil nil nil nil d-time d-hour) ">"))) + ;; maybe transform to inactive timestamp + (if org-expiry-inactive-timestamps + (setq timestr (concat "[" (substring timestr 1 -1) "]"))) + (save-excursion (org-entry-put - (point) org-expiry-expiry-property-name - (if today (format-time-string (cdr org-time-stamp-formats)) - (concat "<" (org-read-date - nil nil nil nil d-time d-hour) ">")))))) + (point) org-expiry-expiry-property-name timestr)))) ;;; Functions to process expired entries: --MP_/yohhjVbGx0tKdaNpv1N=n9y--