| Re: Elisp: Simple function to Add Two Numbers |
|
 |
|
 |
|
 |
|
 |
Group: gnu.emacs.help · Group Profile
Author: Barry MargolinBarry Margolin Date: Aug 27, 2006 18:50
In article chlr7032.ch.intel.com>,
Edward Dodge wrote:
> Pascal Bourguignon informatimago.com> writes:
>
>
>> The whitespaces don't matter, as long as they're not just after a
>> newline. The problem is that there are two newlines with three
>> characters specifying a total of four interactive arguments: n, n and r.
>> (r gives two arguments, start and end of region).
>
> Yes, this is correct. And I have managed to keep the function from causing
> an error by rewriting it:
>
> (defun ekd-average (jabba wabba)
> "Adds two numbers and returns the difference between"
> (interactive "nFirstvar: \nnSecondvar: ")
> (eval ( + jabba wabba)))
You don't need eval.
>
> Now the only problem is this: it returns no answer when I run it. I thought
> lisp functions always returned a value. I even made it explicit by using the
> "eval" statement, but still I get no answer in either the minibuffer or
> *Messages*.
Yes, the function returns a value. But your command never displays the
value anywhere, and M-x doesn't automatically display the return value
of functions. Use (print (+ jabba wabba)) and it will be displayed in
the echo area.
--
Barry Margolin, barmar@ alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
|