From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Joakim Hove Newsgroups: gmane.emacs.help Subject: Re: [elisp]How to ask and provide a Default value? Date: Fri, 05 Mar 2004 08:45:45 +0100 Organization: University of Bergen Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <4ysmgnka8m.fsf@skjellgran.ii.uib.no> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1078784396 26758 80.91.224.253 (8 Mar 2004 22:19:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 8 Mar 2004 22:19:56 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Mar 08 23:19:48 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1B0T6C-0004BO-00 for ; Mon, 08 Mar 2004 23:19:48 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B0T53-0005nC-Mb for geh-help-gnu-emacs@m.gmane.org; Mon, 08 Mar 2004 17:18:37 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!feed.news.tiscali.de!uio.no!nntp.uib.no!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 38 Original-NNTP-Posting-Host: skjellgran.ii.uib.no Original-X-Trace: toralf.uib.no 1078472663 90570 129.177.20.52 (5 Mar 2004 07:44:23 GMT) Original-X-Complaints-To: abuse@uib.no Original-NNTP-Posting-Date: 5 Mar 2004 07:44:23 GMT User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) Cancel-Lock: sha1:1dRc7B8oA/ALn/8g0XDqOcNy1zU= Original-Xref: shelby.stanford.edu gnu.emacs.help:121482 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:17467 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:17467 Hello, maybe you can use this little function: (defun read-number-with-default (prompt &optional default) (let ((default-string (if default (number-to-string default) ""))) (string-to-number (read-from-minibuffer prompt default-string)))) Observe two things: 1. The default value is presented to the read routine as "INITIAL-CONTENTS", and *not* "DEFAULT-VALUE". 2. The routine does not check the number format, and (string-to-number ) seemingly eats anything with digits in it. In case you want to use this function you would typically read the input in the body of the function, i.e. something like: (defun sleeve-step-region (beginning end base step column) "Insert a column of increasing numbers in the region." (let* ((beginning (read-number-with-default "Beginning: " 100)) (end (read-number-with-default "End: " (+ beginning 10))) ... HTH - Joakim -- /--------------------------------------------------------------------\ / Joakim Hove / hove@bccs.no / (55 5) 84076 | \ | Unifob AS, Avdeling for Beregningsvitenskap (BCCS) | Stabburveien 18 | | CMU | 5231 Paradis | \ Thormøhlensgt.55, 5020 Bergen. | 55 91 28 18 / \--------------------------------------------------------------------/