[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: open file/buffer and insert date into it
From: |
Bingham, Jay |
Subject: |
RE: open file/buffer and insert date into it |
Date: |
Thu, 28 Jun 2001 09:21:27 -0700 |
All things are possible to those that believe.
If what you want is to automatically date a file every time it is written,
take a look at the function time-stamp in the package time-stamp.el
If you want a function that can be used for inserting dates in log files
then you could use something like this:
(defvar tl_dts-format-string "%e %b %Y %H:%M:%S"
"A string specifying the format of the date-time stamp.
Refer to the documentation for format-time-string for an explanation of the
meta characters available for use in this string. Non-meta characters will
be inserted into the buffer without interpretation.")
;; Function: insert-dts
;; Insert the date and time into the current buffer at the current
location.
;;
;; Psuedo code:
;; insert the date and time into the current buffer at the current location
;;
(defun insert-dts ()
"Insert the date and time into the current buffer at the current location.
See the documentation for tl_dts-format-string to change the format of the
date-time stamp."
(interactive)
(insert (format-time-string tl_dts-format-string (current-time))))
J_)
C_)ingham
. COMPAQ Telecommunications
. Austin, TX
-----Original Message-----
From: Kenneth E. Fisler [mailto:kefisler@sherwin.com]
Sent: Thursday, 28 June, 2001 10:43 a
To: GNU Emacs Help
Subject: open file/buffer and insert date into it
While we're talking about inserting a date, I would like to open a file
(actually a buffer) and insert some text and today's date into it, something
like:
(defun datefile (dfname)
"Open file with date in it two times."
(interactive
(prgn
(find-file dfname)
; buffer should have text in it something like:
; "Today is " (format-time-string "%Y-%m-%d" nil)
)))
Can this be done? How?
tia,
kf
_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnu-emacs