Hi again. I am hoping to get your insight on a small issue that has appeared relating to the solution you gave me. To provide a working example, I have this function:
Code:
(defun cm-sphere-volume (r)
"Calculate the volume of a sphere from the radius."
(interactive "nradius: ")
(let ((result (* (/ 4.0 3.0) pi (expt r 3))))
(when (called-interactively-p)
(message "%.15f" result)) result))
This works great. However, when I byte-compile, I get this warning:
Code:
In cm-sphere-volume:
math.el:29:12:Warning: called-interactively-p called with 0 arguments, but
requires 1
I checked the documentation for the called-interactively-p function. It still isn't quite clear to me, but I expected this to work:
Code:
(defun cm-sphere-volume (r)
"Calculate the volume of a sphere from the radius."
(interactive "nradius: ")
(let ((result (* (/ 4.0 3.0) pi (expt r 3))))
(when (called-interactively-p (interactive))
(message "%.15f" result)) result))
But, in this case, I get the error:
Code:
In cm-sphere-volume:
math.el:27:4:Warning: misplaced interactive spec: `(interactive)'
Again - I really like the the approach you suggested here (a single function serving both interactive and non-interactive uses) but I'm inclined never to ignore compiler warning messages without at least understanding what is going on.