[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Inserting date, Disabling the Yes/No question
From: |
Le Wang |
Subject: |
Re: Inserting date, Disabling the Yes/No question |
Date: |
Sat, 31 Aug 2002 21:07:39 GMT |
User-agent: |
KNode/0.7.1 |
Jesse Mathias Marder wrote:
> 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?
Here is something I use to insert the date/time:
(defvar le::date-formats
'("%m/%d/%Y"
"%m-%d-%Y"
"%b/%d/%Y"
"%b-%d-%Y"
"%b %e, %Y"
"%Y-%m-%d"
"%a %b %e, %Y"
"%A %B %e, %Y"
"%a %d %b %Y"
))
(defvar le::time-formats
'("%r %Z"
"%r%z"
"%I:%M %p %Z"
"%I:%M %p%z"
"%T %Z"
"%T%z"
"%R %Z"
"%R%z"
"T%T%z"
))
;;;###autoload
(defun le::insert-date ()
"Offers date in various formats via completion.
Try <prioor> for menu selection"
(interactive)
(let ((time (current-time))
date
time
completion-table)
(setq completion-table (mapcar
#'(lambda (x)
(cons (format-time-string x time)
(format-time-string x time)))
le::date-formats))
(setq date (completing-read "date format: " completion-table nil t))
(setq completion-table
(mapcar
#'(lambda (x)
(cons (format-time-string x time)
(format-time-string x time)))
le::time-formats))
(setq time (completing-read
(concat "[ " date " ] - time format: ")
completion-table nil t))
(insert (concat date
(when (and (> (length time) 0)
(numberp (aref time 0)))
" ")
time))))
> 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?
This will make all yes/no questions y/n questions. There are ways of killing
modified buffers w/o confirmations, but that is very very dangerous...
(fset 'yes-or-no-p 'y-or-n-p)
> Thanks in anvance,
np.
--
Le