From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>
Received: from mp12.migadu.com ([2001:41d0:403:4789::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by ms9.migadu.com with LMTPS
	id ULT/CjfW5WR7WQEASxT56A
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Wed, 23 Aug 2023 11:49:43 +0200
Received: from aspmx1.migadu.com ([2001:41d0:403:4789::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp12.migadu.com with LMTPS
	id mNClCjfW5WRCigAAauVa8A
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Wed, 23 Aug 2023 11:49:43 +0200
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by aspmx1.migadu.com (Postfix) with ESMTPS id 6CDA240048
	for <larch@yhetil.org>; Wed, 23 Aug 2023 11:49:42 +0200 (CEST)
Authentication-Results: aspmx1.migadu.com;
	dkim=pass header.d=posteo.net header.s=2017 header.b=fpXxtaqi;
	spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org";
	dmarc=pass (policy=none) header.from=posteo.net
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org;
	s=key1; t=1692784183;
	h=from:from:sender:sender:reply-to:subject:subject:date:date:
	 message-id:message-id:to:to:cc:cc:mime-version:mime-version:
	 content-type:content-type:in-reply-to:in-reply-to:
	 references:references:list-id:list-help:list-unsubscribe:
	 list-subscribe:list-post:dkim-signature;
	bh=G2lyf7AblVns/4D4eKWY6zmHEevrdnv0NsKS7WJkRmc=;
	b=HMmXD8JBaRUUvLOarJjFlc3uc5VPzwrgHf9eUzG+jux0G4YPY67UilwPKmJ7i8DuLxqvIP
	CtidAuQ+u1uoejqoTZbt75DE91gVce8nk8CZYzXgj0pSIwDJ87368oKynVf3ySfJSx9NQU
	mCskUuKNHyxuCeRt2KawfwHLhPeNIS4iDzTa/zTGEJhJMmykHs34WLVWfReugPQ02IKGsM
	2F+yM4lZlbv2sG5kCcqJcLMgf4YDCBCJgd4SCOq3YTL+mU0+3PnUHKJ2ObDlygYVgOyxaW
	P3ejoCTHDhAHCv71iiK7ttRQKJM8daUD8UZKgUr7sbquFu5ILetyxuqGbg3fqA==
ARC-Seal: i=1; s=key1; d=yhetil.org; t=1692784183; a=rsa-sha256; cv=none;
	b=iUZopA8pEvEEj3p+nL2AVFN2JyRkR0ijuwjN7tCqz4/4gEc/aFcEqQcaMhCHymZJ80cJKf
	1bReUzsx3aSxyyxgCGdQiX0RjeUxJtUZq921wBfhUELYYkmEFMbdHpntrxsc2/v9Gl+uMB
	/nGCAwWTUe3rsh4kn9a47aavESws62hCXTKKULrWKqitBQPzEKpUYWynBmfV8ii8ViDFPX
	Ckc3orU8v6BJ16L3oZk9/ZTIQOL9AaRsqAf/q9c/nXSHwoefhp21ZOOD15ZrwOhA6D7BGN
	xYCfTKzfGbJmWQ2IQCxpqQmekwAjFs+AdInV101qBqiMpooCWovsq5zn3VAm3w==
ARC-Authentication-Results: i=1;
	aspmx1.migadu.com;
	dkim=pass header.d=posteo.net header.s=2017 header.b=fpXxtaqi;
	spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org";
	dmarc=pass (policy=none) header.from=posteo.net
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <emacs-orgmode-bounces@gnu.org>)
	id 1qYkTy-0002zM-K6; Wed, 23 Aug 2023 05:48:58 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yantar92@posteo.net>)
 id 1qYkTx-0002zE-5T
 for emacs-orgmode@gnu.org; Wed, 23 Aug 2023 05:48:57 -0400
Received: from mout02.posteo.de ([185.67.36.66])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yantar92@posteo.net>)
 id 1qYkTv-00021G-II
 for emacs-orgmode@gnu.org; Wed, 23 Aug 2023 05:48:56 -0400
Received: from submission (posteo.de [185.67.36.169]) 
 by mout02.posteo.de (Postfix) with ESMTPS id 3ED50240101
 for <emacs-orgmode@gnu.org>; Wed, 23 Aug 2023 11:48:53 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1692784133; bh=aIs+3u8a+uXEu9bfS4X2NypssJrW4tZezduI1g1rn60=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From;
 b=fpXxtaqiDKd/tyDqhdKBsMDT1H9lHrb6TVMhbZ4IcRPVKPSB6IIcserkcFV89LFiO
 lJQMgJ3Dx2a4yzLJwzeF7XadRTgZM5LhDULjXUmRXhfLeV3HtZ8KY3eFfGnPObFrWc
 YOHULeqfu4SMZRA6QYVCe9UT2dZBL9N8arNsxjNWHwclB+ayYqAgj7yrjFIsfsiXoq
 XlKjV9zZRA6X/+PHPD+HylOjyIqKNbnw2bCsxvvbdkIUCEzHZM5u19OcZd0fUzo0XY
 CtPMMSTYLTZn0Yv1eCdZHOGWU+BjzgZM75lbFPRUch/SjB3hlZ724t65ZYZkkgr2U8
 mln7GBL+COxpA==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4RW1d04J6Fz9rxB;
 Wed, 23 Aug 2023 11:48:52 +0200 (CEST)
From: Ihor Radchenko <yantar92@posteo.net>
To: Hraban Luyat <hraban@0brg.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: org-element: headline's :title is sometimes string, sometimes list
In-Reply-To: <cf10ff8e-b22b-4a9e-bd63-4b7a5bcc6df4@0brg.net>
References: <cf10ff8e-b22b-4a9e-bd63-4b7a5bcc6df4@0brg.net>
Date: Wed, 23 Aug 2023 09:49:22 +0000
Message-ID: <87jztm6qcd.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net;
 helo=mout02.posteo.de
X-Spam_score_int: -43
X-Spam_score: -4.4
X-Spam_bar: ----
X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: emacs-orgmode@gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org
Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org
X-Migadu-Flow: FLOW_IN
X-Migadu-Country: US
X-Migadu-Spam-Score: -8.43
X-Spam-Score: -8.43
X-Migadu-Queue-Id: 6CDA240048
X-Migadu-Scanner: mx1.migadu.com
X-TUID: zvXuXJILrvgL

Hraban Luyat <hraban@0brg.net> writes:

> I expect: "string" everywhere.
>
> I get:
>
>      Headline title from map is of type: cons
>      Headline title from context is of type: string
>      Headline title from at-point is of type: string
>
> Question 1: Do you know what that `cons' structure is? Where is it 
> documented, how would I go about figuring this out myself? The 
> org-element API documentation is daunting.

This is "anonymous element". `org-element-parse-buffer', by default,
parses down to object level:

* Heading *bold* text

contains bold markup, which is reflected in the parsed AST. The title
itself is called secondary value, which may contain Org markup.

You are not getting it using `org-element-at-point' API because it does
not parse objects and simply returns a heading parsed down to element
level - :title is not parsed in details.

> Question 2: how do I reliably get the title as a string? Properties are 
> fine, I don't mind, but that weird list structure is awkward to handle.

Use `org-element-interpret-data' to convert Org AST back to plain text.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
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>