From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 243OOpbDpGBAiwAAgWs5BA (envelope-from ) for ; Wed, 19 May 2021 09:51:50 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id OLniNZbDpGDfSwAAbx9fmQ (envelope-from ) for ; Wed, 19 May 2021 07:51:50 +0000 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 C26982681B for ; Wed, 19 May 2021 09:51:49 +0200 (CEST) Received: from localhost ([::1]:48848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljGzb-0007R7-Fi for larch@yhetil.org; Wed, 19 May 2021 03:51:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljGyt-0007Qw-9u for emacs-orgmode@gnu.org; Wed, 19 May 2021 03:51:03 -0400 Received: from mail.xgm.de ([45.83.105.139]:58652) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljGyo-0001ck-3z for emacs-orgmode@gnu.org; Wed, 19 May 2021 03:51:02 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPA id A4434180354 for ; Wed, 19 May 2021 09:50:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xgm.de; s=dkim; t=1621410645; h=from:subject:date:message-id:to:mime-version:content-type; bh=nudIEoa93RD5eXAB0/Vh/fyouw27c0J/2GduU3NZpwM=; b=qKWdugKPj7r8KP5D7zF8RlVF1oRsLZIAdyEWPKBPpuG/Cduc5bet8MBHqHC7xd+Wj7CdC6 Zmshwm0WU5RA09jY3H8l73OFpdeuieyf/KL2wMl+Ok+aSRX487se0158lWGd75aOXQjgAB kCwH3IjHQx7eDrUeSJEcwGc0J/9j83hhSiE1b4zKrzqdfKz8LCide9y/w/sseu5oge//Qp S7rg1Qg0uSl0drkkFowvamv3d5jzqBcCSaRzrndigT0Q8vqQVrYYcoXTQCtUNwPXN+2mS/ 1ZXsUuMYXdqC3plxcwud59cOokPb3hTRqgjvOzoqxMtmZZ0uoQwJpSc6ka9Vzw== From: "Florian Lindner" To: "Org Mode List" User-Agent: SOGoMail 5.1.0 MIME-Version: 1.0 Date: Wed, 19 May 2021 09:50:45 +0200 Subject: Get list of top-level headings Message-ID: <41-60a4c380-5-7d67d100@4304905> Content-Type: multipart/alternative; boundary="----=_=-_OpenGroupware_org_NGMime-65-1621410645.503369-1------" X-Last-TLS-Session-Version: None Received-SPF: pass client-ip=45.83.105.139; envelope-from=mailinglists@xgm.de; helo=mail.xgm.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, HTML_MESSAGE=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.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1621410710; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=nudIEoa93RD5eXAB0/Vh/fyouw27c0J/2GduU3NZpwM=; b=Rgrcecw/CwlXS5Xry922bX6zqlJfs4EzOB1Qmn//F1eCgn+MdJsgt2t+cuY4+PftdXXfXT K190O7Xoshxr5DAV08BaWgGzH9DM82A8sjW1CmI/W0j3BBqXjWQF3xTADJxLuEYAhQn0YG zjfofyE9xaeFKpTd0YlrEHFMBOOLMrOBLY4myNu2cul6b3dpfNNgDoRciCXzDA5Hx6uGtP GDBzvY2Qfi8fLremqnwALm3JVP1qJLliYxV89qOIP5lNCGOO2u9PIIC2Ylp6uC+4zIRPOT +xcGaxBkkZiOxSuHT4Tl19736oyK5zarKh4frK8mEyUISGmAgoW594ILG+QT5Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1621410710; a=rsa-sha256; cv=none; b=fpK5DvygPZTu6BgUzeChA48Wgbu1GV1lqJMEFB6S2Qfsc0oPie8xd53EEhtzI2eUS7lbBE liqX71OR93SgJhSgU0eRTVb9bGAWg0XAjkwpsIswd2xq265+Ms0crdu8aGA1jNucwa6+Cj nfm1qN1OonWmK8FsoeNqVoh13eoQcuZGmcKgmvh6zvmWU7LPYTfnJZMo4JacLJGVRpyQjD oLBxXewyXda8E+UkGZ1q+FFp4MsHg1HGiV0C5zIDUhdsvOTrIeQ4aCBVSscFj6VuFcV8px nU7Y6/DNDAfTrwiNsxfuUbStgkr+SDs6Adj3rkOEdQruJxuQMo3OddN5qqNYbw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=xgm.de header.s=dkim header.b=qKWdugKP; dmarc=pass (policy=none) header.from=xgm.de; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -2.64 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=xgm.de header.s=dkim header.b=qKWdugKP; dmarc=pass (policy=none) header.from=xgm.de; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: C26982681B X-Spam-Score: -2.64 X-Migadu-Scanner: scn0.migadu.com X-TUID: panEVkmT6shT ------=_=-_OpenGroupware_org_NGMime-65-1621410645.503369-1------ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Length: 2063 Hello, I, an Emacs Lisp newbie, want to get a list of all top-level headings o= f the current buffer. My approach so far is: (defun test-org-map() =C2=A0 (interactive) =C2=A0 (setq headings '()) =C2=A0 (org-map-entries (lambda () =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq current-header-i= tem (org-element-property :title (org-element-at-point)) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (message "Header: %s" = current-header-item) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (message "Is String: %= s" (stringp (org-element-property :title (org-element-at-point)))) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq headings (append= current-header-item headings)) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "LEVEL=3D1" =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ) =C2=A0 (dolist (heading headings) =C2=A0=C2=A0=C2=A0 (message "Header Item: %s" heading) =C2=A0=C2=A0=C2=A0 ) =C2=A0 ) 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) do= es exactly what I want, but building the list does not what I want. I s= uppose that comes from a fundamental misunderstanding of how strings wo= rk 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 bet= ter, approches to that simply problem! Thanks, Florian =C2=A0 ------=_=-_OpenGroupware_org_NGMime-65-1621410645.503369-1------ Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Length: 2289 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)
  (s= etq headings '())
  (org-map-entries (lambda ()
 &n= bsp;           &= nbsp;       (setq current-header-item (or= g-element-property :title (org-element-at-point))
  &nbs= p;           &nb= sp;      (message "Header: %s" current-header-= item)
          =            (message "= Is String: %s" (stringp (org-element-property :title (org-element-at-po= int))))
         &nbs= p;           (setq he= adings (append current-header-item headings))
   &n= bsp;           &= nbsp;     )
     &nbs= p;           &nb= sp; "LEVEL=3D1"
        &n= bsp;          )
 = ; (dolist (heading headings)
    (message "Header I= tem: %s" heading)
    )
  )

Th= is gives the otput:

Header: AAA
Is String: t
Heade= r: BBB
Is String: t
Header Item: 66 [3 times]
Header Ite= m: 65 [3 times]

so basically the (org-element-property :titl= e (org-element-at-point) does exactly what I want, but building the lis= t does not what I want. I suppose that comes from a fundamental misunde= rstanding 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 th= at simply problem!

Thanks,
Florian
  ------=_=-_OpenGroupware_org_NGMime-65-1621410645.503369-1--------