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: gnuist006
Subject: Re: HOW TO GIVE A DEFAULT TO A TRULY INTERACTIVE FUNCTION
Date: 17 Oct 2002 07:27:36 -0700

Edi Weitz <edi@agharta.de> wrote in message 

> This guy is obviously a troll who doesn't deserve an answer but for
> the sake of others who might read this:

> I'm sure the real Emacs experts know better ways to do this, I just
> wanted to show that it's doable.

You are sure of too many things about others but how much are you sure
of yourself?

Anyways, I am still looking for "the real Emacs experts" that you are
so sure of.

The problem is restated below for convenience of the "rEes":

(defun demo (&optional number)
"Demo of an     optional argument of the function."
(interactive "nEnter a number:")
(setq defaultval 5)
(if (null number) (setq number defaultval))
(insert (format "%s" number))
)                                        (demo)                       
           ; works due to optional argument

I want the default to work on the command line also.
They say emacs is customizable. OK it is if you only want to do what
it
can do, and never try to do what you want to do.

I want to invoke it on command line ie M-x demo
It comes and says
Enter a number:_

I prefer it display the default 5 in the message and there is
SINGLE instance of 5 in the function. ie using defaultval.

If this cannot do this and you were all lying to yourself that
emacs is customizable, infinitely extensible, then I atleast want
quick fix for this.

When I hit RTN after it begs for number once, it go away and use
defaultval and stop buggin me.

At present it does not stap and keeps bugging till I enter 5.
Why do I have to remember the default when I am giving it that much
money?


reply via email to

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