unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Richard Lawrence <rwl@recursewithless.net>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: emacs-devel@gnu.org
Subject: Re: Upstreaming org-element-ast (was: Improving Emacs' iCalendar support)
Date: Tue, 31 Dec 2024 08:55:09 +0100	[thread overview]
Message-ID: <87cyh8guci.fsf@recursewithless.net> (raw)
In-Reply-To: <87h66l2isk.fsf@localhost>

Hi Ihor,

Ihor Radchenko <yantar92@posteo.net> writes:

> The main question is making things usable outside Org mode.
> And that's where your work is the most valuable.
> So, it was me who is waiting for your input before upstreaming :)

Got it! I sat down yesterday and tried to convert to using
org-element-ast, and I've run into a couple of questions:

1) Is there any way to use my own list of standard-properties? In
   particular, besides :begin, :end, :contents-begin, :contents-end, I'd
   like to have :value-begin and :value-end as standard properties, and
   always include (:value) in :secondary. If there's no way to do that
   yet, I think it would be useful to add for use outside of org.
   
2) I'm finding org-element-create rather unintuitive to work with, I
   think because of its &rest argument for children and the handling of
   "anonymous" nodes.

   In all my use cases, I build up children as an explicit list of nodes
   before calling icalendar-make-ast-node, which stores the list in
   the children slot, and returns that list from icalendar-ast-node-children.

   An interface like
     (org-element-create type props children)
   would be sufficient for me, where children is a list of
   nodes (and hence can be nil).

   As it is, I can't figure out how to call org-element-create and
   org-element-contents in the right way to set the contents of a node
   to a list of other nodes, and return that list from
   org-element-contents.

   I always seem to end up with an extra level of nesting. 
   e.g. Instead of (child1 child2 child3 ...)
   org-element-contents returns ((child1 child2 child3 ...)).
   Likewise, if there are no children, instead of nil it returns (nil).
   I can't figure out why this happens; as far as I can tell, I'm
   calling both org-element-create and org-element-contents in the right
   way.

   I tried to write a wrapper for org-element-create using apply, with
   children as the last argument, like
     (apply #'org-element-create type props children)
   but that didn't help. I also tried just unconditionally unwrapping
   the list returned by org-element-contents by just taking its car. But
   (if I remember right) that seemed to create one level too *few* of
   nesting in at least some cases, such that org-element-contents would
   return stuff from the properties list.

   Can you help me understand what the right thing for me to do here is?
   All I want to do is store a list of child nodes at construction time,
   and get that list back later on, which seems like it should be a
   simple thing to do.

   In any case, it might be worth reviewing the interfaces and
   docstrings for these functions, because there is something about how
   they work that I clearly don't understand yet, and might be
   surprising to other library consumers.

Hope that's useful feedback!

Best,
Richard



  reply	other threads:[~2024-12-31  7:55 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-18  9:01 Improving Emacs' iCalendar support Richard Lawrence
2024-10-18  9:24 ` Eli Zaretskii
2024-10-19  8:22   ` Richard Lawrence
2024-10-19 10:11     ` Eli Zaretskii
2024-10-20  5:08       ` Richard Lawrence
2024-10-20  5:21         ` Eli Zaretskii
2024-10-18 12:58 ` Sebastián Monía
2024-10-19  8:28   ` Richard Lawrence
2024-10-19  5:44 ` Adam Porter
2024-10-19  8:39   ` Richard Lawrence
2024-10-20  3:09     ` Adam Porter
2024-10-22 18:40     ` Ihor Radchenko
2024-10-23  7:29       ` Björn Bidar
     [not found]       ` <87plnr6zvk.fsf@>
2024-10-23  8:09         ` Ihor Radchenko
2024-10-23  9:05         ` Richard Lawrence
2024-10-23 10:03           ` Björn Bidar
2024-10-23  9:01       ` Richard Lawrence
2024-10-23 20:24         ` Ferdinand Pieper
2024-10-24 14:52           ` Richard Lawrence
2024-10-24 17:45             ` Ihor Radchenko
2024-10-25 12:53               ` Richard Lawrence
2024-10-25 18:59                 ` Ihor Radchenko
2024-10-21  6:10 ` Björn Bidar
2024-10-21  6:22 ` Visuwesh
2024-10-23  9:15   ` Richard Lawrence
2024-10-23  9:45     ` Visuwesh
     [not found] ` <87wmi29eaf.fsf@>
2024-10-26 17:49   ` Ihor Radchenko
2024-10-28 10:44     ` Björn Bidar
     [not found]     ` <87r080tslf.fsf@>
2024-10-28 19:09       ` Ihor Radchenko
2024-11-23  8:44 ` Richard Lawrence
2024-11-24  9:50   ` Eli Zaretskii
2024-11-24 10:21     ` Ihor Radchenko
2024-11-24 10:41       ` Eli Zaretskii
2024-11-24 10:58         ` Ihor Radchenko
2024-11-24 11:08           ` Eli Zaretskii
2024-11-24 11:21             ` Upstreaming org-element-ast (was: Improving Emacs' iCalendar support) Ihor Radchenko
2024-11-24 12:55               ` Eli Zaretskii
2024-12-25 11:31                 ` Ihor Radchenko
2024-12-29 20:19                   ` Richard Lawrence
2024-12-29 20:53                     ` Richard Lawrence
2024-12-30 17:18                       ` Ihor Radchenko
2024-12-30 17:16                     ` bug#74994: " Ihor Radchenko
2024-12-31  7:55                       ` Richard Lawrence [this message]
2025-01-01  9:29                         ` Ihor Radchenko
2025-01-01 12:38                           ` Richard Lawrence
2025-01-02 18:03                             ` Ihor Radchenko
2025-01-02 20:01                               ` Richard Lawrence
2025-01-02 20:09                                 ` Ihor Radchenko
2025-01-01 13:01                           ` Richard Lawrence
2024-11-25  9:09     ` Improving Emacs' iCalendar support Richard Lawrence
2024-11-25 12:42       ` Eli Zaretskii
2024-11-25 13:03         ` Rudolf Schlatte
2024-11-25 13:36           ` Eli Zaretskii
2024-11-25 17:14           ` Richard Lawrence
2024-12-20 13:21 ` Richard Lawrence

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87cyh8guci.fsf@recursewithless.net \
    --to=rwl@recursewithless.net \
    --cc=emacs-devel@gnu.org \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).