home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.emacs.help
- Path: sparky!uunet!stanford.edu!agate!ames!sun-barr!cs.utexas.edu!usc!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnewsk!cbnewsj!att-out!cbnewsh!cbnewsh!tds
- From: tds@hoserve.att.com (Tony DeSimone)
- Subject: Re: HELP: function insert current date and time into buffer
- Reply-To: tds@hoserve.att.com (Tony DeSimone)
- Organization: AT&T Bell Laboratories
- Date: Thu, 12 Nov 1992 20:38:43 GMT
- Message-ID: <TDS.92Nov12153843@qpc1.ATT.COM>
- In-Reply-To: ron@wc18.yorku.ca's message of Thu, 12 Nov 1992 19:09:56 GMT
- References: <1992Nov7.214255.14388@magnus.acs.ohio-state.edu>
- <RON.92Nov12140956@wc18.yorku.ca>
- Sender: news@cbnewsh.cb.att.com (NetNews Administrator)
- Nntp-Posting-Host: qpc1.ho.att.com
- Lines: 36
-
- >>>>> On Thu, 12 Nov 1992 19:09:56 GMT, ron@wc18.yorku.ca (Ron Sheese) said:
-
- Ron> Hi, all,
-
- Ron> Is there a function in emacs which can insert the current date and
- Ron> time into current buffer?
-
- This is what I have in my .emacs, to make things like [tds 92/11/12 15:38].
-
- (defconst month-number-alist
- '(("Jan" . "01") ("Feb" . "02") ("Mar" . "03")
- ("Apr" . "04") ("May" . "05") ("Jun" . "06")
- ("Jul" . "07") ("Aug" . "08") ("Sep" . "09")
- ("Oct" . "10") ("Nov" . "11") ("Dec" . "12"))
- "assoc list of months/numeric string numbers.")
-
- (defun insert-date-stamp ()
- "Put date-stamp at point."
- (interactive)
- (let ((date (current-time-string)))
- (insert "[" (getenv "USER") " "
- (substring date -2 nil) ; yyyy
- "/"
- (cdr (assoc (substring date 4 7)
- month-number-alist)) ; MM
- "/"
- (let ((d (substring date 8 9)))
- (if (equal d " ") "0" d))
- (substring date 9 10) ; d
- " "
- (substring date 11 13) ; hh
- ":"
- (substring date 14 16) ; mm
- "]")))
- (global-set-key "\C-cd" 'insert-date-stamp)
-
-