emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Auto insert and change date in header?
@ 2013-07-25  0:30 Xebar Saram
  2013-07-26 20:49 ` Dave Marquardt
  0 siblings, 1 reply; 6+ messages in thread
From: Xebar Saram @ 2013-07-25  0:30 UTC (permalink / raw)
  To: org mode

[-- Attachment #1: Type: text/plain, Size: 212 bytes --]

Hi list

does any one know of a way to auto insert/change the date in each sections
header when the section is edited?IE have a date in the header showing last
edited date.
Is this technically possible?

best

Z

[-- Attachment #2: Type: text/html, Size: 330 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Auto insert and change date in header?
  2013-07-25  0:30 Auto insert and change date in header? Xebar Saram
@ 2013-07-26 20:49 ` Dave Marquardt
  2015-08-01 14:45   ` Xebar Saram
  0 siblings, 1 reply; 6+ messages in thread
From: Dave Marquardt @ 2013-07-26 20:49 UTC (permalink / raw)
  To: emacs-orgmode

Xebar Saram <zeltakc@gmail.com> writes:

> does any one know of a way to auto insert/change the date in each sections
> header when the section is edited?IE have a date in the header showing
> last edited date.
> Is this technically possible?

Try setting before-save-hook.  See "(elisp) Saving Buffers".

-Dave

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Auto insert and change date in header?
  2013-07-26 20:49 ` Dave Marquardt
@ 2015-08-01 14:45   ` Xebar Saram
  2015-08-01 16:05     ` John Kitchin
  0 siblings, 1 reply; 6+ messages in thread
From: Xebar Saram @ 2015-08-01 14:45 UTC (permalink / raw)
  To: Dave Marquardt; +Cc: org mode

[-- Attachment #1: Type: text/plain, Size: 707 bytes --]

Hi all

coming back to it after 3 years :)

im wondering if anyone has a hook or anything like that that auto adds a
date when he creates a header. and maybe also auto change the date each
time  the text under the header is changed? kind of simulating a timestamp
type function :)

best

Z

On Fri, Jul 26, 2013 at 11:49 PM, Dave Marquardt <davemarq@us.ibm.com>
wrote:

> Xebar Saram <zeltakc@gmail.com> writes:
>
> > does any one know of a way to auto insert/change the date in each
> sections
> > header when the section is edited?IE have a date in the header showing
> > last edited date.
> > Is this technically possible?
>
> Try setting before-save-hook.  See "(elisp) Saving Buffers".
>
> -Dave
>
>
>

[-- Attachment #2: Type: text/html, Size: 1282 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Auto insert and change date in header?
  2015-08-01 14:45   ` Xebar Saram
@ 2015-08-01 16:05     ` John Kitchin
  2015-08-02 18:34       ` Xebar Saram
  0 siblings, 1 reply; 6+ messages in thread
From: John Kitchin @ 2015-08-01 16:05 UTC (permalink / raw)
  To: Xebar Saram; +Cc: Dave Marquardt, org mode


This seems to do what you want for the changes. The timestamp is
automatically added when you make changes. It does not propagate
timestamps up though, so if you change a subheading the timestamp there
is updated, but the one in the parent for example. also, this will
update every headline.

You may need to add another (add-hook 'org-mode-hook (lambda ()
(add-to-list 'after-change-functions 'update-last-edited))) kind of line
to enable this in all org-files, the code below might be buffer local.

#+BEGIN_SRC emacs-lisp
(defun update-last-edited (beg end length)
  (when
      (and
       (not (org-before-first-heading-p))
       (org-get-heading))
    (org-entry-put nil "LAST-EDITED" (format-time-string "[%Y-%m-%d %a %H:%M:%S]"))))

(add-to-list 'after-change-functions 'update-last-edited)
#+END_SRC



Xebar Saram writes:

> Hi all
>
> coming back to it after 3 years :)
>
> im wondering if anyone has a hook or anything like that that auto adds a
> date when he creates a header. and maybe also auto change the date each
> time  the text under the header is changed? kind of simulating a timestamp
> type function :)
>
> best
>
> Z
>
> On Fri, Jul 26, 2013 at 11:49 PM, Dave Marquardt <davemarq@us.ibm.com>
> wrote:
>
>> Xebar Saram <zeltakc@gmail.com> writes:
>>
>> > does any one know of a way to auto insert/change the date in each
>> sections
>> > header when the section is edited?IE have a date in the header showing
>> > last edited date.
>> > Is this technically possible?
>>
>> Try setting before-save-hook.  See "(elisp) Saving Buffers".
>>
>> -Dave
>>
>>
>>

--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Auto insert and change date in header?
  2015-08-01 16:05     ` John Kitchin
@ 2015-08-02 18:34       ` Xebar Saram
  2015-08-03  0:09         ` John Kitchin
  0 siblings, 1 reply; 6+ messages in thread
From: Xebar Saram @ 2015-08-02 18:34 UTC (permalink / raw)
  To: John Kitchin; +Cc: Dave Marquardt, org mode

[-- Attachment #1: Type: text/plain, Size: 2680 bytes --]

Hi John

i tried it by evaluating it and then it works exactly as i needed:) the
only bizarre thing is that when i add it to my config emacs is frozen
during startup.
ive also tried adding the extra lines you suggested so now the lisp part
looks like this


#+BEGIN_SRC emacs-lisp
(defun update-last-edited (beg end length)
  (when
      (and
       (not (org-before-first-heading-p))
       (org-get-heading))
    (org-entry-put nil "LAST-EDITED" (format-time-string
"[%d-%m-%Y(%H:%M)]"))))

(add-to-list 'after-change-functions 'update-last-edited)

(add-hook 'org-mode-hook (lambda ()
(add-to-list 'after-change-functions 'update-last-edited)))

