* Inserting date, Disabling the Yes/No question
@ 2002-08-31 20:51 Jesse Mathias Marder
2002-09-02 20:51 ` Ehud Karni
2002-09-10 13:14 ` Oliver Scholz
0 siblings, 2 replies; 3+ messages in thread
From: Jesse Mathias Marder @ 2002-08-31 20:51 UTC (permalink / raw)
Hello,
Is there a built in function or a package to gnu emacs 21.2 that
inserts the current date in the document, undepedent of the current
major mode?
And besides that, I'd like to disable the yes/no question when killing
a modified buffer,m or at least chatnge t it no y/n. How can I do
this?
Thanks in anvance,
Jesse
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Inserting date, Disabling the Yes/No question
2002-08-31 20:51 Inserting date, Disabling the Yes/No question Jesse Mathias Marder
@ 2002-09-02 20:51 ` Ehud Karni
2002-09-10 13:14 ` Oliver Scholz
1 sibling, 0 replies; 3+ messages in thread
From: Ehud Karni @ 2002-09-02 20:51 UTC (permalink / raw)
Cc: help-gnu-emacs
On Sat, 31 Aug 2002 22:51:46 +0200, Jesse Mathias Marder <yarblocks@yahoo.com> wrote:
>
> Is there a built in function or a package to gnu emacs 21.2 that
> inserts the current date in the document, undepedent of the current
> major mode?
Here is a simple function I use to inserts the date and time:
(defvar current-date-time-format " %d/%m/%y %H:%M:%S "
"Format of date to insert with `insert-current-date-time' func
See help of `format-time-string' for possible replacements")
(defun insert-current-date-time ()
"insert the current date and time into current buffer.
Uses `current-date-time-format' for the formatting the date/time."
(interactive)
(insert (format-time-string current-date-time-format (current-time))))
I use the Alt Shift C combination for this function:
(global-set-key [?\A-C] 'insert-current-date-time)
If your Alt key creates the Meta modifier, then use:
(global-set-key [?\M-C] 'insert-current-date-time)
Of course, you can choose any key you like.
Ehud.
--
Ehud Karni Tel: +972-3-7966-561 /"\
Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign
Insurance agencies (USA) voice mail and X Against HTML Mail
http://www.mvs.co.il FAX: 1-815-5509341 / \
mailto:ehud@unix.mvs.co.il Better Safe Than Sorry
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Inserting date, Disabling the Yes/No question
2002-08-31 20:51 Inserting date, Disabling the Yes/No question Jesse Mathias Marder
2002-09-02 20:51 ` Ehud Karni
@ 2002-09-10 13:14 ` Oliver Scholz
1 sibling, 0 replies; 3+ messages in thread
From: Oliver Scholz @ 2002-09-10 13:14 UTC (permalink / raw)
Jesse Mathias Marder <yarblocks@yahoo.com> writes:
> Hello,
>
> Is there a built in function or a package to gnu emacs 21.2 that
> inserts the current date in the document, undepedent of the current
> major mode?
Yes. There is time-stamp.el, which ships with Emacs 21
,----
| Commentary:
| A template in a file can be updated with a new time stamp when
| you save the file. For example:
| static char *ts = "sdmain.c Time-stamp: <1996-08-13 10:20:51 gildea>";
| See the top of `time-stamp.el' for another example.
|
| To use time-stamping, add this line to your .emacs file:
| (add-hook 'write-file-hooks 'time-stamp)
| Now any time-stamp templates in your files will be updated automatically.
|
| See the documentation for the functions `time-stamp'
| and `time-stamp-toggle-active' for details.
`----
> And besides that, I'd like to disable the yes/no question when killing
> a modified buffer,m or at least chatnge t it no y/n. How can I do
> this?
[...]
Thomas Burdick once posted a nice macro to change `yes-or-no-p' to
`y-or-n-p' function-wise:
(require 'cl)
(defmacro make-shorter-response (&rest names)
`(progn
,@(mapcar (lambda (name)
`(defadvice ,name (around shorter-response)
(flet ((yes-or-no-p (prompt) (y-or-n-p prompt)))
ad-do-it)))
names)
,@(mapcar (lambda (name) `(ad-activate (quote ,name)))
names)))
Then you can simply do:
(make-shorter-response kill-buffer)
-- Oliver
--
24 Fructidor an 210 de la Révolution
Liberté, Egalité, Fraternité!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-09-10 13:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-31 20:51 Inserting date, Disabling the Yes/No question Jesse Mathias Marder
2002-09-02 20:51 ` Ehud Karni
2002-09-10 13:14 ` Oliver Scholz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).