如何以交互方式读入两个输入并在函数调用中使用它们

ola*_*ola 8 emacs elisp

我目前正在上课学习elisp,所以我没有这种语言的经验.我试图交互式地读入两个输入(矩形的宽度和长度),然后使用它们来调用函数来计算矩形的面积.我的代码如下:

(defun rectangle_Area(w l)
"Compute the area of a rectangle, given its width and length  interactively."
(interactive "nWidth: ")
(interactive "nLength: ")
(setq area (rectangleArea w l))      
(message "The rectangle's area is %f." area))
Run Code Online (Sandbox Code Playgroud)

目前我得到错误的参数数量错误.就像我说的,我以前没有经验......我真正需要知道的是如何使用交互式存储/读取两个单独的值.

感谢您的任何帮助

Ant*_*nko 9

C-hf interactive RET:

要获取多个参数,请连接各个字符串,并用换行符分隔它们.

所以我们有:

(defun rectangle_Area(w l)
    "Compute the area of a rectangle, given its width and length  interactively."
    (interactive "nWidth: \nnLength: ")
    (setq area (rectangleArea w l))      
    (message "The rectangle's area is %f." area))
Run Code Online (Sandbox Code Playgroud)