From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jorge Morais Neto Subject: Re: Automatic mtime and ctime on all or select group of trees? Date: Sat, 2 Sep 2017 20:18:02 -0300 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doHg4-0002Eo-0w for emacs-orgmode@gnu.org; Sat, 02 Sep 2017 19:18:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doHfz-0002Hh-4S for emacs-orgmode@gnu.org; Sat, 02 Sep 2017 19:18:11 -0400 Received: from mail-pf0-x22e.google.com ([2607:f8b0:400e:c00::22e]:33351) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1doHfy-0002G7-UZ for emacs-orgmode@gnu.org; Sat, 02 Sep 2017 19:18:07 -0400 Received: by mail-pf0-x22e.google.com with SMTP id n73so9224152pfj.0 for ; Sat, 02 Sep 2017 16:18:05 -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" To: Tim Visher Cc: org mode On 31 August 2017 at 08:55, Tim Visher wrote: > I would like to track the time I created a tree and the last time it was > edited, like ctime and mtime on a filesystem. Is that possible to have > happen automatically? To insert a creation timestamp I use org-expiry. I have added ~(require 'org-expiry)~ to my Org Mode setup file. I could then have enabled automatic CREATED property insertion by adding ~(org-expiry-insinuate)~. However, that would make Org insert CREATED not only on heading creation, but also whenever I performed certain actions =E2=80=93 such as scheduling or deadlining =E2=80=93 on headings that lacked CREATED. I do n= ot want that. I want CREATED to reflect the actual creation time. Old headlines (from before I enabled org-expiry) are better off without CREATED than with an inaccurate CREATED timestamp. Also, I want to be able to disable on certain files the automatic CREATED insertion. So instead of ~(org-expiry-insinuate)~, I added this: ;; HACK? (defcustom J-insert-created t "Whether to automatically add CREATED property (org-expiry) on heading creation" :type 'boolean :safe #'booleanp) (defun J-insert-created () (when J-insert-created (org-expiry-insert-created))) (add-hook 'org-insert-heading-hook #'J-insert-created) (add-hook 'org-capture-prepare-finalize-hook (lambda () (org-map-entries #'org-expiry-insert-created))) So the CREATED timestamp is always added on capture, and also added on headline creation except for manually typed headings and buffers where option ~J-insert-created~ is nil. I created that option as an option (instead of a simple variable) so it could be file-local. This works, but I'm not sure it's correct and elegant. I know little Elisp and very little about defining Emacs options. Suggestions welcome. It currently gives compile warnings, which I ignore for now: J-org.el:18:1:Warning: defcustom for =E2=80=98J-insert-created=E2=80=99= fails to specify containing group Org-expiry can also add an EXPIRY property, so it can expire entries after they become irrelevant with time. And for entries without EXPIRY, it can use a (customizable) default time span. It is documented via comments on ~org-expiry.el~. That file comes with org-plus-contrib. I also customized the following options: - org-expiry-handler-function - org-expiry-inactive-timestamps - org-expiry-wait Beware that org-expiry interacts badly with the ~org-clone-subtree-with-time-shift~ command. It messes with org-expiry timestamps on the clones. For example, if the original entry is: * Meeting :PROPERTIES: :CREATED: [2017-09-02 S=C3=A1b 20:10] :EXPIRY: [2017-12-31] :END: <2017-09-04 Seg 10:00-11:00> and one invokes ~org-clone-subtree-with-time-shift~, asking for one clone and a ~+1w~ shift, the clone will be: * Meeting :PROPERTIES: :CREATED: [2017-09-09 S=C3=A1b 20:10] :EXPIRY: [2018-01-07 Dom] :END: <2017-09-11 Seg 10:00-11:00> which is clearly wrong. Regards --=20 - I am Brazilian. I hope my English is correct and I welcome feedback - Please adopt free formats like PDF, ODF, Org, LaTeX, Opus, WebM and 7z - Free (as in free speech) software for Android: https://f-droid.org/