From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ivan Tadeu Ferreira Antunes Filho Subject: Re: org-element-adopt-elements, append before children Date: Sun, 2 Sep 2018 16:48:23 -0400 Message-ID: References: <8736usxewt.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000094f82e0574e98d29" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwZRx-0007xI-16 for emacs-orgmode@gnu.org; Sun, 02 Sep 2018 16:58:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fwZIn-0007or-3N for emacs-orgmode@gnu.org; Sun, 02 Sep 2018 16:49:00 -0400 Received: from mail-lf1-f48.google.com ([209.85.167.48]:41722) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fwZIm-0007oK-Qw for emacs-orgmode@gnu.org; Sun, 02 Sep 2018 16:48:57 -0400 Received: by mail-lf1-f48.google.com with SMTP id l26-v6so13639935lfc.8 for ; Sun, 02 Sep 2018 13:48:56 -0700 (PDT) In-Reply-To: <8736usxewt.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: emacs-orgmode@gnu.org --00000000000094f82e0574e98d29 Content-Type: text/plain; charset="UTF-8" Org element insert before would insert the new element before the selected element, not as the first element child (I think) At the moment I'm finding the first child, checking if it is non nil, and if it is not nil, dolist insert before the first child, else, adopt the elements. Which is a fairly convoluted way On Sun, Sep 2, 2018, 8:27 AM Nicolas Goaziou wrote: > Hello, > > Ivan Tadeu Ferreira Antunes Filho writes: > > > At the moment org-element-adopt-elements always appends the new elements > > after the elements original children. In many cases one might want to > > append before the original children. > > > > I want to propose adding an argument to org-element-adopt-elements that > > defines if the elements should be added before or after the children, > i.e. > > (if append-before > > (nconc children (org-element-contents parent)) > > (nconc (org-element-contents parent) children)) > > > > Would this be okay? > > You can simply use `org-element-insert-before'. > > Regards, > > -- > Nicolas Goaziou > _______________________________________________ > Ita mailing list > Ita@mit.edu > http://mailman.mit.edu/mailman/listinfo/ita > --00000000000094f82e0574e98d29 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Org element insert before would insert the new element be= fore the selected element, not as the first element child (I think)


At the mo= ment I'm finding the first child, checking if it is non nil, and if it = is not nil, dolist insert before the first child, else, adopt the elements.= Which is a fairly convoluted way

On Sun, Sep 2, 2018, 8:27 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
Hello,

Ivan Tadeu Ferreira Antunes Filho <ita@mit.edu> writes:

> At the moment=C2=A0 org-element-adopt-elements always appends the new = elements
> after the elements original children.=C2=A0 In many cases one might wa= nt to
> append before the original children.
>
> I want to propose adding an argument to org-element-adopt-elements tha= t
> defines if the elements should be added before or after the children, = i.e.
> (if append-before
>=C2=A0 =C2=A0(nconc children (org-element-contents parent))
>=C2=A0 =C2=A0(nconc (org-element-contents parent) children))
>
> Would this be okay?

You can simply use `org-element-insert-before'.

Regards,

--
Nicolas Goaziou
_______________________________________________
Ita mailing list
Ita@mit= .edu
http://mailman.mit.edu/mailman/listinfo/ita
--00000000000094f82e0574e98d29--