up vote 1 down vote favorite
share [g+] share [fb]

For some reason, emacs functions which use the interactive form don't work for me on Mac OS x. The emacs I am using is from emacsformacosx.com, which up until now has worked flawlessly. An example of such a function that uses interactive (taken from here) is:

(defun multiply-by-seven (number)       ; Interactive version.
   "Multiply NUMBER by seven."
   (interactive "p")
   (message "The result is %d" (* 7 number)))

I run it in scratch with C-x C-e, but I'm not able to enter a number and get anything out.

link|improve this question

How are you attempting to enter the number? What is the error you're getting? – Darren Hall Jan 6 '10 at 2:28
feedback

1 Answer

up vote 4 down vote accepted

I am a little worried by:

I run it in scratch with C-x C-e

This does not run the function, it just evaluates it. To call the function you can evaluate:

(multiply-by-seven 10)
  => "The result is 70"

with C-x C-e or call it interactivly:

M-x multiply-by-seven
  => "The result is 7"

and call it with an argument

C-u M-x multiply-by-seven
  => "The result is 28"

or

C-u 7 M-x multiply-by-seven
  => "The result is 49"

as (interactive "p") uses the numeric prefix argument, Emacs Manual

link|improve this answer
+1 for "This does not run the function, it just evaluates it." – Doug Harris Jan 6 '10 at 19:39
+1 Yup, I noticed this myself after digging in a bit more. My emacs fu is very weak. Thanks for the comprehensive answer. – Rob Jan 7 '10 at 6:26
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.