[PLUG] Emacs Timestamp Entries In Files
Ali Corbin
ali.corbin at gmail.com
Fri Jul 21 05:03:16 UTC 2006
I cheated for my date function, and just used a shell command:
(defun enter-date nil
"Enter today's date at point."
(interactive)
(shell-command "date '+%B %d, %Y'" 1))
Ali
On 7/20/06, Carlos Konstanski <ckonstanski at pippiandcarlos.com> wrote:
> Maybe add a function to Semantic Highlight Edits Mode Hook or Vc Before
> Checkin Hook? Or write a save function of your own, and bind it to a
> keychord of your choice. That's how to get the timestamp function to
> run at the right time.
>
> To actually write a timestamp into a file, I scraped this up online.
> Function foo is the one you call with M-x foo while in the buffer you
> want to timestamp and save. The other 3 functions just give you a
> choice of date formats.
>
> I didn't bother placing the timestamp with much elegance because I don't
> know where you need it exactly. Elisp buffer functions are easy enough
> to find docs for and use.
>
> (defun foo ()
> (interactive)
> (goto-char (point-min))
> (insert (insert-date-iso))
> (save-buffer))
>
> (defun insert-date-iso ()
> "Inserts the current local date and time (to the minute) into the current buffer
> before Point. The data are formatted per ISO 8601 specification. This is useful for
> prefixing entries in a log book."
> (interactive)
> (setq now (decode-time)
> final-string (format "%04d-%02d-%02dT%02d:%02d+%d"
> (nth 5 now) ; yyyy
> (nth 4 now) ; mm
> (nth 3 now) ; dd
> (nth 2 now) ; HH
> (nth 1 now) ; MM
> (/ (nth 8 now) 36))) ; UTCO
> (insert final-string))
>
> (defun insert-date-stamp ()
> "Inserts the current local date into the current buffer before Point. The data are
> formatted per ISO 8601 short specification and prefixed with my initials 'MJL'. This
> is useful for inserting mod comments into code files."
> (interactive)
> (setq now (decode-time)
> final-string (format "MJL%04d%02d%02d - "
> (nth 5 now) ; yyyy
> (nth 4 now) ; mm
> (nth 3 now))) ; dd
> (insert final-string))
>
> (defun insert-date-dow ()
> "Inserts the current local date and the day of the week into the current buffer
> before Point. The date data are formatted per ISO 8601 specification. The DOW is
> expanded to the full name. This is useful for prefixing day entries in a log book."
> (interactive)
> (setq DOWlist '(Sunday Monday Tuesday Wednesday Thursday Friday Saturday))
> (setq now (decode-time)
> final-string (format "%04d-%02d-%02d %s"
> (nth 5 now) ; yyyy
> (nth 4 now) ; mm
> (nth 3 now) ; dd
> (nth (nth 6 now) DOWlist))) ; day
> (insert final-string))
>
>
> Carlos Konstanski
>
> On Thu, 20 Jul 2006, Rich Shepard wrote:
>
> > Date: Thu, 20 Jul 2006 19:47:49 -0700 (PDT)
> > From: Rich Shepard <rshepard at appl-ecosys.com202>
> > To: plug at pdxlinux.org203
> > Subject: [PLUG] Emacs Timestamp Entries In Files
> >
> > In the ORA Emacs book (p. 278) are directions for adding a timestamp to an
> > html file. But, I find nothing that shows me how to add a timestamp in other
> > files.
> >
> > Specifically, I'd like to add a timestamp to the revision section of a
> > program file when I've modified it. Is there an emacs function I can assign
> > to a key to do this? Ali?
> >
> > TIA,
> >
> > Rich
> >
> > --
> > Richard B. Shepard, Ph.D. | The Environmental Permitting
> > Applied Ecosystem Services, Inc.(TM) | Accelerator
> > <http://www.appl-ecosys.com204> Voice: 503-667-4517 Fax: 503-667-8863
> > _______________________________________________
> > PLUG mailing list
> > PLUG at lists.pdxlinux.org205
> > http://lists.pdxlinux.org/mailman/listinfo/plug206
> >
> >
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org207
> http://lists.pdxlinux.org/mailman/listinfo/plug208
>
More information about the PLUG
mailing list