* Automatic mtime and ctime on all or select group of trees?
@ 2017-08-31 11:55 Tim Visher
2017-08-31 13:44 ` Eric S Fraga
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Tim Visher @ 2017-08-31 11:55 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 294 bytes --]
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?
Thanks in advance!
--
In Christ,
Timmy V.
http://blog.twonegatives.com/
http://five.sentenc.es/ -- Spend less time on mail
[-- Attachment #2: Type: text/html, Size: 539 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Automatic mtime and ctime on all or select group of trees?
2017-08-31 11:55 Automatic mtime and ctime on all or select group of trees? Tim Visher
@ 2017-08-31 13:44 ` Eric S Fraga
2017-08-31 14:20 ` Tim Visher
2017-09-02 23:18 ` Jorge Morais Neto
2017-09-02 23:34 ` Samuel Wales
2 siblings, 1 reply; 11+ messages in thread
From: Eric S Fraga @ 2017-08-31 13:44 UTC (permalink / raw)
To: Tim Visher; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 538 bytes --]
On Thursday, 31 Aug 2017 at 07: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?
I don't know of any org mechanism for handling this, especially the
modified time element. However, I would suggest you consider using a
revision control system (mercurial, git) which would allow even finer
tracking than this...
--
: Eric S Fraga via Emacs 26.0.50, Org release_9.0.10-723-g23eba9
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Automatic mtime and ctime on all or select group of trees?
2017-08-31 13:44 ` Eric S Fraga
@ 2017-08-31 14:20 ` Tim Visher
2017-09-01 9:57 ` Eric S Fraga
0 siblings, 1 reply; 11+ messages in thread
From: Tim Visher @ 2017-08-31 14:20 UTC (permalink / raw)
To: Tim Visher, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 972 bytes --]
On Thu, Aug 31, 2017 at 9:44 AM, Eric S Fraga <esflists@gmail.com> wrote:
> On Thursday, 31 Aug 2017 at 07: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?
>
> I don't know of any org mechanism for handling this, especially the
> modified time element. However, I would suggest you consider using a
> revision control system (mercurial, git) which would allow even finer
> tracking than this...
>
Thanks for the suggestion. It doesn't really meet my needs here in that I'm
really looking for org to behave more like a filesystem, not something that
I have to manually commit changes to.
If this doesn't already exist, does org already provide hooks or something
that I can plug in to? I would assume a heading-created and
heading-modified hook of some kind would allow me to implement my own
solution fairly cleanly.
[-- Attachment #2: Type: text/html, Size: 1381 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Automatic mtime and ctime on all or select group of trees?
2017-08-31 14:20 ` Tim Visher
@ 2017-09-01 9:57 ` Eric S Fraga
2017-09-02 1:09 ` Adam Porter
0 siblings, 1 reply; 11+ messages in thread
From: Eric S Fraga @ 2017-09-01 9:57 UTC (permalink / raw)
To: Tim Visher; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1392 bytes --]
On Thursday, 31 Aug 2017 at 10:20, Tim Visher wrote:
> Thanks for the suggestion. It doesn't really meet my needs here in that I'm
> really looking for org to behave more like a filesystem, not something that
> I have to manually commit changes to.
I understand but I think you may be expecting more from org than it
really is designed to do. It is primarily about text markup as the
basis.
> If this doesn't already exist, does org already provide hooks or something
> that I can plug in to? I would assume a heading-created and
> heading-modified hook of some kind would allow me to implement my own
> solution fairly cleanly.
The problem is that you can create a heading by simply typing "* blah"
at the start of a line. There are some methods that create new headings
(see org-meta-return and or-insert-heading-respect-content, e.g.) but
you don't need to use them at all.
However, if you are very disciplined, you could probably use org-capture
to do what you want. Look at the capture-refile-archive section
(section 9) of the info manual. Many of us use capturing for logs and
journals, for instance, which do some of what you want (not all). You
may wish to combine capturing with special TODO states and there are
indeed hooks invoked when changing such states.
HTH,
eric
--
: Eric S Fraga via Emacs 26.0.50, Org release_9.0.10-723-g23eba9
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Automatic mtime and ctime on all or select group of trees?
2017-09-01 9:57 ` Eric S Fraga
@ 2017-09-02 1:09 ` Adam Porter
0 siblings, 0 replies; 11+ messages in thread
From: Adam Porter @ 2017-09-02 1:09 UTC (permalink / raw)
To: emacs-orgmode
As Eric mentioned, a heading can be created by simply typing, so making
that detect whether a new heading is created is possible, but I guess it
would require some ugly hacks. Maybe if you could hook into the
font-lock code, but like I said...ugly hacks. :)
However, it would be easy to add advice to the heading-creating
commands, so if you always use those to create headings, that would do
it for you.
For modification time, that would be more challenging. I guess you
could use post-command-hook and update an mtime property in the current
node with every keystroke. Another way might be to add a function to
the before-save-hook that would diff the buffer with the file and update
the mtime in each node that has been changed.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Automatic mtime and ctime on all or select group of trees?
2017-08-31 11:55 Automatic mtime and ctime on all or select group of trees? Tim Visher
2017-08-31 13:44 ` Eric S Fraga
@ 2017-09-02 23:18 ` Jorge Morais Neto
2017-09-03 1:10 ` Adam Porter
2017-09-02 23:34 ` Samuel Wales
2 siblings, 1 reply; 11+ messages in thread
From: Jorge Morais Neto @ 2017-09-02 23:18 UTC (permalink / raw)
To: Tim Visher; +Cc: org mode
On 31 August 2017 at 08:55, Tim Visher <tim.visher@gmail.com> 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 – such as
scheduling or deadlining – on headings that lacked CREATED. I do not
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 ‘J-insert-created’ 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áb 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áb 20:10]
:EXPIRY: [2018-01-07 Dom]
:END:
<2017-09-11 Seg 10:00-11:00>
which is clearly wrong.
Regards
--
- 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/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Automatic mtime and ctime on all or select group of trees?
2017-08-31 11:55 Automatic mtime and ctime on all or select group of trees? Tim Visher
2017-08-31 13:44 ` Eric S Fraga
2017-09-02 23:18 ` Jorge Morais Neto
@ 2017-09-02 23:34 ` Samuel Wales
2017-09-03 1:06 ` Adam Porter
2 siblings, 1 reply; 11+ messages in thread
From: Samuel Wales @ 2017-09-02 23:34 UTC (permalink / raw)
To: Tim Visher; +Cc: emacs-orgmode
pedantry:
birth time, sometimes called btime, is a new kernel feature, present
in some filesystems but not traditionally available to stat.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Automatic mtime and ctime on all or select group of trees?
2017-09-02 23:34 ` Samuel Wales
@ 2017-09-03 1:06 ` Adam Porter
0 siblings, 0 replies; 11+ messages in thread
From: Adam Porter @ 2017-09-03 1:06 UTC (permalink / raw)
To: emacs-orgmode
Samuel Wales <samologist@gmail.com> writes:
> pedantry:
>
> birth time, sometimes called btime, is a new kernel feature, present
> in some filesystems but not traditionally available to stat.
Actually that's a very good reminder, especially for people who work on
both Windows and *nix. In Windows, the "C" time is "Creation", but in
Linux it's "change." Just found this article which looks interesting:
https://lwn.net/Articles/397442/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Automatic mtime and ctime on all or select group of trees?
2017-09-02 23:18 ` Jorge Morais Neto
@ 2017-09-03 1:10 ` Adam Porter
2017-09-05 16:47 ` Jorge Morais Neto
0 siblings, 1 reply; 11+ messages in thread
From: Adam Porter @ 2017-09-03 1:10 UTC (permalink / raw)
To: emacs-orgmode
Jorge Morais Neto <jorge13515@gmail.com> writes:
Hi Jorge,
Thanks for sharing that, I didn't even remember org-expiry. Very clever
use of it! You seem to know more about elisp than you give yourself
credit for. :)
> Suggestions welcome. It currently
> gives compile warnings, which I ignore for now:
>
> J-org.el:18:1:Warning: defcustom for ‘J-insert-created’ fails to specify
> containing group
You can fix that by adding e.g. ":group 'org" to the defcustom.
Normally the defcustom would pick up whatever group was last defined in
the same file.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Automatic mtime and ctime on all or select group of trees?
2017-09-03 1:10 ` Adam Porter
@ 2017-09-05 16:47 ` Jorge Morais Neto
2017-09-07 1:38 ` Adam Porter
0 siblings, 1 reply; 11+ messages in thread
From: Jorge Morais Neto @ 2017-09-05 16:47 UTC (permalink / raw)
To: Adam Porter; +Cc: org mode
[unfortunately the first email went only to Adam Porter; now I address the list]
On 2 September 2017 at 22:10, Adam Porter <adam@alphapapa.net> wrote:
> Thanks for sharing that, I didn't even remember org-expiry. Very clever
> use of it! You seem to know more about elisp than you give yourself
> credit for. :)
Thank you for the encouragement!
>> Suggestions welcome. It currently
>> gives compile warnings, which I ignore for now:
>>
>> J-org.el:18:1:Warning: defcustom for ‘J-insert-created’ fails to specify
>> containing group
>
> You can fix that by adding e.g. ":group 'org" to the defcustom.
> Normally the defcustom would pick up whatever group was last defined in
> the same file.
Thank you for the tip. But instead of adding precisely what you
suggested, I have added “:group 'org-expiry”. The warning is gone and
the option does show up when I invoke customize-group and type
“org-expiry”. I have run some other minimal tests and it seems to be
working.
Regards
--
- 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/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Automatic mtime and ctime on all or select group of trees?
2017-09-05 16:47 ` Jorge Morais Neto
@ 2017-09-07 1:38 ` Adam Porter
0 siblings, 0 replies; 11+ messages in thread
From: Adam Porter @ 2017-09-07 1:38 UTC (permalink / raw)
To: emacs-orgmode
Jorge Morais Neto <jorge13515@gmail.com> writes:
> Thank you for the tip. But instead of adding precisely what you
> suggested, I have added “:group 'org-expiry”. The warning is gone and
> the option does show up when I invoke customize-group and type
> “org-expiry”. I have run some other minimal tests and it seems to be
> working.
Muito bem feito! :)
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2017-09-07 1:39 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-31 11:55 Automatic mtime and ctime on all or select group of trees? Tim Visher
2017-08-31 13:44 ` Eric S Fraga
2017-08-31 14:20 ` Tim Visher
2017-09-01 9:57 ` Eric S Fraga
2017-09-02 1:09 ` Adam Porter
2017-09-02 23:18 ` Jorge Morais Neto
2017-09-03 1:10 ` Adam Porter
2017-09-05 16:47 ` Jorge Morais Neto
2017-09-07 1:38 ` Adam Porter
2017-09-02 23:34 ` Samuel Wales
2017-09-03 1:06 ` Adam Porter
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).