all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Florian Lindner" <mailinglists@xgm.de>
To: "Org Mode List" <emacs-orgmode@gnu.org>
Subject: Get list of top-level headings
Date: Wed, 19 May 2021 09:50:45 +0200	[thread overview]
Message-ID: <41-60a4c380-5-7d67d100@4304905> (raw)

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


Hello,

I, an Emacs Lisp newbie, want to get a list of all top-level headings of the current buffer. My approach so far is:

(defun test-org-map()
  (interactive)
  (setq headings '())
  (org-map-entries (lambda ()
                     (setq current-header-item (org-element-property :title (org-element-at-point))
                     (message "Header: %s" current-header-item)
                     (message "Is String: %s" (stringp (org-element-property :title (org-element-at-point))))
                     (setq headings (append current-header-item headings))
                     )
                   "LEVEL=1"
                   )
  (dolist (heading headings)
    (message "Header Item: %s" heading)
    )
  )

This gives the otput:

Header: AAA
Is String: t
Header: BBB
Is String: t
Header Item: 66 [3 times]
Header Item: 65 [3 times]

so basically the (org-element-property :title (org-element-at-point) does exactly what I want, but building the list does not what I want. I suppose that comes from a fundamental misunderstanding of how strings work in elisp.

I would appreciate a short explanation (or pointers) why this does not work. And of course, I am very open to completely different, likely better, approches to that simply problem!

Thanks,
Florian
 

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

             reply	other threads:[~2021-05-19  7:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19  7:50 Florian Lindner [this message]
2021-05-19 13:33 ` Get list of top-level headings John Kitchin
2021-05-19 14:15   ` Jonathan Gregory
2021-05-19 14:36     ` John Kitchin
2021-05-19 13:48 ` Jonathan Gregory

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

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

  git send-email \
    --in-reply-to=41-60a4c380-5-7d67d100@4304905 \
    --to=mailinglists@xgm.de \
    --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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.