help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HOW TO GIVE A DEFAULT TO A TRULY INTERACTIVE FUNCTION


From: Friedrich Dominicus
Subject: Re: HOW TO GIVE A DEFAULT TO A TRULY INTERACTIVE FUNCTION
Date: 18 Oct 2002 09:13:37 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp)

gnuist006@hotmail.com (gnuist006) writes:

> Edi Weitz <edi@agharta.de> wrote in message 
> 
> >   (require 'cl)
> > 
> >   (defun* bar (&optional (default 5))
> >     (let* ((default-string (format "%s" default))
> >            (string (read-string "Number: "
> >                                 default-string
> >                                 nil
> >                                 default-string)))
> >       ;; needs check for wrong input
> >       (list (string-to-number string))))
> >   
> >   (defun foo (n)
> >     (interactive
> >      (bar 42))
> >     (insert (format "%s" (* 3 n))))
> 
> Pathetic solution. breaks one, fixes noone.
> It just accepted "u" as the input and did not do number
> validation.
Well people who can read do definitly have an advantage. Edi has
written 
;; needs check ....

So it's either up to you as programmer to check the input or let Emacs
do the job. I have posted a solution in which I used a better suited
input routine. 

Friedrich



reply via email to

[Prev in Thread] Current Thread [Next in Thread]