From: gnuist006@hotmail.com (gnuist006)
Subject: Re: HOW TO GIVE A DEFAULT TO A TRULY INTERACTIVE FUNCTION
Date: 17 Oct 2002 07:22:41 -0700 [thread overview]
Message-ID: <b00bb831.0210170622.552e83ac@posting.google.com> (raw)
In-Reply-To: mailman.1034620095.15632.help-gnu-emacs@gnu.org
"Bingham, Jay" <Jay.Bingham@hp.com> wrote in message news:<mailman.1034620095.15632.help-gnu-emacs@gnu.org>...
>
> 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.
next parent reply other threads:[~2002-10-17 14:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.1034620095.15632.help-gnu-emacs@gnu.org>
2002-10-17 14:22 ` gnuist006 [this message]
2002-10-18 7:14 ` HOW TO GIVE A DEFAULT TO A TRULY INTERACTIVE FUNCTION Friedrich Dominicus
2002-10-14 18:27 Bingham, Jay
-- strict thread matches above, loose matches on Subject: below --
2002-10-14 16:02 gnuist006
2002-10-14 17:22 ` Joe Casadonte
2002-10-14 20:07 ` Edi Weitz
2002-10-17 14:27 ` gnuist006
2002-10-17 17:35 ` Barry Margolin
2002-10-18 10:36 ` Oliver Scholz
2002-10-17 14:35 ` gnuist006
2002-10-17 15:03 ` Edi Weitz
2002-10-18 5:51 ` huntingdon
2002-10-18 7:13 ` Friedrich Dominicus
2002-10-18 7:07 ` Friedrich Dominicus
2002-10-18 8:05 ` Friedrich Dominicus
2002-10-18 17:05 ` Kevin Rodgers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b00bb831.0210170622.552e83ac@posting.google.com \
--to=gnuist006@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.