all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* inserting date and time at the cursor location
@ 2002-10-02 13:03 Guy-Armand Kamendje
  2002-10-02 15:30 ` Jesper Harder
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Guy-Armand Kamendje @ 2002-10-02 13:03 UTC (permalink / raw)


Hi,
Is there a way to let xemacs insert the current date and time at the actual
cursor location?
Thanks for any hint
Guy

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

* Re: inserting date and time at the cursor location
  2002-10-02 13:03 inserting date and time at the cursor location Guy-Armand Kamendje
@ 2002-10-02 15:30 ` Jesper Harder
  2002-10-02 15:37   ` David Kastrup
  2002-10-02 15:45 ` kgold
  2002-10-04  4:46 ` ken
  2 siblings, 1 reply; 10+ messages in thread
From: Jesper Harder @ 2002-10-02 15:30 UTC (permalink / raw)


"Guy-Armand Kamendje" <kguy@gmx.at> writes:

> Is there a way to let xemacs insert the current date and time at the
> actual cursor location?

(defun jh-insert-current-time ()
  (interactive)
  (insert (current-time-string)))

Then do `M-x jh-insert-current-time' or bind it to some key sequence.

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

* Re: inserting date and time at the cursor location
  2002-10-02 15:30 ` Jesper Harder
@ 2002-10-02 15:37   ` David Kastrup
  2002-10-03  2:52     ` Clemens Fischer
  0 siblings, 1 reply; 10+ messages in thread
From: David Kastrup @ 2002-10-02 15:37 UTC (permalink / raw)


Jesper Harder <harder@myrealbox.com> writes:

> "Guy-Armand Kamendje" <kguy@gmx.at> writes:
> 
> > Is there a way to let xemacs insert the current date and time at the
> > actual cursor location?
> 
> (defun jh-insert-current-time ()
>   (interactive)
>   (insert (current-time-string)))
> 
> Then do `M-x jh-insert-current-time' or bind it to some key sequence.

You could also use
C-u M-! date RET

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: David.Kastrup@t-online.de

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

* Re: inserting date and time at the cursor location
  2002-10-02 13:03 inserting date and time at the cursor location Guy-Armand Kamendje
  2002-10-02 15:30 ` Jesper Harder
@ 2002-10-02 15:45 ` kgold
  2002-10-04  4:46 ` ken
  2 siblings, 0 replies; 10+ messages in thread
From: kgold @ 2002-10-02 15:45 UTC (permalink / raw)



I don't know about xemacs, but here's the function I use in emacs:

(defun insert-date ()
  "Insert date at the current cursor position in the current buffer."
  (interactive)
  (insert (format-time-string "%d %B %Y ")))

Bonus 1:

I bind it to a key like this:

(define-key esc-map "D" 'insert-date)

Bonus 2:

If you want a time stamp updated automatically every time you write:

; time stamp (Time-stamp: " " in first eight lines of file)

(add-hook 'write-file-hooks 'time-stamp)
(setq time-stamp-active t)
(setq time-stamp-format "%02d %:b %:y %02H:%02M:%02S")

"Guy-Armand Kamendje" <kguy@gmx.at> writes:
> 
> Is there a way to let xemacs insert the current date and time at the actual
> cursor location?

-- 
-- 
Ken Goldman   kgold@watson.ibm.com   914-784-7646

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

* Re: inserting date and time at the cursor location
  2002-10-02 15:37   ` David Kastrup
@ 2002-10-03  2:52     ` Clemens Fischer
  2002-10-03  4:13       ` ftrw
                         ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Clemens Fischer @ 2002-10-03  2:52 UTC (permalink / raw)


David Kastrup <David.Kastrup@t-online.de> writes:

> You could also use
> C-u M-! date RET

ok, how do i bind this to a key?

clemens

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

* Re: inserting date and time at the cursor location
  2002-10-03  2:52     ` Clemens Fischer
@ 2002-10-03  4:13       ` ftrw
  2002-10-03 10:44       ` Reiner Steib
                         ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: ftrw @ 2002-10-03  4:13 UTC (permalink / raw)


Clemens Fischer <ino@despammed.com> writes:

> David Kastrup <David.Kastrup@t-online.de> writes:
> 
> > You could also use
> > C-u M-! date RET
> 
> ok, how do i bind this to a key?
> 
> clemens

C-x (                                    (define macro)
C-u M-! date RET                         (your macro)
C-x )                                    (end macro)
M-x name-last-kbd-macro RET insert-date  (name macro)
C-x C-f ~/.emacs
M-x insert-kbd-macro RET insert-date     (insert macro into .emacs)

Now add this line underneath your new macro (choose
whatever key you want to bind it to):

(global-set-key [M-f4] 'insert-date)

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

* Re: inserting date and time at the cursor location
  2002-10-03  2:52     ` Clemens Fischer
  2002-10-03  4:13       ` ftrw
@ 2002-10-03 10:44       ` Reiner Steib
  2002-10-11 12:14       ` Mario Lang
  2002-10-13 14:25       ` A. Tsakiris
  3 siblings, 0 replies; 10+ messages in thread
