help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: timestamp in emacs


From: Marco Parrone
Subject: Re: timestamp in emacs
Date: Wed, 05 May 2004 19:35:54 GMT
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Antonio Garcia on Wed, 5 May 2004 09:21:05 -0700 writes:

> I would like to easily interject a timestamp, a la date command, in a
> buffer in emacs. Is there a pre-existing macro I can use, or do I have to
> make one myself? If the latter, pointers to how to do so appreciated.

The following code should work.

(setq substitute-keywords-keywords/expressions-alist
      (list (cons "\\$\Date:.*\\$"
                  '(format-time-string "$\Date: %a, %d %B %Y %T %Z $"
                                       (current-time)))))

(defun substitute-keywords ()
  (interactive)
  (save-excursion
    (beginning-of-buffer)
    (mapcar
     (lambda (keyw/exp)
       (replace-regexp (car keyw/exp)
                       (eval (cdr keyw/exp))))
     substitute-keywords-keywords/expressions-alist)
    nil))

;; Deprecated.
;; (add-hook 'write-file-hooks 'substitute-keywords)

-- 
Marco Parrone (marc0) <marc0@autistici.org> [0x45070AD6]

Attachment: pgpnW1P59XCMr.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]