It works, thanks.

On Mon, Aug 16, 2021 at 9:44 PM Lars Ingebrigtsen <larsi@gnus.org> wrote:
Condy Chen <condy0919@gmail.com> writes:

> By defining `foo' with
>
> (defun foo (arg)
>   (interactive "p" org-mode)
>   (message "foo"))
>
> M-x foo is still available in elisp-mode.

Try

(setq read-extended-command-predicate 'command-completion-default-include-p)


--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no