#+END_SRC

any idea why it freezes emacs?

best

Z

On Sat, Aug 1, 2015 at 7:05 PM, John Kitchin <jkitchin@andrew.cmu.edu>
wrote:

>
> This seems to do what you want for the changes. The timestamp is
> automatically added when you make changes. It does not propagate
> timestamps up though, so if you change a subheading the timestamp there
> is updated, but the one in the parent for example. also, this will
> update every headline.
>
> You may need to add another (add-hook 'org-mode-hook (lambda ()
> (add-to-list 'after-change-functions 'update-last-edited))) kind of line
> to enable this in all org-files, the code below might be buffer local.
>
> #+BEGIN_SRC emacs-lisp
> (defun update-last-edited (beg end length)
>   (when
>       (and
>        (not (org-before-first-heading-p))
>        (org-get-heading))
>     (org-entry-put nil "LAST-EDITED" (format-time-string "[%Y-%m-%d %a
> %H:%M:%S]"))))
>
> (add-to-list 'after-change-functions 'update-last-edited)
> #+END_SRC
>
>
>
> Xebar Saram writes:
>
> > Hi all
> >
> > coming back to it after 3 years :)
> >
> > im wondering if anyone has a hook or anything like that that auto adds a
> > date when he creates a header. and maybe also auto change the date each
> > time  the text under the header is changed? kind of simulating a
> timestamp
> > type function :)
> >
> > best
> >
> > Z
> >
> > On Fri, Jul 26, 2013 at 11:49 PM, Dave Marquardt <davemarq@us.ibm.com>
> > wrote:
> >
> >> Xebar Saram <zeltakc@gmail.com> writes:
> >>
> >> > does any one know of a way to auto insert/change the date in each
> >> sections
> >> > header when the section is edited?IE have a date in the header showing
> >> > last edited date.
> >> > Is this technically possible?
> >>
> >> Try setting before-save-hook.  See "(elisp) Saving Buffers".
> >>
> >> -Dave
> >>
> >>
> >>
>
> --
> Professor John Kitchin
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
>

[-- Attachment #2: Type: text/html, Size: 4000 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Auto insert and change date in header?
  2015-08-02 18:34       ` Xebar Saram
@ 2015-08-03  0:09         ` John Kitchin
  0 siblings, 0 replies; 6+ messages in thread
From: John Kitchin @ 2015-08-03  0:09 UTC (permalink / raw)
  To: Xebar Saram; +Cc: Dave Marquardt, org mode

[-- Attachment #1: Type: text/plain, Size: 3446 bytes --]

 you probably only need this:

(add-hook 'org-mode-hook (lambda ()
(add-to-list 'after-change-functions 'update-last-edited)))

and not this:

(add-to-list 'after-change-functions 'update-last-edited)

I guess that this last line could be causing an issue in buffers like
*Messages* which change a lot, especially during startup.


John

-----------------------------------
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu


On Sun, Aug 2, 2015 at 2:34 PM, Xebar Saram <zeltakc@gmail.com> wrote:

> Hi John
>
> i tried it by evaluating it and then it works exactly as i needed:) the
> only bizarre thing is that when i add it to my config emacs is frozen
> during startup.
> ive also tried adding the extra lines you suggested so now the lisp part
> looks like this
>
>
> #+BEGIN_SRC emacs-lisp
> (defun update-last-edited (beg end length)
>   (when
>       (and
>        (not (org-before-first-heading-p))
>        (org-get-heading))
>     (org-entry-put nil "LAST-EDITED" (format-time-string
> "[%d-%m-%Y(%H:%M)]"))))
>
> (add-to-list 'after-change-functions 'update-last-edited)
>
> (add-hook 'org-mode-hook (lambda ()
> (add-to-list 'after-change-functions 'update-last-edited)))
>
> #+END_SRC
>
> any idea why it freezes emacs?
>
> best
>
> Z
>
> On Sat, Aug 1, 2015 at 7:05 PM, John Kitchin <jkitchin@andrew.cmu.edu>
> wrote:
>
>>
>> This seems to do what you want for the changes. The timestamp is
>> automatically added when you make changes. It does not propagate
>> timestamps up though, so if you change a subheading the timestamp there
>> is updated, but the one in the parent for example. also, this will
>> update every headline.
>>
>> You may need to add another (add-hook 'org-mode-hook (lambda ()
>> (add-to-list 'after-change-functions 'update-last-edited))) kind of line
>> to enable this in all org-files, the code below might be buffer local.
>>
>> #+BEGIN_SRC emacs-lisp
>> (defun update-last-edited (beg end length)
>>   (when
>>       (and
>>        (not (org-before-first-heading-p))
>>        (org-get-heading))
>>     (org-entry-put nil "LAST-EDITED" (format-time-string "[%Y-%m-%d %a
>> %H:%M:%S]"))))
>>
>> (add-to-list 'after-change-functions 'update-last-edited)
>> #+END_SRC
>>
>>
>>
>> Xebar Saram writes:
>>
>> > Hi all
>> >
>> > coming back to it after 3 years :)
>> >
>> > im wondering if anyone has a hook or anything like that that auto adds a
>> > date when he creates a header. and maybe also auto change the date each
>> > time  the text under the header is changed? kind of simulating a
>> timestamp
>> > type function :)
>> >
>> > best
>> >
>> > Z
>> >
>> > On Fri, Jul 26, 2013 at 11:49 PM, Dave Marquardt <davemarq@us.ibm.com>
>> > wrote:
>> >
>> >> Xebar Saram <zeltakc@gmail.com> writes:
>> >>
>> >> > does any one know of a way to auto insert/change the date in each
>> >> sections
>> >> > header when the section is edited?IE have a date in the header
>> showing
>> >> > last edited date.
>> >> > Is this technically possible?
>> >>
>> >> Try setting before-save-hook.  See "(elisp) Saving Buffers".
>> >>
>> >> -Dave
>> >>
>> >>
>> >>
>>
>> --
>> Professor John Kitchin
>> Doherty Hall A207F
>> Department of Chemical Engineering
>> Carnegie Mellon University
>> Pittsburgh, PA 15213
>> 412-268-7803
>> @johnkitchin
>> http://kitchingroup.cheme.cmu.edu
>>
>
>

[-- Attachment #2: Type: text/html, Size: 5948 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-08-03  0:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-25  0:30 Auto insert and change date in header? Xebar Saram
2013-07-26 20:49 ` Dave Marquardt
2015-08-01 14:45   ` Xebar Saram
2015-08-01 16:05     ` John Kitchin
2015-08-02 18:34       ` Xebar Saram
2015-08-03  0:09         ` John Kitchin

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).