From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: gnuist006@hotmail.com (gnuist006) Newsgroups: gmane.emacs.help Subject: Re: HOW TO GIVE A DEFAULT TO A TRULY INTERACTIVE FUNCTION Date: 17 Oct 2002 07:22:41 -0700 Organization: http://groups.google.com/ Sender: help-gnu-emacs-admin@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1034957418 21479 80.91.224.249 (18 Oct 2002 16:10:18 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 18 Oct 2002 16:10:18 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 182ZhW-0005Zi-00 for ; Fri, 18 Oct 2002 18:10:14 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 182Zh4-0006KG-00; Fri, 18 Oct 2002 12:09:46 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews1.google.com!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs Original-Lines: 33 Original-NNTP-Posting-Host: 209.179.38.68 Original-X-Trace: posting.google.com 1034864562 16847 127.0.0.1 (17 Oct 2002 14:22:42 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: 17 Oct 2002 14:22:42 GMT Original-Xref: shelby.stanford.edu gnu.emacs.help:106144 comp.emacs:75317 Original-To: help-gnu-emacs@gnu.org Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:2677 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:2677 "Bingham, Jay" wrote in message news:... > > Here is your function using a string arg-descriptor, that does some very > crude numeric validation and inserts a 5 when nothing is entered at the > prompt. > > (defun demo (&optional number) > "Demo of an optional argument of the function." > (interactive "sEnter a numeric value:") > (setq defaultval "5") > (if (string= "" number) (setq number defaultval)) > (if (not (string-match "[:alpha:]" number)) > (insert (format "%s" number)) > (message "non-numeric value entered, please re-enter")) > ) It works on my GNU Emacs 20.3.1 when modified to: (if (string-match "[0-9]+" number) (insert (format "%s" number)) (message "non-numeric value entered, please re-enter")) ) But as you said below fails to ask number again when "x" is given as the value. I am still lookin for a good solution that does validation and probably displays the default value when it asks the number first time without ruining single instantiation of the default value. > If you want a function that prompts for a number until one is entered > you will have to use an elisp expression type arg-descriptor and do your > own number validation.