emacs-devel
[Top][All Lists]
Advanced

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

Re: Upstreaming org-element-ast (was: Improving Emacs' iCalendar support


From: Ihor Radchenko
Subject: Re: Upstreaming org-element-ast (was: Improving Emacs' iCalendar support)
Date: Thu, 02 Jan 2025 18:03:31 +0000

Richard Lawrence <rwl@recursewithless.net> writes:

>> Should be just
>> (org-element-create type props contents)
>> and then
>> (org-element-contents new-node)
>
> That's what I would have thought. In my experiment, I have done this:
>
> (defun ical:make-ast-node (type &optional props &rest children)
>   ;; automatically mark :value as a seconary property for org-element-ast:
>   (let ((full-props (plist-put props :secondary (list :value))))
>         (org-element-create type full-props children)))
>
> (so basically just aliasing org-element-create) and

That's not what you did.
You did not replicate the calling convention
 (org-element-create 'type properties '(<child1> <child2> ...))

  (ical:make-ast-node 'test nil '("a" "b" "c"))

will have CHILDREN = '(("a" "b" "c"))
and pass this argument to `org-element-create' that will faithfully
create a node with a single child - anonymous node ("a" "b" "c").

You should do

  (apply #'org-element-create type full-props children)

This is a common pattern when passing argument to a function with &rest.

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

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