From: Reiner Steib @ 2002-10-03 10:44 UTC (permalink / raw)


On Thu, Oct 03 2002, Clemens Fischer wrote:

> David Kastrup <David.Kastrup@t-online.de> writes:
>
>> You could also use
>> C-u M-! date RET
>
> ok, how do i bind this to a key?

(1) Find out the function called by `M-!' using `C-h k' ...

,----[ C-h k M-! ]
| M-! runs the command shell-command
|    which is an interactive compiled Lisp function in `simple'.
| (shell-command COMMAND &optional OUTPUT-BUFFER ERROR-BUFFER)
| 
| Execute string COMMAND in inferior shell; display output, if any.
| With prefix argument, insert the COMMAND's output at point.
`----

(2) Read the doc-string, especially about the prefix argument in this
    case (C-u).

(3) Bind it to a key (e.g. `C-c i d'), with the arguments you like.
    Remember that you need an interactive function for key bindings:

(global-set-key [(control c) (i) (d)]
		'(lambda ()
		   (interactive)
		   (shell-command "date" t t)))

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo--- PGP key available via WWW   http://rsteib.home.pages.de/

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

* Re: inserting date and time at the cursor location
  2002-10-02 13:03 inserting date and time at the cursor location Guy-Armand Kamendje
  2002-10-02 15:30 ` Jesper Harder
  2002-10-02 15:45 ` kgold
@ 2002-10-04  4:46 ` ken
  2 siblings, 0 replies; 10+ messages in thread
From: ken @ 2002-10-04  4:46 UTC (permalink / raw)
  Cc: help-gnu-emacs


Here's some elisp which does them separately... what I use:

(defun now ()
  "Insert string for the current time formatted like '2:34 PM'."
  (interactive)                 ; permit invocation in minibuffer
  (insert (format-time-string "%-I:%M %p"))
)


(defun today ()
  "Insert string for today's date nicely formatted in American style,
e.g. Sunday, September 17, 2000."
  (interactive)                 ; permit invocation in minibuffer
  (insert (format-time-string "%A, %B %e, %Y"))
)

Put these in a file in your emacs path.  Do "M-x today" or "M-x now" to 
invoke.  Also, it should be obvious how to integrate the two.


hth,
ken

-- 
AMD crashes?  See http://cleveland.lug.net/~ken/amd-problem/.

Spake Guy-Armand Kamendje at 15:03 (UTC+0200) on Wed, 2 Oct 2002:

= Hi,
= Is there a way to let xemacs insert the current date and time at the actual
= cursor location?
= Thanks for any hint
= Guy
= 
= 
= _______________________________________________
= Help-gnu-emacs mailing list
= Help-gnu-emacs@gnu.org
= http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
= 

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

* Re: inserting date and time at the cursor location
  2002-10-03  2:52     ` Clemens Fischer
  2002-10-03  4:13       ` ftrw
  2002-10-03 10:44       ` Reiner Steib
@ 2002-10-11 12:14       ` Mario Lang
  2002-10-13 14:25       ` A. Tsakiris
  3 siblings, 0 replies; 10+ messages in thread
From: Mario Lang @ 2002-10-11 12:14 UTC (permalink / raw)


Clemens Fischer <ino@despammed.com> writes:

> David Kastrup <David.Kastrup@t-online.de> writes:
>
>> You could also use
>> C-u M-! date RET
>
> ok, how do i bind this to a key?

Using keyboard macros for instance:

C-x ( C-u M-! date RET C-x )

Now you can use C-x e to call the last kbd macro or

M-x edit-kbd-macro RET C-x e 

to see the whole macro, being able to edit it and give it a name
and keybinding.  Use C-c C-c to save.

-- 
CYa,
  Mario

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

* Re: inserting date and time at the cursor location
  2002-10-03  2:52     ` Clemens Fischer
                         ` (2 preceding siblings ...)
  2002-10-11 12:14       ` Mario Lang
@ 2002-10-13 14:25       ` A. Tsakiris
  3 siblings, 0 replies; 10+ messages in thread
From: A. Tsakiris @ 2002-10-13 14:25 UTC (permalink / raw)


> (defun jh-insert-current-time ()
>   (interactive)
>   (insert (current-time-string)))
> 
> Then do `M-x jh-insert-current-time' or bind it to some key sequence.

  > ok, how do i bind this to a key?
  > 

Try

(global-set-key (kbd "C-c d") 'jh-insert-current-date)

in your .emacs file.  This will bind the function to the key
sequence C-c d.

-- 
A. Tsakiris

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

end of thread, other threads:[~2002-10-13 14:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-02 13:03 inserting date and time at the cursor location Guy-Armand Kamendje
2002-10-02 15:30 ` Jesper Harder
2002-10-02 15:37   ` David Kastrup
2002-10-03  2:52     ` Clemens Fischer
2002-10-03  4:13       ` ftrw
2002-10-03 10:44       ` Reiner Steib
2002-10-11 12:14       ` Mario Lang
2002-10-13 14:25       ` A. Tsakiris
2002-10-02 15:45 ` kgold
2002-10-04  4:46 ` ken

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.