From: Kauser
Subject: Timestamps
Date: 
Message-ID: <9570242d.0209041449.1bba8203@posting.google.com>
Hello everyone:

Is there any way I could get a file's timestamp using lisp code.
Timestamp as in the last time the file was modified. I probably need
to call some OS routine from lisp. And I need to do this for Windows,
Linux and Unix.

Any ideas?

Thanks,
Kauser

From: Erik Naggum
Subject: Re: Timestamps
Date: 
Message-ID: <3240170102529277@naggum.no>
[ Not cross-posting to comp.emacs ]

* ·······@utoronto.ca (Kauser)
| Is there any way I could get a file's timestamp using lisp code.  Timestamp
| as in the last time the file was modified. I probably need to call some OS
| routine from lisp. And I need to do this for Windows, Linux and Unix.

  Do you want the file's write date?

-- 
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.
From: Peter Breitfeld
Subject: Re: Timestamps
Date: 
Message-ID: <3kh7la.ej1.ln@phbrf.dialin.t-online.de>
Kauser schrieb:
> Hello everyone:
> 
> Is there any way I could get a file's timestamp using lisp code.
> Timestamp as in the last time the file was modified. I probably need
> to call some OS routine from lisp. And I need to do this for Windows,
> Linux and Unix.
> 
> Any ideas?
> 
> Thanks,
> Kauser

I use the following in my .emacs to create timestamps (hope you can
understand the German comments):

----------------8<----------------8<----------------
;; time-stamps in Buffer aktualisieren:
(add-hook 'find-file-hooks 'auto-insert)
(require 'time-stamp)
(add-hook 'write-file-hooks 'time-stamp)
(set 'time-stamp-active t)
(set 'time-stamp-format "%3a %2d.%3b %4y %02H:%02M:%02S %f")

(defun make-kopf-string (auf mark zu)
  "'mark' ist das Kommentarzeichen am Anfang der Zeile incl. evtl.
Blanks. 'auf' ist das �ffnende Kommentarzeichen (zB '(*' bei Pascal) und
'zu' das schlie�ende."
  (concat auf "Erzeugt am: "
			 (format-time-string "%a %d.%b %Y %H:%M:%S %Z") "\n"
			 mark "von " (user-full-name) " auf " (system-name) "\n"
			 mark "Zuletzt ge�ndert:\n"
			 mark "   Time-stamp: <>\n" zu "\n"))

(setq auto-insert-alist '(  
  (("\\.\\(tex\\|sty\\)\\'" .
	 "LaTeX-Kommentar") . (insert (make-kopf-string "% " "% " "")))
  (("\\.\\([Hh]\\|hh\\|hpp\\|[Cc]\\|cc\\|cpp\\|cxx\\|java\\|pov\\)\\'" .
	 "C-Kommentar") . (insert (make-kopf-string "// " "// " "")))
  (("\\.pas\\'" .
	 "Pascal-Kommentar") . (insert (make-kopf-string "(* " " * " " *)")))
  (("Makefile$" . "Makefile-Kommentar") .
	(insert (make-kopf-string "# " "# " "")))
  (("\\.*\\'" .
	 "Shell/Perl-Kommentar") .
	 (concat "#!/bin/bash\n#!/usr/bin/perl -w\n"
				(make-kopf-string "# " "# " "")))))

(defun insert-time-stamp ()
  (interactive)
  (insert (make-kopf-string "% " "% " "")))
----------------8<----------------8<---------------- 


Now, whenever I open a new file, I get asked if I want to insert a
time-stamp. If I agree the time-stamp is inserted and updated each time
I write the file. 


Gru� Peter
-- 
=--=--=--=--=--=--=--=--=--=--=--=--=--= http://home.t-online.de/home/phbrf
 Peter Breitfeld, Bad Saulgau, Germany   Meinen GnuPG/PGP-5x Key gibts dort
From: Matthieu Moy
Subject: Re: Timestamps
Date: 
Message-ID: <vpq1y88fum0.fsf@montrose.imag.fr>
·······@utoronto.ca (Kauser) writes:

> Hello everyone:
>
> Is there any way I could get a file's timestamp using lisp code.

Yes.

> Timestamp as in the last time the file was modified. I probably need
> to call some OS routine from lisp. And I need to do this for Windows,
> Linux and Unix.

Using only lisp, it will be portable.

M-x apropos

is your friend in those cases. (search for a regexp)

Here, the function is file-attributes. 

,----[ C-h f file-attributes RET ]
| file-attributes is a built-in function.
| (file-attributes FILENAME)
| 
| Return a list of attributes of file FILENAME.
| Value is nil if specified file cannot be opened.
|
|  [...] 
|
|  4. Last access  time, as a list of two  integers. First integer has
|  high-order 16 bits of time, second has low 16 bits. 
|  5. Last modification time, likewise. 
|
|  [...] 
|
`----

-- 
Matthieu