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

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

Re: mixing argument types


From: Stefan Monnier
Subject: Re: mixing argument types
Date: Sun, 26 Aug 2018 16:23:11 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> (defun do-a-on-b (a b &optional start stop)
>   (interactive
>     ;; check (use-region-p)
>     (list 
>       ;; ask for a
>       ;; ask for b
>       start
>       stop)
>       ;; ...
>       )

The interactive spec can't use `start` and `stop` like you did, since
it (the interactive spec) is what is used to find the arguments to pass
to the function (i.e. to find `start`, `stop, `a`, and `b`).

So you'd write:

    (defun do-a-on-b (a b &optional start stop)
      (interactive
        (list
          (completing-read "Give me A: " '("foo" "bar"))
          (read-file-name "Give me B:")
          (region-beginning)
          (region-end)))
      ...)


-- Stefan




reply via email to

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