[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Simple lisp question - printing out file name
From: |
B. T. Raven |
Subject: |
Re: Simple lisp question - printing out file name |
Date: |
Wed, 11 Jan 2006 04:11:07 GMT |
"exits funnel" <exitsfunnel@yahoo.com> wrote in message
news:mailman.648.1136926006.26925.help-gnu-emacs@gnu.org...
> Hi Pascal,
>
> This looks like exactly what I want except that it
> doens't work :) Is time-stamp-string availaible only
> in cvs emacs? I should have mentioned that I'm
> running the precompiled emacs 21.3.1 on a windows box.
> Apropos doesn't show any hits for time-stamp-string.
> If the case is that your suggested code is only good
> for cvs emacs, do you know of any older functions
> which are roughly equivalent? Thanks.
>
> -exits
>
> --- Pascal Bourguignon <spam@mouse-potato.com> wrote:
>
> > exits funnel <exitsfunnel@yahoo.com> writes:
> >
> > > Hello,
> > >
> > > I have added to several .el files something like
> > this:
> > >
> > > (message "In prj.el")
> > >
> > > to help me straighten out configuration issues.
> > I'd
> > > like to make it slightly more sophisicated by (a)
> > > replacing the hard coded string with some lisp to
> > read
> > > the fully qualified file name and (b) to prepend a
> > > timestamp. I'm sure this is trivial lisp, but
> > > apparently it's not quite trivial enough for me :)
> > It
> > > seems that buffer-file-name and
> > current-time-string
> > > should be of interest to me but I can't get them
> > to
> > > work inside my message call. Can anyone help me
> > out
> > > here? Thanks in advance.
> >
> > (message (format "On %s loading %s"
> > (time-stamp-string) load-file-name))
> >
> > You can also specify the time-stamp-format:
> >
> > (time-stamp-string "%:y-%02m-%02d
> > %02H:%02M:%02S")
> >
E.F.:
I have the same set-up you do but that isn't the problem. To understand
what's going on type the following:
C-h f time [tab] ;; this gives you completions for some
;; functions starting with 'time...'
;; time-stamp is the only one similar to what you're
;; looking for. Click on it and you will see that it's
;; defined in time-stamp.el. Before you look into this
;; file, put (time-stamp) into the *scratch* buffer and
;; with the cursor after the close paren, type
C-j.
;; notice that this loads the time-stamp.el file.
;; Now type C-h f time [tab] again and you will
;; that many more functions are now available to
;; the emacs. If you put (time-stamp-string) in the
;; *scratch* buffer and evaluate it with
C-j
;;you will see the current time and machine name printed
;; on the next line. Evaluate again and you will see that
;; the time has been updated.
Now you can use it in a lisp function as indicated by Stephen.
You could also load the time-stamp.el by putting it in your
.emacs file but it is auto-loaded by calling the function.
Ed