emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-element-adopt-elements, append before children
@ 2018-09-02  6:52 Ivan Tadeu Ferreira Antunes Filho
  2018-09-02 12:27 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Ivan Tadeu Ferreira Antunes Filho @ 2018-09-02  6:52 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 468 bytes --]

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?

[-- Attachment #2: Type: text/html, Size: 726 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: org-element-adopt-elements, append before children
  2018-09-02  6:52 org-element-adopt-elements, append before children Ivan Tadeu Ferreira Antunes Filho
@ 2018-09-02 12:27 ` Nicolas Goaziou
  2018-09-02 20:48   ` Ivan Tadeu Ferreira Antunes Filho
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2018-09-02 12:27 UTC (permalink / raw)
  To: Ivan Tadeu Ferreira Antunes Filho; +Cc: emacs-orgmode

Hello,

Ivan Tadeu Ferreira Antunes Filho <ita@mit.edu> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: org-element-adopt-elements, append before children
  2018-09-02 12:27 ` Nicolas Goaziou
@ 2018-09-02 20:48   ` Ivan Tadeu Ferreira Antunes Filho
  2018-09-03  8:04     ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Ivan Tadeu Ferreira Antunes Filho @ 2018-09-02 20:48 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1199 bytes --]

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 <mail@nicolasgoaziou.fr> wrote:

> Hello,
>
> Ivan Tadeu Ferreira Antunes Filho <ita@mit.edu> 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
>

[-- Attachment #2: Type: text/html, Size: 1882 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: org-element-adopt-elements, append before children
  2018-09-02 20:48   ` Ivan Tadeu Ferreira Antunes Filho
@ 2018-09-03  8:04     ` Nicolas Goaziou
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2018-09-03  8:04 UTC (permalink / raw)
  To: Ivan Tadeu Ferreira Antunes Filho; +Cc: emacs-orgmode

Hello,

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

> 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

The current way would be: find first child if any; if there is not,
adopt, otherwise, insert before it.

In any case, feel free to provide a patch, along with some tests to
implement what you suggest.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-03  8:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-02  6:52 org-element-adopt-elements, append before children Ivan Tadeu Ferreira Antunes Filho
2018-09-02 12:27 ` Nicolas Goaziou
2018-09-02 20:48   ` Ivan Tadeu Ferreira Antunes Filho
2018-09-03  8:04     ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).