0

I am writing a simple keyboard macro to insert a comment with my name and a short timestamp. Is there an easy way to get a timestamp? Ideally I would be able to define it in my macro so that it uses a relatively short form like YY-MM-DD HH:MM.

I'd like it to be as common to emacs as possible, so I'd rather not resort to Org mode or other add-ons that might not be part of a standard installation. Here's basically what I have so far, what I need is what's between the angle braces:

(fset 'my-timestamp "[myname <YY-MM-DD HH:MM>]: ")
(global-set-key (kbd "C-c #") 'my-timestamp)

1 Answer 1

0

Duh. I should have checked the emacs wiki first (http://www.emacswiki.org/emacs/InsertingTodaysDate). Here's a way they show that only relies on the emacs calendar. That's good enough for me.

  (defun timestamp ()
  (interactive)
  (insert (format-time-string "%Y-%m-%d %H:%M")))

After playing with several options from the emacs wiki link, I've revised this post to use the above, simpler function. Then I used the timestamp function while recording a macro I then put in my .emacs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .