Xue Fuqiao <xfq.free@gmail.com> writes:
In (info "(elisp) Programming Tips"):
* In `interactive', if you use a Lisp expression to produce a list
of arguments, don't try to provide the "correct" default values for
region or position arguments.
[...]
You do not need to take such precautions when you use interactive
specs `d', `m' and `r', because they make special arrangements to
recompute the argument values on repetition of the command.
I'm confused with these two sentences. The first sentence says that
"don't try to provide the 'correct' default values for region or
position arguments", but the second sentence says that "you don't need
to take such precautions when you use interactive specs `d', `m' and
`r'". IIRC the specs `d', `m' and `r' are "region or position
arguments". Where do I understand wrong, or is it a bug? Thanks.
(defun foo-1 (beg end)
(interactive (list (read-number "Beg: " (region-beginning))
(read-number "End: " (region-end))))
(message "%S" (buffer-substring beg end)))
(defun foo (beg end)
(interactive "r")
(message "%S" (buffer-substring beg end)))
In other words you don't have to use foo-1, it is easier to use foo.