all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* timestamp in emacs
@ 2004-05-05 16:21 Antonio Garcia
  2004-05-05 19:35 ` Marco Parrone
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Antonio Garcia @ 2004-05-05 16:21 UTC (permalink / raw)



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.

Antonio

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Antonio Garcia-Martinez
UC-Berkeley Physics/Joint Genome Institute
http://cryptologia.com

        .=$=.   .=$=.           .=$=.   .=$=.
@       @ | | | @ | | | @       @ | | | @ | | |
| @   @ | | | @   @ | | | @   @ | | | @   @ | |
| | @ | | | @       @ | | | @ | | | @       @ |
~'   `~$~'           `~$~'   `~$~'           `

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: timestamp in emacs
  2004-05-05 16:21 timestamp in emacs Antonio Garcia
@ 2004-05-05 19:35 ` Marco Parrone
  2004-05-05 19:47   ` Marco Parrone
  2004-05-05 20:01 ` Martin Stemplinger
  2004-05-05 21:00 ` Stefan Monnier
  2 siblings, 1 reply; 5+ messages in thread
From: Marco Parrone @ 2004-05-05 19:35 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 878 bytes --]

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 #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 151 bytes --]

_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnu-emacs

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: timestamp in emacs
  2004-05-05 19:35 ` Marco Parrone
@ 2004-05-05 19:47   ` Marco Parrone
  0 siblings, 0 replies; 5+ messages in thread
From: Marco Parrone @ 2004-05-05 19:47 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 716 bytes --]

Marco Parrone on Wed, 05 May 2004 19:35:54 GMT writes:

> (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))

Sorry, the previous was wrong, this one should work.

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

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 151 bytes --]

_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnu-emacs

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: timestamp in emacs
  2004-05-05 16:21 timestamp in emacs Antonio Garcia
  2004-05-05 19:35 ` Marco Parrone
@ 2004-05-05 20:01 ` Martin Stemplinger
  2004-05-05 21:00 ` Stefan Monnier
  2 siblings, 0 replies; 5+ messages in thread
From: Martin Stemplinger @ 2004-05-05 20:01 UTC (permalink / raw)


On Mit Mai 05 2004 at 18:21, Antonio Garcia <agm@socrates.berkeley.edu> wrote:

> I would like to easily interject a timestamp, a la date command, in a
> buffer in emacs. 

You can use (the time format adapted of course)

(defun insert-timestamp ()
  "German timestamp insertion function."
  (interactive)
  (insert (format-time-string "%H:%M %d.%m.%Y")))

(defun insert-date()
  "German date insertion function."
  (interactive)
  (insert (format-time-string "%d.%m.%Y")))

There was also a niftier version, probably in gnu.emacs.sources, that
uses different formats depending on arguments.

Is this what you are looking for? 

HTH
MArtin
-- 
Remove NOSPAM to reply by mail

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: timestamp in emacs
  2004-05-05 16:21 timestamp in emacs Antonio Garcia
  2004-05-05 19:35 ` Marco Parrone
  2004-05-05 20:01 ` Martin Stemplinger
@ 2004-05-05 21:00 ` Stefan Monnier
  2 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2004-05-05 21:00 UTC (permalink / raw)


> 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.

C-u M-! date RET


        Stefan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-05-05 21:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-05 16:21 timestamp in emacs Antonio Garcia
2004-05-05 19:35 ` Marco Parrone
2004-05-05 19:47   ` Marco Parrone
2004-05-05 20:01 ` Martin Stemplinger
2004-05-05 21:00 ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.