emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Hraban Luyat <hraban@0brg.net>
To: emacs-orgmode@gnu.org
Subject: org-element: headline's :title is sometimes string, sometimes list
Date: Wed, 23 Aug 2023 01:25:04 +0000	[thread overview]
Message-ID: <cf10ff8e-b22b-4a9e-bd63-4b7a5bcc6df4@0brg.net> (raw)

Hi all.

I'll let the code speak:

     (with-temp-buffer
       (org-mode)
       (insert "* Hello")
       (cl-flet ((say-type (prefix hl)
                   (message "Headline title from %s is of type: %s"
                            prefix
                            (type-of (org-element-property :title hl)))))
         (org-element-map (org-element-parse-buffer) 'headline
           (lambda (hl) (say-type "map" hl)))
         (goto-char (point-min))
         (say-type "context" (org-element-context))
         (say-type "at-point" (org-element-at-point))))

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.

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.

Thank you

Hraban



             reply	other threads:[~2023-08-23  1:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-23  1:25 Hraban Luyat [this message]
2023-08-23  9:49 ` org-element: headline's :title is sometimes string, sometimes list Ihor Radchenko
2023-08-23 15:01   ` Hraban Luyat

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.orgmode.org/

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

  git send-email \
    --in-reply-to=cf10ff8e-b22b-4a9e-bd63-4b7a5bcc6df4@0brg.net \
    --to=hraban@0brg.net \
    --cc=emacs-orgmode@gnu.org \
    /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/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).