all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Harry Putnam <reader@newsguy.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Inserting a timestamp in a file
Date: Sat, 31 Jan 2009 10:30:47 -0600	[thread overview]
Message-ID: <87hc3fjv48.fsf@newsguy.com> (raw)
In-Reply-To: 40785.25014.qm@web59703.mail.ac4.yahoo.com

Fred Picher <frederificc@yahoo.ca> writes:

> Hello,
>
>   Is there a way to insert a timestamp at a precise place in a file,
>   eg. is there a function that does this ?

Sounds like the kind of thing skeletons are good for.  If you want
something more customized than the existing timestamp functions. (Like
I did) take a look at skeletons here:

     (info "(autotype)Top")

This example may help you get it the way you want:

I wanted something for adding timestamped comments to files in a
certain format... like this:

# [HP 01/31/09_10:24:55 <MY COMMENT GOES HERE> ]

You can get just about any style time format you want by messing with
format-time-string.

This code inserts the above timestamp comment 
(minus the stuff above between `<>')

(define-skeleton hp-comdate
	"Insert #[HP] comment and 
	date string with no newline."
	nil
	"# [HP "
	(format-time-string "%m/%d/%y_%T ") _ " ] ")

So then you can say `M-x hp-comdate <RET>' to insert the skeleton





  parent reply	other threads:[~2009-01-31 16:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-29 14:25 Inserting a timestamp in a file Fred Picher
2009-01-29 16:59 ` Drew Adams
2009-01-31 16:30 ` Harry Putnam [this message]
     [not found] <mailman.6165.1233240186.26697.help-gnu-emacs@gnu.org>
2009-01-29 16:59 ` Maarten Bergvelt
2009-01-30 11:26 ` Kiwon Um
2009-01-31  5:15 ` B. T. Raven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87hc3fjv48.fsf@newsguy.com \
    --to=reader@newsguy.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.