Under certain conditions (triggered by selection of a package option) I would like to change specific environments into margin notes. However marginnote is not itself an environment, but a command that takes its contents as an argument. So what I want to do is replace
\begin{someenvironment}
...
\end{someenvironment}
with
\marginnote{
...
}
but I clearly cannot do this with something like
\renewenvironment{someenvironment}
{\marginnote{ }
{ }}
What is the correct way to replace an environment with a command that takes the environment's contents as an argument?

\usepackage[maxfloats=36]{morefloats}and\let\existingenv ... \NewEnviron{existingenv}.... – orome Feb 21 '12 at 22:25\begin{someenvironment}..., not writing\someenvironment{...– Toivo Säwén May 24 '23 at 07:52