help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: About a programming tip


From: Thierry Volpiatto
Subject: Re: About a programming tip
Date: Thu, 21 Feb 2013 07:42:55 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Xue Fuqiao <address@hidden> 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.

-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]